diff --git a/azure-mgmt-containerinstance/pom.xml b/azure-mgmt-containerinstance/pom.xml new file mode 100644 index 00000000000..46fee2f5d9c --- /dev/null +++ b/azure-mgmt-containerinstance/pom.xml @@ -0,0 +1,148 @@ + + + 4.0.0 + + com.microsoft.azure + azure-parent + 1.2.2-SNAPSHOT + ../pom.xml + + + azure-mgmt-containerinstance + jar + + Microsoft Azure SDK for Container Instance Management + This package contains Microsoft Azure Container Instance SDK. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + UTF-8 + + + + + + microsoft + Microsoft + + + + + + com.microsoft.azure + azure-client-runtime + + + com.microsoft.azure + azure-mgmt-resources + 1.2.2-SNAPSHOT + + + junit + junit + test + + + com.microsoft.azure + azure-client-authentication + test + + + com.microsoft.azure + azure-mgmt-storage + 1.2.2-SNAPSHOT + + + com.microsoft.azure + azure-mgmt-resources + 1.2.2-SNAPSHOT + test-jar + test + + + com.microsoft.azure + azure-mgmt-storage + 1.2.2-SNAPSHOT + + + com.microsoft.azure + azure-storage + 4.4.0 + + + commons-io + commons-io + test + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + com.microsoft.azure.management.apigeneration.LangDefinitionProcessor + + true + true + + true + true + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.storage + /** +
* Copyright (c) Microsoft Corporation. All rights reserved. +
* Licensed under the MIT License. See License.txt in the project root for +
* license information. +
*/]]>
+
+
+ +
+
+ +
diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/AzureFileVolume.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/AzureFileVolume.java new file mode 100644 index 00000000000..c7d098d4b23 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/AzureFileVolume.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The Azure file volume. + */ +public class AzureFileVolume { + /** + * The Azure file share name. + */ + @JsonProperty(value = "shareName", required = true) + private String shareName; + + /** + * The flag indicating whether the Azure file volume is read only. + */ + @JsonProperty(value = "readOnly") + private Boolean readOnly; + + /** + * The storage account name to access to the Azure file. + */ + @JsonProperty(value = "storageAccountName", required = true) + private String storageAccountName; + + /** + * The storage account key to access to the Azure file. + */ + @JsonProperty(value = "storageAccountKey") + private String storageAccountKey; + + /** + * Get the shareName value. + * + * @return the shareName value + */ + public String shareName() { + return this.shareName; + } + + /** + * Set the shareName value. + * + * @param shareName the shareName value to set + * @return the AzureFileVolume object itself. + */ + public AzureFileVolume withShareName(String shareName) { + this.shareName = shareName; + return this; + } + + /** + * Get the readOnly value. + * + * @return the readOnly value + */ + public Boolean readOnly() { + return this.readOnly; + } + + /** + * Set the readOnly value. + * + * @param readOnly the readOnly value to set + * @return the AzureFileVolume object itself. + */ + public AzureFileVolume withReadOnly(Boolean readOnly) { + this.readOnly = readOnly; + return this; + } + + /** + * Get the storageAccountName value. + * + * @return the storageAccountName value + */ + public String storageAccountName() { + return this.storageAccountName; + } + + /** + * Set the storageAccountName value. + * + * @param storageAccountName the storageAccountName value to set + * @return the AzureFileVolume object itself. + */ + public AzureFileVolume withStorageAccountName(String storageAccountName) { + this.storageAccountName = storageAccountName; + return this; + } + + /** + * Get the storageAccountKey value. + * + * @return the storageAccountKey value + */ + public String storageAccountKey() { + return this.storageAccountKey; + } + + /** + * Set the storageAccountKey value. + * + * @param storageAccountKey the storageAccountKey value to set + * @return the AzureFileVolume object itself. + */ + public AzureFileVolume withStorageAccountKey(String storageAccountKey) { + this.storageAccountKey = storageAccountKey; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/Container.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/Container.java new file mode 100644 index 00000000000..824c8445f5a --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/Container.java @@ -0,0 +1,217 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * A container instance. + */ +@JsonFlatten +public class Container { + /** + * The user-provided name of this container. + */ + @JsonProperty(value = "name", required = true) + private String name; + + /** + * The name of the image used when creating this container. + */ + @JsonProperty(value = "properties.image", required = true) + private String image; + + /** + * Command array to execute within the container in exec form. + */ + @JsonProperty(value = "properties.command") + private List command; + + /** + * The ports exposed by this container. + */ + @JsonProperty(value = "properties.ports") + private List ports; + + /** + * The environment variables to set in this container. + */ + @JsonProperty(value = "properties.environmentVariables") + private List environmentVariables; + + /** + * The instance view of the container. Only valid in response. + */ + @JsonProperty(value = "properties.instanceView", access = JsonProperty.Access.WRITE_ONLY) + private ContainerPropertiesInstanceView instanceView; + + /** + * The resource requirements of this container. + */ + @JsonProperty(value = "properties.resources", required = true) + private ResourceRequirements resources; + + /** + * The volume mounts. + */ + @JsonProperty(value = "properties.volumeMounts") + private List volumeMounts; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the Container object itself. + */ + public Container withName(String name) { + this.name = name; + return this; + } + + /** + * Get the image value. + * + * @return the image value + */ + public String image() { + return this.image; + } + + /** + * Set the image value. + * + * @param image the image value to set + * @return the Container object itself. + */ + public Container withImage(String image) { + this.image = image; + return this; + } + + /** + * Get the command value. + * + * @return the command value + */ + public List command() { + return this.command; + } + + /** + * Set the command value. + * + * @param command the command value to set + * @return the Container object itself. + */ + public Container withCommand(List command) { + this.command = command; + return this; + } + + /** + * Get the ports value. + * + * @return the ports value + */ + public List ports() { + return this.ports; + } + + /** + * Set the ports value. + * + * @param ports the ports value to set + * @return the Container object itself. + */ + public Container withPorts(List ports) { + this.ports = ports; + return this; + } + + /** + * Get the environmentVariables value. + * + * @return the environmentVariables value + */ + public List environmentVariables() { + return this.environmentVariables; + } + + /** + * Set the environmentVariables value. + * + * @param environmentVariables the environmentVariables value to set + * @return the Container object itself. + */ + public Container withEnvironmentVariables(List environmentVariables) { + this.environmentVariables = environmentVariables; + return this; + } + + /** + * Get the instanceView value. + * + * @return the instanceView value + */ + public ContainerPropertiesInstanceView instanceView() { + return this.instanceView; + } + + /** + * Get the resources value. + * + * @return the resources value + */ + public ResourceRequirements resources() { + return this.resources; + } + + /** + * Set the resources value. + * + * @param resources the resources value to set + * @return the Container object itself. + */ + public Container withResources(ResourceRequirements resources) { + this.resources = resources; + return this; + } + + /** + * Get the volumeMounts value. + * + * @return the volumeMounts value + */ + public List volumeMounts() { + return this.volumeMounts; + } + + /** + * Set the volumeMounts value. + * + * @param volumeMounts the volumeMounts value to set + * @return the Container object itself. + */ + public Container withVolumeMounts(List volumeMounts) { + this.volumeMounts = volumeMounts; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerEvent.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerEvent.java new file mode 100644 index 00000000000..9a3e3c5aae1 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerEvent.java @@ -0,0 +1,148 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A container event. + */ +public class ContainerEvent { + /** + * The count of the event. + */ + @JsonProperty(value = "count") + private Integer count; + + /** + * Date/time of the first event. + */ + @JsonProperty(value = "firstTimestamp") + private DateTime firstTimestamp; + + /** + * Date/time of the last event. + */ + @JsonProperty(value = "lastTimestamp") + private DateTime lastTimestamp; + + /** + * The event message. + */ + @JsonProperty(value = "message") + private String message; + + /** + * The event type. + */ + @JsonProperty(value = "type") + private String type; + + /** + * Get the count value. + * + * @return the count value + */ + public Integer count() { + return this.count; + } + + /** + * Set the count value. + * + * @param count the count value to set + * @return the ContainerEvent object itself. + */ + public ContainerEvent withCount(Integer count) { + this.count = count; + return this; + } + + /** + * Get the firstTimestamp value. + * + * @return the firstTimestamp value + */ + public DateTime firstTimestamp() { + return this.firstTimestamp; + } + + /** + * Set the firstTimestamp value. + * + * @param firstTimestamp the firstTimestamp value to set + * @return the ContainerEvent object itself. + */ + public ContainerEvent withFirstTimestamp(DateTime firstTimestamp) { + this.firstTimestamp = firstTimestamp; + return this; + } + + /** + * Get the lastTimestamp value. + * + * @return the lastTimestamp value + */ + public DateTime lastTimestamp() { + return this.lastTimestamp; + } + + /** + * Set the lastTimestamp value. + * + * @param lastTimestamp the lastTimestamp value to set + * @return the ContainerEvent object itself. + */ + public ContainerEvent withLastTimestamp(DateTime lastTimestamp) { + this.lastTimestamp = lastTimestamp; + return this; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + * @return the ContainerEvent object itself. + */ + public ContainerEvent withMessage(String message) { + this.message = message; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the ContainerEvent object itself. + */ + public ContainerEvent withType(String type) { + this.type = type; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerGroup.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerGroup.java new file mode 100644 index 00000000000..50589191824 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerGroup.java @@ -0,0 +1,725 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.containerinstance; + +import com.microsoft.azure.management.apigeneration.Beta; +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.containerinstance.implementation.ContainerGroupInner; +import com.microsoft.azure.management.containerinstance.implementation.ContainerInstanceManager; +import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; +import com.microsoft.azure.management.resources.fluentcore.model.Attachable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; +import com.microsoft.azure.management.resources.fluentcore.model.Refreshable; +import rx.Observable; + +import java.util.Collection; +import java.util.Map; + +/** + * An immutable client-side representation of an Azure Container Group. + */ +@Fluent +@Beta(Beta.SinceVersion.V1_3_0) +public interface ContainerGroup extends + GroupableResource, + Refreshable { + + /*********************************************************** + * Getters + ***********************************************************/ + + /** + * @return the container instances in this container group + */ + Map containers(); + + /** + * @return all the ports publicly exposed for this container group + */ + Collection externalPorts(); + + /** + * @return the TCP ports publicly exposed for this container group + */ + int[] externalTcpPorts(); + + /** + * @return the UDP ports publicly exposed for this container group + */ + int[] externalUdpPorts(); + + /** + * @return the volumes for this container group + */ + Map volumes(); + + /** + * @return the Docker image registry servers by which the container group is created from + */ + Collection imageRegistryServers(); + + /** + * @return `always` Always restart + + */ + ContainerRestartPolicy restartPolicy(); + + /** + * @return the IP address + */ + String ipAddress(); + + /** + * @return true if IP address is public + */ + boolean isIPAddressPublic(); + + /** + * @return the base level OS type required by the containers in the group + */ + OperatingSystemTypes osType(); + + /** + * @return the state of the container group; only valid in response + */ + String state(); + + /** + * @return the provisioningState of the container group + */ + String provisioningState(); + + + /*********************************************************** + * Actions + ***********************************************************/ + + /** + * Get the log content for the specified container instance within the container group. + * + * @param containerName the container instance name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return all available log lines + */ + String getLogContent(String containerName); + + /** + * Get the log content for the specified container instance within the container group. + * + * @param containerName the container instance name + * @param tailLineCount only get the last log lines up to this + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the log lines from the end, up to the number specified + */ + String getLogContent(String containerName, int tailLineCount); + + /** + * Get the log content for the specified container instance within the container group. + * + * @param containerName the container instance name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return a representation of the future computation of this call + */ + Observable getLogContentAsync(String containerName); + + /** + * Get the log content for the specified container instance within the container group. + * + * @param containerName the container instance name + * @param tailLineCount only get the last log lines up to this + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return a representation of the future computation of this call + */ + Observable getLogContentAsync(String containerName, int tailLineCount); + + + /** + * The entirety of the Azure Container Instance service container group definition. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithGroup, + DefinitionStages.WithOsType, + DefinitionStages.WithPublicOrPrivateImageRegistry, + DefinitionStages.WithPrivateImageRegistryOrVolume, + DefinitionStages.WithVolume, + DefinitionStages.WithFirstContainerInstance, + DefinitionStages.WithNextContainerInstance, + DefinitionStages.WithCreate { + } + + /** + * Grouping of the container group definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the container group definition. + */ + interface Blank + extends GroupableResource.DefinitionWithRegion { + } + + /** + * The stage of the container group definition allowing to specify the resource group. + */ + interface WithGroup + extends GroupableResource.DefinitionStages.WithGroup { + } + + /** + * The stage of the container group definition allowing to specify the OS type. + */ + interface WithOsType { + /** + * Specifies this is a Linux container group. + * + * @return the next stage of the definition + */ + WithPublicOrPrivateImageRegistry withLinux(); + + /** + * Specifies this is a Windows container group. + * + * @return the next stage of the definition + */ + WithPublicOrPrivateImageRegistry withWindows(); + } + + /** + * The stage of the container group definition allowing to specify a public only or private image registry. + */ + interface WithPublicOrPrivateImageRegistry extends WithPublicImageRegistryOnly, WithPrivateImageRegistry { + } + + /** + * The stage of the container group definition allowing to skip the private image registry. + */ + interface WithPublicImageRegistryOnly { + /** + * Only public container image repository will be used to create the container instances in the container group. + * + * @return the next stage of the definition + */ + WithPrivateImageRegistryOrVolume withPublicImageRegistryOnly(); + } + + /** + * The stage of the container group definition allowing to specify a private image registry. + */ + interface WithPrivateImageRegistry { + /** + * Specifies the private container image registry server login for the container group. + * + * @param server Docker image registry server, without protocol such as "http" and "https" + * @param username the username for the private registry + * @param password the password for the private registry + * @return the next stage of the definition + */ + WithPrivateImageRegistryOrVolume withPrivateImageRegistry(String server, String username, String password); + } + + /** + * The stage of the container group definition allowing to specify a private image registry or a volume. + */ + interface WithPrivateImageRegistryOrVolume extends WithPrivateImageRegistry { + /** + * Skips the definition of volumes to be shared by the container instances. + * + *

+ * An IllegalArgumentException will be thrown if a container instance attempts to define a volume mounting. + * @return the next stage of the definition + */ + WithFirstContainerInstance withoutVolume(); + + /** + * Specifies a new Azure file share name to be created. + * + * @param volumeName the name of the volume + * @param shareName the Azure file share name to be created + * @return the next stage of the definition + */ + WithFirstContainerInstance withNewAzureFileShareVolume(String volumeName, String shareName); + + /** + * Begins the definition of a volume that can be shared by the container instances in the container group. + * + *

+ * The definition must be completed with a call to {@link VolumeDefinitionStages.WithAttach#attach()} + * @param name the name of the volume + * @return the next stage of the definition + */ + VolumeDefinitionStages.Blank defineVolume(String name); + } + + + + /** + * The stage of the container group definition allowing to specify a volume that can be mounted by a container instance. + */ + interface WithVolume extends WithFirstContainerInstance { + /** + * Begins the definition of a volume that can be shared by the container instances in the container group. + * + *

+ * The definition must be completed with a call to {@link VolumeDefinitionStages.WithAttach#attach()} + * @param name the name of the volume + * @return the next stage of the definition + */ + VolumeDefinitionStages.Blank defineVolume(String name); + + } + + /** + * Grouping of volume definition stages. + */ + interface VolumeDefinitionStages { + /** + * The first stage of the volume definition. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface Blank extends WithAzureFileShare { + } + + /** + * The stage of the volume definition allowing to specify a read only Azure File Share name. + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithAzureFileShare { + /** + * Specifies an existing Azure file share name. + * + * @param shareName an existing Azure file share name + * @return the next stage of the definition + */ + WithStorageAccountName withExistingReadWriteAzureFileShare(String shareName); + + /** + * Specifies an existing Azure file share name. + * + * @param shareName an existing Azure file share name + * @return the next stage of the definition + */ + WithStorageAccountName withExistingReadOnlyAzureFileShare(String shareName); + } + + /** + * The stage of the volume definition allowing to specify the storage account name to access to the Azure file. + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithStorageAccountName { + /** + * Specifies the storage account name to access to the Azure file. + * + * @param storageAccountName the storage account name + * @return the next stage of the definition + */ + WithStorageAccountKey withStorageAccountName(String storageAccountName); + } + + /** + * The stage of the volume definition allowing to specify the storage account key to access to the Azure file. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithStorageAccountKey { + /** + * Specifies the storage account key to access to the Azure file. + * + * @param storageAccountKey the storage account key + * @return the next stage of the definition + */ + WithAttach withStorageAccountKey(String storageAccountKey); + } + + /** The final stage of the volume definition. + *

+ * At this stage, any remaining optional settings can be specified, or the subnet definition + * can be attached to the parent virtual network definition. + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithAttach extends + Attachable.InDefinition { + } + + /** + * Grouping of the container group's volume definition stages. + */ + interface VolumeDefinition extends + Blank, + WithAzureFileShare, + WithStorageAccountName, + WithStorageAccountKey, + WithAttach { + } + } + + /** + * The stage of the container group definition allowing to specify first required container instance. + */ + interface WithFirstContainerInstance { + /** + * Begins the definition of a container instance. + * + * @param name the name of the container instance + * @return the next stage of the definition + */ + ContainerInstanceDefinitionStages.Blank defineContainerInstance(String name); + + /** + * Defines one container instance for the specified image with one CPU count and 1.5 GB memory, with TCP port 80 opened externally. + * + * @param imageName the name of the container image + * @return the next stage of the definition + */ + WithCreate withContainerInstance(String imageName); + + /** + * Defines one container instance for the specified image with one CPU count and 1.5 GB memory, with a custom TCP port opened externally. + * + * @param imageName the name of the container image + * @param port the external port to be opened + * @return the next stage of the definition + */ + WithCreate withContainerInstance(String imageName, int port); + } + + /** + * The stage of the container group definition allowing to specify a container instance. + */ + interface WithNextContainerInstance extends WithCreate { + /** + * Begins the definition of a container instance. + * + * @param name the name of the volume + * @return the next stage of the definition + */ + ContainerInstanceDefinitionStages.Blank defineContainerInstance(String name); + } + + /** + * Grouping of volume definition stages. + */ + interface ContainerInstanceDefinitionStages { + /** + * The first stage of the container instance definition. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface Blank extends WithImage { + } + + /** + * The stage of the container instance definition allowing to specify the container image. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithImage { + /** + * Specifies the container image to be used. + * + * @param imageName the container image + * @return the next stage of the definition + */ + WithOrWithoutPorts withImage(String imageName); + } + + /** + * The stage of the container instance definition allowing to specify (or not) the container ports. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithOrWithoutPorts extends + WithPorts, + WithoutPorts { + } + + /** + * The stage of the container instance definition allowing not to specify any container ports internal or external. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithoutPorts { + /** + * Specifies that not ports will be opened internally or externally for this container instance. + * + * @return the next stage of the definition + */ + WithAttach withoutPorts(); + } + + /** + * The stage of the container instance definition allowing to specify one or more container ports. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithPortsOrAttach extends + WithPorts, + WithAttach { + } + + /** + * The stage of the container instance definition allowing to specify the container ports. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithPorts { + /** + * Specifies the container's TCP ports available to external clients. + *

+ * A public IP address will be create to allow external clients to reach the containers within the group. + * To enable external clients to reach a container within the group, you must expose the port on the + * IP address and from the container. Because containers within the group share a port namespace, port + * mapping is not supported. + * + * @param ports array of TCP ports to be exposed externally + * @return the next stage of the definition + */ + WithPortsOrAttach withExternalTcpPorts(int... ports); + + /** + * Specifies the container's TCP port available to external clients. + *

+ * A public IP address will be create to allow external clients to reach the containers within the group. + * To enable external clients to reach a container within the group, you must expose the port on the + * IP address and from the container. Because containers within the group share a port namespace, port + * mapping is not supported. + * + * @param port TCP port to be exposed externally + * @return the next stage of the definition + */ + WithPortsOrAttach withExternalTcpPort(int port); + + /** + * Specifies the container's UDP ports available to external clients. + *

+ * A public IP address will be create to allow external clients to reach the containers within the group. + * To enable external clients to reach a container within the group, you must expose the port on the + * IP address and from the container. Because containers within the group share a port namespace, port + * mapping is not supported. + * + * @param ports array of UDP ports to be exposed externally + * @return the next stage of the definition + */ + WithPortsOrAttach withExternalUdpPorts(int... ports); + + /** + * Specifies the container's UDP port available to external clients. + *

+ * A public IP address will be create to allow external clients to reach the containers within the group. + * To enable external clients to reach a container within the group, you must expose the port on the + * IP address and from the container. Because containers within the group share a port namespace, port + * mapping is not supported. + * + * @param port UDP port to be exposed externally + * @return the next stage of the definition + */ + WithPortsOrAttach withExternalUdpPort(int port); + + /** + * Specifies the container's ports are available to internal clients only (other container instances within the container group). + *

+ * Containers within a group can reach each other via localhost on the ports that they have exposed, + * even if those ports are not exposed externally on the group's IP address. + * + * @param ports array of TCP ports to be exposed internally + * @return the next stage of the definition + */ + WithPortsOrAttach withInternalPorts(int... ports); + + /** + * Specifies the container's port is available to internal clients only (other container instances within the container group). + *

+ * Containers within a group can reach each other via localhost on the ports that they have exposed, + * even if those ports are not exposed externally on the group's IP address. + * + * @param port TCP port to be exposed internally + * @return the next stage of the definition + */ + WithPortsOrAttach withInternalPort(int port); + } + + /** + * The stage of the container instance definition allowing to specify the number of CPU cores. + *

+ * The CPU cores can be specified as a fraction, i.e. 1.5 represents one and a half atomic CPU cores + * will be assigned to this container instance. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithCpuCoreCount { + /** + * Specifies the number of CPU cores assigned to this container instance. + * + * @param cpuCoreCount the number of CPU cores + * @return the next stage of the definition + */ + WithAttach withCpuCoreCount(double cpuCoreCount); + } + + /** + * The stage of the container instance definition allowing to specify the memory size in GB. + *

+ * The memory size can be specified as a fraction, i.e. 1.5 represents one and a half GB of memory. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithMemorySize { + /** + * Specifies the memory size in GB assigned to this container instance. + * + * @param memorySize the memory size in GB + * @return the next stage of the definition + */ + WithAttach withMemorySizeInGB(double memorySize); + } + + /** + * The stage of the container instance definition allowing to specify the starting command line. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithStartingCommandLine { + /** + * Specifies the starting command lines. + * + * @param commandLines the starting command lines the container will execute after it gets initialized + * @return the next stage of the definition + */ + WithAttach withStartingCommandLines(String... commandLines); + + /** + * Specifies the starting command line. + * + * @param commandLine the starting command line the container will execute after it gets initialized + * @return the next stage of the definition + */ + WithAttach withStartingCommandLine(String commandLine); + } + + /** + * The stage of the container instance definition allowing to specify the environment variables. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithEnvironmentVariables { + /** + * Specifies the environment variables. + * + * @param environmentVariables the environment variables in a name and value pair to be set after the container gets initialized + * @return the next stage of the definition + */ + WithAttach withEnvironmentVariables(Map environmentVariables); + + /** + * Specifies the environment variable. + * + * @param envName the environment variable name + * @param envValue the environment variable value + * @return the next stage of the definition + */ + WithAttach withEnvironmentVariable(String envName, String envValue); + } + + /** + * The stage of the container instance definition allowing to specify volume mount setting. + * + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithVolumeMountSetting { + /** + * Specifies the container group's volume to be mounted by the container instance at a specified mount path. + *

+ * Mounting an Azure file share as a volume in a container is a two-step process. First, you provide + * the details of the share as part of defining the container group, then you specify how you wan + * the volume mounted within one or more of the containers in the group. + * + * @param volumeName the volume name as defined in the volumes of the container group + * @param mountPath the local path the volume will be mounted at + * @return the next stage of the definition + * @throws IllegalArgumentException thrown if volumeName was not defined in the respective container group definition stage. + */ + WithAttach withVolumeMountSetting(String volumeName, String mountPath); + + /** + * Specifies the container group's volume to be mounted by the container instance at a specified mount path. + *

+ * Mounting an Azure file share as a volume in a container is a two-step process. First, you provide + * the details of the share as part of defining the container group, then you specify how you wan + * the volume mounted within one or more of the containers in the group. + * + * @param volumeMountSetting the name and value pair representing volume names as defined in the volumes of the container group and the local paths the volume will be mounted at + * @return the next stage of the definition + * @throws IllegalArgumentException thrown if volumeName was not defined in the respective container group definition stage. + */ + WithAttach withVolumeMountSetting(Map volumeMountSetting); + + /** + * Specifies the container group's volume to be mounted by the container instance at a specified mount path. + *

+ * Mounting an Azure file share as a volume in a container is a two-step process. First, you provide + * the details of the share as part of defining the container group, then you specify how you wan + * the volume mounted within one or more of the containers in the group. + * + * @param volumeName the volume name as defined in the volumes of the container group + * @param mountPath the local path the volume will be mounted at + * @return the next stage of the definition + * @throws IllegalArgumentException thrown if volumeName was not defined in the respective container group definition stage. + */ + WithAttach withReadOnlyVolumeMountSetting(String volumeName, String mountPath); + + /** + * Specifies the container group's volume to be mounted by the container instance at a specified mount path. + *

+ * Mounting an Azure file share as a volume in a container is a two-step process. First, you provide + * the details of the share as part of defining the container group, then you specify how you wan + * the volume mounted within one or more of the containers in the group. + * + * @param volumeMountSetting the name and value pair representing volume names as defined in the volumes of the container group and the local paths the volume will be mounted at + * @return the next stage of the definition + * @throws IllegalArgumentException thrown if volumeName was not defined in the respective container group definition stage. + */ + WithAttach withReadOnlyVolumeMountSetting(Map volumeMountSetting); + } + + /** The final stage of the container instance definition. + *

+ * At this stage, any remaining optional settings can be specified, or the subnet definition + * can be attached to the parent virtual network definition. + * @param the stage of the parent definition to return to after attaching this definition + */ + interface WithAttach extends + WithCpuCoreCount, + WithMemorySize, + WithStartingCommandLine, + WithEnvironmentVariables, + WithVolumeMountSetting, + Attachable.InDefinition { + } + + /** + * Grouping of the container group's volume definition stages. + */ + interface ContainerInstanceDefinition extends + Blank, + WithImage, + WithOrWithoutPorts, + WithPortsOrAttach, + WithAttach { + } + } + + /** + * The stage of the definition which contains all the minimum required inputs for the resource to be created + * (via {@link WithCreate#create()}), but also allows for any other optional settings to be specified. + */ + interface WithCreate extends + Creatable, + Resource.DefinitionWithTags { + } + } +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerGroupNetworkProtocol.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerGroupNetworkProtocol.java new file mode 100644 index 00000000000..35192c1b8b8 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerGroupNetworkProtocol.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for ContainerGroupNetworkProtocol. + */ +public final class ContainerGroupNetworkProtocol { + /** Static value TCP for ContainerGroupNetworkProtocol. */ + public static final ContainerGroupNetworkProtocol TCP = new ContainerGroupNetworkProtocol("TCP"); + + /** Static value UDP for ContainerGroupNetworkProtocol. */ + public static final ContainerGroupNetworkProtocol UDP = new ContainerGroupNetworkProtocol("UDP"); + + private String value; + + /** + * Creates a custom value for ContainerGroupNetworkProtocol. + * @param value the custom value + */ + public ContainerGroupNetworkProtocol(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } + + @Override + public int hashCode() { + return value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ContainerGroupNetworkProtocol)) { + return false; + } + if (obj == this) { + return true; + } + ContainerGroupNetworkProtocol rhs = (ContainerGroupNetworkProtocol) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerGroups.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerGroups.java new file mode 100644 index 00000000000..975750d7ff4 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerGroups.java @@ -0,0 +1,88 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.containerinstance; + +import com.microsoft.azure.management.apigeneration.Beta; +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.containerinstance.implementation.ContainerGroupsInner; +import com.microsoft.azure.management.containerinstance.implementation.ContainerInstanceManager; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsBatchDeletion; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByResourceGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByResourceGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByResourceGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.models.HasManager; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsBatchCreation; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; +import com.microsoft.azure.management.resources.fluentcore.model.HasInner; +import rx.Observable; + +/** + * Entry point to the container instance management API. + */ +@Fluent() +@Beta(Beta.SinceVersion.V1_3_0) +public interface ContainerGroups extends + SupportsCreating, + HasManager, + HasInner, + SupportsBatchCreation, + SupportsGettingByResourceGroup, + SupportsGettingById, + SupportsDeletingByResourceGroup, + SupportsDeletingById, + SupportsBatchDeletion, + SupportsListingByResourceGroup, + SupportsListing { + + /** + * Get the log content for the specified container instance within a container group. + * + * @param resourceGroupName the Azure resource group name + * @param containerName the container instance name + * @param containerGroupName the container group name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return all available log lines + */ + String getLogContent(String resourceGroupName, String containerName, String containerGroupName); + + /** + * Get the log content for the specified container instance within a container group. + * + * @param resourceGroupName the Azure resource group name + * @param containerName the container instance name + * @param containerGroupName the container group name + * @param tailLineCount only get the last log lines up to this + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the log lines from the end, up to the number specified + */ + String getLogContent(String resourceGroupName, String containerName, String containerGroupName, int tailLineCount); + + /** + * Get the log content for the specified container instance within a container group. + * + * @param resourceGroupName the Azure resource group name + * @param containerName the container instance name + * @param containerGroupName the container group name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return a representation of the future computation of this call + */ + Observable getLogContentAsync(String resourceGroupName, String containerName, String containerGroupName); + + /** + * Get the log content for the specified container instance within a container group. + * + * @param resourceGroupName the Azure resource group name + * @param containerName the container instance name + * @param containerGroupName the container group name + * @param tailLineCount only get the last log lines up to this + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return a representation of the future computation of this call + */ + Observable getLogContentAsync(String resourceGroupName, String containerName, String containerGroupName, int tailLineCount); +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerPort.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerPort.java new file mode 100644 index 00000000000..c5ed1b12ca8 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerPort.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The container port. + */ +public class ContainerPort { + /** + * Port number to expose within the container group. + */ + @JsonProperty(value = "port", required = true) + private int port; + + /** + * Get the port value. + * + * @return the port value + */ + public int port() { + return this.port; + } + + /** + * Set the port value. + * + * @param port the port value to set + * @return the ContainerPort object itself. + */ + public ContainerPort withPort(int port) { + this.port = port; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerPropertiesInstanceView.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerPropertiesInstanceView.java new file mode 100644 index 00000000000..923a1560593 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerPropertiesInstanceView.java @@ -0,0 +1,122 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The instance view of the container. Only valid in response. + */ +public class ContainerPropertiesInstanceView { + /** + * The number of times that the container has been restarted. + */ + @JsonProperty(value = "restartCount") + private Integer restartCount; + + /** + * Current container state. + */ + @JsonProperty(value = "currentState") + private ContainerState currentState; + + /** + * Previous container state. + */ + @JsonProperty(value = "previousState") + private ContainerState previousState; + + /** + * The events of this container instance. + */ + @JsonProperty(value = "events") + private List events; + + /** + * Get the restartCount value. + * + * @return the restartCount value + */ + public Integer restartCount() { + return this.restartCount; + } + + /** + * Set the restartCount value. + * + * @param restartCount the restartCount value to set + * @return the ContainerPropertiesInstanceView object itself. + */ + public ContainerPropertiesInstanceView withRestartCount(Integer restartCount) { + this.restartCount = restartCount; + return this; + } + + /** + * Get the currentState value. + * + * @return the currentState value + */ + public ContainerState currentState() { + return this.currentState; + } + + /** + * Set the currentState value. + * + * @param currentState the currentState value to set + * @return the ContainerPropertiesInstanceView object itself. + */ + public ContainerPropertiesInstanceView withCurrentState(ContainerState currentState) { + this.currentState = currentState; + return this; + } + + /** + * Get the previousState value. + * + * @return the previousState value + */ + public ContainerState previousState() { + return this.previousState; + } + + /** + * Set the previousState value. + * + * @param previousState the previousState value to set + * @return the ContainerPropertiesInstanceView object itself. + */ + public ContainerPropertiesInstanceView withPreviousState(ContainerState previousState) { + this.previousState = previousState; + return this; + } + + /** + * Get the events value. + * + * @return the events value + */ + public List events() { + return this.events; + } + + /** + * Set the events value. + * + * @param events the events value to set + * @return the ContainerPropertiesInstanceView object itself. + */ + public ContainerPropertiesInstanceView withEvents(List events) { + this.events = events; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerRestartPolicy.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerRestartPolicy.java new file mode 100644 index 00000000000..0feb5fc48a4 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerRestartPolicy.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for ContainerRestartPolicy. + */ +public final class ContainerRestartPolicy { + /** Static value always for ContainerRestartPolicy. */ + public static final ContainerRestartPolicy ALWAYS = new ContainerRestartPolicy("always"); + + private String value; + + /** + * Creates a custom value for ContainerRestartPolicy. + * @param value the custom value + */ + public ContainerRestartPolicy(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } + + @Override + public int hashCode() { + return value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ContainerRestartPolicy)) { + return false; + } + if (obj == this) { + return true; + } + ContainerRestartPolicy rhs = (ContainerRestartPolicy) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerState.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerState.java new file mode 100644 index 00000000000..73390195241 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerState.java @@ -0,0 +1,148 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The container state. + */ +public class ContainerState { + /** + * The state of this container. + */ + @JsonProperty(value = "state") + private String state; + + /** + * Date/time when the container state started. + */ + @JsonProperty(value = "startTime") + private DateTime startTime; + + /** + * The container exit code. + */ + @JsonProperty(value = "exitCode") + private Integer exitCode; + + /** + * Date/time when the container state finished. + */ + @JsonProperty(value = "finishTime") + private DateTime finishTime; + + /** + * Human-readable status of this state. + */ + @JsonProperty(value = "detailStatus") + private String detailStatus; + + /** + * Get the state value. + * + * @return the state value + */ + public String state() { + return this.state; + } + + /** + * Set the state value. + * + * @param state the state value to set + * @return the ContainerState object itself. + */ + public ContainerState withState(String state) { + this.state = state; + return this; + } + + /** + * Get the startTime value. + * + * @return the startTime value + */ + public DateTime startTime() { + return this.startTime; + } + + /** + * Set the startTime value. + * + * @param startTime the startTime value to set + * @return the ContainerState object itself. + */ + public ContainerState withStartTime(DateTime startTime) { + this.startTime = startTime; + return this; + } + + /** + * Get the exitCode value. + * + * @return the exitCode value + */ + public Integer exitCode() { + return this.exitCode; + } + + /** + * Set the exitCode value. + * + * @param exitCode the exitCode value to set + * @return the ContainerState object itself. + */ + public ContainerState withExitCode(Integer exitCode) { + this.exitCode = exitCode; + return this; + } + + /** + * Get the finishTime value. + * + * @return the finishTime value + */ + public DateTime finishTime() { + return this.finishTime; + } + + /** + * Set the finishTime value. + * + * @param finishTime the finishTime value to set + * @return the ContainerState object itself. + */ + public ContainerState withFinishTime(DateTime finishTime) { + this.finishTime = finishTime; + return this; + } + + /** + * Get the detailStatus value. + * + * @return the detailStatus value + */ + public String detailStatus() { + return this.detailStatus; + } + + /** + * Set the detailStatus value. + * + * @param detailStatus the detailStatus value to set + * @return the ContainerState object itself. + */ + public ContainerState withDetailStatus(String detailStatus) { + this.detailStatus = detailStatus; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/EnvironmentVariable.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/EnvironmentVariable.java new file mode 100644 index 00000000000..78a3dcbe5a1 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/EnvironmentVariable.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Environment variable to set within the container. + */ +public class EnvironmentVariable { + /** + * The name of the environment variable. + */ + @JsonProperty(value = "name", required = true) + private String name; + + /** + * The value of the environment variable. + */ + @JsonProperty(value = "value", required = true) + private String value; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the EnvironmentVariable object itself. + */ + public EnvironmentVariable withName(String name) { + this.name = name; + return this; + } + + /** + * Get the value value. + * + * @return the value value + */ + public String value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the EnvironmentVariable object itself. + */ + public EnvironmentVariable withValue(String value) { + this.value = value; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ImageRegistryCredential.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ImageRegistryCredential.java new file mode 100644 index 00000000000..72ff6d293dd --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ImageRegistryCredential.java @@ -0,0 +1,96 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Image registry credential. + */ +public class ImageRegistryCredential { + /** + * Docker image registry server, without protocol such as "http" and + * "https". + */ + @JsonProperty(value = "server", required = true) + private String server; + + /** + * The username for the private registry. + */ + @JsonProperty(value = "username", required = true) + private String username; + + /** + * The password for the private registry. + */ + @JsonProperty(value = "password") + private String password; + + /** + * Get the server value. + * + * @return the server value + */ + public String server() { + return this.server; + } + + /** + * Set the server value. + * + * @param server the server value to set + * @return the ImageRegistryCredential object itself. + */ + public ImageRegistryCredential withServer(String server) { + this.server = server; + return this; + } + + /** + * Get the username value. + * + * @return the username value + */ + public String username() { + return this.username; + } + + /** + * Set the username value. + * + * @param username the username value to set + * @return the ImageRegistryCredential object itself. + */ + public ImageRegistryCredential withUsername(String username) { + this.username = username; + return this; + } + + /** + * Get the password value. + * + * @return the password value + */ + public String password() { + return this.password; + } + + /** + * Set the password value. + * + * @param password the password value to set + * @return the ImageRegistryCredential object itself. + */ + public ImageRegistryCredential withPassword(String password) { + this.password = password; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/IpAddress.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/IpAddress.java new file mode 100644 index 00000000000..0df00661d8d --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/IpAddress.java @@ -0,0 +1,103 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * IP address for the group. + */ +public class IpAddress { + /** + * The ports. + */ + @JsonProperty(value = "ports", required = true) + private List ports; + + /** + * Determines whether the IP is exposed to the public internet. + */ + @JsonProperty(value = "type", required = true) + private String type; + + /** + * The IP exposed to the public internet. + */ + @JsonProperty(value = "ip") + private String ip; + + /** + * Creates an instance of IpAddress class. + */ + public IpAddress() { + type = "Public"; + } + + /** + * Get the ports value. + * + * @return the ports value + */ + public List ports() { + return this.ports; + } + + /** + * Set the ports value. + * + * @param ports the ports value to set + * @return the IpAddress object itself. + */ + public IpAddress withPorts(List ports) { + this.ports = ports; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the IpAddress object itself. + */ + public IpAddress withType(String type) { + this.type = type; + return this; + } + + /** + * Get the ip value. + * + * @return the ip value + */ + public String ip() { + return this.ip; + } + + /** + * Set the ip value. + * + * @param ip the ip value to set + * @return the IpAddress object itself. + */ + public IpAddress withIp(String ip) { + this.ip = ip; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/OperatingSystemTypes.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/OperatingSystemTypes.java new file mode 100644 index 00000000000..a32bc2fd9e1 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/OperatingSystemTypes.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for OperatingSystemTypes. + */ +public final class OperatingSystemTypes { + /** Static value Windows for OperatingSystemTypes. */ + public static final OperatingSystemTypes WINDOWS = new OperatingSystemTypes("Windows"); + + /** Static value Linux for OperatingSystemTypes. */ + public static final OperatingSystemTypes LINUX = new OperatingSystemTypes("Linux"); + + private String value; + + /** + * Creates a custom value for OperatingSystemTypes. + * @param value the custom value + */ + public OperatingSystemTypes(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } + + @Override + public int hashCode() { + return value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof OperatingSystemTypes)) { + return false; + } + if (obj == this) { + return true; + } + OperatingSystemTypes rhs = (OperatingSystemTypes) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/Port.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/Port.java new file mode 100644 index 00000000000..b9ad75e775f --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/Port.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The port. + */ +public class Port { + /** + * The protocol associated with the port. Possible values include: 'TCP', + * 'UDP'. + */ + @JsonProperty(value = "protocol") + private ContainerGroupNetworkProtocol protocol; + + /** + * The port. + */ + @JsonProperty(value = "port", required = true) + private int port; + + /** + * Get the protocol value. + * + * @return the protocol value + */ + public ContainerGroupNetworkProtocol protocol() { + return this.protocol; + } + + /** + * Set the protocol value. + * + * @param protocol the protocol value to set + * @return the Port object itself. + */ + public Port withProtocol(ContainerGroupNetworkProtocol protocol) { + this.protocol = protocol; + return this; + } + + /** + * Get the port value. + * + * @return the port value + */ + public int port() { + return this.port; + } + + /** + * Set the port value. + * + * @param port the port value to set + * @return the Port object itself. + */ + public Port withPort(int port) { + this.port = port; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ResourceLimits.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ResourceLimits.java new file mode 100644 index 00000000000..124eff3504a --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ResourceLimits.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The resource limits. + */ +public class ResourceLimits { + /** + * The memory limit in GB of this container. + */ + @JsonProperty(value = "memoryInGB") + private Double memoryInGB; + + /** + * The CPU limit of this container. + */ + @JsonProperty(value = "cpu") + private Double cpu; + + /** + * Get the memoryInGB value. + * + * @return the memoryInGB value + */ + public Double memoryInGB() { + return this.memoryInGB; + } + + /** + * Set the memoryInGB value. + * + * @param memoryInGB the memoryInGB value to set + * @return the ResourceLimits object itself. + */ + public ResourceLimits withMemoryInGB(Double memoryInGB) { + this.memoryInGB = memoryInGB; + return this; + } + + /** + * Get the cpu value. + * + * @return the cpu value + */ + public Double cpu() { + return this.cpu; + } + + /** + * Set the cpu value. + * + * @param cpu the cpu value to set + * @return the ResourceLimits object itself. + */ + public ResourceLimits withCpu(Double cpu) { + this.cpu = cpu; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ResourceRequests.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ResourceRequests.java new file mode 100644 index 00000000000..01a329a6fed --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ResourceRequests.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The resource requests. + */ +public class ResourceRequests { + /** + * The memory request in GB of this container. + */ + @JsonProperty(value = "memoryInGB", required = true) + private double memoryInGB; + + /** + * The CPU request of this container. + */ + @JsonProperty(value = "cpu", required = true) + private double cpu; + + /** + * Get the memoryInGB value. + * + * @return the memoryInGB value + */ + public double memoryInGB() { + return this.memoryInGB; + } + + /** + * Set the memoryInGB value. + * + * @param memoryInGB the memoryInGB value to set + * @return the ResourceRequests object itself. + */ + public ResourceRequests withMemoryInGB(double memoryInGB) { + this.memoryInGB = memoryInGB; + return this; + } + + /** + * Get the cpu value. + * + * @return the cpu value + */ + public double cpu() { + return this.cpu; + } + + /** + * Set the cpu value. + * + * @param cpu the cpu value to set + * @return the ResourceRequests object itself. + */ + public ResourceRequests withCpu(double cpu) { + this.cpu = cpu; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ResourceRequirements.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ResourceRequirements.java new file mode 100644 index 00000000000..e3025c26187 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ResourceRequirements.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The resource requirements. + */ +public class ResourceRequirements { + /** + * The resource requests of this container. + */ + @JsonProperty(value = "requests", required = true) + private ResourceRequests requests; + + /** + * The resource limits of this container. + */ + @JsonProperty(value = "limits") + private ResourceLimits limits; + + /** + * Get the requests value. + * + * @return the requests value + */ + public ResourceRequests requests() { + return this.requests; + } + + /** + * Set the requests value. + * + * @param requests the requests value to set + * @return the ResourceRequirements object itself. + */ + public ResourceRequirements withRequests(ResourceRequests requests) { + this.requests = requests; + return this; + } + + /** + * Get the limits value. + * + * @return the limits value + */ + public ResourceLimits limits() { + return this.limits; + } + + /** + * Set the limits value. + * + * @param limits the limits value to set + * @return the ResourceRequirements object itself. + */ + public ResourceRequirements withLimits(ResourceLimits limits) { + this.limits = limits; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/Volume.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/Volume.java new file mode 100644 index 00000000000..e77d4221c76 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/Volume.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The volume. + */ +public class Volume { + /** + * The volume name. + */ + @JsonProperty(value = "name", required = true) + private String name; + + /** + * The Azure file volume. + */ + @JsonProperty(value = "azureFile", required = true) + private AzureFileVolume azureFile; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the Volume object itself. + */ + public Volume withName(String name) { + this.name = name; + return this; + } + + /** + * Get the azureFile value. + * + * @return the azureFile value + */ + public AzureFileVolume azureFile() { + return this.azureFile; + } + + /** + * Set the azureFile value. + * + * @param azureFile the azureFile value to set + * @return the Volume object itself. + */ + public Volume withAzureFile(AzureFileVolume azureFile) { + this.azureFile = azureFile; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/VolumeMount.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/VolumeMount.java new file mode 100644 index 00000000000..40ef1cc26c3 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/VolumeMount.java @@ -0,0 +1,96 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The volume mount. + */ +public class VolumeMount { + /** + * The volume mount name. + */ + @JsonProperty(value = "name", required = true) + private String name; + + /** + * The path with in the container at which the volume should be mounted. + * Must not contain ':'. + */ + @JsonProperty(value = "mountPath", required = true) + private String mountPath; + + /** + * The flag indicating whether the volume mount is read only. + */ + @JsonProperty(value = "readOnly") + private Boolean readOnly; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the VolumeMount object itself. + */ + public VolumeMount withName(String name) { + this.name = name; + return this; + } + + /** + * Get the mountPath value. + * + * @return the mountPath value + */ + public String mountPath() { + return this.mountPath; + } + + /** + * Set the mountPath value. + * + * @param mountPath the mountPath value to set + * @return the VolumeMount object itself. + */ + public VolumeMount withMountPath(String mountPath) { + this.mountPath = mountPath; + return this; + } + + /** + * Get the readOnly value. + * + * @return the readOnly value + */ + public Boolean readOnly() { + return this.readOnly; + } + + /** + * Set the readOnly value. + * + * @param readOnly the readOnly value to set + * @return the VolumeMount object itself. + */ + public VolumeMount withReadOnly(Boolean readOnly) { + this.readOnly = readOnly; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerGroupImpl.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerGroupImpl.java new file mode 100644 index 00000000000..5e90545df3c --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerGroupImpl.java @@ -0,0 +1,448 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.containerinstance.implementation; + +import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.containerinstance.Container; +import com.microsoft.azure.management.containerinstance.ContainerGroup; +import com.microsoft.azure.management.containerinstance.ContainerGroupNetworkProtocol; +import com.microsoft.azure.management.containerinstance.ContainerRestartPolicy; +import com.microsoft.azure.management.containerinstance.ImageRegistryCredential; +import com.microsoft.azure.management.containerinstance.OperatingSystemTypes; +import com.microsoft.azure.management.containerinstance.Port; +import com.microsoft.azure.management.containerinstance.Volume; +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableParentResourceImpl; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; +import com.microsoft.azure.management.resources.fluentcore.utils.SdkContext; +import com.microsoft.azure.management.storage.StorageAccount; +import com.microsoft.azure.management.storage.StorageAccountKey; +import com.microsoft.azure.management.storage.implementation.StorageManager; +import com.microsoft.azure.storage.CloudStorageAccount; +import com.microsoft.azure.storage.file.CloudFileClient; +import com.microsoft.azure.storage.file.CloudFileShare; +import rx.Observable; +import rx.exceptions.Exceptions; +import rx.functions.Action2; +import rx.functions.Func0; +import rx.functions.Func1; + +import java.net.URISyntaxException; +import java.security.InvalidKeyException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; + +/** + * Implementation for ContainerGroup and its create interfaces. + */ +@LangDefinition +public class ContainerGroupImpl + extends + GroupableParentResourceImpl< + ContainerGroup, + ContainerGroupInner, + ContainerGroupImpl, + ContainerInstanceManager> + implements ContainerGroup, + ContainerGroup.Definition { + + private final StorageManager storageManager; + private String creatableStorageAccountKey; + private Map newFileShares; + + private Map containers; + private Map volumes; + private List imageRegistryServers; + private int[] externalTcpPorts; + private int[] externalUdpPorts; + + protected ContainerGroupImpl(String name, ContainerGroupInner innerObject, ContainerInstanceManager manager, final StorageManager storageManager) { + super(name, innerObject, manager); + this.storageManager = storageManager; + } + + @Override + protected void beforeCreating() { + } + + @Override + protected Observable createInner() { + final ContainerGroupImpl self = this; + + if (!isInCreateMode()) { + throw new UnsupportedOperationException("Update on an existing container group resource is not supported"); + } else if (newFileShares == null || creatableStorageAccountKey == null) { + return this.manager().inner().containerGroups().createOrUpdateAsync(this.resourceGroupName(), this.name(), this.inner()); + } else { + final StorageAccount storageAccount = (StorageAccount) this.createdResource(this.creatableStorageAccountKey); + return createFileShareAsync(storageAccount) + .collect(new Func0>>() { + @Override + public List> call() { + return new ArrayList<>(); + } + }, new Action2>, Triple>() { + @Override + public void call(List> cloudFileShares, Triple fileShare) { + cloudFileShares.add(fileShare); + } + }) + .flatMap(new Func1>, Observable>() { + @Override + public Observable call(List> fileShares) { + for (Triple fileShareEntry : fileShares) { + self.defineVolume(fileShareEntry.getLeft()) + .withExistingReadWriteAzureFileShare(fileShareEntry.getMiddle()) + .withStorageAccountName(storageAccount.name()) + .withStorageAccountKey(fileShareEntry.getRight()) + .attach(); + } + return self.manager().inner().containerGroups().createOrUpdateAsync(self.resourceGroupName(), self.name(), self.inner()); + } + }); + } + } + + private Observable> createFileShareAsync(final StorageAccount storageAccount) { + return storageAccount.getKeysAsync() + .map(new Func1, String>() { + @Override + public String call(List storageAccountKeys) { + return storageAccountKeys.get(0).value(); + } + }) + .flatMap(new Func1>>() { + CloudFileClient cloudFileClient; + @Override + public Observable> call(final String storageAccountKey) { + try { + cloudFileClient = CloudStorageAccount.parse(String.format("DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;EndpointSuffix=core.windows.net", + storageAccount.name(), + storageAccountKey)) + .createCloudFileClient(); + } catch (URISyntaxException syntaxException) { + throw Exceptions.propagate(syntaxException); + } catch (InvalidKeyException keyException) { + throw Exceptions.propagate(keyException); + } + return Observable.from(newFileShares.entrySet()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Map.Entry fileShareEntry) { + return createSingleFileShareAsync(cloudFileClient, fileShareEntry.getKey(), fileShareEntry.getValue(), storageAccountKey); + } + }); + } + }); + } + + private Observable> createSingleFileShareAsync(final CloudFileClient client, final String volumeName, final String fileShareName, final String storageAccountKey) { + return Observable.fromCallable(new Callable>() { + @Override + public Triple call() throws Exception { + CloudFileShare cloudFileShare = client.getShareReference(fileShareName); + cloudFileShare.createIfNotExists(); + + return new Triple<>(volumeName, fileShareName, storageAccountKey); + } + }); + } + + class Triple { + private L leftValue; + private M middleValue; + private R rightValue; + + Triple(L left, M middle, R right) { + this.leftValue = left; + this.middleValue = middle; + this.rightValue = right; + } + + public L getLeft() { + return this.leftValue; + } + + public M getMiddle() { + return this.middleValue; + } + + public R getRight() { + return this.rightValue; + } + } + + @Override + protected void afterCreating() { + initializeChildrenFromInner(); + } + + @Override + protected void initializeChildrenFromInner() { + // Getting the container instances + this.containers = new HashMap<>(); + if (this.inner().containers() != null && this.inner().containers().size() > 0) { + for (Container containerInstance : this.inner().containers()) { + this.containers.put(containerInstance.name(), containerInstance); + } + } + + // Getting the volumes + this.volumes = new HashMap<>(); + if (this.inner().volumes() != null && this.inner().volumes().size() > 0) { + for (Volume volume : this.inner().volumes()) { + this.volumes.put(volume.name(), volume); + } + } + + // Getting the private image registry servers + this.imageRegistryServers = new ArrayList<>(); + if (this.inner().imageRegistryCredentials() != null && this.inner().imageRegistryCredentials().size() > 0) { + for (ImageRegistryCredential imageRegistry : this.inner().imageRegistryCredentials()) { + this.imageRegistryServers.add(imageRegistry.server()); + } + } + + // Splitting ports between TCP and UDP ports + if (this.inner().ipAddress() != null && this.inner().ipAddress().ports() != null) { + List tcpPorts = new ArrayList<>(); + List udpPorts = new ArrayList<>(); + for (Port port : this.inner().ipAddress().ports()) { + if (port.protocol().equals(ContainerGroupNetworkProtocol.TCP)) { + tcpPorts.add(port); + } else if (port.protocol().equals(ContainerGroupNetworkProtocol.UDP)) { + udpPorts.add(port); + } + } + this.externalTcpPorts = new int[tcpPorts.size()]; + for (int i = 0; i < this.externalTcpPorts.length; i++) { + this.externalTcpPorts[i] = tcpPorts.get(i).port(); + } + this.externalUdpPorts = new int[udpPorts.size()]; + for (int i = 0; i < this.externalTcpPorts.length; i++) { + this.externalTcpPorts[i] = tcpPorts.get(i).port(); + } + } else { + this.externalTcpPorts = new int[0]; + this.externalUdpPorts = new int[0]; + } + } + + // Verbs + + @Override + public Observable refreshAsync() { + return super.refreshAsync().map(new Func1() { + @Override + public ContainerGroup call(ContainerGroup containerGroup) { + ContainerGroupImpl impl = (ContainerGroupImpl) containerGroup; + impl.initializeChildrenFromInner(); + return impl; + } + }); + } + + @Override + protected Observable getInnerAsync() { + return this.manager().inner().containerGroups().getByResourceGroupAsync(this.resourceGroupName(), this.name()); + } + + @Override + public ContainerGroupImpl withLinux() { + this.inner().withOsType(OperatingSystemTypes.LINUX); + + return this; + } + + @Override + public ContainerGroupImpl withWindows() { + this.inner().withOsType(OperatingSystemTypes.WINDOWS); + + return this; + } + + @Override + public ContainerGroupImpl withPublicImageRegistryOnly() { + this.inner().withImageRegistryCredentials(null); + + return this; + } + + @Override + public ContainerGroupImpl withPrivateImageRegistry(String server, String username, String password) { + if (this.inner().imageRegistryCredentials() == null) { + this.inner().withImageRegistryCredentials(new ArrayList()); + } + this.inner().imageRegistryCredentials().add(new ImageRegistryCredential() + .withServer(server) + .withUsername(username) + .withPassword(password)); + + return this; + } + + @Override + public ContainerGroupImpl withNewAzureFileShareVolume(String volumeName, String shareName) { + if (this.newFileShares == null || this.creatableStorageAccountKey == null) { + StorageAccount.DefinitionStages.WithGroup definitionWithGroup = this.storageManager + .storageAccounts() + .define(SdkContext.randomResourceName("fs", 24)) + .withRegion(this.regionName()); + Creatable creatable; + if (this.creatableGroup != null) { + creatable = definitionWithGroup.withNewResourceGroup(this.creatableGroup); + } else { + creatable = definitionWithGroup.withExistingResourceGroup(this.resourceGroupName()); + } + this.creatableStorageAccountKey = creatable.key(); + this.addCreatableDependency(creatable); + + this.newFileShares = new HashMap<>(); + } + this.newFileShares.put(volumeName, shareName); + + return this; + } + + @Override + public VolumeImpl defineVolume(String name) { + return new VolumeImpl(this, name); + } + + @Override + public ContainerGroupImpl withoutVolume() { + this.inner().withVolumes(null); + + return this; + } + + @Override + public ContainerImpl defineContainerInstance(String name) { + return new ContainerImpl(this, name); + } + + @Override + public ContainerGroupImpl withContainerInstance(String imageName) { + return this.defineContainerInstance(this.name()) + .withImage(imageName) + .withoutPorts() + .withCpuCoreCount(1) + .withMemorySizeInGB(1.5) + .attach(); + } + + @Override + public ContainerGroupImpl withContainerInstance(String imageName, int port) { + return this.defineContainerInstance(this.name()) + .withImage(imageName) + .withExternalTcpPort(port) + .withCpuCoreCount(1) + .withMemorySizeInGB(1.5) + .attach(); + } + + @Override + public Map containers() { + return Collections.unmodifiableMap(this.containers); + } + + @Override + public Collection externalPorts() { + if (this.inner().ipAddress() != null && this.inner().ipAddress().ports() != null) { + return Collections.unmodifiableCollection(this.inner().ipAddress().ports()); + } else { + return null; + } + } + + @Override + public int[] externalTcpPorts() { + return this.externalTcpPorts; + } + + @Override + public int[] externalUdpPorts() { + return this.externalUdpPorts; + } + + @Override + public Map volumes() { + return Collections.unmodifiableMap(this.volumes); + } + + @Override + public Collection imageRegistryServers() { + return Collections.unmodifiableCollection(this.imageRegistryServers); + } + + @Override + public ContainerRestartPolicy restartPolicy() { + return this.inner().restartPolicy(); + } + + @Override + public String ipAddress() { + if (this.inner().ipAddress() != null) { + return this.inner().ipAddress().ip(); + } else { + return null; + } + } + + @Override + public boolean isIPAddressPublic() { + return this.inner().ipAddress() != null && this.inner().ipAddress().type().toLowerCase().equals("public"); + } + + @Override + public OperatingSystemTypes osType() { + return this.inner().osType(); + } + + @Override + public String state() { + if (this.inner().state() != null) { + return this.inner().state(); + } else { + return null; + } + } + + @Override + public String provisioningState() { + if (this.inner().provisioningState() != null) { + return this.inner().provisioningState(); + } else { + return null; + } + } + + @Override + public String getLogContent(String containerName) { + return this.manager().containerGroups().getLogContent(this.resourceGroupName(), containerName, this.name()); + } + + @Override + public String getLogContent(String containerName, int tailLineCount) { + return this.manager().containerGroups().getLogContent(this.resourceGroupName(), containerName, this.name(), tailLineCount); + } + + @Override + public Observable getLogContentAsync(String containerName) { + return this.manager().containerGroups().getLogContentAsync(this.resourceGroupName(), containerName, this.name()); + } + + @Override + public Observable getLogContentAsync(String containerName, int tailLineCount) { + return this.manager().containerGroups().getLogContentAsync(this.resourceGroupName(), containerName, this.name(), tailLineCount); + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerGroupInner.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerGroupInner.java new file mode 100644 index 00000000000..843437ee81b --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerGroupInner.java @@ -0,0 +1,216 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance.implementation; + +import java.util.List; +import com.microsoft.azure.management.containerinstance.Container; +import com.microsoft.azure.management.containerinstance.ImageRegistryCredential; +import com.microsoft.azure.management.containerinstance.ContainerRestartPolicy; +import com.microsoft.azure.management.containerinstance.IpAddress; +import com.microsoft.azure.management.containerinstance.OperatingSystemTypes; +import com.microsoft.azure.management.containerinstance.Volume; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.Resource; + +/** + * A container group. + */ +@JsonFlatten +public class ContainerGroupInner extends Resource { + /** + * The provisioning state, which only appears in the response. + */ + @JsonProperty(value = "properties.provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private String provisioningState; + + /** + * The containers in this container group. + */ + @JsonProperty(value = "properties.containers") + private List containers; + + /** + * The image registry credentials by which the container group is created + * from. + */ + @JsonProperty(value = "properties.imageRegistryCredentials") + private List imageRegistryCredentials; + + /** + * - `always` Always restart + * . Possible values include: 'always'. + */ + @JsonProperty(value = "properties.restartPolicy") + private ContainerRestartPolicy restartPolicy; + + /** + * The IP address type. + */ + @JsonProperty(value = "properties.ipAddress") + private IpAddress ipAddress; + + /** + * The base level OS type required by the containers in the group. Possible + * values include: 'Windows', 'Linux'. + */ + @JsonProperty(value = "properties.osType") + private OperatingSystemTypes osType; + + /** + * The state of the container group. Only valid in response. + */ + @JsonProperty(value = "properties.state", access = JsonProperty.Access.WRITE_ONLY) + private String state; + + /** + * The volumes for this container group. + */ + @JsonProperty(value = "properties.volumes") + private List volumes; + + /** + * Get the provisioningState value. + * + * @return the provisioningState value + */ + public String provisioningState() { + return this.provisioningState; + } + + /** + * Get the containers value. + * + * @return the containers value + */ + public List containers() { + return this.containers; + } + + /** + * Set the containers value. + * + * @param containers the containers value to set + * @return the ContainerGroupInner object itself. + */ + public ContainerGroupInner withContainers(List containers) { + this.containers = containers; + return this; + } + + /** + * Get the imageRegistryCredentials value. + * + * @return the imageRegistryCredentials value + */ + public List imageRegistryCredentials() { + return this.imageRegistryCredentials; + } + + /** + * Set the imageRegistryCredentials value. + * + * @param imageRegistryCredentials the imageRegistryCredentials value to set + * @return the ContainerGroupInner object itself. + */ + public ContainerGroupInner withImageRegistryCredentials(List imageRegistryCredentials) { + this.imageRegistryCredentials = imageRegistryCredentials; + return this; + } + + /** + * Get the restartPolicy value. + * + * @return the restartPolicy value + */ + public ContainerRestartPolicy restartPolicy() { + return this.restartPolicy; + } + + /** + * Set the restartPolicy value. + * + * @param restartPolicy the restartPolicy value to set + * @return the ContainerGroupInner object itself. + */ + public ContainerGroupInner withRestartPolicy(ContainerRestartPolicy restartPolicy) { + this.restartPolicy = restartPolicy; + return this; + } + + /** + * Get the ipAddress value. + * + * @return the ipAddress value + */ + public IpAddress ipAddress() { + return this.ipAddress; + } + + /** + * Set the ipAddress value. + * + * @param ipAddress the ipAddress value to set + * @return the ContainerGroupInner object itself. + */ + public ContainerGroupInner withIpAddress(IpAddress ipAddress) { + this.ipAddress = ipAddress; + return this; + } + + /** + * Get the osType value. + * + * @return the osType value + */ + public OperatingSystemTypes osType() { + return this.osType; + } + + /** + * Set the osType value. + * + * @param osType the osType value to set + * @return the ContainerGroupInner object itself. + */ + public ContainerGroupInner withOsType(OperatingSystemTypes osType) { + this.osType = osType; + return this; + } + + /** + * Get the state value. + * + * @return the state value + */ + public String state() { + return this.state; + } + + /** + * Get the volumes value. + * + * @return the volumes value + */ + public List volumes() { + return this.volumes; + } + + /** + * Set the volumes value. + * + * @param volumes the volumes value to set + * @return the ContainerGroupInner object itself. + */ + public ContainerGroupInner withVolumes(List volumes) { + this.volumes = volumes; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerGroupsImpl.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerGroupsImpl.java new file mode 100644 index 00000000000..65fabc5048b --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerGroupsImpl.java @@ -0,0 +1,94 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.containerinstance.implementation; + + +import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.containerinstance.ContainerGroup; +import com.microsoft.azure.management.containerinstance.ContainerGroups; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.TopLevelModifiableResourcesImpl; +import com.microsoft.azure.management.storage.implementation.StorageManager; +import rx.Completable; +import rx.Observable; +import rx.functions.Func1; + +/** + * Implementation for ContainerGroups. + */ +@LangDefinition +public class ContainerGroupsImpl + extends + TopLevelModifiableResourcesImpl< + ContainerGroup, + ContainerGroupImpl, + ContainerGroupInner, + ContainerGroupsInner, + ContainerInstanceManager> + implements ContainerGroups { + + private final StorageManager storageManager; + + protected ContainerGroupsImpl(final ContainerInstanceManager manager, final StorageManager storageManager) { + super(manager.inner().containerGroups(), manager); + this.storageManager = storageManager; + } + + @Override + protected ContainerGroupImpl wrapModel(String name) { + return new ContainerGroupImpl(name, new ContainerGroupInner(), this.manager(), this.storageManager); + } + + @Override + protected ContainerGroupImpl wrapModel(ContainerGroupInner inner) { + if (inner == null) { + return null; + } + return new ContainerGroupImpl(inner.name(), inner, this.manager(), this.storageManager); + } + + @Override + protected Completable deleteInnerAsync(String resourceGroupName, String name) { + return this.manager().inner().containerGroups().deleteAsync(resourceGroupName, name).toCompletable(); + } + + @Override + public ContainerGroup.DefinitionStages.Blank define(String name) { + return wrapModel(name); + } + + @Override + public String getLogContent(String resourceGroupName, String containerName, String containerGroupName) { + return this.manager().inner().containerLogs().list(resourceGroupName, containerName, containerGroupName).content(); + } + + @Override + public String getLogContent(String resourceGroupName, String containerName, String containerGroupName, int tailLineCount) { + return this.manager().inner().containerLogs().list(resourceGroupName, containerName, containerGroupName, tailLineCount).content(); + } + + @Override + public Observable getLogContentAsync(String resourceGroupName, String containerName, String containerGroupName) { + return this.manager().inner().containerLogs().listAsync(resourceGroupName, containerName, containerGroupName) + .map(new Func1() { + @Override + public String call(LogsInner logsInner) { + return logsInner.content(); + } + }); + } + + @Override + public Observable getLogContentAsync(String resourceGroupName, String containerName, String containerGroupName, int tailLineCount) { + return this.manager().inner().containerLogs().listAsync(resourceGroupName, containerName, containerGroupName, tailLineCount) + .map(new Func1() { + @Override + public String call(LogsInner logsInner) { + return logsInner.content(); + } + }); + } +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerGroupsInner.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerGroupsInner.java new file mode 100644 index 00000000000..e50be7f09dd --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerGroupsInner.java @@ -0,0 +1,809 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance.implementation; + +import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsGet; +import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsDelete; +import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsListing; +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.CloudException; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.Path; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in ContainerGroups. + */ +public class ContainerGroupsInner implements InnerSupportsGet, InnerSupportsDelete, InnerSupportsListing { + /** The Retrofit service to perform REST calls. */ + private ContainerGroupsService service; + /** The service client containing this operation class. */ + private ContainerInstanceManagementClientImpl client; + + /** + * Initializes an instance of ContainerGroupsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ContainerGroupsInner(Retrofit retrofit, ContainerInstanceManagementClientImpl client) { + this.service = retrofit.create(ContainerGroupsService.class); + this.client = client; + } + + /** + * The interface defining all the services for ContainerGroups to be + * used by Retrofit to perform actually REST calls. + */ + interface ContainerGroupsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.containerinstance.ContainerGroups list" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups") + Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.containerinstance.ContainerGroups listByResourceGroup" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups") + Observable> listByResourceGroup(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.containerinstance.ContainerGroups getByResourceGroup" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}") + Observable> getByResourceGroup(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("containerGroupName") String containerGroupName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.containerinstance.ContainerGroups createOrUpdate" }) + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}") + Observable> createOrUpdate(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("containerGroupName") String containerGroupName, @Query("api-version") String apiVersion, @Body ContainerGroupInner containerGroup, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.containerinstance.ContainerGroups delete" }) + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}", method = "DELETE", hasBody = true) + Observable> delete(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("containerGroupName") String containerGroupName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.containerinstance.ContainerGroups listNext" }) + @GET + Observable> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.containerinstance.ContainerGroups listByResourceGroupNext" }) + @GET + Observable> listByResourceGroupNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Get the list of container groups in a given subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ContainerGroupInner> object if successful. + */ + public PagedList list() { + ServiceResponse> response = listSinglePageAsync().toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Get the list of container groups in a given subscription. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listSinglePageAsync(), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Get the list of container groups in a given subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ContainerGroupInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync() + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get the list of container groups in a given subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ContainerGroupInner> object + */ + public Observable>> listWithServiceResponseAsync() { + return listSinglePageAsync() + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Get the list of container groups in a given subscription. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ContainerGroupInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listSinglePageAsync() { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Get the list of container groups in a given resource group. + * + * @param resourceGroupName Azure resource group name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ContainerGroupInner> object if successful. + */ + public PagedList listByResourceGroup(final String resourceGroupName) { + ServiceResponse> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Get the list of container groups in a given resource group. + * + * @param resourceGroupName Azure resource group name + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByResourceGroupAsync(final String resourceGroupName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByResourceGroupSinglePageAsync(resourceGroupName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Get the list of container groups in a given resource group. + * + * @param resourceGroupName Azure resource group name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ContainerGroupInner> object + */ + public Observable> listByResourceGroupAsync(final String resourceGroupName) { + return listByResourceGroupWithServiceResponseAsync(resourceGroupName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get the list of container groups in a given resource group. + * + * @param resourceGroupName Azure resource group name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ContainerGroupInner> object + */ + public Observable>> listByResourceGroupWithServiceResponseAsync(final String resourceGroupName) { + return listByResourceGroupSinglePageAsync(resourceGroupName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByResourceGroupNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Get the list of container groups in a given resource group. + * + ServiceResponse> * @param resourceGroupName Azure resource group name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ContainerGroupInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByResourceGroupSinglePageAsync(final String resourceGroupName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listByResourceGroup(this.client.subscriptionId(), resourceGroupName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByResourceGroupDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByResourceGroupDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Get details for this container group. + * + * @param resourceGroupName Azure resource group name + * @param containerGroupName Container group name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ContainerGroupInner object if successful. + */ + public ContainerGroupInner getByResourceGroup(String resourceGroupName, String containerGroupName) { + return getByResourceGroupWithServiceResponseAsync(resourceGroupName, containerGroupName).toBlocking().single().body(); + } + + /** + * Get details for this container group. + * + * @param resourceGroupName Azure resource group name + * @param containerGroupName Container group name + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getByResourceGroupAsync(String resourceGroupName, String containerGroupName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getByResourceGroupWithServiceResponseAsync(resourceGroupName, containerGroupName), serviceCallback); + } + + /** + * Get details for this container group. + * + * @param resourceGroupName Azure resource group name + * @param containerGroupName Container group name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ContainerGroupInner object + */ + public Observable getByResourceGroupAsync(String resourceGroupName, String containerGroupName) { + return getByResourceGroupWithServiceResponseAsync(resourceGroupName, containerGroupName).map(new Func1, ContainerGroupInner>() { + @Override + public ContainerGroupInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get details for this container group. + * + * @param resourceGroupName Azure resource group name + * @param containerGroupName Container group name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ContainerGroupInner object + */ + public Observable> getByResourceGroupWithServiceResponseAsync(String resourceGroupName, String containerGroupName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (containerGroupName == null) { + throw new IllegalArgumentException("Parameter containerGroupName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.getByResourceGroup(this.client.subscriptionId(), resourceGroupName, containerGroupName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getByResourceGroupDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getByResourceGroupDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Create or update container groups. + * + * @param resourceGroupName Azure resource group name + * @param containerGroupName Container group name + * @param containerGroup Definition of the container to be created. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ContainerGroupInner object if successful. + */ + public ContainerGroupInner createOrUpdate(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, containerGroupName, containerGroup).toBlocking().single().body(); + } + + /** + * Create or update container groups. + * + * @param resourceGroupName Azure resource group name + * @param containerGroupName Container group name + * @param containerGroup Definition of the container to be created. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createOrUpdateAsync(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(resourceGroupName, containerGroupName, containerGroup), serviceCallback); + } + + /** + * Create or update container groups. + * + * @param resourceGroupName Azure resource group name + * @param containerGroupName Container group name + * @param containerGroup Definition of the container to be created. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ContainerGroupInner object + */ + public Observable createOrUpdateAsync(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, containerGroupName, containerGroup).map(new Func1, ContainerGroupInner>() { + @Override + public ContainerGroupInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create or update container groups. + * + * @param resourceGroupName Azure resource group name + * @param containerGroupName Container group name + * @param containerGroup Definition of the container to be created. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ContainerGroupInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (containerGroupName == null) { + throw new IllegalArgumentException("Parameter containerGroupName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (containerGroup == null) { + throw new IllegalArgumentException("Parameter containerGroup is required and cannot be null."); + } + Validator.validate(containerGroup); + return service.createOrUpdate(this.client.subscriptionId(), resourceGroupName, containerGroupName, this.client.apiVersion(), containerGroup, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(201, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Delete container groups. + * + * @param resourceGroupName Azure resource group name + * @param containerGroupName Name of the container group to be deleted + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the ContainerGroupInner object if successful. + */ + public ContainerGroupInner delete(String resourceGroupName, String containerGroupName) { + return deleteWithServiceResponseAsync(resourceGroupName, containerGroupName).toBlocking().single().body(); + } + + /** + * Delete container groups. + * + * @param resourceGroupName Azure resource group name + * @param containerGroupName Name of the container group to be deleted + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String resourceGroupName, String containerGroupName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, containerGroupName), serviceCallback); + } + + /** + * Delete container groups. + * + * @param resourceGroupName Azure resource group name + * @param containerGroupName Name of the container group to be deleted + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ContainerGroupInner object + */ + public Observable deleteAsync(String resourceGroupName, String containerGroupName) { + return deleteWithServiceResponseAsync(resourceGroupName, containerGroupName).map(new Func1, ContainerGroupInner>() { + @Override + public ContainerGroupInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete container groups. + * + * @param resourceGroupName Azure resource group name + * @param containerGroupName Name of the container group to be deleted + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ContainerGroupInner object + */ + public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String containerGroupName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (containerGroupName == null) { + throw new IllegalArgumentException("Parameter containerGroupName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.delete(this.client.subscriptionId(), resourceGroupName, containerGroupName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Get the list of container groups in a given subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ContainerGroupInner> object if successful. + */ + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Get the list of container groups in a given subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Get the list of container groups in a given subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ContainerGroupInner> object + */ + public Observable> listNextAsync(final String nextPageLink) { + return listNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get the list of container groups in a given subscription. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ContainerGroupInner> object + */ + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { + return listNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Get the list of container groups in a given subscription. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ContainerGroupInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listNextDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Get the list of container groups in a given resource group. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<ContainerGroupInner> object if successful. + */ + public PagedList listByResourceGroupNext(final String nextPageLink) { + ServiceResponse> response = listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Get the list of container groups in a given resource group. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByResourceGroupNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByResourceGroupNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Get the list of container groups in a given resource group. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ContainerGroupInner> object + */ + public Observable> listByResourceGroupNextAsync(final String nextPageLink) { + return listByResourceGroupNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Get the list of container groups in a given resource group. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<ContainerGroupInner> object + */ + public Observable>> listByResourceGroupNextWithServiceResponseAsync(final String nextPageLink) { + return listByResourceGroupNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByResourceGroupNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Get the list of container groups in a given resource group. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<ContainerGroupInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByResourceGroupNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByResourceGroupNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByResourceGroupNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByResourceGroupNextDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerImpl.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerImpl.java new file mode 100644 index 00000000000..9d95510ceb9 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerImpl.java @@ -0,0 +1,230 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.containerinstance.implementation; + +import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.containerinstance.Container; +import com.microsoft.azure.management.containerinstance.ContainerGroup; +import com.microsoft.azure.management.containerinstance.ContainerGroupNetworkProtocol; +import com.microsoft.azure.management.containerinstance.ContainerPort; +import com.microsoft.azure.management.containerinstance.EnvironmentVariable; +import com.microsoft.azure.management.containerinstance.IpAddress; +import com.microsoft.azure.management.containerinstance.Port; +import com.microsoft.azure.management.containerinstance.ResourceRequests; +import com.microsoft.azure.management.containerinstance.ResourceRequirements; +import com.microsoft.azure.management.containerinstance.VolumeMount; + +import java.util.ArrayList; +import java.util.Map; + +/** + * Implementation for container group's container instance definition stages interface. + */ +@LangDefinition +class ContainerImpl implements + ContainerGroup.DefinitionStages.ContainerInstanceDefinitionStages.ContainerInstanceDefinition { + private Container innerContainer; + private ContainerGroupImpl parent; + + ContainerImpl(ContainerGroupImpl parent, String containerName) { + this.parent = parent; + this.innerContainer = new Container() + .withName(containerName) + .withResources(new ResourceRequirements() + .withRequests(new ResourceRequests() + .withCpu(1) + .withMemoryInGB(1.5))); + } + + @Override + public ContainerGroupImpl attach() { + if (parent.inner().containers() == null) { + parent.inner().withContainers(new ArrayList()); + } + parent.inner().containers().add(innerContainer); + + return parent; + } + + @Override + public ContainerImpl withImage(String imageName) { + innerContainer.withImage(imageName); + return this; + } + + @Override + public ContainerImpl withoutPorts() { + innerContainer.withPorts(null); + + return this; + } + + @Override + public ContainerImpl withExternalTcpPorts(int... ports) { + for (int port : ports) { + this.withExternalTcpPort(port); + } + + return this; + } + + @Override + public ContainerImpl withExternalTcpPort(int port) { + ensureParentIpAddress().ports().add(new Port() + .withPort(port) + .withProtocol(ContainerGroupNetworkProtocol.TCP)); + this.withInternalPort(port); + + return this; + } + + private IpAddress ensureParentIpAddress() { + if (parent.inner().ipAddress() == null) { + parent.inner().withIpAddress(new IpAddress() + .withType("Public") + .withPorts(new ArrayList())); + } + + return parent.inner().ipAddress(); + } + + @Override + public ContainerImpl withExternalUdpPorts(int... ports) { + for (int port : ports) { + this.withExternalUdpPort(port); + } + + return this; + } + + @Override + public ContainerImpl withExternalUdpPort(int port) { + ensureParentIpAddress().ports().add(new Port() + .withPort(port) + .withProtocol(ContainerGroupNetworkProtocol.UDP)); + this.withInternalPort(port); + + return this; + } + + @Override + public ContainerImpl withInternalPorts(int... ports) { + for (int port : ports) { + this.withInternalPort(port); + } + + return this; + } + + @Override + public ContainerImpl withInternalPort(int port) { + if (innerContainer.ports() == null) { + innerContainer.withPorts(new ArrayList()); + } + innerContainer.ports().add(new ContainerPort().withPort(port)); + + return this; + } + + @Override + public ContainerImpl withCpuCoreCount(double cpuCoreCount) { + innerContainer.resources().requests().withCpu(cpuCoreCount); + + return this; + } + + @Override + public ContainerImpl withMemorySizeInGB(double memorySize) { + innerContainer.resources().requests().withMemoryInGB(memorySize); + + return this; + } + + @Override + public ContainerImpl withStartingCommandLines(String... commandLines) { + for (String command : commandLines) { + this.withStartingCommandLine(command); + } + + return this; + } + + @Override + public ContainerImpl withStartingCommandLine(String commandLine) { + if (innerContainer.command() == null) { + innerContainer.withCommand(new ArrayList()); + } + innerContainer.command().add(commandLine); + + return this; + } + + @Override + public ContainerImpl withEnvironmentVariables(Map environmentVariables) { + for (Map.Entry entry : environmentVariables.entrySet()) { + this.withEnvironmentVariable(entry.getKey(), entry.getValue()); + } + + return this; + } + + @Override + public ContainerImpl withEnvironmentVariable(String envName, String envValue) { + if (innerContainer.environmentVariables() == null) { + innerContainer.withEnvironmentVariables(new ArrayList()); + } + + innerContainer.environmentVariables().add(new EnvironmentVariable() + .withName(envName) + .withValue(envValue)); + + return this; + } + + @Override + public ContainerImpl withVolumeMountSetting(String volumeName, String mountPath) { + if (innerContainer.volumeMounts() == null) { + innerContainer.withVolumeMounts(new ArrayList()); + } + innerContainer.volumeMounts().add(new VolumeMount() + .withName(volumeName) + .withMountPath(mountPath) + .withReadOnly(false)); + + return this; + } + + @Override + public ContainerImpl withVolumeMountSetting(Map volumeMountSetting) { + for (Map.Entry entry : volumeMountSetting.entrySet()) { + this.withVolumeMountSetting(entry.getKey(), entry.getValue()); + } + + return this; + } + + @Override + public ContainerImpl withReadOnlyVolumeMountSetting(String volumeName, String mountPath) { + if (innerContainer.volumeMounts() == null) { + innerContainer.withVolumeMounts(new ArrayList()); + } + innerContainer.volumeMounts().add(new VolumeMount() + .withName(volumeName) + .withMountPath(mountPath) + .withReadOnly(true)); + + return this; + } + + @Override + public ContainerImpl withReadOnlyVolumeMountSetting(Map volumeMountSetting) { + for (Map.Entry entry : volumeMountSetting.entrySet()) { + this.withReadOnlyVolumeMountSetting(entry.getKey(), entry.getValue()); + } + + return this; + } +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerInstanceManagementClientImpl.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerInstanceManagementClientImpl.java new file mode 100644 index 00000000000..62ab41d464e --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerInstanceManagementClientImpl.java @@ -0,0 +1,210 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance.implementation; + +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestClient; + +/** + * Initializes a new instance of the ContainerInstanceManagementClientImpl class. + */ +public class ContainerInstanceManagementClientImpl extends AzureServiceClient { + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. */ + private String subscriptionId; + + /** + * Gets Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Sets Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + * + * @param subscriptionId the subscriptionId value. + * @return the service client itself + */ + public ContainerInstanceManagementClientImpl withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** Client API version. */ + private String apiVersion; + + /** + * Gets Client API version. + * + * @return the apiVersion value. + */ + public String apiVersion() { + return this.apiVersion; + } + + /** Gets or sets the preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public ContainerInstanceManagementClientImpl withAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + public ContainerInstanceManagementClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; + } + + /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + public ContainerInstanceManagementClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The ContainerGroupsInner object to access its operations. + */ + private ContainerGroupsInner containerGroups; + + /** + * Gets the ContainerGroupsInner object to access its operations. + * @return the ContainerGroupsInner object. + */ + public ContainerGroupsInner containerGroups() { + return this.containerGroups; + } + + /** + * The ContainerLogsInner object to access its operations. + */ + private ContainerLogsInner containerLogs; + + /** + * Gets the ContainerLogsInner object to access its operations. + * @return the ContainerLogsInner object. + */ + public ContainerLogsInner containerLogs() { + return this.containerLogs; + } + + /** + * Initializes an instance of ContainerInstanceManagementClient client. + * + * @param credentials the management credentials for Azure + */ + public ContainerInstanceManagementClientImpl(ServiceClientCredentials credentials) { + this("https://management.azure.com", credentials); + } + + /** + * Initializes an instance of ContainerInstanceManagementClient client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + public ContainerInstanceManagementClientImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of ContainerInstanceManagementClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public ContainerInstanceManagementClientImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.apiVersion = "2017-08-01-preview"; + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.containerGroups = new ContainerGroupsInner(restClient().retrofit(), this); + this.containerLogs = new ContainerLogsInner(restClient().retrofit(), this); + this.azureClient = new AzureClient(this); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("%s (%s, %s)", super.userAgent(), "ContainerInstanceManagementClient", "2017-08-01-preview"); + } +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerInstanceManager.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerInstanceManager.java new file mode 100644 index 00000000000..e725a7824ab --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerInstanceManager.java @@ -0,0 +1,115 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.containerinstance.implementation; + +import com.microsoft.azure.AzureEnvironment; +import com.microsoft.azure.AzureResponseBuilder; +import com.microsoft.azure.credentials.AzureTokenCredentials; +import com.microsoft.azure.management.apigeneration.Beta; +import com.microsoft.azure.management.apigeneration.Beta.SinceVersion; +import com.microsoft.azure.management.containerinstance.ContainerGroups; +import com.microsoft.azure.management.resources.fluentcore.arm.AzureConfigurable; +import com.microsoft.azure.management.resources.fluentcore.arm.implementation.AzureConfigurableImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.implementation.Manager; +import com.microsoft.azure.management.resources.fluentcore.utils.ProviderRegistrationInterceptor; +import com.microsoft.azure.management.resources.fluentcore.utils.ResourceManagerThrottlingInterceptor; +import com.microsoft.azure.management.storage.implementation.StorageManager; +import com.microsoft.azure.serializer.AzureJacksonAdapter; +import com.microsoft.rest.RestClient; + +/** + * Entry point to Azure container instance management. + */ +@Beta(SinceVersion.V1_3_0) +public final class ContainerInstanceManager extends Manager { + + // The service managers + private ContainerGroupsImpl containerGroups; + private StorageManager storageManager; + + /** + * Get a Configurable instance that can be used to create ContainerInstanceManager with optional configuration. + * + * @return Configurable + */ + public static Configurable configure() { + return new ContainerInstanceManager.ConfigurableImpl(); + } + + /** + * Creates an instance of ContainerInstanceManager that exposes resource management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription + * @return the ContainerInstanceManager + */ + public static ContainerInstanceManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return new ContainerInstanceManager(new RestClient.Builder() + .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) + .withCredentials(credentials) + .withSerializerAdapter(new AzureJacksonAdapter()) + .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) + .withInterceptor(new ProviderRegistrationInterceptor(credentials)) + .withInterceptor(new ResourceManagerThrottlingInterceptor()) + .build(), subscriptionId); + } + + /** + * Creates an instance of ContainerInstanceManager that exposes resource management API entry points. + * + * @param restClient the RestClient to be used for API calls. + * @param subscriptionId the subscription + * @return the ContainerInstanceManager + */ + public static ContainerInstanceManager authenticate(RestClient restClient, String subscriptionId) { + return new ContainerInstanceManager(restClient, subscriptionId); + } + + /** + * The interface allowing configurations to be set. + */ + public interface Configurable extends AzureConfigurable { + /** + * Creates an instance of ContainerInstanceManager that exposes resource management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription + * @return the ContainerInstanceManager + */ + ContainerInstanceManager authenticate(AzureTokenCredentials credentials, String subscriptionId); + } + + /** + * The implementation for Configurable interface. + */ + private static final class ConfigurableImpl extends AzureConfigurableImpl implements Configurable { + @Override + public ContainerInstanceManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return ContainerInstanceManager.authenticate(buildRestClient(credentials), subscriptionId); + } + } + + private ContainerInstanceManager(RestClient restClient, String subscriptionId) { + super( + restClient, + subscriptionId, + new ContainerInstanceManagementClientImpl(restClient).withSubscriptionId(subscriptionId)); + + this.storageManager = StorageManager.authenticate(restClient, subscriptionId); + } + + /** + * @return the resource management API entry point + */ + public ContainerGroups containerGroups() { + if (containerGroups == null) { + containerGroups = new ContainerGroupsImpl(this, this.storageManager); + } + + return containerGroups; + } +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerLogsInner.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerLogsInner.java new file mode 100644 index 00000000000..6fb99f1ccd4 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerLogsInner.java @@ -0,0 +1,244 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.CloudException; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in ContainerLogs. + */ +public class ContainerLogsInner { + /** The Retrofit service to perform REST calls. */ + private ContainerLogsService service; + /** The service client containing this operation class. */ + private ContainerInstanceManagementClientImpl client; + + /** + * Initializes an instance of ContainerLogsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ContainerLogsInner(Retrofit retrofit, ContainerInstanceManagementClientImpl client) { + this.service = retrofit.create(ContainerLogsService.class); + this.client = client; + } + + /** + * The interface defining all the services for ContainerLogs to be + * used by Retrofit to perform actually REST calls. + */ + interface ContainerLogsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.containerinstance.ContainerLogs list" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs") + Observable> list(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("containerName") String containerName, @Path("containerGroupName") String containerGroupName, @Query("api-version") String apiVersion, @Query("tail") Integer tail, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Get the logs for this container. + * + * @param resourceGroupName Azure resource group name + * @param containerName Container name + * @param containerGroupName Container group name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the LogsInner object if successful. + */ + public LogsInner list(String resourceGroupName, String containerName, String containerGroupName) { + return listWithServiceResponseAsync(resourceGroupName, containerName, containerGroupName).toBlocking().single().body(); + } + + /** + * Get the logs for this container. + * + * @param resourceGroupName Azure resource group name + * @param containerName Container name + * @param containerGroupName Container group name + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture listAsync(String resourceGroupName, String containerName, String containerGroupName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(resourceGroupName, containerName, containerGroupName), serviceCallback); + } + + /** + * Get the logs for this container. + * + * @param resourceGroupName Azure resource group name + * @param containerName Container name + * @param containerGroupName Container group name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LogsInner object + */ + public Observable listAsync(String resourceGroupName, String containerName, String containerGroupName) { + return listWithServiceResponseAsync(resourceGroupName, containerName, containerGroupName).map(new Func1, LogsInner>() { + @Override + public LogsInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get the logs for this container. + * + * @param resourceGroupName Azure resource group name + * @param containerName Container name + * @param containerGroupName Container group name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LogsInner object + */ + public Observable> listWithServiceResponseAsync(String resourceGroupName, String containerName, String containerGroupName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (containerName == null) { + throw new IllegalArgumentException("Parameter containerName is required and cannot be null."); + } + if (containerGroupName == null) { + throw new IllegalArgumentException("Parameter containerGroupName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final Integer tail = null; + return service.list(this.client.subscriptionId(), resourceGroupName, containerName, containerGroupName, this.client.apiVersion(), tail, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Get the logs for this container. + * + * @param resourceGroupName Azure resource group name + * @param containerName Container name + * @param containerGroupName Container group name + * @param tail Only show this number of log lines. If not provided, all available logs are shown. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the LogsInner object if successful. + */ + public LogsInner list(String resourceGroupName, String containerName, String containerGroupName, Integer tail) { + return listWithServiceResponseAsync(resourceGroupName, containerName, containerGroupName, tail).toBlocking().single().body(); + } + + /** + * Get the logs for this container. + * + * @param resourceGroupName Azure resource group name + * @param containerName Container name + * @param containerGroupName Container group name + * @param tail Only show this number of log lines. If not provided, all available logs are shown. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture listAsync(String resourceGroupName, String containerName, String containerGroupName, Integer tail, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(resourceGroupName, containerName, containerGroupName, tail), serviceCallback); + } + + /** + * Get the logs for this container. + * + * @param resourceGroupName Azure resource group name + * @param containerName Container name + * @param containerGroupName Container group name + * @param tail Only show this number of log lines. If not provided, all available logs are shown. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LogsInner object + */ + public Observable listAsync(String resourceGroupName, String containerName, String containerGroupName, Integer tail) { + return listWithServiceResponseAsync(resourceGroupName, containerName, containerGroupName, tail).map(new Func1, LogsInner>() { + @Override + public LogsInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get the logs for this container. + * + * @param resourceGroupName Azure resource group name + * @param containerName Container name + * @param containerGroupName Container group name + * @param tail Only show this number of log lines. If not provided, all available logs are shown. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LogsInner object + */ + public Observable> listWithServiceResponseAsync(String resourceGroupName, String containerName, String containerGroupName, Integer tail) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (containerName == null) { + throw new IllegalArgumentException("Parameter containerName is required and cannot be null."); + } + if (containerGroupName == null) { + throw new IllegalArgumentException("Parameter containerGroupName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.list(this.client.subscriptionId(), resourceGroupName, containerName, containerGroupName, this.client.apiVersion(), tail, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse listDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/LogsInner.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/LogsInner.java new file mode 100644 index 00000000000..7ca3fc15c1e --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/LogsInner.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The logs. + */ +public class LogsInner { + /** + * content of the log. + */ + @JsonProperty(value = "content") + private String content; + + /** + * Get the content value. + * + * @return the content value + */ + public String content() { + return this.content; + } + + /** + * Set the content value. + * + * @param content the content value to set + * @return the LogsInner object itself. + */ + public LogsInner withContent(String content) { + this.content = content; + return this; + } + +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/PageImpl.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/PageImpl.java new file mode 100644 index 00000000000..d25c79f983a --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/PageImpl.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.containerinstance.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.Page; +import java.util.List; + +/** + * An instance of this class defines a page of Azure resources and a link to + * get the next page of resources, if any. + * + * @param type of Azure resource + */ +public class PageImpl implements Page { + /** + * The link to the next page. + */ + @JsonProperty("nextLink") + private String nextPageLink; + + /** + * The list of items. + */ + @JsonProperty("value") + private List items; + + /** + * Gets the link to the next page. + * + * @return the link to the next page. + */ + @Override + public String nextPageLink() { + return this.nextPageLink; + } + + /** + * Gets the list of items. + * + * @return the list of items in {@link List}. + */ + @Override + public List items() { + return items; + } + + /** + * Sets the link to the next page. + * + * @param nextPageLink the link to the next page. + * @return this Page object itself. + */ + public PageImpl setNextPageLink(String nextPageLink) { + this.nextPageLink = nextPageLink; + return this; + } + + /** + * Sets the list of items. + * + * @param items the list of items in {@link List}. + * @return this Page object itself. + */ + public PageImpl setItems(List items) { + this.items = items; + return this; + } +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/VolumeImpl.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/VolumeImpl.java new file mode 100644 index 00000000000..046ab48cac3 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/VolumeImpl.java @@ -0,0 +1,77 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.containerinstance.implementation; + +import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.containerinstance.AzureFileVolume; +import com.microsoft.azure.management.containerinstance.ContainerGroup; +import com.microsoft.azure.management.containerinstance.Volume; + +import java.util.ArrayList; + +/** + * Implementation for container group's volume definition stages interface. + */ +@LangDefinition +class VolumeImpl implements ContainerGroup.DefinitionStages.VolumeDefinitionStages.VolumeDefinition { + private Volume innerVolume; + private ContainerGroupImpl parent; + + VolumeImpl(ContainerGroupImpl parent, String volumeName) { + this.parent = parent; + this.innerVolume = new Volume().withName(volumeName); + } + + @Override + public ContainerGroupImpl attach() { + if (parent.inner().volumes() == null) { + parent.inner().withVolumes(new ArrayList()); + } + parent.inner().volumes().add(innerVolume); + + return parent; + } + + @Override + public VolumeImpl withExistingReadWriteAzureFileShare(String shareName) { + ensureAzureFileVolume() + .withReadOnly(false) + .withShareName(shareName); + + return this; + } + + @Override + public VolumeImpl withExistingReadOnlyAzureFileShare(String shareName) { + ensureAzureFileVolume() + .withReadOnly(true) + .withShareName(shareName); + + return this; + } + + private AzureFileVolume ensureAzureFileVolume() { + if (innerVolume.azureFile() == null) { + innerVolume.withAzureFile(new AzureFileVolume()); + } + + return innerVolume.azureFile(); + } + + @Override + public VolumeImpl withStorageAccountName(String storageAccountName) { + ensureAzureFileVolume().withStorageAccountName(storageAccountName); + + return this; + } + + @Override + public VolumeImpl withStorageAccountKey(String storageAccountKey) { + ensureAzureFileVolume().withStorageAccountKey(storageAccountKey); + + return this; + } +} diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/package-info.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/package-info.java new file mode 100644 index 00000000000..b7fea6151a7 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the implementation classes for ContainerInstanceManagementClient. + */ +package com.microsoft.azure.management.containerinstance.implementation; diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/package-info.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/package-info.java new file mode 100644 index 00000000000..8747d52a811 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the classes for ContainerInstanceManagementClient. + */ +package com.microsoft.azure.management.containerinstance; diff --git a/azure-samples/pom.xml b/azure-samples/pom.xml index 438e337f76c..0be307ae7de 100644 --- a/azure-samples/pom.xml +++ b/azure-samples/pom.xml @@ -165,6 +165,11 @@ azure-documentdb 1.9.4 + + com.spotify + docker-client + 8.9.0 + diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceWithAzureFileShareMount.java b/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceWithAzureFileShareMount.java new file mode 100644 index 00000000000..84be187afea --- /dev/null +++ b/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceWithAzureFileShareMount.java @@ -0,0 +1,145 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.containerinstance.samples; + +import com.microsoft.azure.management.Azure; +import com.microsoft.azure.management.containerinstance.ContainerGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.utils.SdkContext; +import com.microsoft.azure.management.samples.Utils; +import com.microsoft.azure.management.storage.StorageAccount; +import com.microsoft.azure.storage.CloudStorageAccount; +import com.microsoft.azure.storage.file.CloudFileShare; +import com.microsoft.azure.storage.file.ListFileItem; +import com.microsoft.rest.LogLevel; + +import java.io.File; + +/** + * Azure Container Instance sample for managing container instances with Azure File Share mount. + * - Create an Azure container instance using Docker image "seanmckenna/aci-hellofiles" with a mount to a new file share + * - Test that the container app can be reached via "curl" like HTTP GET calls + * - Retrieve container log content + */ +public class ManageContainerInstanceWithAzureFileShareMount { + /** + * Main function which runs the actual sample. + * + * @param azure instance of the azure client + * @return true if sample runs successfully + */ + public static boolean runSample(Azure azure) { + final String rgName = SdkContext.randomResourceName("rgACI", 15); + final String aciName = SdkContext.randomResourceName("acisample", 20); + final String shareName = SdkContext.randomResourceName("fileshare", 20); + final String containerImageName = "seanmckenna/aci-hellofiles"; + final String volumeMountName = "aci-helloshare"; + + try { + + //============================================================= + // Create a container group with one container instance of default CPU core count and memory size + // using public Docker image "seanmckenna/aci-hellofiles" which mounts the file share created previously + // as read/write shared container volume. + + ContainerGroup containerGroup = azure.containerGroups().define(aciName) + .withRegion(Region.US_WEST) + .withNewResourceGroup(rgName) + .withLinux() + .withPublicImageRegistryOnly() + .withNewAzureFileShareVolume(volumeMountName, shareName) + .defineContainerInstance(aciName) + .withImage(containerImageName) + .withExternalTcpPort(80) + .withVolumeMountSetting(volumeMountName, "/aci/logs/") + .attach() + .create(); + + Utils.print(containerGroup); + + //============================================================= + // Check that the container instance is up and running + + // warm up + System.out.println("Warming up " + containerGroup.ipAddress()); + Utils.curl("http://" + containerGroup.ipAddress()); + SdkContext.sleep(30000); + System.out.println("CURLing " + containerGroup.ipAddress()); + System.out.println(Utils.curl("http://" + containerGroup.ipAddress())); + + //============================================================= + // Check the container instance logs + + String logContent = containerGroup.getLogContent(aciName); + System.out.format("Logs for container instance: %s\n%s", aciName, logContent); + + //============================================================= + // List the file share content + + String storageAccountName = containerGroup.volumes().get(volumeMountName).azureFile().storageAccountName(); + StorageAccount storageAccount = azure.storageAccounts().getByResourceGroup(rgName, storageAccountName); + CloudFileShare cloudFileShare = CloudStorageAccount.parse(String.format("DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;EndpointSuffix=core.windows.net", + storageAccountName, + storageAccount.getKeys().get(0).value())) + .createCloudFileClient() + .getShareReference(shareName); + Iterable shareContent = cloudFileShare.getRootDirectoryReference().listFilesAndDirectories(); + + for (ListFileItem item : shareContent) { + System.out.format("Found shared file %s:\n", item.getUri().toString()); + } + + //============================================================= + // Remove the container group + + azure.containerGroups().deleteById(containerGroup.id()); + + return true; + } catch (Exception f) { + System.out.println(f.getMessage()); + f.printStackTrace(); + } finally { + try { + System.out.println("Deleting Resource Group: " + rgName); + azure.resourceGroups().beginDeleteByName(rgName); + System.out.println("Deleted Resource Group: " + rgName); + } catch (NullPointerException npe) { + System.out.println("Did not create any resources in Azure. No clean up is necessary"); + } catch (Exception g) { + g.printStackTrace(); + } + } + return false; + } + + /** + * Main entry point. + * + * @param args the parameters + */ + public static void main(String[] args) { + try { + //============================================================= + // Authenticate + + final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); + + Azure azure = Azure.configure() + .withLogLevel(LogLevel.BODY) + .authenticate(credFile) + .withDefaultSubscription(); + + // Print selected subscription + System.out.println("Selected subscription: " + azure.subscriptionId()); + + runSample(azure); + } catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceWithManualAzureFileShareMountCreation.java b/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceWithManualAzureFileShareMountCreation.java new file mode 100644 index 00000000000..5d52dc76c85 --- /dev/null +++ b/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceWithManualAzureFileShareMountCreation.java @@ -0,0 +1,162 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.containerinstance.samples; + +import com.microsoft.azure.management.Azure; +import com.microsoft.azure.management.containerinstance.ContainerGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.utils.SdkContext; +import com.microsoft.azure.management.samples.Utils; +import com.microsoft.azure.management.storage.StorageAccount; +import com.microsoft.azure.management.storage.StorageAccountKey; +import com.microsoft.azure.storage.CloudStorageAccount; +import com.microsoft.azure.storage.file.CloudFileShare; +import com.microsoft.azure.storage.file.ListFileItem; +import com.microsoft.rest.LogLevel; + +import java.io.File; + +/** + * Azure Container Instance sample for managing container instances with Azure File Share mount. + * - Create a storage account and an Azure file share resource + * - Create an Azure container instance using Docker image "seanmckenna/aci-hellofiles" with a mount to the file share from above + * - Test that the container app can be reached via "curl" like HTTP GET calls + * - Retrieve container log content + */ +public class ManageContainerInstanceWithManualAzureFileShareMountCreation { + /** + * Main function which runs the actual sample. + * + * @param azure instance of the azure client + * @return true if sample runs successfully + */ + public static boolean runSample(Azure azure) { + final String rgName = SdkContext.randomResourceName("rgACI", 15); + final String aciName = SdkContext.randomResourceName("acisample", 20); + final String saName = SdkContext.randomResourceName("sa", 20); + final String shareName = SdkContext.randomResourceName("fileshare", 20); + final String containerImageName = "seanmckenna/aci-hellofiles"; + final String volumeMountName = "aci-helloshare"; + + try { + + //============================================================= + // Create a new storage account and an Azure file share resource + + StorageAccount storageAccount = azure.storageAccounts().define(saName) + .withRegion(Region.US_WEST) + .withNewResourceGroup(rgName) + .create(); + + StorageAccountKey storageAccountKey = storageAccount.getKeys().get(0); + + CloudFileShare cloudFileShare = CloudStorageAccount.parse(String.format("DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;EndpointSuffix=core.windows.net", + saName, + storageAccount.getKeys().get(0).value())) + .createCloudFileClient() + .getShareReference(shareName); + cloudFileShare.create(); + + //============================================================= + // Create a container group with one container instance of default CPU core count and memory size + // using public Docker image "seanmckenna/aci-hellofiles" which mounts the file share created previously + // as read/write shared container volume. + + ContainerGroup containerGroup = azure.containerGroups().define(aciName) + .withRegion(Region.US_WEST) + .withExistingResourceGroup(rgName) + .withLinux() + .withPublicImageRegistryOnly() + .defineVolume(volumeMountName) + .withExistingReadWriteAzureFileShare(shareName) + .withStorageAccountName(saName) + .withStorageAccountKey(storageAccountKey.value()) + .attach() + .defineContainerInstance(aciName) + .withImage(containerImageName) + .withExternalTcpPort(80) + .withVolumeMountSetting(volumeMountName, "/aci/logs/") + .attach() + .create(); + + Utils.print(containerGroup); + + //============================================================= + // Check that the container instance is up and running + + // warm up + System.out.println("Warming up " + containerGroup.ipAddress()); + Utils.curl("http://" + containerGroup.ipAddress()); + SdkContext.sleep(15000); + System.out.println("CURLing " + containerGroup.ipAddress()); + System.out.println(Utils.curl("http://" + containerGroup.ipAddress())); + + //============================================================= + // Check the container instance logs + + String logContent = containerGroup.getLogContent(aciName); + System.out.format("Logs for container instance: %s\n%s", aciName, logContent); + + //============================================================= + // Remove the container group + + azure.containerGroups().deleteById(containerGroup.id()); + + //============================================================= + // List the file share content + + Iterable shareContent = cloudFileShare.getRootDirectoryReference().listFilesAndDirectories(); + + for (ListFileItem item : shareContent) { + System.out.format("Found shared file %s:\n", item.getUri().toString()); + } + + return true; + } catch (Exception f) { + System.out.println(f.getMessage()); + f.printStackTrace(); + } finally { + try { + System.out.println("Deleting Resource Group: " + rgName); + azure.resourceGroups().beginDeleteByName(rgName); + System.out.println("Deleted Resource Group: " + rgName); + } catch (NullPointerException npe) { + System.out.println("Did not create any resources in Azure. No clean up is necessary"); + } catch (Exception g) { + g.printStackTrace(); + } + } + return false; + } + + /** + * Main entry point. + * + * @param args the parameters + */ + public static void main(String[] args) { + try { + //============================================================= + // Authenticate + + final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); + + Azure azure = Azure.configure() + .withLogLevel(LogLevel.BODY) + .authenticate(credFile) + .withDefaultSubscription(); + + // Print selected subscription + System.out.println("Selected subscription: " + azure.subscriptionId()); + + runSample(azure); + } catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceWithMultipleContainerImages.java b/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceWithMultipleContainerImages.java new file mode 100644 index 00000000000..bfd2ade1c39 --- /dev/null +++ b/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceWithMultipleContainerImages.java @@ -0,0 +1,131 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.containerinstance.samples; + +import com.microsoft.azure.management.Azure; +import com.microsoft.azure.management.containerinstance.ContainerGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.utils.SdkContext; +import com.microsoft.azure.management.samples.Utils; +import com.microsoft.rest.LogLevel; + +import java.io.File; + +/** + * Azure Container Instance sample for managing container instances. + * - Create an Azure container group with two container instances using Docker images "microsoft/aci-helloworld" and "microsoft/aci-tutorial-sidecar" + * - Test that the container app can be reached via "curl" like HTTP GET calls + * - Retrieve container log content + * - Delete the container group resource + */ +public class ManageContainerInstanceWithMultipleContainerImages { + /** + * Main function which runs the actual sample. + * + * @param azure instance of the azure client + * @return true if sample runs successfully + */ + public static boolean runSample(Azure azure) { + final String rgName = SdkContext.randomResourceName("rgACI", 15); + final String aciName = SdkContext.randomResourceName("acisample", 20); + final String containerImageName1 = "microsoft/aci-helloworld"; + final String containerImageName2 = "microsoft/aci-tutorial-sidecar"; + + try { + //============================================================= + // Create a container group with two container instances + + ContainerGroup containerGroup = azure.containerGroups().define(aciName) + .withRegion(Region.US_WEST) + .withNewResourceGroup(rgName) + .withLinux() + .withPublicImageRegistryOnly() + .withoutVolume() + .defineContainerInstance(aciName + "-1") + .withImage(containerImageName1) + .withExternalTcpPort(80) + .withCpuCoreCount(.5) + .withMemorySizeInGB(.75) + .attach() + .defineContainerInstance(aciName + "-2") + .withImage(containerImageName2) + .withoutPorts() + .withCpuCoreCount(.5) + .withMemorySizeInGB(.75) + .attach() + .create(); + + Utils.print(containerGroup); + + //============================================================= + // Check that the container instance is up and running + + // warm up + System.out.println("Warming up " + containerGroup.ipAddress()); + Utils.curl("http://" + containerGroup.ipAddress()); + SdkContext.sleep(15000); + System.out.println("CURLing " + containerGroup.ipAddress()); + System.out.println(Utils.curl("http://" + containerGroup.ipAddress())); + + //============================================================= + // Check the container instance logs + + String logContent = containerGroup.getLogContent(aciName + "-1"); + System.out.format("Logs for container instance: %s\n%s", aciName + "-1", logContent); + logContent = containerGroup.getLogContent(aciName + "-2"); + System.out.format("Logs for container instance: %s\n%s", aciName + "-2", logContent); + + //============================================================= + // Remove the container group + + azure.containerGroups().deleteById(containerGroup.id()); + + return true; + } catch (Exception f) { + System.out.println(f.getMessage()); + f.printStackTrace(); + } finally { + try { + System.out.println("Deleting Resource Group: " + rgName); + azure.resourceGroups().beginDeleteByName(rgName); + System.out.println("Deleted Resource Group: " + rgName); + } catch (NullPointerException npe) { + System.out.println("Did not create any resources in Azure. No clean up is necessary"); + } catch (Exception g) { + g.printStackTrace(); + } + } + return false; + } + + /** + * Main entry point. + * + * @param args the parameters + */ + public static void main(String[] args) { + try { + //============================================================= + // Authenticate + + final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); + + Azure azure = Azure.configure() + .withLogLevel(LogLevel.BODY) + .authenticate(credFile) + .withDefaultSubscription(); + + // Print selected subscription + System.out.println("Selected subscription: " + azure.subscriptionId()); + + runSample(azure); + } catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceZeroToOneAndOneToManyUsingDockerSwarmOrchestration.java b/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceZeroToOneAndOneToManyUsingDockerSwarmOrchestration.java new file mode 100644 index 00000000000..22d5c4d94f5 --- /dev/null +++ b/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceZeroToOneAndOneToManyUsingDockerSwarmOrchestration.java @@ -0,0 +1,160 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.containerinstance.samples; + +import com.microsoft.azure.management.Azure; +import com.microsoft.azure.management.containerinstance.ContainerGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.utils.SdkContext; +import com.microsoft.azure.management.samples.Utils; +import com.microsoft.rest.LogLevel; +//import com.spotify.docker.client.DefaultDockerClient; +//import com.spotify.docker.client.DockerCertificates; +//import com.spotify.docker.client.DockerClient; +//import com.spotify.docker.client.messages.RegistryAuth; + +import java.io.File; +//import java.nio.file.Paths; +//import java.util.List; + +/** + * Azure Container Instance sample for managing container instances. + * - Create an Azure container instance using Docker image "microsoft/aci-helloworld" with a mount to the file share from above + * - Test that the container app can be reached via "curl" like HTTP GET call + * - Retrieve container log content + */ +public class ManageContainerInstanceZeroToOneAndOneToManyUsingDockerSwarmOrchestration { + /** + * Main function which runs the actual sample. + * + * @param azure instance of the azure client + * @return true if sample runs successfully + */ + public static boolean runSample(Azure azure) { + final String rgName = SdkContext.randomResourceName("rgACI", 15); + final String aciName = SdkContext.randomResourceName("acisample", 20); + final String saName = SdkContext.randomResourceName("sa", 20); + final String containerImageName = "microsoft/aci-helloworld"; + + try { +// final String envDockerHost = System.getenv("DOCKER_HOST"); +// final String envDockerCertPath = System.getenv("DOCKER_CERT_PATH"); +// DockerClient dockerClient; +// +// if (envDockerHost != null && !envDockerHost.isEmpty()) { +// dockerClient = DefaultDockerClient.fromEnv().build(); +// } else { +// boolean usePrivateRegistry = true; +// boolean dockerHostTlsEnabled = true; +// String dockerHostUrl = dockerHostTlsEnabled ? "https://localhost:2376" : "http://localhost:2375"; +// String tempCertPath = ""; +// +// DefaultDockerClient.Builder builder = new DefaultDockerClient.Builder(); +// builder.uri(dockerHostUrl); +// +// if (dockerHostTlsEnabled) { +// builder.dockerCertificates(new DockerCertificates(Paths.get(tempCertPath))); +// } +// if (usePrivateRegistry) { +// builder.registryAuth(RegistryAuth.create( +// "username", "password", "test@email.com", "server-address", "", null +// )); +// } +// dockerClient = builder.build(); +// dockerClient.pull("hello-world"); +// dockerClient.listImages(DockerClient.ListImagesParam.allImages()); +// +// dockerClient.close(); +// +// } + + //============================================================= + //============================================================= + // Create a container group with one container instance of default CPU core count and memory size + // using public Docker image "microsoft/aci-helloworld" which mounts the file share created previously + // as read/write shared container volume. + + ContainerGroup containerGroup = azure.containerGroups().define(aciName) + .withRegion(Region.US_WEST) + .withNewResourceGroup(rgName) + .withLinux() + .withPublicImageRegistryOnly() + .withoutVolume() + .defineContainerInstance(aciName) + .withImage(containerImageName) + .withExternalTcpPort(80) + .attach() + .create(); + + Utils.print(containerGroup); + + //============================================================= + // Check that the container instance is up and running + + // warm up + System.out.println("Warming up " + containerGroup.ipAddress()); + Utils.curl("http://" + containerGroup.ipAddress()); + Thread.sleep(15000); + System.out.println("CURLing " + containerGroup.ipAddress()); + System.out.println(Utils.curl("http://" + containerGroup.ipAddress())); + + //============================================================= + // Check the container instance logs + + String logContent = containerGroup.getLogContent(aciName); + System.out.format("Logs for container instance: %s\n%s", aciName, logContent); + + //============================================================= + // Remove the container group + + azure.containerGroups().deleteById(containerGroup.id()); + + return true; + } catch (Exception f) { + System.out.println(f.getMessage()); + f.printStackTrace(); + } finally { + try { + System.out.println("Deleting Resource Group: " + rgName); + azure.resourceGroups().beginDeleteByName(rgName); + System.out.println("Deleted Resource Group: " + rgName); + } catch (NullPointerException npe) { + System.out.println("Did not create any resources in Azure. No clean up is necessary"); + } catch (Exception g) { + g.printStackTrace(); + } + } + return false; + } + + /** + * Main entry point. + * + * @param args the parameters + */ + public static void main(String[] args) { + try { + //============================================================= + // Authenticate + + final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); + + Azure azure = Azure.configure() + .withLogLevel(LogLevel.BODY) + .authenticate(credFile) + .withDefaultSubscription(); + + // Print selected subscription + System.out.println("Selected subscription: " + azure.subscriptionId()); + + runSample(azure); + } catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceZeroToOneAndOneToManyUsingKubernetesOrchestration.java b/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceZeroToOneAndOneToManyUsingKubernetesOrchestration.java new file mode 100644 index 00000000000..3c876926f13 --- /dev/null +++ b/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/ManageContainerInstanceZeroToOneAndOneToManyUsingKubernetesOrchestration.java @@ -0,0 +1,516 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.containerinstance.samples; + +import com.github.dockerjava.api.DockerClient; +import com.github.dockerjava.api.command.CreateContainerResponse; +import com.github.dockerjava.api.exception.NotFoundException; +import com.github.dockerjava.api.model.Container; +import com.github.dockerjava.api.model.Image; +import com.github.dockerjava.core.command.PullImageResultCallback; +import com.github.dockerjava.core.command.PushImageResultCallback; +import com.microsoft.azure.management.Azure; +import com.microsoft.azure.management.compute.ContainerService; +import com.microsoft.azure.management.compute.ContainerServiceMasterProfileCount; +import com.microsoft.azure.management.compute.ContainerServiceVMSizeTypes; +import com.microsoft.azure.management.containerinstance.ContainerGroup; +import com.microsoft.azure.management.containerregistry.Registry; +import com.microsoft.azure.management.containerregistry.implementation.RegistryListCredentials; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.utils.SdkContext; +import com.microsoft.azure.management.samples.DockerUtils; +import com.microsoft.azure.management.samples.SSHShell; +import com.microsoft.azure.management.samples.Utils; +import com.microsoft.rest.LogLevel; +import io.fabric8.kubernetes.api.model.LoadBalancerIngress; +import io.fabric8.kubernetes.api.model.Namespace; +import io.fabric8.kubernetes.api.model.NamespaceBuilder; +import io.fabric8.kubernetes.api.model.Pod; +import io.fabric8.kubernetes.api.model.ReplicationController; +import io.fabric8.kubernetes.api.model.ReplicationControllerBuilder; +import io.fabric8.kubernetes.api.model.Secret; +import io.fabric8.kubernetes.api.model.SecretBuilder; +import io.fabric8.kubernetes.api.model.Service; +import io.fabric8.kubernetes.api.model.ServiceBuilder; +import io.fabric8.kubernetes.client.Config; +import io.fabric8.kubernetes.client.DefaultKubernetesClient; +import io.fabric8.kubernetes.client.KubernetesClient; +import org.apache.commons.codec.binary.Base64; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +/** + * Azure Container Instance sample for managing container instances. + * - Create an Azure Container Registry to be used for holding private Docker container images + * - If a local Docker engine cannot be found, create a Linux virtual machine that will host a Docker engine + * to be used for this sample + * - Use Docker Java to create a Docker client that will push/pull an image to/from Azure Container Registry + * - Pull a test image from the public Docker repo (tomcat:8) to be used as a sample for pushing/pulling + * to/from an Azure Container Registry + * - Create an Azure container group with a container instance using the container image that was pushed to the + * container registry created above + * - Test that the container app can be reached via "curl" like HTTP GET calls + * - Retrieve container log content + * - Create a SSH private/public key to be used when creating a container service + * - Create an Azure Container Service with Kubernetes orchestration + * - Log in via the SSH client and download the Kubernetes config + * - Create a Kubernetes client using the Kubernetes config file downloaded from one of the virtual machine managers + * - Create a Kubernetes namespace + * - Create a Kubernetes secret of type "docker-registry" using the Azure Container Registry credentials from above + * - Create a Kubernetes replication controller using a container image from the Azure private registry from above + * and a load balancer service that will expose the app to the world + */ +public class ManageContainerInstanceZeroToOneAndOneToManyUsingKubernetesOrchestration { + /** + * Main function which runs the actual sample. + * + * @param azure instance of the azure client + * @param clientId secondary service principal client ID + * @param secret secondary service principal secret + * @return true if sample runs successfully + */ + public static boolean runSample(Azure azure, String clientId, String secret) { + final String rgName = SdkContext.randomResourceName("rgaci", 15); + final Region region = Region.US_WEST; + + final String acrName = SdkContext.randomResourceName("acr", 20); + final String saName = SdkContext.randomResourceName("sa", 20); + + final String aciName = SdkContext.randomResourceName("acisample", 20); + final String containerImageName = "microsoft/aci-helloworld"; + final String containerImageTag = "latest"; + final String dockerContainerName = "sample-hello"; + + final String acsName = SdkContext.randomResourceName("acssample", 30); + String servicePrincipalClientId = clientId; // replace with a real service principal client id + String servicePrincipalSecret = secret; // and corresponding secret + final String rootUserName = "acsuser"; + String acsSecretName = "mysecret112233"; + String acsNamespace = "acrsample"; + String acsLbIngressName = "lb-acrsample"; + SSHShell shell = null; + + try { + //============================================================= + // Create an Azure Container Registry to store and manage private Docker container images + + System.out.println("Creating an Azure Container Registry"); + + Date t1 = new Date(); + + Registry azureRegistry = azure.containerRegistries().define(acrName) + .withRegion(region) + .withNewResourceGroup(rgName) + .withNewStorageAccount(saName) + .withRegistryNameAsAdminUser() + .create(); + + Date t2 = new Date(); + System.out.println("Created Azure Container Registry: (took " + ((t2.getTime() - t1.getTime()) / 1000) + " seconds) " + azureRegistry.id()); + Utils.print(azureRegistry); + + + //============================================================= + // Create a Docker client that will be used to push/pull images to/from the Azure Container Registry + + RegistryListCredentials acrCredentials = azureRegistry.listCredentials(); + DockerClient dockerClient = DockerUtils.createDockerClient(azure, rgName, region, + azureRegistry.loginServerUrl(), acrCredentials.username(), acrCredentials.passwords().get(0).value()); + + //============================================================= + // Pull a temp image from public Docker repo and create a temporary container from that image + // These steps can be replaced and instead build a custom image using a Dockerfile and the app's JAR + + dockerClient.pullImageCmd(containerImageName) + .withTag(containerImageTag) + .exec(new PullImageResultCallback()) + .awaitSuccess(); + System.out.println("List local Docker images:"); + List images = dockerClient.listImagesCmd().withShowAll(true).exec(); + for (Image image : images) { + System.out.format("\tFound Docker image %s (%s)\n", image.getRepoTags()[0], image.getId()); + } + + CreateContainerResponse dockerContainerInstance = dockerClient.createContainerCmd(containerImageName + ":" + containerImageTag) + .withName(dockerContainerName) + .exec(); + System.out.println("List Docker containers:"); + List dockerContainers = dockerClient.listContainersCmd() + .withShowAll(true) + .exec(); + for (Container container : dockerContainers) { + System.out.format("\tFound Docker container %s (%s)\n", container.getImage(), container.getId()); + } + + //============================================================= + // Commit the new container + + String privateRepoUrl = azureRegistry.loginServerUrl() + "/samples/" + dockerContainerName; + String dockerImageId = dockerClient.commitCmd(dockerContainerInstance.getId()) + .withRepository(privateRepoUrl) + .withTag("latest").exec(); + + // We can now remove the temporary container instance + dockerClient.removeContainerCmd(dockerContainerInstance.getId()) + .withForce(true) + .exec(); + + //============================================================= + // Push the new Docker image to the Azure Container Registry + + dockerClient.pushImageCmd(privateRepoUrl) + .withAuthConfig(dockerClient.authConfig()) + .exec(new PushImageResultCallback()).awaitSuccess(); + + // Remove the temp image from the local Docker host + try { + dockerClient.removeImageCmd(containerImageName + ":" + containerImageTag).withForce(true).exec(); + } catch (NotFoundException e) { + // just ignore if not exist + } + + //============================================================= + // Create a container group with one container instance of default CPU core count and memory size + // using public Docker image "microsoft/aci-helloworld" which mounts the file share created previously + // as read/write shared container volume. + + ContainerGroup containerGroup = azure.containerGroups().define(aciName) + .withRegion(region) + .withNewResourceGroup(rgName) + .withLinux() + .withPrivateImageRegistry(azureRegistry.loginServerUrl(), acrCredentials.username(), acrCredentials.passwords().get(0).value()) + .withoutVolume() + .defineContainerInstance(aciName) + .withImage(privateRepoUrl) + .withExternalTcpPort(80) + .attach() + .create(); + + Utils.print(containerGroup); + + //============================================================= + // Check that the container instance is up and running + + // warm up + System.out.println("Warming up " + containerGroup.ipAddress()); + Utils.curl("http://" + containerGroup.ipAddress()); + SdkContext.sleep(15000); + System.out.println("CURLing " + containerGroup.ipAddress()); + System.out.println(Utils.curl("http://" + containerGroup.ipAddress())); + + //============================================================= + // Check the container instance logs + + String logContent = containerGroup.getLogContent(aciName); + System.out.format("Logs for container instance: %s\n%s", aciName, logContent); + + //============================================================= + // If service principal client id and secret are not set via the local variables, attempt to read the service + // principal client id and secret from a secondary ".azureauth" file set through an environment variable. + // + // If the environment variable was not set then reuse the main service principal set for running this sample. + + if (servicePrincipalClientId.isEmpty() || servicePrincipalSecret.isEmpty()) { + String envSecondaryServicePrincipal = System.getenv("AZURE_AUTH_LOCATION_2"); + + if (envSecondaryServicePrincipal == null || !envSecondaryServicePrincipal.isEmpty() || !Files.exists(Paths.get(envSecondaryServicePrincipal))) { + envSecondaryServicePrincipal = System.getenv("AZURE_AUTH_LOCATION"); + } + + servicePrincipalClientId = Utils.getSecondaryServicePrincipalClientID(envSecondaryServicePrincipal); + servicePrincipalSecret = Utils.getSecondaryServicePrincipalSecret(envSecondaryServicePrincipal); + } + + + //============================================================= + // Create an SSH private/public key pair to be used when creating the container service + + System.out.println("Creating an SSH private and public key pair"); + + SSHShell.SshPublicPrivateKey sshKeys = SSHShell.generateSSHKeys("", "ACS"); + System.out.println("SSH private key value: \n" + sshKeys.getSshPrivateKey()); + System.out.println("SSH public key value: \n" + sshKeys.getSshPublicKey()); + + + //============================================================= + // Create an Azure Container Service with Kubernetes orchestration + + System.out.println("Creating an Azure Container Service with Kubernetes ochestration and one agent (virtual machine)"); + + t1 = new Date(); + + ContainerService azureContainerService = azure.containerServices().define(acsName) + .withRegion(region) + .withNewResourceGroup(rgName) + .withKubernetesOrchestration() + .withServicePrincipal(servicePrincipalClientId, servicePrincipalSecret) + .withLinux() + .withRootUsername(rootUserName) + .withSshKey(sshKeys.getSshPublicKey()) + .withMasterNodeCount(ContainerServiceMasterProfileCount.MIN) + .withMasterLeafDomainLabel("dns-" + acsName) + .defineAgentPool("agentpool") + .withVMCount(1) + .withVMSize(ContainerServiceVMSizeTypes.STANDARD_D1_V2) + .withLeafDomainLabel("dns-ap-" + acsName) + .attach() + .create(); + + t2 = new Date(); + System.out.println("Created Azure Container Service: (took " + ((t2.getTime() - t1.getTime()) / 1000) + " seconds) " + azureContainerService.id()); + Utils.print(azureContainerService); + + Thread.sleep(30000); + + + //============================================================= + // Download the Kubernetes config file from one of the master virtual machines + + azureContainerService = azure.containerServices().getByResourceGroup(rgName, acsName); + System.out.println("Found Kubernetes master at: " + azureContainerService.masterFqdn()); + + shell = SSHShell.open(azureContainerService.masterFqdn(), 22, rootUserName, sshKeys.getSshPrivateKey().getBytes()); + + String kubeConfigContent = shell.download("config", ".kube", true); + System.out.println("Found Kubernetes config:\n" + kubeConfigContent); + + + //============================================================= + // Instantiate the Kubernetes client using the downloaded ".kube/config" file content + // The Kubernetes client API requires setting an environment variable pointing at a real file; + // we will create a temporary file that will be deleted automatically when the sample exits + + File tempKubeConfigFile = File.createTempFile("kube", ".config", new File(System.getProperty("java.io.tmpdir"))); + tempKubeConfigFile.deleteOnExit(); + BufferedWriter buffOut = new BufferedWriter(new FileWriter(tempKubeConfigFile)); + buffOut.write(kubeConfigContent); + buffOut.close(); + + System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, tempKubeConfigFile.getPath()); + Config config = new Config(); + KubernetesClient kubernetesClient = new DefaultKubernetesClient(config); + + Thread.sleep(5000); + + + //============================================================= + // List all the nodes available in the Kubernetes cluster + + System.out.println(kubernetesClient.nodes().list()); + + + //============================================================= + // Create a namespace where all the sample Kubernetes resources will be created + + Namespace ns = new NamespaceBuilder() + .withNewMetadata() + .withName(acsNamespace) + .addToLabels("acr", "sample") + .endMetadata() + .build(); + try { + System.out.println("Created namespace" + kubernetesClient.namespaces().create(ns)); + } catch (Exception ignored) { + } + + Thread.sleep(5000); + for (Namespace namespace : kubernetesClient.namespaces().list().getItems()) { + System.out.println("\tFound Kubernetes namespace: " + namespace.toString()); + } + + + //============================================================= + // Create a secret of type "docker-repository" that will be used for downloading the container image from + // our Azure private container repo + + String basicAuth = new String(Base64.encodeBase64((acrCredentials.username() + ":" + acrCredentials.passwords().get(0).value()).getBytes())); + HashMap secretData = new HashMap<>(1); + String dockerCfg = String.format("{ \"%s\": { \"auth\": \"%s\", \"email\": \"%s\" } }", + azureRegistry.loginServerUrl(), + basicAuth, + "acrsample@azure.com"); + + dockerCfg = new String(Base64.encodeBase64(dockerCfg.getBytes("UTF-8")), "UTF-8"); + secretData.put(".dockercfg", dockerCfg); + SecretBuilder secretBuilder = new SecretBuilder() + .withNewMetadata() + .withName(acsSecretName) + .withNamespace(acsNamespace) + .endMetadata() + .withData(secretData) + .withType("kubernetes.io/dockercfg"); + + System.out.println("Creating new secret: " + kubernetesClient.secrets().inNamespace(acsNamespace).create(secretBuilder.build())); + + Thread.sleep(5000); + + for (Secret kubeS : kubernetesClient.secrets().inNamespace(acsNamespace).list().getItems()) { + System.out.println("\tFound secret: " + kubeS); + } + + + //============================================================= + // Create a replication controller for our image stored in the Azure Container Registry + + ReplicationController rc = new ReplicationControllerBuilder() + .withNewMetadata() + .withName("acrsample-rc") + .withNamespace(acsNamespace) + .addToLabels("acrsample-myimg", "myimg") + .endMetadata() + .withNewSpec() + .withReplicas(2) + .withNewTemplate() + .withNewMetadata() + .addToLabels("acrsample-myimg", "myimg") + .endMetadata() + .withNewSpec() + .addNewImagePullSecret(acsSecretName) + .addNewContainer() + .withName("acrsample-pod-myimg") + .withImage(privateRepoUrl) + .addNewPort() + .withContainerPort(80) + .endPort() + .endContainer() + .endSpec() + .endTemplate() + .endSpec() + .build(); + + System.out.println("Creating a replication controller: " + kubernetesClient.replicationControllers().inNamespace(acsNamespace).create(rc)); + Thread.sleep(5000); + + rc = kubernetesClient.replicationControllers().inNamespace(acsNamespace).withName("acrsample-rc").get(); + System.out.println("Found replication controller: " + rc.toString()); + + for (Pod pod : kubernetesClient.pods().inNamespace(acsNamespace).list().getItems()) { + System.out.println("\tFound Kubernetes pods: " + pod.toString()); + } + + + //============================================================= + // Create a Load Balancer service that will expose the service to the world + + Service lbService = new ServiceBuilder() + .withNewMetadata() + .withName(acsLbIngressName) + .withNamespace(acsNamespace) + .endMetadata() + .withNewSpec() + .withType("LoadBalancer") + .addNewPort() + .withPort(80) + .withProtocol("TCP") + .endPort() + .addToSelector("acrsample-myimg", "myimg") + .endSpec() + .build(); + + System.out.println("Creating a service: " + kubernetesClient.services().inNamespace(acsNamespace).create(lbService)); + + Thread.sleep(5000); + + System.out.println("\tFound service: " + kubernetesClient.services().inNamespace(acsNamespace).withName(acsLbIngressName).get()); + + + //============================================================= + // Wait until the external IP becomes available + + String serviceIP = null; + + int timeout = 30 * 60 * 1000; // 30 minutes + String matchIPV4 = "^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$"; + + while (timeout > 0) { + try { + List lbIngressList = kubernetesClient.services().inNamespace(acsNamespace).withName(acsLbIngressName).get().getStatus().getLoadBalancer().getIngress(); + if (lbIngressList != null && !lbIngressList.isEmpty() && lbIngressList.get(0) != null && lbIngressList.get(0).getIp().matches(matchIPV4)) { + serviceIP = lbIngressList.get(0).getIp(); + System.out.println("\tFound ingress IP: " + serviceIP); + timeout = 0; + } + } catch (Exception ignored) { + } + + if (timeout > 0) { + timeout -= 30000; // 30 seconds + Thread.sleep(30000); + } + } + + //============================================================= + // Check that the service is up and running + + if (serviceIP != null) { + // warm up + System.out.println("Warming up " + serviceIP); + Utils.curl("http://" + serviceIP); + SdkContext.sleep(15000); + System.out.println("CURLing " + serviceIP); + System.out.println(Utils.curl("http://" + serviceIP)); + } else { + System.out.println("ERROR: service unavailable"); + } + + // Clean-up + kubernetesClient.namespaces().delete(ns); + + shell.close(); + + return true; + } catch (Exception f) { + System.out.println(f.getMessage()); + f.printStackTrace(); + } finally { + try { + System.out.println("Deleting Resource Group: " + rgName); + azure.resourceGroups().beginDeleteByName(rgName); + System.out.println("Deleted Resource Group: " + rgName); + } catch (NullPointerException npe) { + System.out.println("Did not create any resources in Azure. No clean up is necessary"); + } catch (Exception g) { + g.printStackTrace(); + } + } + return false; + } + + /** + * Main entry point. + * + * @param args the parameters + */ + public static void main(String[] args) { + try { + //============================================================= + // Authenticate + + final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); + + Azure azure = Azure.configure() + .withLogLevel(LogLevel.BODY) + .authenticate(credFile) + .withDefaultSubscription(); + + // Print selected subscription + System.out.println("Selected subscription: " + azure.subscriptionId()); + + runSample(azure, "", ""); + } catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/package-info.java b/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/package-info.java new file mode 100644 index 00000000000..e485e6b8dbc --- /dev/null +++ b/azure-samples/src/main/java/com/microsoft/azure/management/containerinstance/samples/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +/** + * This package contains the classes for Azure container instance samples. + */ +package com.microsoft.azure.management.containerinstance.samples; diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/samples/Utils.java b/azure-samples/src/main/java/com/microsoft/azure/management/samples/Utils.java index 58e35f02b83..a843fb7e2e9 100644 --- a/azure-samples/src/main/java/com/microsoft/azure/management/samples/Utils.java +++ b/azure-samples/src/main/java/com/microsoft/azure/management/samples/Utils.java @@ -32,6 +32,12 @@ import com.microsoft.azure.management.compute.VirtualMachine; import com.microsoft.azure.management.compute.VirtualMachineCustomImage; import com.microsoft.azure.management.compute.VirtualMachineExtension; +import com.microsoft.azure.management.containerinstance.Container; +import com.microsoft.azure.management.containerinstance.ContainerGroup; +import com.microsoft.azure.management.containerinstance.ContainerPort; +import com.microsoft.azure.management.containerinstance.EnvironmentVariable; +import com.microsoft.azure.management.containerinstance.Volume; +import com.microsoft.azure.management.containerinstance.VolumeMount; import com.microsoft.azure.management.containerregistry.Registry; import com.microsoft.azure.management.containerregistry.implementation.RegistryListCredentials; import com.microsoft.azure.management.cosmosdb.CosmosDBAccount; @@ -130,6 +136,8 @@ import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; +import okhttp3.OkHttpClient; +import okhttp3.Request; import org.apache.commons.lang3.StringUtils; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; @@ -146,6 +154,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.concurrent.TimeUnit; /** * Common utils for Azure management samples. @@ -2230,4 +2239,109 @@ public static void print(NextHop resource) { .append("\n\tRoute table id: ").append(resource.routeTableId()) .toString()); } + + /** + * Print container group info. + * + * @param resource a container group + */ + public static void print(ContainerGroup resource) { + StringBuilder info = new StringBuilder().append("Container Group: ").append(resource.id()) + .append("Name: ").append(resource.name()) + .append("\n\tResource group: ").append(resource.resourceGroupName()) + .append("\n\tRegion: ").append(resource.region()) + .append("\n\tTags: ").append(resource.tags()) + .append("\n\tOS type: ").append(resource.osType()); + + if (resource.ipAddress() != null) { + info.append("\n\tPublic IP address: ").append(resource.ipAddress()); + } + if (resource.externalTcpPorts() != null) { + info.append("\n\tExternal TCP ports:"); + for (int port : resource.externalTcpPorts()) { + info.append(" ").append(port); + } + } + if (resource.externalUdpPorts() != null) { + info.append("\n\tExternal UDP ports:"); + for (int port : resource.externalUdpPorts()) { + info.append(" ").append(port); + } + } + if (resource.imageRegistryServers() != null) { + info.append("\n\tPrivate Docker image registries:"); + for (String server : resource.imageRegistryServers()) { + info.append(" ").append(server); + } + } + if (resource.volumes() != null) { + info.append("\n\tVolume mapping: "); + for (Map.Entry entry: resource.volumes().entrySet()) { + info.append("\n\t\tName: ").append(entry.getKey()).append(" -> ").append(entry.getValue().azureFile().shareName()); + } + } + if (resource.containers() != null) { + info.append("\n\tContainer instances: "); + for (Map.Entry entry: resource.containers().entrySet()) { + Container container = entry.getValue(); + info.append("\n\t\tName: ").append(entry.getKey()).append(" -> ").append(container.image()); + info.append("\n\t\t\tResources: "); + info.append(container.resources().requests().cpu()).append("CPUs "); + info.append(container.resources().requests().memoryInGB()).append("GB"); + info.append("\n\t\t\tPorts:"); + for (ContainerPort port : container.ports()) { + info.append(" ").append(port.port()); + } + if (container.volumeMounts() != null) { + info.append("\n\t\t\tVolume mounts:"); + for (VolumeMount volumeMount : container.volumeMounts()) { + info.append(" ").append(volumeMount.name()).append("->").append(volumeMount.mountPath()); + } + } + if (container.command() != null) { + info.append("\n\t\t\tStart commands:"); + for (String command : container.command()) { + info.append("\n\t\t\t\t").append(command); + } + } + if (container.environmentVariables() != null) { + info.append("\n\t\t\tENV vars:"); + for (EnvironmentVariable envVar : container.environmentVariables()) { + info.append("\n\t\t\t\t").append(envVar.name()).append("=").append(envVar.value()); + } + } + } + } + + System.out.println(info.toString()); + } + + private static OkHttpClient httpClient; + + /** + * Ensure the HTTP client is valid. + * + */ + private static OkHttpClient ensureValidHttpClient() { + if (httpClient == null) { + httpClient = new OkHttpClient.Builder().readTimeout(1, TimeUnit.MINUTES).build(); + } + + return httpClient; + } + + /** + * Connect to a specified URL using "curl" like HTTP GET client. + * + * @param url URL to be tested + * @return the HTTP GET response content + */ + public static String curl(String url) { + Request request = new Request.Builder().url(url).get().build(); + try { + return ensureValidHttpClient().newCall(request).execute().body().string(); + } catch (IOException e) { + return null; + } + } } diff --git a/azure-samples/src/test/java/com/microsoft/azure/management/samples/ContainerInstanceTests.java b/azure-samples/src/test/java/com/microsoft/azure/management/samples/ContainerInstanceTests.java new file mode 100644 index 00000000000..6a20e9b8b54 --- /dev/null +++ b/azure-samples/src/test/java/com/microsoft/azure/management/samples/ContainerInstanceTests.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.samples; + +import com.microsoft.azure.management.containerinstance.samples.ManageContainerInstanceWithAzureFileShareMount; +import com.microsoft.azure.management.containerinstance.samples.ManageContainerInstanceWithManualAzureFileShareMountCreation; +import com.microsoft.azure.management.containerinstance.samples.ManageContainerInstanceWithMultipleContainerImages; +import com.microsoft.azure.management.containerinstance.samples.ManageContainerInstanceZeroToOneAndOneToManyUsingKubernetesOrchestration; +import org.junit.Assert; +import org.junit.Test; + +public class ContainerInstanceTests extends SamplesTestBase { + + @Test + public void testManageContainerInstanceWithAzureFileShareMount() { + // Skip test in "playback" mode due to HTTP calls made outside of the management plane which can not be recorded at this time + if (!isPlaybackMode()) { + Assert.assertTrue(ManageContainerInstanceWithAzureFileShareMount.runSample(azure)); + } + } + + @Test + public void testManageContainerInstanceWithManualAzureFileShareMountCreation() { + // Skip test in "playback" mode due to HTTP calls made outside of the management plane which can not be recorded at this time + if (!isPlaybackMode()) { + Assert.assertTrue(ManageContainerInstanceWithManualAzureFileShareMountCreation.runSample(azure)); + } + } + + @Test + public void testManageContainerInstanceWithMultipleContainerImages() { + Assert.assertTrue(ManageContainerInstanceWithMultipleContainerImages.runSample(azure)); + } + + @Test + public void testManageContainerInstanceZeroToOneAndOneToManyUsingKubernetesOrchestration() { + // Skip test in "playback" mode due to HTTP calls made outside of the management plane which can not be recorded at this time + if (!isPlaybackMode()) { + Assert.assertTrue(ManageContainerInstanceZeroToOneAndOneToManyUsingKubernetesOrchestration.runSample(azure, "", "")); + } + } + +} diff --git a/azure-samples/src/test/resources/session-records/testManageContainerInstanceWithAzureFileShareMount.json b/azure-samples/src/test/resources/session-records/testManageContainerInstanceWithAzureFileShareMount.json new file mode 100644 index 00000000000..6f31cf5a2e6 --- /dev/null +++ b/azure-samples/src/test/resources/session-records/testManageContainerInstanceWithAzureFileShareMount.json @@ -0,0 +1 @@ +{ } \ No newline at end of file diff --git a/azure-samples/src/test/resources/session-records/testManageContainerInstanceWithManualAzureFileShareMountCreation.json b/azure-samples/src/test/resources/session-records/testManageContainerInstanceWithManualAzureFileShareMountCreation.json new file mode 100644 index 00000000000..6f31cf5a2e6 --- /dev/null +++ b/azure-samples/src/test/resources/session-records/testManageContainerInstanceWithManualAzureFileShareMountCreation.json @@ -0,0 +1 @@ +{ } \ No newline at end of file diff --git a/azure-samples/src/test/resources/session-records/testManageContainerInstanceWithMultipleContainerImages.json b/azure-samples/src/test/resources/session-records/testManageContainerInstanceWithMultipleContainerImages.json new file mode 100644 index 00000000000..2d05cd28ea7 --- /dev/null +++ b/azure-samples/src/test/resources/session-records/testManageContainerInstanceWithMultipleContainerImages.json @@ -0,0 +1,148 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgaci38c18947a?api-version=2016-09-01", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ResourceManagementClient, 2016-09-01)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Wed, 06 Sep 2017 15:49:23 GMT", + "content-length" : "181", + "expires" : "-1", + "x-ms-ratelimit-remaining-subscription-writes" : "1199", + "retry-after" : "0", + "StatusCode" : "201", + "pragma" : "no-cache", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-correlation-request-id" : "992f926a-30f6-48cd-9620-73a96eaf1182", + "x-ms-routing-request-id" : "WESTUS2:20170906T154924Z:992f926a-30f6-48cd-9620-73a96eaf1182", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "992f926a-30f6-48cd-9620-73a96eaf1182", + "Body" : "{\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci38c18947a\",\"name\":\"rgaci38c18947a\",\"location\":\"westus\",\"properties\":{\"provisioningState\":\"Succeeded\"}}" + } + }, { + "Method" : "PUT", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci38c18947a/providers/Microsoft.ContainerInstance/containerGroups/acisample87a266417?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Wed, 06 Sep 2017 15:49:25 GMT", + "content-length" : "806", + "expires" : "-1", + "x-ms-ratelimit-remaining-subscription-writes" : "1198", + "retry-after" : "0", + "StatusCode" : "201", + "pragma" : "no-cache", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-correlation-request-id" : "b276eea3-a53e-4f58-b64f-a730400dcbfd", + "x-ms-routing-request-id" : "WESTUS2:20170906T154925Z:b276eea3-a53e-4f58-b64f-a730400dcbfd", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:a4976a6e-64f5-4d64-9105-a26889acd650", + "Body" : "{\"properties\":{\"provisioningState\":\"Creating\",\"containers\":[{\"name\":\"acisample87a266417-1\",\"properties\":{\"image\":\"microsoft/aci-helloworld\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":0.75,\"cpu\":0.5}}}},{\"name\":\"acisample87a266417-2\",\"properties\":{\"image\":\"microsoft/aci-tutorial-sidecar\",\"ports\":[],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":0.75,\"cpu\":0.5}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"23.99.52.245\",\"type\":\"Public\"},\"osType\":\"Linux\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci38c18947a/providers/Microsoft.ContainerInstance/containerGroups/acisample87a266417\",\"name\":\"acisample87a266417\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{}}" + } + }, { + "Method" : "GET", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci38c18947a/providers/Microsoft.ContainerInstance/containerGroups/acisample87a266417/containers/acisample87a266417-1/logs?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Wed, 06 Sep 2017 15:49:52 GMT", + "content-length" : "588", + "expires" : "-1", + "transfer-encoding" : "chunked", + "vary" : "Accept-Encoding,Accept-Encoding", + "retry-after" : "0", + "x-ms-ratelimit-remaining-subscription-reads" : "14992", + "StatusCode" : "200", + "pragma" : "no-cache", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-correlation-request-id" : "5aef83e2-b5f8-4cce-85e7-185400deace7", + "x-ms-routing-request-id" : "WESTUS2:20170906T154953Z:5aef83e2-b5f8-4cce-85e7-185400deace7", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:3db7bc9d-6929-497a-9f61-e179ff342ee4", + "Body" : "{\"content\":\"listening on port 80\\n::1 - - [06/Sep/2017:15:49:39 +0000] \\\"HEAD / HTTP/1.1\\\" 200 1663 \\\"-\\\" \\\"curl/7.54.0\\\"\\n::1 - - [06/Sep/2017:15:49:42 +0000] \\\"HEAD / HTTP/1.1\\\" 200 1663 \\\"-\\\" \\\"curl/7.54.0\\\"\\n::1 - - [06/Sep/2017:15:49:45 +0000] \\\"HEAD / HTTP/1.1\\\" 200 1663 \\\"-\\\" \\\"curl/7.54.0\\\"\\n::1 - - [06/Sep/2017:15:49:48 +0000] \\\"HEAD / HTTP/1.1\\\" 200 1663 \\\"-\\\" \\\"curl/7.54.0\\\"\\n::1 - - [06/Sep/2017:15:49:51 +0000] \\\"HEAD / HTTP/1.1\\\" 200 1663 \\\"-\\\" \\\"curl/7.54.0\\\"\\n::ffff:10.240.255.106 - - [06/Sep/2017:15:49:52 +0000] \\\"GET / HTTP/1.1\\\" 200 1663 \\\"-\\\" \\\"okhttp/3.6.0\\\"\\n\"}" + } + }, { + "Method" : "GET", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci38c18947a/providers/Microsoft.ContainerInstance/containerGroups/acisample87a266417/containers/acisample87a266417-2/logs?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Wed, 06 Sep 2017 15:49:52 GMT", + "content-length" : "3709", + "expires" : "-1", + "transfer-encoding" : "chunked", + "vary" : "Accept-Encoding,Accept-Encoding", + "retry-after" : "0", + "x-ms-ratelimit-remaining-subscription-reads" : "14991", + "StatusCode" : "200", + "pragma" : "no-cache", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-correlation-request-id" : "8c4b3db7-8548-40ea-bdab-1c6038959678", + "x-ms-routing-request-id" : "WESTUS2:20170906T154953Z:8c4b3db7-8548-40ea-bdab-1c6038959678", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:49212e3f-4787-4872-823a-1dcaa0927c61", + "Body" : "{\"content\":\"\\u001b[H\\u001b[JEvery 3s: curl -I http://localhost 2017-09-06 15:49:39\\n\\n % Total % Received % Xferd Average Speed Time Time Time Current\\n Dload Upload Total Spent Left Speed\\n\\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\\r 0 1663 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\\nHTTP/1.1 200 OK\\r\\nX-Powered-By: Express\\r\\nAccept-Ranges: bytes\\r\\nCache-Control: public, max-age=0\\r\\nLast-Modified: Thu, 20 Jul 2017 21:57:04 GMT\\r\\nETag: W/\\\"67f-15d62011380\\\"\\r\\nContent-Type: text/html; charset=UTF-8\\r\\nContent-Length: 1663\\r\\nDate: Wed, 06 Sep 2017 15:49:39 GMT\\r\\nConnection: keep-alive\\r\\n\\r\\n\\u001b[H\\u001b[JEvery 3s: curl -I http://localhost 2017-09-06 15:49:42\\n\\n % Total % Received % Xferd Average Speed Time Time Time Current\\n Dload Upload Total Spent Left Speed\\n\\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\\r 0 1663 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\\nHTTP/1.1 200 OK\\r\\nX-Powered-By: Express\\r\\nAccept-Ranges: bytes\\r\\nCache-Control: public, max-age=0\\r\\nLast-Modified: Thu, 20 Jul 2017 21:57:04 GMT\\r\\nETag: W/\\\"67f-15d62011380\\\"\\r\\nContent-Type: text/html; charset=UTF-8\\r\\nContent-Length: 1663\\r\\nDate: Wed, 06 Sep 2017 15:49:42 GMT\\r\\nConnection: keep-alive\\r\\n\\r\\n\\u001b[H\\u001b[JEvery 3s: curl -I http://localhost 2017-09-06 15:49:45\\n\\n % Total % Received % Xferd Average Speed Time Time Time Current\\n Dload Upload Total Spent Left Speed\\nHTTP/1.1 200 OK\\r\\nX-Powered-By: Express\\r\\nAccept-Ranges: bytes\\r\\nCache-Control: public, max-age=0\\r\\nLast-Modified: Thu, 20 Jul 2017 21:57:04 GMT\\r\\nETag: W/\\\"67f-15d62011380\\\"\\r\\nContent-Type: text/html; charset=UTF-8\\r\\nContent-Length: 1663\\r\\nDate: Wed, 06 Sep 2017 15:49:45 GMT\\r\\nConnection: keep-alive\\r\\n\\r\\n\\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\\r 0 1663 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\\n\\u001b[H\\u001b[JEvery 3s: curl -I http://localhost 2017-09-06 15:49:48\\n\\n % Total % Received % Xferd Average Speed Time Time Time Current\\n Dload Upload Total Spent Left Speed\\n\\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\\r 0 1663 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\\nHTTP/1.1 200 OK\\r\\nX-Powered-By: Express\\r\\nAccept-Ranges: bytes\\r\\nCache-Control: public, max-age=0\\r\\nLast-Modified: Thu, 20 Jul 2017 21:57:04 GMT\\r\\nETag: W/\\\"67f-15d62011380\\\"\\r\\nContent-Type: text/html; charset=UTF-8\\r\\nContent-Length: 1663\\r\\nDate: Wed, 06 Sep 2017 15:49:48 GMT\\r\\nConnection: keep-alive\\r\\n\\r\\n\\u001b[H\\u001b[JEvery 3s: curl -I http://localhost 2017-09-06 15:49:51\\n\\n % Total % Received % Xferd Average Speed Time Time Time Current\\n Dload Upload Total Spent Left Speed\\n\\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\\r 0 1663 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\\nHTTP/1.1 200 OK\\r\\nX-Powered-By: Express\\r\\nAccept-Ranges: bytes\\r\\nCache-Control: public, max-age=0\\r\\nLast-Modified: Thu, 20 Jul 2017 21:57:04 GMT\\r\\nETag: W/\\\"67f-15d62011380\\\"\\r\\nContent-Type: text/html; charset=UTF-8\\r\\nContent-Length: 1663\\r\\nDate: Wed, 06 Sep 2017 15:49:51 GMT\\r\\nConnection: keep-alive\\r\\n\\r\\n\"}" + } + }, { + "Method" : "DELETE", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci38c18947a/providers/Microsoft.ContainerInstance/containerGroups/acisample87a266417?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Wed, 06 Sep 2017 15:49:53 GMT", + "content-length" : "2685", + "expires" : "-1", + "transfer-encoding" : "chunked", + "vary" : "Accept-Encoding,Accept-Encoding", + "x-ms-ratelimit-remaining-subscription-writes" : "1197", + "retry-after" : "0", + "StatusCode" : "200", + "pragma" : "no-cache", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-correlation-request-id" : "8680e799-73c8-4e33-b94b-c7c379c17da8", + "x-ms-routing-request-id" : "WESTUS2:20170906T154954Z:8680e799-73c8-4e33-b94b-c7c379c17da8", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:a2c79bd7-8d0e-4f9f-aa0f-bfd043ce1e8d", + "Body" : "{\"properties\":{\"provisioningState\":\"Succeeded\",\"containers\":[{\"name\":\"acisample87a266417-1\",\"properties\":{\"image\":\"microsoft/aci-helloworld\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"instanceView\":{\"restartCount\":0,\"currentState\":{\"state\":\"Running\",\"startTime\":\"2017-09-06T15:49:36Z\",\"detailStatus\":\"\"},\"events\":[{\"count\":1,\"firstTimestamp\":\"2017-09-06T15:49:29Z\",\"lastTimestamp\":\"2017-09-06T15:49:29Z\",\"message\":\"Pulling: pulling image \\\"microsoft/aci-helloworld\\\"\",\"type\":\"Normal\"},{\"count\":1,\"firstTimestamp\":\"2017-09-06T15:49:36Z\",\"lastTimestamp\":\"2017-09-06T15:49:36Z\",\"message\":\"Pulled: Successfully pulled image \\\"microsoft/aci-helloworld\\\"\",\"type\":\"Normal\"},{\"count\":1,\"firstTimestamp\":\"2017-09-06T15:49:36Z\",\"lastTimestamp\":\"2017-09-06T15:49:36Z\",\"message\":\"Created: Created container with id caac8630c915b94180c3eba24c38a867faf4e7a8fec31c4374acf61c03782837\",\"type\":\"Normal\"},{\"count\":1,\"firstTimestamp\":\"2017-09-06T15:49:36Z\",\"lastTimestamp\":\"2017-09-06T15:49:36Z\",\"message\":\"Started: Started container with id caac8630c915b94180c3eba24c38a867faf4e7a8fec31c4374acf61c03782837\",\"type\":\"Normal\"}]},\"resources\":{\"requests\":{\"memoryInGB\":0.75,\"cpu\":0.5}}}},{\"name\":\"acisample87a266417-2\",\"properties\":{\"image\":\"microsoft/aci-tutorial-sidecar\",\"ports\":[],\"environmentVariables\":[],\"instanceView\":{\"restartCount\":0,\"currentState\":{\"state\":\"Running\",\"startTime\":\"2017-09-06T15:49:39Z\",\"detailStatus\":\"\"},\"events\":[{\"count\":1,\"firstTimestamp\":\"2017-09-06T15:49:36Z\",\"lastTimestamp\":\"2017-09-06T15:49:36Z\",\"message\":\"Pulling: pulling image \\\"microsoft/aci-tutorial-sidecar\\\"\",\"type\":\"Normal\"},{\"count\":1,\"firstTimestamp\":\"2017-09-06T15:49:39Z\",\"lastTimestamp\":\"2017-09-06T15:49:39Z\",\"message\":\"Pulled: Successfully pulled image \\\"microsoft/aci-tutorial-sidecar\\\"\",\"type\":\"Normal\"},{\"count\":1,\"firstTimestamp\":\"2017-09-06T15:49:39Z\",\"lastTimestamp\":\"2017-09-06T15:49:39Z\",\"message\":\"Created: Created container with id 77981e4e05c1ec74ddcad75400e60146c188ab5c3a1ba05f44b33b5c1aab882d\",\"type\":\"Normal\"},{\"count\":1,\"firstTimestamp\":\"2017-09-06T15:49:39Z\",\"lastTimestamp\":\"2017-09-06T15:49:39Z\",\"message\":\"Started: Started container with id 77981e4e05c1ec74ddcad75400e60146c188ab5c3a1ba05f44b33b5c1aab882d\",\"type\":\"Normal\"}]},\"resources\":{\"requests\":{\"memoryInGB\":0.75,\"cpu\":0.5}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"23.99.52.245\",\"type\":\"Public\"},\"osType\":\"Linux\",\"state\":\"Running\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci38c18947a/providers/Microsoft.ContainerInstance/containerGroups/acisample87a266417\",\"name\":\"acisample87a266417\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{}}" + } + }, { + "Method" : "DELETE", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgaci38c18947a?api-version=2016-09-01", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ResourceManagementClient, 2016-09-01)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Wed, 06 Sep 2017 15:49:53 GMT", + "content-length" : "0", + "expires" : "-1", + "x-ms-ratelimit-remaining-subscription-writes" : "1196", + "retry-after" : "0", + "StatusCode" : "202", + "pragma" : "no-cache", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-correlation-request-id" : "f368c119-da03-4fb5-a3ff-8c019f1aaa1a", + "x-ms-routing-request-id" : "WESTUS2:20170906T154954Z:f368c119-da03-4fb5-a3ff-8c019f1aaa1a", + "location" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1SR0FDSTM4QzE4OTQ3QS1XRVNUVVMiLCJqb2JMb2NhdGlvbiI6Indlc3R1cyJ9?api-version=2016-09-01", + "cache-control" : "no-cache", + "x-ms-request-id" : "f368c119-da03-4fb5-a3ff-8c019f1aaa1a", + "Body" : "" + } + } ], + "variables" : [ "rgaci38c18947a", "acisample87a266417" ] +} \ No newline at end of file diff --git a/azure-samples/src/test/resources/session-records/testManageContainerInstanceZeroToOneAndOneToManyUsingKubernetesOrchestration.json b/azure-samples/src/test/resources/session-records/testManageContainerInstanceZeroToOneAndOneToManyUsingKubernetesOrchestration.json new file mode 100644 index 00000000000..6f31cf5a2e6 --- /dev/null +++ b/azure-samples/src/test/resources/session-records/testManageContainerInstanceZeroToOneAndOneToManyUsingKubernetesOrchestration.json @@ -0,0 +1 @@ +{ } \ No newline at end of file diff --git a/azure/pom.xml b/azure/pom.xml index 6b79b2d2ccc..32c332c6bc2 100644 --- a/azure/pom.xml +++ b/azure/pom.xml @@ -136,6 +136,11 @@ azure-mgmt-sql 1.2.2-SNAPSHOT + + com.microsoft.azure + azure-mgmt-containerinstance + 1.2.2-SNAPSHOT + com.microsoft.azure azure-mgmt-containerregistry diff --git a/azure/src/main/java/com/microsoft/azure/management/Azure.java b/azure/src/main/java/com/microsoft/azure/management/Azure.java index 96c3e60dac2..8cd64d3bdc8 100644 --- a/azure/src/main/java/com/microsoft/azure/management/Azure.java +++ b/azure/src/main/java/com/microsoft/azure/management/Azure.java @@ -30,6 +30,8 @@ import com.microsoft.azure.management.compute.VirtualMachineScaleSets; import com.microsoft.azure.management.compute.VirtualMachines; import com.microsoft.azure.management.compute.implementation.ComputeManager; +import com.microsoft.azure.management.containerinstance.ContainerGroups; +import com.microsoft.azure.management.containerinstance.implementation.ContainerInstanceManager; import com.microsoft.azure.management.containerregistry.Registries; import com.microsoft.azure.management.containerregistry.implementation.ContainerRegistryManager; import com.microsoft.azure.management.dns.DnsZones; @@ -107,6 +109,7 @@ public final class Azure { private final AppServiceManager appServiceManager; private final SqlServerManager sqlServerManager; private final ServiceBusManager serviceBusManager; + private final ContainerInstanceManager containerInstanceManager; private final ContainerRegistryManager containerRegistryManager; private final SearchServiceManager searchServiceManager; private final CosmosDBManager cosmosDBManager; @@ -381,6 +384,7 @@ private Azure(RestClient restClient, String subscriptionId, String tenantId, Aut this.appServiceManager = AppServiceManager.authenticate(restClient, tenantId, subscriptionId); this.sqlServerManager = SqlServerManager.authenticate(restClient, subscriptionId); this.serviceBusManager = ServiceBusManager.authenticate(restClient, subscriptionId); + this.containerInstanceManager = ContainerInstanceManager.authenticate(restClient, subscriptionId); this.containerRegistryManager = ContainerRegistryManager.authenticate(restClient, subscriptionId); this.cosmosDBManager = CosmosDBManager.authenticate(restClient, subscriptionId); this.searchServiceManager = SearchServiceManager.authenticate(restClient, subscriptionId); @@ -681,6 +685,14 @@ public ContainerServices containerServices() { return computeManager.containerServices(); } + /** + * @return entry point to managing Azure Container Instances. + */ + @Beta(SinceVersion.V1_3_0) + public ContainerGroups containerGroups() { + return containerInstanceManager.containerGroups(); + } + /** * @return entry point to managing Container Registries. */ diff --git a/azure/src/test/java/com/microsoft/azure/management/AzureTests.java b/azure/src/test/java/com/microsoft/azure/management/AzureTests.java index ccae5415825..1c9c3387502 100644 --- a/azure/src/test/java/com/microsoft/azure/management/AzureTests.java +++ b/azure/src/test/java/com/microsoft/azure/management/AzureTests.java @@ -801,6 +801,12 @@ public void testContainerService() throws Exception { .runTest(azure.containerServices(), azure.resourceGroups()); } + @Test + public void testContainerInstance() throws Exception { + new TestContainerInstance() + .runTest(azure.containerGroups(), azure.resourceGroups()); + } + @Test public void testContainerRegistry() throws Exception { new TestContainerRegistry() diff --git a/azure/src/test/java/com/microsoft/azure/management/TestContainerInstance.java b/azure/src/test/java/com/microsoft/azure/management/TestContainerInstance.java new file mode 100644 index 00000000000..5d73473544c --- /dev/null +++ b/azure/src/test/java/com/microsoft/azure/management/TestContainerInstance.java @@ -0,0 +1,163 @@ +package com.microsoft.azure.management; + +import com.microsoft.azure.management.containerinstance.Container; +import com.microsoft.azure.management.containerinstance.ContainerGroup; +import com.microsoft.azure.management.containerinstance.ContainerGroups; +import com.microsoft.azure.management.containerinstance.ContainerPort; +import com.microsoft.azure.management.containerinstance.EnvironmentVariable; +import com.microsoft.azure.management.containerinstance.Volume; +import com.microsoft.azure.management.containerinstance.VolumeMount; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import org.junit.Assert; + +import java.util.List; +import java.util.Map; + +public class TestContainerInstance extends TestTemplate { + + @Override + public ContainerGroup createResource(ContainerGroups containerGroups) throws Exception { + final String cgName = "aci" + this.testId; + final String rgName = "rgaci" + this.testId; + ContainerGroup containerGroup = containerGroups.define(cgName) + .withRegion(Region.US_WEST) + .withNewResourceGroup(rgName) + .withLinux() + .withPublicImageRegistryOnly() + .withoutVolume() + .defineContainerInstance("tomcat") + .withImage("tomcat") + .withExternalTcpPort(8080) + .withCpuCoreCount(1) + .attach() + .defineContainerInstance("nginx") + .withImage("nginx") + .withExternalTcpPort(80) + .attach() + .withTag("tag1", "value1") + .create(); + + Assert.assertEquals(cgName, containerGroup.name()); + Assert.assertEquals("Linux", containerGroup.osType().toString()); + Assert.assertEquals(0, containerGroup.imageRegistryServers().size()); + Assert.assertEquals(0, containerGroup.volumes().size()); + Assert.assertNotNull(containerGroup.ipAddress()); + Assert.assertTrue(containerGroup.isIPAddressPublic()); + Assert.assertEquals(2, containerGroup.externalTcpPorts().length); + Assert.assertEquals(2, containerGroup.externalPorts().size()); + Assert.assertEquals(2, containerGroup.externalTcpPorts().length); + Assert.assertEquals(8080, containerGroup.externalTcpPorts()[0]); + Assert.assertEquals(80, containerGroup.externalTcpPorts()[1]); + Assert.assertEquals(2, containerGroup.containers().size()); + Container tomcatContainer = containerGroup.containers().get("tomcat"); + Assert.assertNotNull(tomcatContainer); + Container nginxContainer = containerGroup.containers().get("nginx"); + Assert.assertNotNull(nginxContainer); + Assert.assertEquals("tomcat", tomcatContainer.name()); + Assert.assertEquals("tomcat", tomcatContainer.image()); + Assert.assertEquals(1.0, tomcatContainer.resources().requests().cpu(), .1); + Assert.assertEquals(1.5, tomcatContainer.resources().requests().memoryInGB(), .1); + Assert.assertEquals(1, tomcatContainer.ports().size()); + Assert.assertEquals(8080, tomcatContainer.ports().get(0).port()); + Assert.assertNull(tomcatContainer.volumeMounts()); + Assert.assertNull(tomcatContainer.command()); + Assert.assertNotNull(tomcatContainer.environmentVariables()); + Assert.assertEquals(0, tomcatContainer.environmentVariables().size()); + Assert.assertEquals("nginx", nginxContainer.name()); + Assert.assertEquals("nginx", nginxContainer.image()); + Assert.assertEquals(1.0, nginxContainer.resources().requests().cpu(), .1); + Assert.assertEquals(1.5, nginxContainer.resources().requests().memoryInGB(), .1); + Assert.assertEquals(1, nginxContainer.ports().size()); + Assert.assertEquals(80, nginxContainer.ports().get(0).port()); + Assert.assertNull(nginxContainer.volumeMounts()); + Assert.assertNull(nginxContainer.command()); + Assert.assertNotNull(nginxContainer.environmentVariables()); + Assert.assertEquals(0, nginxContainer.environmentVariables().size()); + Assert.assertTrue(containerGroup.tags().containsKey("tag1")); + + ContainerGroup containerGroup2 = containerGroups.getByResourceGroup(rgName, cgName); + + List containerGroupList = containerGroups.listByResourceGroup(rgName); + + containerGroup.refresh(); + + return containerGroup; + } + + @Override + public ContainerGroup updateResource(ContainerGroup containerGroup) throws Exception { + return containerGroup; + } + + @Override + public void print(ContainerGroup resource) { + StringBuilder info = new StringBuilder().append("Container Group: ").append(resource.id()) + .append("Name: ").append(resource.name()) + .append("\n\tResource group: ").append(resource.resourceGroupName()) + .append("\n\tRegion: ").append(resource.region()) + .append("\n\tTags: ").append(resource.tags()) + .append("\n\tOS type: ").append(resource.osType()); + + if (resource.ipAddress() != null) { + info.append("\n\tPublic IP address: ").append(resource.ipAddress()); + } + if (resource.externalTcpPorts() != null) { + info.append("\n\tExternal TCP ports:"); + for (int port : resource.externalTcpPorts()) { + info.append(" ").append(port); + } + } + if (resource.externalUdpPorts() != null) { + info.append("\n\tExternal UDP ports:"); + for (int port : resource.externalUdpPorts()) { + info.append(" ").append(port); + } + } + if (resource.imageRegistryServers() != null) { + info.append("\n\tPrivate Docker image registries:"); + for (String server : resource.imageRegistryServers()) { + info.append(" ").append(server); + } + } + if (resource.volumes() != null) { + info.append("\n\tVolume mapping: "); + for (Map.Entry entry: resource.volumes().entrySet()) { + info.append("\n\t\tName: ").append(entry.getKey()).append(" -> ").append(entry.getValue().azureFile().shareName()); + } + } + if (resource.containers() != null) { + info.append("\n\tContainer instances: "); + for (Map.Entry entry: resource.containers().entrySet()) { + Container container = entry.getValue(); + info.append("\n\t\tName: ").append(entry.getKey()).append(" -> ").append(container.image()); + info.append("\n\t\t\tResources: "); + info.append(container.resources().requests().cpu()).append("CPUs "); + info.append(container.resources().requests().memoryInGB()).append("GB"); + info.append("\n\t\t\tPorts:"); + for (ContainerPort port : container.ports()) { + info.append(" ").append(port.port()); + } + if (container.volumeMounts() != null) { + info.append("\n\t\t\tVolume mounts:"); + for (VolumeMount volumeMount : container.volumeMounts()) { + info.append(" ").append(volumeMount.name()).append("->").append(volumeMount.mountPath()); + } + } + if (container.command() != null) { + info.append("\n\t\t\tStart commands:"); + for (String command : container.command()) { + info.append("\n\t\t\t\t").append(command); + } + } + if (container.environmentVariables() != null) { + info.append("\n\t\t\tENV vars:"); + for (EnvironmentVariable envVar : container.environmentVariables()) { + info.append("\n\t\t\t\t").append(envVar.name()).append("=").append(envVar.value()); + } + } + } + } + + System.out.println(info.toString()); + } +} \ No newline at end of file diff --git a/azure/src/test/resources/session-records/testContainerInstance.json b/azure/src/test/resources/session-records/testContainerInstance.json new file mode 100644 index 00000000000..2b27376b9d6 --- /dev/null +++ b/azure/src/test/resources/session-records/testContainerInstance.json @@ -0,0 +1,273 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ContainerInstance/containerGroups?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Sat, 26 Aug 2017 01:56:34 GMT", + "content-length" : "3072", + "expires" : "-1", + "transfer-encoding" : "chunked", + "vary" : "Accept-Encoding,Accept-Encoding", + "retry-after" : "0", + "x-ms-ratelimit-remaining-subscription-reads" : "14995", + "StatusCode" : "200", + "pragma" : "no-cache", + "x-ms-correlation-request-id" : "d0c6c578-c8d5-4a81-a029-91b8b4cb61a8", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-routing-request-id" : "WESTUS2:20170826T015634Z:d0c6c578-c8d5-4a81-a029-91b8b4cb61a8", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:cf446823-d779-4512-a2b4-427d2762963e", + "Body" : "{\"value\":[{\"properties\":{\"provisioningState\":\"Succeeded\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.64.237.225\",\"type\":\"Public\"},\"osType\":\"Linux\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci358384/providers/Microsoft.ContainerInstance/containerGroups/aci358384\",\"name\":\"aci358384\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{\"tag1\":\"value1\"}},{\"properties\":{\"provisioningState\":\"Succeeded\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.88.20.196\",\"type\":\"Public\"},\"osType\":\"Linux\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci564224/providers/Microsoft.ContainerInstance/containerGroups/aci564224\",\"name\":\"aci564224\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{}},{\"properties\":{\"provisioningState\":\"Succeeded\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.64.109.180\",\"type\":\"Public\"},\"osType\":\"Linux\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci726622/providers/Microsoft.ContainerInstance/containerGroups/aci726622\",\"name\":\"aci726622\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{\"tag1\":\"value1\"}},{\"properties\":{\"provisioningState\":\"Succeeded\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"40.85.155.158\",\"type\":\"Public\"},\"osType\":\"Linux\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci854848/providers/Microsoft.ContainerInstance/containerGroups/aci854848\",\"name\":\"aci854848\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{}}]}" + } + }, { + "Method" : "PUT", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgaci84892f?api-version=2016-09-01", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ResourceManagementClient, 2016-09-01)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Sat, 26 Aug 2017 01:56:35 GMT", + "content-length" : "175", + "expires" : "-1", + "x-ms-ratelimit-remaining-subscription-writes" : "1199", + "retry-after" : "0", + "StatusCode" : "201", + "pragma" : "no-cache", + "x-ms-correlation-request-id" : "68be111d-7804-4564-8182-6f2c884d1719", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-routing-request-id" : "WESTUS2:20170826T015636Z:68be111d-7804-4564-8182-6f2c884d1719", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "68be111d-7804-4564-8182-6f2c884d1719", + "Body" : "{\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f\",\"name\":\"rgaci84892f\",\"location\":\"westus\",\"properties\":{\"provisioningState\":\"Succeeded\"}}" + } + }, { + "Method" : "PUT", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Sat, 26 Aug 2017 01:56:37 GMT", + "content-length" : "771", + "expires" : "-1", + "x-ms-ratelimit-remaining-subscription-writes" : "1198", + "retry-after" : "0", + "StatusCode" : "201", + "pragma" : "no-cache", + "x-ms-correlation-request-id" : "128f6317-0343-4617-b77a-41a6d26e1311", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-routing-request-id" : "WESTUS2:20170826T015637Z:128f6317-0343-4617-b77a-41a6d26e1311", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:d722dbc3-28e1-468c-a237-195bed08129a", + "Body" : "{\"properties\":{\"provisioningState\":\"Creating\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.64.249.247\",\"type\":\"Public\"},\"osType\":\"Linux\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f\",\"name\":\"aci84892f\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{\"tag1\":\"value1\"}}" + } + }, { + "Method" : "GET", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Sat, 26 Aug 2017 01:56:37 GMT", + "content-length" : "789", + "expires" : "-1", + "transfer-encoding" : "chunked", + "vary" : "Accept-Encoding,Accept-Encoding", + "retry-after" : "0", + "x-ms-ratelimit-remaining-subscription-reads" : "14994", + "StatusCode" : "200", + "pragma" : "no-cache", + "x-ms-correlation-request-id" : "f071d166-c4a2-4901-9a03-82ab9144a8a3", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-routing-request-id" : "WESTUS2:20170826T015637Z:f071d166-c4a2-4901-9a03-82ab9144a8a3", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:661c6da5-1c4b-4088-85e8-6f09908c7468", + "Body" : "{\"properties\":{\"provisioningState\":\"Creating\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.64.249.247\",\"type\":\"Public\"},\"osType\":\"Linux\",\"state\":\"Pending\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f\",\"name\":\"aci84892f\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{\"tag1\":\"value1\"}}" + } + }, { + "Method" : "GET", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Sat, 26 Aug 2017 01:56:37 GMT", + "content-length" : "783", + "expires" : "-1", + "transfer-encoding" : "chunked", + "vary" : "Accept-Encoding,Accept-Encoding", + "retry-after" : "0", + "x-ms-ratelimit-remaining-subscription-reads" : "14993", + "StatusCode" : "200", + "pragma" : "no-cache", + "x-ms-correlation-request-id" : "869d0ca6-34f2-4297-9345-da449015071f", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-routing-request-id" : "WESTUS2:20170826T015637Z:869d0ca6-34f2-4297-9345-da449015071f", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:c1e8c2f0-f179-4b7c-8d97-0893a2406612", + "Body" : "{\"value\":[{\"properties\":{\"provisioningState\":\"Creating\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.64.249.247\",\"type\":\"Public\"},\"osType\":\"Linux\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f\",\"name\":\"aci84892f\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{\"tag1\":\"value1\"}}]}" + } + }, { + "Method" : "GET", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Sat, 26 Aug 2017 01:56:37 GMT", + "content-length" : "789", + "expires" : "-1", + "transfer-encoding" : "chunked", + "vary" : "Accept-Encoding,Accept-Encoding", + "retry-after" : "0", + "x-ms-ratelimit-remaining-subscription-reads" : "14992", + "StatusCode" : "200", + "pragma" : "no-cache", + "x-ms-correlation-request-id" : "41458f22-7924-4be4-a105-78835baaa44f", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-routing-request-id" : "WESTUS2:20170826T015638Z:41458f22-7924-4be4-a105-78835baaa44f", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:accf2ece-ca68-41ef-8b12-33d0add335de", + "Body" : "{\"properties\":{\"provisioningState\":\"Creating\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.64.249.247\",\"type\":\"Public\"},\"osType\":\"Linux\",\"state\":\"Pending\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f\",\"name\":\"aci84892f\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{\"tag1\":\"value1\"}}" + } + }, { + "Method" : "GET", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ContainerInstance/containerGroups?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Sat, 26 Aug 2017 01:56:37 GMT", + "content-length" : "3844", + "expires" : "-1", + "transfer-encoding" : "chunked", + "vary" : "Accept-Encoding,Accept-Encoding", + "retry-after" : "0", + "x-ms-ratelimit-remaining-subscription-reads" : "14991", + "StatusCode" : "200", + "pragma" : "no-cache", + "x-ms-correlation-request-id" : "195759e2-18a5-4fe4-b7d6-30846fee327e", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-routing-request-id" : "WESTUS2:20170826T015638Z:195759e2-18a5-4fe4-b7d6-30846fee327e", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:ff1f1686-79e1-4f7e-81b1-c7d37e8475fe", + "Body" : "{\"value\":[{\"properties\":{\"provisioningState\":\"Succeeded\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.64.237.225\",\"type\":\"Public\"},\"osType\":\"Linux\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci358384/providers/Microsoft.ContainerInstance/containerGroups/aci358384\",\"name\":\"aci358384\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{\"tag1\":\"value1\"}},{\"properties\":{\"provisioningState\":\"Succeeded\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.88.20.196\",\"type\":\"Public\"},\"osType\":\"Linux\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci564224/providers/Microsoft.ContainerInstance/containerGroups/aci564224\",\"name\":\"aci564224\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{}},{\"properties\":{\"provisioningState\":\"Succeeded\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.64.109.180\",\"type\":\"Public\"},\"osType\":\"Linux\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci726622/providers/Microsoft.ContainerInstance/containerGroups/aci726622\",\"name\":\"aci726622\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{\"tag1\":\"value1\"}},{\"properties\":{\"provisioningState\":\"Creating\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.64.249.247\",\"type\":\"Public\"},\"osType\":\"Linux\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f\",\"name\":\"aci84892f\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{\"tag1\":\"value1\"}},{\"properties\":{\"provisioningState\":\"Succeeded\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"40.85.155.158\",\"type\":\"Public\"},\"osType\":\"Linux\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci854848/providers/Microsoft.ContainerInstance/containerGroups/aci854848\",\"name\":\"aci854848\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{}}]}" + } + }, { + "Method" : "GET", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Sat, 26 Aug 2017 01:56:37 GMT", + "content-length" : "789", + "expires" : "-1", + "transfer-encoding" : "chunked", + "vary" : "Accept-Encoding,Accept-Encoding", + "retry-after" : "0", + "x-ms-ratelimit-remaining-subscription-reads" : "14990", + "StatusCode" : "200", + "pragma" : "no-cache", + "x-ms-correlation-request-id" : "24acbb3f-f1d4-4322-81cd-23ecac114d5a", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-routing-request-id" : "WESTUS2:20170826T015638Z:24acbb3f-f1d4-4322-81cd-23ecac114d5a", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:85d527c7-66b7-466f-88d8-616b1ea8ad6d", + "Body" : "{\"properties\":{\"provisioningState\":\"Creating\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.64.249.247\",\"type\":\"Public\"},\"osType\":\"Linux\",\"state\":\"Pending\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f\",\"name\":\"aci84892f\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{\"tag1\":\"value1\"}}" + } + }, { + "Method" : "GET", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Sat, 26 Aug 2017 01:56:38 GMT", + "content-length" : "789", + "expires" : "-1", + "transfer-encoding" : "chunked", + "vary" : "Accept-Encoding,Accept-Encoding", + "retry-after" : "0", + "x-ms-ratelimit-remaining-subscription-reads" : "14989", + "StatusCode" : "200", + "pragma" : "no-cache", + "x-ms-correlation-request-id" : "1ab50a04-7539-449b-81e7-173591cb0ce8", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-routing-request-id" : "WESTUS2:20170826T015638Z:1ab50a04-7539-449b-81e7-173591cb0ce8", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:12654ae4-b703-43b6-9243-e6056bd78f20", + "Body" : "{\"properties\":{\"provisioningState\":\"Creating\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.64.249.247\",\"type\":\"Public\"},\"osType\":\"Linux\",\"state\":\"Pending\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f\",\"name\":\"aci84892f\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{\"tag1\":\"value1\"}}" + } + }, { + "Method" : "DELETE", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f?api-version=2017-08-01-preview", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ContainerInstanceManagementClient, 2017-08-01-preview)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Sat, 26 Aug 2017 01:56:38 GMT", + "content-length" : "789", + "expires" : "-1", + "transfer-encoding" : "chunked", + "vary" : "Accept-Encoding,Accept-Encoding", + "x-ms-ratelimit-remaining-subscription-writes" : "1197", + "retry-after" : "0", + "StatusCode" : "200", + "pragma" : "no-cache", + "x-ms-correlation-request-id" : "e16d9513-ea03-4f52-949c-70755f889694", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-routing-request-id" : "WESTUS2:20170826T015639Z:e16d9513-ea03-4f52-949c-70755f889694", + "content-type" : "application/json; charset=utf-8", + "cache-control" : "no-cache", + "x-ms-request-id" : "westus:cb67ee87-5f0d-4c86-8c14-57084147006c", + "Body" : "{\"properties\":{\"provisioningState\":\"Creating\",\"containers\":[{\"name\":\"tomcat\",\"properties\":{\"image\":\"tomcat\",\"ports\":[{\"port\":8080}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}},{\"name\":\"nginx\",\"properties\":{\"image\":\"nginx\",\"ports\":[{\"port\":80}],\"environmentVariables\":[],\"resources\":{\"requests\":{\"memoryInGB\":1.5,\"cpu\":1.0}}}}],\"ipAddress\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":8080},{\"protocol\":\"TCP\",\"port\":80}],\"ip\":\"13.64.249.247\",\"type\":\"Public\"},\"osType\":\"Linux\",\"state\":\"Pending\"},\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgaci84892f/providers/Microsoft.ContainerInstance/containerGroups/aci84892f\",\"name\":\"aci84892f\",\"type\":\"Microsoft.ContainerInstance/containerGroups\",\"location\":\"westus\",\"tags\":{\"tag1\":\"value1\"}}" + } + }, { + "Method" : "DELETE", + "Uri" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgaci84892f?api-version=2016-09-01", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Mac OS X/10.11.6 MacAddressHash:f3e724d972426a79006ddccaa8ceddefd1cc85387ab9dd050187dc3a455d02a7 Java:1.8.0_102 (ResourceManagementClient, 2016-09-01)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Sat, 26 Aug 2017 01:56:39 GMT", + "content-length" : "0", + "expires" : "-1", + "x-ms-ratelimit-remaining-subscription-writes" : "1196", + "retry-after" : "0", + "StatusCode" : "202", + "pragma" : "no-cache", + "x-ms-correlation-request-id" : "86bbc8ff-9d14-415b-a264-ccc41379bc3b", + "strict-transport-security" : "max-age=31536000; includeSubDomains", + "x-ms-routing-request-id" : "WESTUS2:20170826T015639Z:86bbc8ff-9d14-415b-a264-ccc41379bc3b", + "location" : "http://localhost:1234/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1SR0FDSTg0ODkyRi1XRVNUVVMiLCJqb2JMb2NhdGlvbiI6Indlc3R1cyJ9?api-version=2016-09-01", + "cache-control" : "no-cache", + "x-ms-request-id" : "86bbc8ff-9d14-415b-a264-ccc41379bc3b", + "Body" : "" + } + } ], + "variables" : [ "84892f" ] +} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 8e0dbbc5c74..a73ea8dbfb9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -332,6 +332,12 @@ var mappings = { 'package': 'com.microsoft.azure.management.containerregistry', 'args': '-FT 1', }, + 'containerinstance': { + 'dir': 'azure-mgmt-containerinstance', + 'source': 'arm-containerinstance/2017-08-01-preview/swagger/ContainerInstance.json', + 'package': 'com.microsoft.azure.management.containerinstance', + 'args': '-FT 1', + }, 'scheduler': { 'dir': 'azure-mgmt-scheduler', 'source': 'arm-scheduler/2016-03-01/swagger/scheduler.json', diff --git a/pom.xml b/pom.xml index 4d6e7ad929b..70321341b97 100644 --- a/pom.xml +++ b/pom.xml @@ -382,6 +382,7 @@ ./azure-mgmt-cognitiveservices ./azure-mgmt-compute ./azure-mgmt-consumption + ./azure-mgmt-containerinstance ./azure-mgmt-containerregistry ./azure-mgmt-customerinsights ./azure-mgmt-datalake-analytics