http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/NetworkSettings.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/NetworkSettings.java b/docker/src/main/java/org/jclouds/docker/domain/NetworkSettings.java deleted file mode 100644 index b8c1a83..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/NetworkSettings.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.domain; - -import static org.jclouds.docker.internal.NullSafeCopies.copyOf; - -import java.util.List; -import java.util.Map; - -import org.jclouds.docker.internal.NullSafeCopies; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -@AutoValue -public abstract class NetworkSettings { - - @AutoValue - public abstract static class Details { - - Details() {} // For AutoValue only! - - public abstract String endpoint(); - - public abstract String gateway(); - - public abstract String ipAddress(); - - public abstract int ipPrefixLen(); - - public abstract String ipv6Gateway(); - - public abstract String globalIPv6Address(); - - public abstract int globalIPv6PrefixLen(); - - public abstract String macAddress(); - - @SerializedNames({ "EndpointID", "Gateway", "IPAddress", "IPPrefixLen", "IPv6Gateway", "GlobalIPv6Address", "GlobalIPv6PrefixLen", "MacAddress" }) - public static Details create(String endpointId, String gateway, String ipAddress, int ipPrefixLen, String ipv6Gateway, String globalIPv6Address, - int globalIPv6PrefixLen, String macAddress) { - return builder().endpoint(endpointId).gateway(gateway).ipAddress(ipAddress).ipPrefixLen(ipPrefixLen) - .ipv6Gateway(ipv6Gateway).globalIPv6Address(globalIPv6Address) - .globalIPv6PrefixLen(globalIPv6PrefixLen).macAddress(macAddress) - .build(); - } - - public Builder toBuilder() { - return new AutoValue_NetworkSettings_Details.Builder(this); - } - - public static Builder builder() { - return new AutoValue_NetworkSettings_Details.Builder(); - } - - @AutoValue.Builder - public abstract static class Builder { - public abstract Builder endpoint(String value); - public abstract Builder gateway(String value); - public abstract Builder ipAddress(String value); - public abstract Builder ipPrefixLen(int value); - public abstract Builder ipv6Gateway(String value); - public abstract Builder globalIPv6Address(String value); - public abstract Builder globalIPv6PrefixLen(int value); - public abstract Builder macAddress(String value); - - public abstract Details build(); - } - } - - public abstract String bridge(); - - @Nullable public abstract String sandboxId(); - - public abstract boolean hairpinMode(); - - @Nullable public abstract String linkLocalIPv6Address(); - - public abstract int linkLocalIPv6PrefixLen(); - - @Nullable public abstract Map<String, List<Map<String, String>>> ports(); - - @Nullable public abstract String sandboxKey(); - - public abstract List<String> secondaryIPAddresses(); - - public abstract List<String> secondaryIPv6Addresses(); - - @Nullable public abstract String endpointId(); - - public abstract String gateway(); - - @Nullable public abstract String globalIPv6Address(); - - public abstract int globalIPv6PrefixLen(); - - public abstract String ipAddress(); - - public abstract int ipPrefixLen(); - - @Nullable public abstract String ipv6Gateway(); - - @Nullable public abstract String macAddress(); - - public abstract Map<String, Details> networks(); - - @Nullable public abstract String portMapping(); - - NetworkSettings() { - } - - @SerializedNames({ "Bridge", "SandboxID", "HairpinMode", "LinkLocalIPv6Address", - "LinkLocalIPv6PrefixLen", "Ports", "SandboxKey", "SecondaryIPAddresses", - "SecondaryIPv6Addresses", "EndpointID", "Gateway", "GlobalIPv6Address", - "GlobalIPv6PrefixLen", "IPAddress", "IPPrefixLen", "IPv6Gateway", - "MacAddress", "Networks", "PortMapping" }) - public static NetworkSettings create(String bridge, String sandboxId, boolean hairpinMode, String linkLocalIPv6Address, - int linkLocalIPv6PrefixLen, Map<String, List<Map<String, String>>> ports, String sandboxKey, List<String> secondaryIPAddresses, - List<String> secondaryIPv6Addresses, String endpointId, String gateway, String globalIPv6Address, - int globalIPv6PrefixLen, String ipAddress, int ipPrefixLen, String ipv6Gateway, - String macAddress, Map<String, Details> networks, String portMapping) { - return new AutoValue_NetworkSettings( - bridge, sandboxId, hairpinMode, linkLocalIPv6Address, - linkLocalIPv6PrefixLen, ports, sandboxKey, copyOf(secondaryIPAddresses), copyOf(secondaryIPv6Addresses), - endpointId, gateway, globalIPv6Address, globalIPv6PrefixLen, - ipAddress, ipPrefixLen, ipv6Gateway, - macAddress, copyOf(networks), portMapping); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromNetworkSettings(this); - } - - public static final class Builder { - - private String ipAddress; - private int ipPrefixLen; - private String gateway; - private String bridge; - private String portMapping; - private Map<String, List<Map<String, String>>> ports; - private String sandboxId; - private boolean hairpinMode; - private String linkLocalIPv6Address; - private int linkLocalIPv6PrefixLen; - private String sandboxKey; - private List<String> secondaryIPAddresses = Lists.newArrayList(); - private List<String> secondaryIPv6Addresses = Lists.newArrayList(); - private String endpointId; - private String globalIPv6Address; - private int globalIPv6PrefixLen; - private String ipv6Gateway; - private String macAddress; - private Map<String, Details> networks = Maps.newHashMap(); - - public Builder ipAddress(String ipAddress) { - this.ipAddress = ipAddress; - return this; - } - - public Builder ipPrefixLen(int ipPrefixLen) { - this.ipPrefixLen = ipPrefixLen; - return this; - } - - public Builder gateway(String gateway) { - this.gateway = gateway; - return this; - } - - public Builder bridge(String bridge) { - this.bridge = bridge; - return this; - } - - public Builder portMapping(String portMapping) { - this.portMapping = portMapping; - return this; - } - - public Builder ports(Map<String, List<Map<String, String>>> ports) { - this.ports = NullSafeCopies.copyWithNullOf(ports); - return this; - } - - public Builder sandboxId(String sandboxId) { - this.sandboxId = sandboxId; - return this; - } - - public Builder hairpinMode(boolean hairpinMode) { - this.hairpinMode = hairpinMode; - return this; - } - - public Builder linkLocalIPv6Address(String linkLocalIPv6Address) { - this.linkLocalIPv6Address = linkLocalIPv6Address; - return this; - } - - public Builder linkLocalIPv6PrefixLen(int linkLocalIPv6PrefixLen) { - this.linkLocalIPv6PrefixLen = linkLocalIPv6PrefixLen; - return this; - } - - public Builder sandboxKey(String sandboxKey) { - this.sandboxKey = sandboxKey; - return this; - } - - public Builder secondaryIPAddresses(List<String> secondaryIPAddresses) { - this.secondaryIPAddresses = secondaryIPAddresses; - return this; - } - - public Builder secondaryIPv6Addresses(List<String> secondaryIPv6Addresses) { - this.secondaryIPv6Addresses = secondaryIPv6Addresses; - return this; - } - - public Builder endpointId(String endpointId) { - this.endpointId = endpointId; - return this; - } - - public Builder globalIPv6Address(String globalIPv6Address) { - this.globalIPv6Address = globalIPv6Address; - return this; - } - - public Builder globalIPv6PrefixLen(int globalIPv6PrefixLen) { - this.globalIPv6PrefixLen = globalIPv6PrefixLen; - return this; - } - - public Builder ipv6Gateway(String ipv6Gateway) { - this.ipv6Gateway = ipv6Gateway; - return this; - } - - public Builder macAddress(String macAddress) { - this.macAddress = macAddress; - return this; - } - - public Builder networks(Map<String, Details> networks) { - this.networks.putAll(networks); - return this; - } - - public NetworkSettings build() { - return NetworkSettings.create(bridge, sandboxId, hairpinMode, linkLocalIPv6Address, linkLocalIPv6PrefixLen, ports, - sandboxKey, secondaryIPAddresses, secondaryIPv6Addresses, endpointId, gateway, - globalIPv6Address, globalIPv6PrefixLen, ipAddress, ipPrefixLen, ipv6Gateway, macAddress, networks, portMapping); - } - - public Builder fromNetworkSettings(NetworkSettings in) { - return this.ipAddress(in.ipAddress()).ipPrefixLen(in.ipPrefixLen()).gateway(in.gateway()).bridge(in.bridge()) - .portMapping(in.portMapping()).ports(in.ports()).sandboxId(in.sandboxId()).hairpinMode(in.hairpinMode()).linkLocalIPv6Address(in - .linkLocalIPv6Address()).linkLocalIPv6PrefixLen(in.linkLocalIPv6PrefixLen()).sandboxKey(in.sandboxKey()).secondaryIPAddresses(in - .secondaryIPAddresses()).secondaryIPv6Addresses(in.secondaryIPv6Addresses()).endpointId(in.endpointId()).globalIPv6Address(in - .globalIPv6Address()).globalIPv6PrefixLen(in.globalIPv6PrefixLen()).ipv6Gateway(in.ipv6Gateway()).macAddress(in.macAddress()) - .networks(in.networks()); - } - } - -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/Node.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/Node.java b/docker/src/main/java/org/jclouds/docker/domain/Node.java deleted file mode 100644 index 343835a..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/Node.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.domain; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Node { - - Node() { - } - - @SerializedNames({"IP"}) - public static Node create(String ip) { - return new AutoValue_Node(ip); - } - - public static Builder builder() { - return new Builder(); - } - - @Nullable - public abstract String ip(); - - public Builder toBuilder() { - return builder().fromNode(this); - } - - public static final class Builder { - - private String ip; - - public Builder ip(String ip) { - this.ip = ip; - return this; - } - - public Node build() { - return Node.create(this.ip); - } - - public Builder fromNode(Node in) { - return this.ip(in.ip()); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/Port.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/Port.java b/docker/src/main/java/org/jclouds/docker/domain/Port.java deleted file mode 100644 index 45fa966..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/Port.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.domain; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Port { - @Nullable public abstract String ip(); - - public abstract int privatePort(); - - @Nullable public abstract Integer publicPort(); - - public abstract String type(); - - Port() { - } - - @SerializedNames({ "IP", "PrivatePort", "PublicPort", "Type" }) - public static Port create(String ip, int privatePort, Integer publicPort, String type) { - return new AutoValue_Port(ip, privatePort, publicPort, type); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/Resource.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/Resource.java b/docker/src/main/java/org/jclouds/docker/domain/Resource.java deleted file mode 100644 index 701318c..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/Resource.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Resource { - - public abstract String resource(); - - Resource() { - } - - @SerializedNames({ "Resource" }) - public static Resource create(String resource) { - return new AutoValue_Resource(resource); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/State.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/State.java b/docker/src/main/java/org/jclouds/docker/domain/State.java deleted file mode 100644 index 30ec8c1..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/State.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.domain; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class State { - - - public abstract int pid(); - - public abstract boolean running(); - - public abstract int exitCode(); - - public abstract String startedAt(); - - public abstract String finishedAt(); - - public abstract boolean paused(); - - public abstract boolean restarting(); - - @Nullable public abstract String status(); - - public abstract boolean oomKilled(); - - public abstract boolean dead(); - - @Nullable public abstract String error(); - - State() { - } - - @SerializedNames({ "Pid", "Running", "ExitCode", "StartedAt", "FinishedAt", "Paused", "Restarting", "Status", "OOMKilled", "Dead", "Error" }) - public static State create(int pid, boolean running, int exitCode, String startedAt, String finishedAt, - boolean paused, boolean restarting, String status, boolean oomKilled, boolean dead, String error) { - return new AutoValue_State(pid, running, exitCode, startedAt, finishedAt, paused, restarting, status, oomKilled, dead, error); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/StatusCode.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/StatusCode.java b/docker/src/main/java/org/jclouds/docker/domain/StatusCode.java deleted file mode 100644 index 0bdfdc7..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/StatusCode.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class StatusCode { - - public abstract int statusCode(); - - StatusCode() { - } - - @SerializedNames({ "StatusCode" }) - public static StatusCode create(int statusCode) { - return new AutoValue_StatusCode(statusCode); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/domain/Version.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/domain/Version.java b/docker/src/main/java/org/jclouds/docker/domain/Version.java deleted file mode 100644 index 9002d41..0000000 --- a/docker/src/main/java/org/jclouds/docker/domain/Version.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Version { - - public abstract String apiVersion(); - - public abstract String arch(); - - public abstract String gitCommit(); - - public abstract String goVersion(); - - public abstract String kernelVersion(); - - public abstract String os(); - - public abstract String version(); - - Version() { - } - - @SerializedNames({ "ApiVersion", "Arch", "GitCommit", "GoVersion", "KernelVersion", "Os", "Version" }) - public static Version create(String apiVersion, String arch, String gitCommit, String goVersion, - String kernelVersion, String os, String version) { - return new AutoValue_Version(apiVersion, arch, gitCommit, goVersion, kernelVersion, os, version); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/features/ContainerApi.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/features/ContainerApi.java b/docker/src/main/java/org/jclouds/docker/features/ContainerApi.java deleted file mode 100644 index fb592c8..0000000 --- a/docker/src/main/java/org/jclouds/docker/features/ContainerApi.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.features; - -import java.io.InputStream; -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.docker.domain.Config; -import org.jclouds.docker.domain.Container; -import org.jclouds.docker.domain.ContainerSummary; -import org.jclouds.docker.domain.HostConfig; -import org.jclouds.docker.domain.Image; -import org.jclouds.docker.domain.Resource; -import org.jclouds.docker.domain.StatusCode; -import org.jclouds.docker.options.AttachOptions; -import org.jclouds.docker.options.CommitOptions; -import org.jclouds.docker.options.ListContainerOptions; -import org.jclouds.docker.options.RemoveContainerOptions; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.binders.BindToJsonPayload; - -@Consumes(MediaType.APPLICATION_JSON) -@Path("/v{jclouds.api-version}") -public interface ContainerApi { - - /** - * @return a set of containers - */ - @Named("containers:list") - @GET - @Path("/containers/json") - @Fallback(EmptyListOnNotFoundOr404.class) - List<ContainerSummary> listContainers(); - - /** - * @param options the options to list the containers (@see ListContainerOptions) - * @return a set of containers - */ - @Named("containers:list") - @GET - @Path("/containers/json") - @Fallback(EmptyListOnNotFoundOr404.class) - List<ContainerSummary> listContainers(ListContainerOptions options); - - /** - * @param name the name for the new container. Must match /?[a-zA-Z0-9_-]+. - * @param config the containerâs configuration (@see BindToJsonPayload) - * @return a new container - */ - @Named("container:create") - @POST - @Path("/containers/create") - Container createContainer(@QueryParam("name") String name, @BinderParam(BindToJsonPayload.class) Config config); - - /** - * Return low-level information on the container id - * @param containerId The id of the container to get. - * @return The details of the container or <code>null</code> if the container with the given id doesn't exist. - */ - @Named("container:inspect") - @GET - @Path("/containers/{id}/json") - @Fallback(NullOnNotFoundOr404.class) - Container inspectContainer(@PathParam("id") String containerId); - - /** - * @param containerId The id of the container to be removed. - */ - @Named("container:delete") - @DELETE - @Path("/containers/{id}") - void removeContainer(@PathParam("id") String containerId); - - /** - * @param containerId The id of the container to be removed. - * @param options the operationâs configuration (@see RemoveContainerOptions) - */ - @Named("container:delete") - @DELETE - @Path("/containers/{id}") - void removeContainer(@PathParam("id") String containerId, RemoveContainerOptions options); - - /** - * @param containerId The id of the container to be started. - */ - @Named("container:start") - @POST - @Path("/containers/{id}/start") - void startContainer(@PathParam("id") String containerId); - - /** - * @param containerId The id of the container to be started. - * @param hostConfig the containerâs host configuration - */ - @Named("container:start") - @POST - @Path("/containers/{id}/start") - void startContainer(@PathParam("id") String containerId, @BinderParam(BindToJsonPayload.class) HostConfig hostConfig); - - /** - * @param containerId The id of the container to be stopped. - */ - @Named("container:stop") - @POST - @Path("/containers/{id}/stop") - void stopContainer(@PathParam("id") String containerId); - - @Named("container:stop") - @POST - @Path("/containers/{id}/stop") - void stopContainer(@PathParam("id") String containerId, @QueryParam("t") int secondsToWait); - - /** - * Create a new image from a containerâs changes - * - * @return a new image created from the current container's status. - */ - @Named("container:commit") - @POST - @Path("/commit") - Image commit(); - - /** - * Create a new image from a containerâs changes - * - * @param options the commitâs configuration (@see CommitOptions) - * @return a new image created from the current container's status. - */ - @Named("container:commit") - @POST - @Path("/commit") - Image commit(CommitOptions options); - - /** - * @param containerId The id of the container to be paused. - */ - @Named("container:pause") - @POST - @Path("/containers/{id}/pause") - void pause(@PathParam("id") String containerId); - - /** - * @param containerId The id of the container to be unpaused. - */ - @Named("container:unpause") - @POST - @Path("/containers/{id}/unpause") - void unpause(@PathParam("id") String containerId); - - /** - * @param containerId The id of the container to be attached. - */ - @Named("container:attach") - @POST - @Path("/containers/{id}/attach") - InputStream attach(@PathParam("id") String containerId); - - /** - * @param containerId The id of the container to be attached. - * @param options the attach options @see org.jclouds.docker.options.AttachOptions - * - */ - @Named("container:attach") - @POST - @Path("/containers/{id}/attach") - InputStream attach(@PathParam("id") String containerId, AttachOptions options); - - /** - * Block until container @param containerId stops, then returns the exit code - */ - @Named("container:wait") - @POST - @Path("/containers/{id}/wait") - StatusCode wait(@PathParam("id") String containerId); - - /** - * @param containerId restarts - */ - @Named("container:restart") - @POST - @Path("/containers/{id}/restart") - void restart(@PathParam("id") String containerId); - - @Named("container:restart") - @POST - @Path("/containers/{id}/restart") - void restart(@PathParam("id") String containerId, @QueryParam("t") int secondsToWait); - - - /** - * @param containerId to be killed - */ - @Named("container:kill") - @POST - @Path("/containers/{id}/kill") - void kill(@PathParam("id") String containerId); - - /** - * @param containerId to be killed - * @param signal Signal to send to the container. When not set, SIGKILL is assumed and the call will waits for the - * container to exit. - */ - @Named("container:kill") - @POST - @Path("/containers/{id}/kill") - void kill(@PathParam("id") String containerId, @QueryParam("signal") int signal); - - /** - * @param containerId to be killed - * @param signal Signal string like "SIGINT" to send to the container. When not set, SIGKILL is assumed and the call will waits for - * the container to exit. - */ - @Named("container:kill") - @POST - @Path("/containers/{id}/kill") - void kill(@PathParam("id") String containerId, @QueryParam("signal") String signal); - - /** - * @param containerId id of the container to copy files from - */ - @Named("container:copy") - @POST - @Path("/containers/{id}/copy") - InputStream copy(@PathParam("id") String containerId, @BinderParam(BindToJsonPayload.class) Resource resource); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/features/ImageApi.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/features/ImageApi.java b/docker/src/main/java/org/jclouds/docker/features/ImageApi.java deleted file mode 100644 index c93c322..0000000 --- a/docker/src/main/java/org/jclouds/docker/features/ImageApi.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.features; - -import java.io.InputStream; -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.docker.domain.Image; -import org.jclouds.docker.domain.ImageHistory; -import org.jclouds.docker.domain.ImageSummary; -import org.jclouds.docker.options.CreateImageOptions; -import org.jclouds.docker.options.DeleteImageOptions; -import org.jclouds.docker.options.ListImageOptions; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.annotations.Fallback; - -@Consumes(MediaType.APPLICATION_JSON) -@Path("/v{jclouds.api-version}") -public interface ImageApi { - - /** - * @return the images available. - */ - @Named("images:list") - @GET - @Path("/images/json") - @Fallback(EmptyListOnNotFoundOr404.class) - List<ImageSummary> listImages(); - - /** - * @param options the configuration to list images (@see ListImageOptions) - * @return the images available. - */ - @Named("images:list") - @GET - @Path("/images/json") - @Fallback(EmptyListOnNotFoundOr404.class) - List<ImageSummary> listImages(ListImageOptions options); - - /** - * Return low-level information on the image with given name. Not all fields from the returned {@link Image} instance - * are populated by this method (e.g. {@link Image#repoTags()}). - * - * @param imageName The id of the image to inspect. - * @return low-level information on the image name - */ - @Named("image:inspect") - @GET - @Path("/images/{name}/json") - @Fallback(NullOnNotFoundOr404.class) - @Nullable - Image inspectImage(@PathParam("name") String imageName); - - /** - * Create an image, either by pull it from the registry or by importing it - * - * @param options the configuration to create an image (@see CreateImageOptions) - * @return a stream of the image creation. - */ - @Named("image:create") - @POST - @Path("/images/create") - InputStream createImage(CreateImageOptions options); - - /** - * @param name the image name to be deleted - * @return the stream of the deletion execution. - */ - @Named("image:delete") - @DELETE - @Path("/images/{name}") - InputStream deleteImage(@PathParam("name") String name); - - /** - * @param name the name of the image to be removed - * @param options the image deletion's options (@see DeleteImageOptions) - * @return the stream of the deletion execution. - */ - @Named("image:delete") - @DELETE - @Path("/images/{name}") - InputStream deleteImage(@PathParam("name") String name, DeleteImageOptions options); - - /** - * Tag the image name into a repository. - * - * @param name - * the name of the image to be tagged - * @param repoName - * the repository to tag in - * @param tag - * the new tag name - * @param force - * force create if tag already exists - */ - @Named("image:tag") - @POST - @Path("/images/{name}/tag") - void tagImage(@PathParam("name") String name, @QueryParam("repo") String repoName, - @QueryParam("tag") String tag, @QueryParam("force") boolean force); - - /** - * Return the history of the image with given {@code name}. - * - * @param name - * the name of the image for which the history is retrieved - */ - @Named("image:history") - @GET - @Path("/images/{name}/history") - @Fallback(EmptyListOnNotFoundOr404.class) - List<ImageHistory> getHistory(@PathParam("name") String name); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/features/MiscApi.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/features/MiscApi.java b/docker/src/main/java/org/jclouds/docker/features/MiscApi.java deleted file mode 100644 index 5df5d04..0000000 --- a/docker/src/main/java/org/jclouds/docker/features/MiscApi.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.features; - -import java.io.InputStream; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.docker.domain.Exec; -import org.jclouds.docker.domain.ExecCreateParams; -import org.jclouds.docker.domain.ExecInspect; -import org.jclouds.docker.domain.ExecStartParams; -import org.jclouds.docker.domain.Info; -import org.jclouds.docker.domain.Version; -import org.jclouds.docker.options.BuildOptions; -import org.jclouds.docker.util.DockerInputStream; -import org.jclouds.io.Payload; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.binders.BindToJsonPayload; - -@Consumes(MediaType.APPLICATION_JSON) -@Path("/v{jclouds.api-version}") -public interface MiscApi { - - /** - * Get the information of the current docker version. - * - * @return The information of the current docker version. - */ - @Named("version") - @GET - @Path("/version") - Version getVersion(); - - /** - * Get the information of the current docker version. - * - * @return The information of the current docker version. - */ - @Named("info") - @GET - @Path("/info") - Info getInfo(); - - /** - * Build an image from Dockerfile via stdin - * - * @param inputStream The stream must be a tar archive compressed with one of the following algorithms: identity - * (no compression), gzip, bzip2, xz. - * @return a stream of the build execution - */ - @Named("image:build") - @POST - @Path("/build") - @Headers(keys = { "Content-Type", "Connection" }, values = { "application/tar", "close" }) - InputStream build(Payload inputStream); - - /** - * Build an image from Dockerfile via stdin - * - * @param inputStream The stream must be a tar archive compressed with one of the following algorithms: identity - * (no compression), gzip, bzip2, xz. - * @param options the image build's options (@see BuildOptions) - * @return a stream of the build execution - */ - @Named("image:build") - @POST - @Path("/build") - @Headers(keys = { "Content-Type", "Connection" }, values = { "application/tar", "close" }) - InputStream build(Payload inputStream, BuildOptions options); - - /** - * Sets up an exec instance in a running container with given Id. - * - * @param containerId - * container Id - * @param execCreateParams - * exec parameters - * @return an instance which holds exec identifier - */ - @Named("container:exec") - @POST - @Path("/containers/{id}/exec") - Exec execCreate(@PathParam("id") String containerId, - @BinderParam(BindToJsonPayload.class) ExecCreateParams execCreateParams); - - /** - * Starts a previously set up exec instance id. If - * {@link ExecStartParams#detach()} is true, this API returns after starting - * the exec command. Otherwise, this API sets up an interactive session with - * the exec command. - * - * @param execId - * exec instance id - * @param execStartParams - * start parameters - * @return raw docker stream which can be wrapped to - * {@link DockerInputStream} - * @see #execCreate(String, ExecCreateParams) - * @see DockerInputStream - */ - @Named("exec:start") - @POST - @Path("/exec/{id}/start") - InputStream execStart(@PathParam("id") String execId, - @BinderParam(BindToJsonPayload.class) ExecStartParams execStartParams); - - /** - * Returns low-level information about the exec command id. - * - * @param execId - * exec instance id - * @return details about exec instance - */ - @Named("exec:inspect") - @GET - @Path("/exec/{id}/json") - ExecInspect execInspect(@PathParam("id") String execId); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/features/NetworkApi.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/features/NetworkApi.java b/docker/src/main/java/org/jclouds/docker/features/NetworkApi.java deleted file mode 100644 index 79671cc..0000000 --- a/docker/src/main/java/org/jclouds/docker/features/NetworkApi.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.docker.domain.Network; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.binders.BindToJsonPayload; - -@Consumes(MediaType.APPLICATION_JSON) -@Path("/v{jclouds.api-version}/networks") -public interface NetworkApi { - - /** - * @return a set of networks - */ - @Named("networks:list") - @GET - @Fallback(EmptyListOnNotFoundOr404.class) - List<Network> listNetworks(); - - /** - * @param network the networkâs configuration (@see BindToJsonPayload) - * @return a new network - */ - @Named("network:create") - @POST - @Path("/create") - Network createNetwork(@BinderParam(BindToJsonPayload.class) Network network); - - /** - * Return low-level information on the network id - * @param networkIdOrName The id or name of the network to get. - * @return The details of the network or <code>null</code> if the network with the given id doesn't exist. - */ - @Named("network:inspect") - @GET - @Path("/{idOrName}") - @Fallback(NullOnNotFoundOr404.class) - Network inspectNetwork(@PathParam("idOrName") String networkIdOrName); - - /** - * @param networkIdOrName The id or name of the network to be removed. - */ - @Named("network:delete") - @DELETE - @Path("/{idOrName}") - void removeNetwork(@PathParam("idOrName") String networkIdOrName); - - /** - * @param networkIdOrName The id or name of the network where the container will be attached. - */ - @Named("network:connectContainer") - @POST - @Path("/{idOrName}/connect") - @Payload("%7B\"Container\":\"{containerIdOrName}\"%7D") - @Headers(keys = "Content-Type", values = "application/json") - void connectContainerToNetwork(@PathParam("idOrName") String networkIdOrName, @PayloadParam("containerIdOrName") String containerIdOrName); - - /** - * @param networkIdOrName The id or name of the network where the container was attached. - */ - @Named("network:disconnectContainer") - @POST - @Path("/{idOrName}/disconnect") - @Payload("%7B\"Container\":\"{containerIdOrName}\"%7D") - @Headers(keys = "Content-Type", values = "application/json") - void disconnectContainerFromNetwork(@PathParam("idOrName") String networkIdOrName, @PayloadParam("containerIdOrName") String containerIdOrName); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/handlers/DockerErrorHandler.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/handlers/DockerErrorHandler.java b/docker/src/main/java/org/jclouds/docker/handlers/DockerErrorHandler.java deleted file mode 100644 index a319014..0000000 --- a/docker/src/main/java/org/jclouds/docker/handlers/DockerErrorHandler.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.handlers; - -import static org.jclouds.util.Closeables2.closeQuietly; - -import java.io.IOException; - -import javax.annotation.Resource; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.logging.Logger; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.util.Strings2; - -import com.google.common.base.Throwables; - -/** - * This will parse and set an appropriate exception on the command object. - * <p/> - * <p/> - * Errors are returned with an appropriate HTTP status code, an X-Elastic- Error header specifying - * the error type, and a text description in the HTTP body. - */ -public class DockerErrorHandler implements HttpErrorHandler { - @Resource - protected Logger logger = Logger.NULL; - - public void handleError(HttpCommand command, HttpResponse response) { - // it is important to always read fully and close streams - String message = parseMessage(response); - Exception exception = message != null ? new HttpResponseException(command, response, message) - : new HttpResponseException(command, response); - try { - message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), - response.getStatusLine()); - switch (response.getStatusCode()) { - case 400: - if ((command.getCurrentRequest().getEndpoint().getPath().endsWith("/info")) - || (message != null && message.indexOf("could not be found") != -1)) - exception = new ResourceNotFoundException(message, exception); - else if (message != null && message.indexOf("currently in use") != -1) - exception = new IllegalStateException(message, exception); - else - exception = new IllegalArgumentException(message, exception); - break; - case 401: - exception = new AuthorizationException(message, exception); - break; - case 402: - exception = new IllegalStateException(message, exception); - break; - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - exception = new ResourceNotFoundException(message, exception); - } - break; - case 405: - exception = new IllegalArgumentException(message, exception); - break; - case 409: - exception = new IllegalStateException(message, exception); - break; - } - } finally { - closeQuietly(response.getPayload()); - command.setException(exception); - } - } - - public String parseMessage(HttpResponse response) { - if (response.getPayload() == null) - return null; - try { - return Strings2.toStringAndClose(response.getPayload().openStream()); - } catch (IOException e) { - throw Throwables.propagate(e); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/internal/NullSafeCopies.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/internal/NullSafeCopies.java b/docker/src/main/java/org/jclouds/docker/internal/NullSafeCopies.java deleted file mode 100644 index f3d9eb8..0000000 --- a/docker/src/main/java/org/jclouds/docker/internal/NullSafeCopies.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.internal; - -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -public class NullSafeCopies { - - public static <K, V> Map<K, V> copyOf(@Nullable Map<K, V> map) { - return map != null ? ImmutableMap.copyOf(map) : ImmutableMap.<K, V> of(); - } - - public static <E> List<E> copyOf(@Nullable List<E> list) { - return list != null ? ImmutableList.copyOf(list) : ImmutableList.<E> of(); - } - - public static <E> List<E> copyOf(@Nullable Iterable<E> list) { - return list != null ? ImmutableList.copyOf(list) : ImmutableList.<E> of(); - } - - public static <E> List<E> copyOf(@Nullable E[] array) { - return array != null ? ImmutableList.copyOf(array) : ImmutableList.<E> of(); - } - - /** - * Copies given List with keeping null value if provided. - * - * @param list - * instance to copy (maybe <code>null</code>) - * @return if the parameter is not-<code>null</code> then immutable copy; - * <code>null</code> otherwise - */ - public static <E> List<E> copyWithNullOf(@Nullable List<E> list) { - return list != null ? ImmutableList.copyOf(list) : null; - } - - /** - * Copies given Map with keeping null value if provided. - * - * @param map - * instance to copy (maybe <code>null</code>) - * @return if the parameter is not-<code>null</code> then immutable copy; - * <code>null</code> otherwise - */ - public static <K, V> Map<K, V> copyWithNullOf(@Nullable Map<K, V> map) { - return map != null ? ImmutableMap.copyOf(map) : null; - } - - /** - * Copies given {@link Iterable} into immutable {@link List} with keeping null value if provided. - * - * @param iterable - * instance to copy (maybe <code>null</code>) - * @return if the parameter is not-<code>null</code> then immutable copy; - * <code>null</code> otherwise - */ - public static <E> List<E> copyWithNullOf(@Nullable Iterable<E> iterable) { - return iterable != null ? ImmutableList.copyOf(iterable) : null; - } - - /** - * Copies given array into immutable {@link List} with keeping null value if provided. - * - * @param array - * instance to copy (maybe <code>null</code>) - * @return if the parameter is not-<code>null</code> then immutable copy; - * <code>null</code> otherwise - */ - public static <E> List<E> copyWithNullOf(@Nullable E[] array) { - return array != null ? ImmutableList.copyOf(array) : null; - } - - private NullSafeCopies() { - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/options/AttachOptions.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/options/AttachOptions.java b/docker/src/main/java/org/jclouds/docker/options/AttachOptions.java deleted file mode 100644 index 3c21865..0000000 --- a/docker/src/main/java/org/jclouds/docker/options/AttachOptions.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -public class AttachOptions extends BaseHttpRequestOptions { - - /** - * @param stream When TTY is enabled, the stream is the raw data from the process PTY and client's stdin. - * When TTY is disabled, the stream is multiplexed to separate stdout and stderr. - * @return AttachOptions - */ - public AttachOptions stream(boolean stream) { - this.queryParameters.put("stream", String.valueOf(stream)); - return this; - } - - /** - * @param logs require logs to be attached. Default false. - * @return AttachOptions - */ - public AttachOptions logs(boolean logs) { - this.queryParameters.put("logs", String.valueOf(logs)); - return this; - } - - /** - * @param stdin if stream=true, attach to stdin. Default false - * @return AttachOptions - */ - public AttachOptions stdin(boolean stdin) { - this.queryParameters.put("stdin", String.valueOf(stdin)); - return this; - } - - /** - * @param stdout if logs=true, return stdout log, if stream=true, attach to stdout. Default false - * @return - */ - public AttachOptions stdout(boolean stdout) { - this.queryParameters.put("stdout", String.valueOf(stdout)); - return this; - } - - /** - * - * @param stderr if logs=true, return stderr log, if stream=true, attach to stderr. Default false - * @return - */ - public AttachOptions stderr(boolean stderr) { - this.queryParameters.put("stderr", String.valueOf(stderr)); - return this; - } - - public static class Builder { - - /** - * @see org.jclouds.docker.options.AttachOptions#stream - */ - public static AttachOptions stream(boolean stream) { - AttachOptions options = new AttachOptions(); - return options.stream(stream); - } - - /** - * @see org.jclouds.docker.options.AttachOptions#logs(Boolean) - */ - public static AttachOptions logs(boolean logs) { - AttachOptions options = new AttachOptions(); - return options.logs(logs); - } - - /** - * @see org.jclouds.docker.options.AttachOptions#stdin(Boolean) - */ - public static AttachOptions stdin(boolean stdin) { - AttachOptions options = new AttachOptions(); - return options.stdin(stdin); - } - - /** - * @see org.jclouds.docker.options.AttachOptions#stdout(Boolean) - */ - public static AttachOptions stdout(boolean stdout) { - AttachOptions options = new AttachOptions(); - return options.stdout(stdout); - } - - /** - * @see org.jclouds.docker.options.AttachOptions#stderr(Boolean) - */ - public static AttachOptions stderr(boolean stderr) { - AttachOptions options = new AttachOptions(); - return options.stderr(stderr); - } - - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/options/BuildOptions.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/options/BuildOptions.java b/docker/src/main/java/org/jclouds/docker/options/BuildOptions.java deleted file mode 100644 index 15d95e0..0000000 --- a/docker/src/main/java/org/jclouds/docker/options/BuildOptions.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -public class BuildOptions extends BaseHttpRequestOptions { - - public BuildOptions tag(String tag) { - this.queryParameters.put("t", tag); - return this; - } - - public BuildOptions verbose(boolean verbose) { - this.queryParameters.put("verbose", String.valueOf(verbose)); - return this; - } - - public BuildOptions nocache(boolean nocache) { - this.queryParameters.put("nocache", String.valueOf(nocache)); - return this; - } - - public static class Builder { - - /** - * @see BuildOptions#tag - */ - public static BuildOptions tag(String tag) { - BuildOptions options = new BuildOptions(); - return options.tag(tag); - } - - /** - * @see BuildOptions#verbose(Boolean) - */ - public static BuildOptions verbose(boolean verbose) { - BuildOptions options = new BuildOptions(); - return options.verbose(verbose); - } - - /** - * @see BuildOptions#nocache(Boolean) - */ - public static BuildOptions nocache(boolean nocache) { - BuildOptions options = new BuildOptions(); - return options.nocache(nocache); - } - - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/options/CommitOptions.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/options/CommitOptions.java b/docker/src/main/java/org/jclouds/docker/options/CommitOptions.java deleted file mode 100644 index fbf35b6..0000000 --- a/docker/src/main/java/org/jclouds/docker/options/CommitOptions.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -public class CommitOptions extends BaseHttpRequestOptions { - - public CommitOptions containerId(String containerId) { - this.queryParameters.put("containerId", containerId); - return this; - } - - public CommitOptions repository(String repository) { - this.queryParameters.put("repository", repository); - return this; - } - - public CommitOptions tag(String tag) { - this.queryParameters.put("tag", tag); - return this; - } - - public CommitOptions message(String message) { - this.queryParameters.put("message", message); - return this; - } - - public CommitOptions author(String author) { - this.queryParameters.put("author", author); - return this; - } - - public CommitOptions run(String run) { - this.queryParameters.put("run", run); - return this; - } - - public static class Builder { - - /** - * @see CommitOptions#containerId - */ - public static CommitOptions containerId(String containerId) { - CommitOptions options = new CommitOptions(); - return options.containerId(containerId); - } - - /** - * @see CommitOptions#repository - */ - public static CommitOptions repository(String repository) { - CommitOptions options = new CommitOptions(); - return options.repository(repository); - } - - /** - * @see CommitOptions#tag - */ - public static CommitOptions tag(String tag) { - CommitOptions options = new CommitOptions(); - return options.tag(tag); - } - - /** - * @see CommitOptions#message - */ - public static CommitOptions message(String message) { - CommitOptions options = new CommitOptions(); - return options.message(message); - } - - /** - * @see CommitOptions#author - */ - public static CommitOptions author(String author) { - CommitOptions options = new CommitOptions(); - return options.author(author); - } - - /** - * @see CommitOptions#run - */ - public static CommitOptions run(String run) { - CommitOptions options = new CommitOptions(); - return options.run(run); - } - - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/options/CreateImageOptions.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/options/CreateImageOptions.java b/docker/src/main/java/org/jclouds/docker/options/CreateImageOptions.java deleted file mode 100644 index 91b8413..0000000 --- a/docker/src/main/java/org/jclouds/docker/options/CreateImageOptions.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -public class CreateImageOptions extends BaseHttpRequestOptions { - - public CreateImageOptions fromImage(String fromImage) { - this.queryParameters.put("fromImage", fromImage); - return this; - } - - public CreateImageOptions fromSrc(String fromSrc) { - this.queryParameters.put("fromSrc", fromSrc); - return this; - } - - public CreateImageOptions repo(String repo) { - this.queryParameters.put("repo", repo); - return this; - } - - public CreateImageOptions tag(String tag) { - this.queryParameters.put("tag", tag); - return this; - } - - public CreateImageOptions registry(String registry) { - this.queryParameters.put("registry", registry); - return this; - } - - public static class Builder { - /** - * @see CreateImageOptions#fromImage - */ - public static CreateImageOptions fromImage(String fromImage) { - CreateImageOptions options = new CreateImageOptions(); - return options.fromImage(fromImage); - } - - /** - * @see CreateImageOptions#fromSrc - */ - public static CreateImageOptions fromSrc(String fromSrc) { - CreateImageOptions options = new CreateImageOptions(); - return options.fromSrc(fromSrc); - } - - /** - * @see CreateImageOptions#repo - */ - public static CreateImageOptions repo(String repo) { - CreateImageOptions options = new CreateImageOptions(); - return options.repo(repo); - } - - /** - * @see CreateImageOptions#tag - */ - public static CreateImageOptions tag(String tag) { - CreateImageOptions options = new CreateImageOptions(); - return options.tag(tag); - } - - /** - * @see CreateImageOptions#registry - */ - public static CreateImageOptions registry(String registry) { - CreateImageOptions options = new CreateImageOptions(); - return options.registry(registry); - } - - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/options/DeleteImageOptions.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/options/DeleteImageOptions.java b/docker/src/main/java/org/jclouds/docker/options/DeleteImageOptions.java deleted file mode 100644 index c284fd9..0000000 --- a/docker/src/main/java/org/jclouds/docker/options/DeleteImageOptions.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -public class DeleteImageOptions extends BaseHttpRequestOptions { - - public DeleteImageOptions force(boolean force) { - this.queryParameters.put("force", String.valueOf(force)); - return this; - } - - public DeleteImageOptions noPrune(boolean noPrune) { - this.queryParameters.put("noPrune", String.valueOf(noPrune)); - return this; - } - - public static class Builder { - - /** - * @see DeleteImageOptions#force - */ - public static DeleteImageOptions force(boolean force) { - DeleteImageOptions options = new DeleteImageOptions(); - return options.force(force); - } - - /** - * @see DeleteImageOptions#noPrune - */ - public static DeleteImageOptions noPrune(boolean noPrune) { - DeleteImageOptions options = new DeleteImageOptions(); - return options.noPrune(noPrune); - } - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/options/ListContainerOptions.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/options/ListContainerOptions.java b/docker/src/main/java/org/jclouds/docker/options/ListContainerOptions.java deleted file mode 100644 index 173f6fb..0000000 --- a/docker/src/main/java/org/jclouds/docker/options/ListContainerOptions.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -public class ListContainerOptions extends BaseHttpRequestOptions { - - public ListContainerOptions all(boolean all) { - this.queryParameters.put("all", String.valueOf(all)); - return this; - } - - public ListContainerOptions limit(Integer limit) { - this.queryParameters.put("limit", limit.toString()); - return this; - } - - public ListContainerOptions since(Integer since) { - this.queryParameters.put("since", since.toString()); - return this; - } - - public ListContainerOptions before(Integer before) { - this.queryParameters.put("before", before.toString()); - return this; - } - - public ListContainerOptions size(Integer size) { - this.queryParameters.put("size", size.toString()); - return this; - } - - public static class Builder { - - /** - * @see ListContainerOptions#all - */ - public static ListContainerOptions all(boolean all) { - ListContainerOptions options = new ListContainerOptions(); - return options.all(all); - } - - /** - * @see ListContainerOptions#limit(Integer) - */ - public static ListContainerOptions limit(Integer limit) { - ListContainerOptions options = new ListContainerOptions(); - return options.limit(limit); - } - - /** - * @see ListContainerOptions#since(Integer) - */ - public static ListContainerOptions since(Integer since) { - ListContainerOptions options = new ListContainerOptions(); - return options.since(since); - } - - /** - * @see ListContainerOptions#before(Integer) - */ - public static ListContainerOptions before(Integer before) { - ListContainerOptions options = new ListContainerOptions(); - return options.before(before); - } - - /** - * @see ListContainerOptions#limit(Integer) - */ - public static ListContainerOptions size(Integer size) { - ListContainerOptions options = new ListContainerOptions(); - return options.size(size); - } - - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/options/ListImageOptions.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/options/ListImageOptions.java b/docker/src/main/java/org/jclouds/docker/options/ListImageOptions.java deleted file mode 100644 index f4704d0..0000000 --- a/docker/src/main/java/org/jclouds/docker/options/ListImageOptions.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -public class ListImageOptions extends BaseHttpRequestOptions { - - public ListImageOptions all(boolean all) { - this.queryParameters.put("all", String.valueOf(all)); - return this; - } - - public static class Builder { - /** - * @see ListImageOptions#all - */ - public static ListImageOptions all(boolean all) { - ListImageOptions options = new ListImageOptions(); - return options.all(all); - } - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/options/RemoveContainerOptions.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/options/RemoveContainerOptions.java b/docker/src/main/java/org/jclouds/docker/options/RemoveContainerOptions.java deleted file mode 100644 index f4a6795..0000000 --- a/docker/src/main/java/org/jclouds/docker/options/RemoveContainerOptions.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -public class RemoveContainerOptions extends BaseHttpRequestOptions { - - public RemoveContainerOptions verbose(boolean verbose) { - this.queryParameters.put("verbose", String.valueOf(verbose)); - return this; - } - - public RemoveContainerOptions force(boolean force) { - this.queryParameters.put("force", String.valueOf(force)); - return this; - } - - /** - * Remove the volumes associated to the container - * - * @param volume If set to true the volume associated to the container will be removed. - * Otherwise it will not be removed. - */ - public RemoveContainerOptions volume(boolean volume) { - this.queryParameters.put("v", String.valueOf(volume)); - return this; - } - - public static class Builder { - /** - * @see RemoveContainerOptions#verbose - */ - public static RemoveContainerOptions verbose(boolean verbose) { - RemoveContainerOptions options = new RemoveContainerOptions(); - return options.verbose(verbose); - } - - /** - * @see RemoveContainerOptions#force - */ - public static RemoveContainerOptions force(boolean force) { - RemoveContainerOptions options = new RemoveContainerOptions(); - return options.force(force); - } - - /** - * @see RemoveContainerOptions#volume - */ - public static RemoveContainerOptions volume(boolean volume) { - RemoveContainerOptions options = new RemoveContainerOptions(); - return options.volume(volume); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/suppliers/DockerSSLContextSupplier.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/suppliers/DockerSSLContextSupplier.java b/docker/src/main/java/org/jclouds/docker/suppliers/DockerSSLContextSupplier.java deleted file mode 100644 index 326528a..0000000 --- a/docker/src/main/java/org/jclouds/docker/suppliers/DockerSSLContextSupplier.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.suppliers; - -import com.google.common.base.Strings; -import com.google.common.base.Supplier; - -import org.jclouds.docker.DockerApiMetadata; -import org.jclouds.domain.Credentials; -import org.jclouds.location.Provider; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -import javax.net.ssl.SSLContext; - -import java.io.IOException; -import java.security.GeneralSecurityException; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Throwables.propagate; -import static org.jclouds.docker.suppliers.SSLContextBuilder.isClientKeyAndCertificateData; - -@Singleton -public class DockerSSLContextSupplier implements Supplier<SSLContext> { - private final Supplier<Credentials> creds; - private final String caCertPath; - private final String caCertData; - - @Inject - DockerSSLContextSupplier(@Provider Supplier<Credentials> creds, @Named(DockerApiMetadata.DOCKER_CA_CERT_PATH) String caCertPath, @Named(DockerApiMetadata.DOCKER_CA_CERT_DATA) String caCertData) { - this.creds = creds; - this.caCertPath = caCertPath; - this.caCertData = caCertData; - } - - @Override - public SSLContext get() { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - try { - SSLContextBuilder builder = new SSLContextBuilder(); - if (isClientKeyAndCertificateData(currentCreds.credential, currentCreds.identity)) { - builder.clientKeyAndCertificateData(currentCreds.credential, currentCreds.identity); - } else { - builder.clientKeyAndCertificatePaths(currentCreds.credential, currentCreds.identity); - } - if (!Strings.isNullOrEmpty(caCertPath)) { - builder.caCertificatePath(caCertPath); - } else if (!Strings.isNullOrEmpty(caCertData)) { - builder.caCertificateData(caCertData); - } - return builder.build(); - } catch (GeneralSecurityException e) { - throw propagate(e); - } catch (IOException e) { - throw propagate(e); - } - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/39cd6698/docker/src/main/java/org/jclouds/docker/suppliers/DockerUntrustedSSLContextSupplier.java ---------------------------------------------------------------------- diff --git a/docker/src/main/java/org/jclouds/docker/suppliers/DockerUntrustedSSLContextSupplier.java b/docker/src/main/java/org/jclouds/docker/suppliers/DockerUntrustedSSLContextSupplier.java deleted file mode 100644 index f20ccef..0000000 --- a/docker/src/main/java/org/jclouds/docker/suppliers/DockerUntrustedSSLContextSupplier.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.suppliers; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Supplier; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.config.SSLModule; -import org.jclouds.location.Provider; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.net.ssl.SSLContext; - -import java.io.File; -import java.io.IOException; -import java.security.GeneralSecurityException; - -import static com.google.common.base.Throwables.propagate; -import static org.jclouds.docker.suppliers.SSLContextBuilder.isClientKeyAndCertificateData; - -@Singleton -public class DockerUntrustedSSLContextSupplier implements Supplier<SSLContext> { - private final Supplier<Credentials> creds; - private final SSLModule.TrustAllCerts insecureTrustManager; - - @Inject - DockerUntrustedSSLContextSupplier(@Provider Supplier<Credentials> creds, - SSLModule.TrustAllCerts insecureTrustManager) { - this.creds = creds; - this.insecureTrustManager = insecureTrustManager; - } - - @Override - public SSLContext get() { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - try { - SSLContextBuilder builder = new SSLContextBuilder(); - if (isClientKeyAndCertificateData(currentCreds.credential, currentCreds.identity)) { - builder.clientKeyAndCertificateData(currentCreds.credential, currentCreds.identity); - } else if (new File(currentCreds.identity).isFile() && new File(currentCreds.credential).isFile()) { - builder.clientKeyAndCertificatePaths(currentCreds.credential, currentCreds.identity); - } - builder.trustManager(insecureTrustManager); - return builder.build(); - } catch (GeneralSecurityException e) { - throw propagate(e); - } catch (IOException e) { - throw propagate(e); - } - } - -}
