Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/main/java/com/amihaiemil/docker/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
* A docker plugin.
* @author Boris Kuzmic (boris.kuzmic@gmail.com)
* @see <a href="https://docs.docker.com/engine/api/v1.35/#tag/Plugin">Docker Plugin API</a>
* @todo #266:30min Continue implementing rest of the Plugin methods besides
* enable and disable. More information about API methods can be found at:
* https://docs.docker.com/engine/api/v1.35/#tag/Plugin
* @todo #266:30min Implement Plugin#configure method. The tests are already
* coded, so after the implementation just remove the ignore annotation from
* these tests. More information about Configure API method can be found at:
* https://docs.docker.com/engine/api/v1.35/#operation/PluginSet
* @since 0.0.7
*/
public interface Plugin extends JsonObject {
Expand Down
53 changes: 39 additions & 14 deletions src/main/java/com/amihaiemil/docker/RtPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;

/**
* Runtime {@link Plugin}.
Expand Down Expand Up @@ -122,24 +124,47 @@ public void disable() throws IOException, UnexpectedResponseException {
@Override
public void upgrade(final String remote, final JsonArray properties)
throws IOException, UnexpectedResponseException {
throw new UnsupportedOperationException(
String.join(" ",
"RtPlugin.upgrade() is not yet implemented.",
"If you can contribute please",
"do it here: https://www.github.com/amihaiemil/docker-java-api"
)
);
final HttpPost upgrade =
new HttpPost(
new UncheckedUriBuilder(this.uri.toString().concat("/upgrade"))
.addParameter("remote", remote)
.build()
);
try {
upgrade.setEntity(
new StringEntity(
properties.toString(), ContentType.APPLICATION_JSON
)
);
this.client.execute(
upgrade,
new MatchStatus(
upgrade.getURI(),
HttpStatus.SC_NO_CONTENT
)
);
} finally {
upgrade.releaseConnection();
}
}

@Override
public void push() throws IOException, UnexpectedResponseException {
throw new UnsupportedOperationException(
String.join(" ",
"RtPlugin.push() is not yet implemented.",
"If you can contribute please",
"do it here: https://www.github.com/amihaiemil/docker-java-api"
)
);
final HttpPost push =
new HttpPost(
String.format("%s/%s", this.uri.toString(), "push")
);
try {
this.client.execute(
push,
new MatchStatus(
push.getURI(),
HttpStatus.SC_OK
)
);
} finally {
push.releaseConnection();
}
}

@Override
Expand Down
Loading