diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerExecResponse.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerExecResponse.java new file mode 100644 index 00000000000..bbdbfc8bdcb --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/ContainerExecResponse.java @@ -0,0 +1,32 @@ +/** + * 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.ContainerExecResponseInner; +import com.microsoft.azure.management.resources.fluentcore.model.HasInner; + +/** + * Response containing the container exec command. + */ +@Fluent +@Beta(Beta.SinceVersion.V1_11_0) +public interface ContainerExecResponse extends HasInner { + /** + * Get the webSocketUri value. + * + * @return the webSocketUri value + */ + String webSocketUri(); + + /** + * Get the password value. + * + * @return the password value + */ + String password(); +} 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 index a2c940f3b11..2fa8a8d7aa3 100644 --- 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 @@ -160,9 +160,35 @@ public interface ContainerGroup extends */ Observable getLogContentAsync(String containerName, int tailLineCount); + /** + * Starts the exec command for a specific container instance. + * + * @param containerName the container instance name + * @param command the command to be executed + * @param row the row size of the terminal + * @param column the column size of the terminal + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the log lines from the end, up to the number specified + */ + @Beta(Beta.SinceVersion.V1_11_0) + ContainerExecResponse executeCommand(String containerName, String command, int row, int column); + + /** + * Starts the exec command for a specific container instance within the container group. + * + * @param containerName the container instance name + * @param command the command to be executed + * @param row the row size of the terminal + * @param column the column size of the terminal + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return a representation of the future computation of this call + */ + @Beta(Beta.SinceVersion.V1_11_0) + Observable executeCommandAsync(String containerName, String command, int row, int column); + /** - * The entirety of the Azure Container Instance service container group definition. + * Starts the exec command for a specific container instance within the current group asynchronously. */ interface Definition extends DefinitionStages.Blank, @@ -720,18 +746,20 @@ interface WithStartingCommandLine { /** * Specifies the starting command lines. * - * @param commandLines the starting command lines the container will execute after it gets initialized + * @param executable the executable which it will call after initializing the container + * @param parameters the parameter list for the executable to be called * @return the next stage of the definition */ - WithContainerInstanceAttach withStartingCommandLines(String... commandLines); + @Beta(Beta.SinceVersion.V1_11_0) + WithContainerInstanceAttach withStartingCommandLine(String executable, String... parameters); /** * Specifies the starting command line. * - * @param commandLine the starting command line the container will execute after it gets initialized + * @param executable the executable or path to the executable that will be called after initializing the container * @return the next stage of the definition */ - WithContainerInstanceAttach withStartingCommandLine(String commandLine); + WithContainerInstanceAttach withStartingCommandLine(String executable); } /** diff --git a/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerExecResponseImpl.java b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerExecResponseImpl.java new file mode 100644 index 00000000000..de7a916c2c0 --- /dev/null +++ b/azure-mgmt-containerinstance/src/main/java/com/microsoft/azure/management/containerinstance/implementation/ContainerExecResponseImpl.java @@ -0,0 +1,31 @@ +/** + * 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.ContainerExecResponse; +import com.microsoft.azure.management.resources.fluentcore.model.implementation.WrapperImpl; + +/** + * Implementation for RegistryCredentials. + */ +@LangDefinition +public class ContainerExecResponseImpl extends WrapperImpl + implements ContainerExecResponse { + protected ContainerExecResponseImpl(ContainerExecResponseInner innerObject) { + super(innerObject); + } + + @Override + public String webSocketUri() { + return this.inner().webSocketUri(); + } + + @Override + public String password() { + return this.inner().password(); + } +} 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 index f5bd226a627..7e8d66f03ce 100644 --- 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 @@ -9,6 +9,8 @@ import com.microsoft.azure.Resource; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.containerinstance.Container; +import com.microsoft.azure.management.containerinstance.ContainerExecRequestTerminalSize; +import com.microsoft.azure.management.containerinstance.ContainerExecResponse; import com.microsoft.azure.management.containerinstance.ContainerGroup; import com.microsoft.azure.management.containerinstance.ContainerGroupNetworkProtocol; import com.microsoft.azure.management.containerinstance.ContainerGroupRestartPolicy; @@ -488,4 +490,32 @@ public Observable getLogContentAsync(String containerName) { public Observable getLogContentAsync(String containerName, int tailLineCount) { return this.manager().containerGroups().getLogContentAsync(this.resourceGroupName(), this.name(), containerName, tailLineCount); } + + @Override + public ContainerExecResponse executeCommand(String containerName, String command, int row, int column) { + return new ContainerExecResponseImpl(this.manager().inner().startContainers() + .launchExec(this.resourceGroupName(), this.name(), containerName, + new ContainerExecRequestInner() + .withCommand(command) + .withTerminalSize(new ContainerExecRequestTerminalSize() + .withRow(row) + .withColumn(column)))); + } + + @Override + public Observable executeCommandAsync(String containerName, String command, int row, int column) { + return this.manager().inner().startContainers() + .launchExecAsync(this.resourceGroupName(), this.name(), containerName, + new ContainerExecRequestInner() + .withCommand(command) + .withTerminalSize(new ContainerExecRequestTerminalSize() + .withRow(row) + .withColumn(column))) + .map(new Func1() { + @Override + public ContainerExecResponse call(ContainerExecResponseInner containerExecResponseInner) { + return new ContainerExecResponseImpl(containerExecResponseInner); + } + }); + } } 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 index 1b3362f7dd8..8cc91a47282 100644 --- 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 @@ -166,9 +166,12 @@ public ContainerImpl withMemorySizeInGB(double memorySize) { } @Override - public ContainerImpl withStartingCommandLines(String... commandLines) { - for (String command : commandLines) { - this.withStartingCommandLine(command); + public ContainerImpl withStartingCommandLine(String executable, String... parameters) { + this.withStartingCommandLine(executable); + if (parameters != null) { + for (String parameter : parameters) { + this.withStartingCommandLine(parameter); + } } return this;