diff --git a/services/containerinstance/mgmt/2017-08-01-preview/containerinstance/models.go b/services/containerinstance/mgmt/2017-08-01-preview/containerinstance/models.go index 35f08fd1f2b6..d5539f6d5aa9 100644 --- a/services/containerinstance/mgmt/2017-08-01-preview/containerinstance/models.go +++ b/services/containerinstance/mgmt/2017-08-01-preview/containerinstance/models.go @@ -35,6 +35,11 @@ const ( UDP ContainerGroupNetworkProtocol = "UDP" ) +// PossibleContainerGroupNetworkProtocolValues returns an array of possible values for the ContainerGroupNetworkProtocol const type. +func PossibleContainerGroupNetworkProtocolValues() [2]ContainerGroupNetworkProtocol { + return [2]ContainerGroupNetworkProtocol{TCP, UDP} +} + // ContainerRestartPolicy enumerates the values for container restart policy. type ContainerRestartPolicy string @@ -43,6 +48,11 @@ const ( Always ContainerRestartPolicy = "always" ) +// PossibleContainerRestartPolicyValues returns an array of possible values for the ContainerRestartPolicy const type. +func PossibleContainerRestartPolicyValues() [1]ContainerRestartPolicy { + return [1]ContainerRestartPolicy{Always} +} + // OperatingSystemTypes enumerates the values for operating system types. type OperatingSystemTypes string @@ -53,6 +63,11 @@ const ( Windows OperatingSystemTypes = "Windows" ) +// PossibleOperatingSystemTypesValues returns an array of possible values for the OperatingSystemTypes const type. +func PossibleOperatingSystemTypesValues() [2]OperatingSystemTypes { + return [2]OperatingSystemTypes{Linux, Windows} +} + // AzureFileVolume the properties of the Azure File volume. Azure File shares are mounted as volumes. type AzureFileVolume struct { // ShareName - The name of the Azure File share to be mounted as a volume. diff --git a/services/containerinstance/mgmt/2017-10-01-preview/containerinstance/models.go b/services/containerinstance/mgmt/2017-10-01-preview/containerinstance/models.go index 4c93d8f002f2..ce106a3c4643 100644 --- a/services/containerinstance/mgmt/2017-10-01-preview/containerinstance/models.go +++ b/services/containerinstance/mgmt/2017-10-01-preview/containerinstance/models.go @@ -35,6 +35,11 @@ const ( UDP ContainerGroupNetworkProtocol = "UDP" ) +// PossibleContainerGroupNetworkProtocolValues returns an array of possible values for the ContainerGroupNetworkProtocol const type. +func PossibleContainerGroupNetworkProtocolValues() [2]ContainerGroupNetworkProtocol { + return [2]ContainerGroupNetworkProtocol{TCP, UDP} +} + // ContainerGroupRestartPolicy enumerates the values for container group restart policy. type ContainerGroupRestartPolicy string @@ -47,6 +52,11 @@ const ( OnFailure ContainerGroupRestartPolicy = "OnFailure" ) +// PossibleContainerGroupRestartPolicyValues returns an array of possible values for the ContainerGroupRestartPolicy const type. +func PossibleContainerGroupRestartPolicyValues() [3]ContainerGroupRestartPolicy { + return [3]ContainerGroupRestartPolicy{Always, Never, OnFailure} +} + // ContainerNetworkProtocol enumerates the values for container network protocol. type ContainerNetworkProtocol string @@ -57,6 +67,11 @@ const ( ContainerNetworkProtocolUDP ContainerNetworkProtocol = "UDP" ) +// PossibleContainerNetworkProtocolValues returns an array of possible values for the ContainerNetworkProtocol const type. +func PossibleContainerNetworkProtocolValues() [2]ContainerNetworkProtocol { + return [2]ContainerNetworkProtocol{ContainerNetworkProtocolTCP, ContainerNetworkProtocolUDP} +} + // OperatingSystemTypes enumerates the values for operating system types. type OperatingSystemTypes string @@ -67,6 +82,11 @@ const ( Windows OperatingSystemTypes = "Windows" ) +// PossibleOperatingSystemTypesValues returns an array of possible values for the OperatingSystemTypes const type. +func PossibleOperatingSystemTypesValues() [2]OperatingSystemTypes { + return [2]OperatingSystemTypes{Linux, Windows} +} + // OperationsOrigin enumerates the values for operations origin. type OperationsOrigin string @@ -77,6 +97,11 @@ const ( User OperationsOrigin = "User" ) +// PossibleOperationsOriginValues returns an array of possible values for the OperationsOrigin const type. +func PossibleOperationsOriginValues() [2]OperationsOrigin { + return [2]OperationsOrigin{System, User} +} + // AzureFileVolume the properties of the Azure File volume. Azure File shares are mounted as volumes. type AzureFileVolume struct { // ShareName - The name of the Azure File share to be mounted as a volume. diff --git a/services/containerinstance/mgmt/2017-12-01-preview/containerinstance/models.go b/services/containerinstance/mgmt/2017-12-01-preview/containerinstance/models.go index c9710620cd8d..51404e722219 100644 --- a/services/containerinstance/mgmt/2017-12-01-preview/containerinstance/models.go +++ b/services/containerinstance/mgmt/2017-12-01-preview/containerinstance/models.go @@ -35,6 +35,11 @@ const ( UDP ContainerGroupNetworkProtocol = "UDP" ) +// PossibleContainerGroupNetworkProtocolValues returns an array of possible values for the ContainerGroupNetworkProtocol const type. +func PossibleContainerGroupNetworkProtocolValues() [2]ContainerGroupNetworkProtocol { + return [2]ContainerGroupNetworkProtocol{TCP, UDP} +} + // ContainerGroupRestartPolicy enumerates the values for container group restart policy. type ContainerGroupRestartPolicy string @@ -47,6 +52,11 @@ const ( OnFailure ContainerGroupRestartPolicy = "OnFailure" ) +// PossibleContainerGroupRestartPolicyValues returns an array of possible values for the ContainerGroupRestartPolicy const type. +func PossibleContainerGroupRestartPolicyValues() [3]ContainerGroupRestartPolicy { + return [3]ContainerGroupRestartPolicy{Always, Never, OnFailure} +} + // ContainerNetworkProtocol enumerates the values for container network protocol. type ContainerNetworkProtocol string @@ -57,6 +67,11 @@ const ( ContainerNetworkProtocolUDP ContainerNetworkProtocol = "UDP" ) +// PossibleContainerNetworkProtocolValues returns an array of possible values for the ContainerNetworkProtocol const type. +func PossibleContainerNetworkProtocolValues() [2]ContainerNetworkProtocol { + return [2]ContainerNetworkProtocol{ContainerNetworkProtocolTCP, ContainerNetworkProtocolUDP} +} + // OperatingSystemTypes enumerates the values for operating system types. type OperatingSystemTypes string @@ -67,6 +82,11 @@ const ( Windows OperatingSystemTypes = "Windows" ) +// PossibleOperatingSystemTypesValues returns an array of possible values for the OperatingSystemTypes const type. +func PossibleOperatingSystemTypesValues() [2]OperatingSystemTypes { + return [2]OperatingSystemTypes{Linux, Windows} +} + // OperationsOrigin enumerates the values for operations origin. type OperationsOrigin string @@ -77,6 +97,11 @@ const ( User OperationsOrigin = "User" ) +// PossibleOperationsOriginValues returns an array of possible values for the OperationsOrigin const type. +func PossibleOperationsOriginValues() [2]OperationsOrigin { + return [2]OperationsOrigin{System, User} +} + // AzureFileVolume the properties of the Azure File volume. Azure File shares are mounted as volumes. type AzureFileVolume struct { // ShareName - The name of the Azure File share to be mounted as a volume. diff --git a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/containergroups.go b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/containergroups.go index b909982bca14..c02573f5f961 100644 --- a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/containergroups.go +++ b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/containergroups.go @@ -44,7 +44,7 @@ func NewContainerGroupsClientWithBaseURI(baseURI string, subscriptionID string) // // resourceGroupName is the name of the resource group. containerGroupName is the name of the container group. // containerGroup is the properties of the container group to be created or updated. -func (client ContainerGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, containerGroupName string, containerGroup ContainerGroup) (result ContainerGroup, err error) { +func (client ContainerGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, containerGroupName string, containerGroup ContainerGroup) (result ContainerGroupsCreateOrUpdateFuture, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: containerGroup, Constraints: []validation.Constraint{{Target: "containerGroup.ContainerGroupProperties", Name: validation.Null, Rule: true, @@ -63,18 +63,12 @@ func (client ContainerGroupsClient) CreateOrUpdate(ctx context.Context, resource return } - resp, err := client.CreateOrUpdateSender(req) + result, err = client.CreateOrUpdateSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "CreateOrUpdate", result.Response(), "Failure sending request") return } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - return } @@ -103,9 +97,17 @@ func (client ContainerGroupsClient) CreateOrUpdatePreparer(ctx context.Context, // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the // http.Response Body if it receives an error. -func (client ContainerGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) +func (client ContainerGroupsClient) CreateOrUpdateSender(req *http.Request) (future ContainerGroupsCreateOrUpdateFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated)) + return } // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always @@ -447,7 +449,7 @@ func (client ContainerGroupsClient) ListByResourceGroupComplete(ctx context.Cont // // resourceGroupName is the name of the resource group. containerGroupName is the name of the container group. // resource is the container group resource with just the tags to be updated. -func (client ContainerGroupsClient) Update(ctx context.Context, resourceGroupName string, containerGroupName string, resource *Resource) (result ContainerGroup, err error) { +func (client ContainerGroupsClient) Update(ctx context.Context, resourceGroupName string, containerGroupName string, resource Resource) (result ContainerGroup, err error) { req, err := client.UpdatePreparer(ctx, resourceGroupName, containerGroupName, resource) if err != nil { err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "Update", nil, "Failure preparing request") @@ -470,7 +472,7 @@ func (client ContainerGroupsClient) Update(ctx context.Context, resourceGroupNam } // UpdatePreparer prepares the Update request. -func (client ContainerGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, containerGroupName string, resource *Resource) (*http.Request, error) { +func (client ContainerGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, containerGroupName string, resource Resource) (*http.Request, error) { pathParameters := map[string]interface{}{ "containerGroupName": autorest.Encode("path", containerGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -487,11 +489,8 @@ func (client ContainerGroupsClient) UpdatePreparer(ctx context.Context, resource autorest.AsPatch(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}", pathParameters), + autorest.WithJSON(resource), autorest.WithQueryParameters(queryParameters)) - if resource != nil { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithJSON(resource)) - } return preparer.Prepare((&http.Request{}).WithContext(ctx)) } diff --git a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/models.go b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/models.go index 713d0e65463c..af76e2c0f8f6 100644 --- a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/models.go +++ b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/models.go @@ -20,6 +20,7 @@ package containerinstance import ( "encoding/json" "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/date" "github.com/Azure/go-autorest/autorest/to" "net/http" @@ -35,6 +36,11 @@ const ( UDP ContainerGroupNetworkProtocol = "UDP" ) +// PossibleContainerGroupNetworkProtocolValues returns an array of possible values for the ContainerGroupNetworkProtocol const type. +func PossibleContainerGroupNetworkProtocolValues() [2]ContainerGroupNetworkProtocol { + return [2]ContainerGroupNetworkProtocol{TCP, UDP} +} + // ContainerGroupRestartPolicy enumerates the values for container group restart policy. type ContainerGroupRestartPolicy string @@ -47,6 +53,11 @@ const ( OnFailure ContainerGroupRestartPolicy = "OnFailure" ) +// PossibleContainerGroupRestartPolicyValues returns an array of possible values for the ContainerGroupRestartPolicy const type. +func PossibleContainerGroupRestartPolicyValues() [3]ContainerGroupRestartPolicy { + return [3]ContainerGroupRestartPolicy{Always, Never, OnFailure} +} + // ContainerNetworkProtocol enumerates the values for container network protocol. type ContainerNetworkProtocol string @@ -57,6 +68,11 @@ const ( ContainerNetworkProtocolUDP ContainerNetworkProtocol = "UDP" ) +// PossibleContainerNetworkProtocolValues returns an array of possible values for the ContainerNetworkProtocol const type. +func PossibleContainerNetworkProtocolValues() [2]ContainerNetworkProtocol { + return [2]ContainerNetworkProtocol{ContainerNetworkProtocolTCP, ContainerNetworkProtocolUDP} +} + // OperatingSystemTypes enumerates the values for operating system types. type OperatingSystemTypes string @@ -67,6 +83,11 @@ const ( Windows OperatingSystemTypes = "Windows" ) +// PossibleOperatingSystemTypesValues returns an array of possible values for the OperatingSystemTypes const type. +func PossibleOperatingSystemTypesValues() [2]OperatingSystemTypes { + return [2]OperatingSystemTypes{Linux, Windows} +} + // OperationsOrigin enumerates the values for operations origin. type OperationsOrigin string @@ -77,6 +98,11 @@ const ( User OperationsOrigin = "User" ) +// PossibleOperationsOriginValues returns an array of possible values for the OperationsOrigin const type. +func PossibleOperationsOriginValues() [2]OperationsOrigin { + return [2]OperationsOrigin{System, User} +} + // AzureFileVolume the properties of the Azure File volume. Azure File shares are mounted as volumes. type AzureFileVolume struct { // ShareName - The name of the Azure File share to be mounted as a volume. @@ -130,6 +156,31 @@ func (c *Container) UnmarshalJSON(body []byte) error { return nil } +// ContainerExecRequest the start container exec request. +type ContainerExecRequest struct { + // Command - The command to be executed. + Command *string `json:"command,omitempty"` + // TerminalSize - The size of the terminal. + TerminalSize *ContainerExecRequestTerminalSize `json:"terminalSize,omitempty"` +} + +// ContainerExecRequestTerminalSize the size of the terminal. +type ContainerExecRequestTerminalSize struct { + // Row - The row size of the terminal + Row *int32 `json:"row,omitempty"` + // Column - The column size of the terminal + Column *int32 `json:"column,omitempty"` +} + +// ContainerExecResponse the information for the container exec command. +type ContainerExecResponse struct { + autorest.Response `json:"-"` + // WebSocketURI - The uri for the exec websocket. + WebSocketURI *string `json:"webSocketUri,omitempty"` + // Password - The password to start the exec command. + Password *string `json:"password,omitempty"` +} + // ContainerGroup a container group. type ContainerGroup struct { autorest.Response `json:"-"` @@ -373,6 +424,55 @@ type ContainerGroupPropertiesInstanceView struct { State *string `json:"state,omitempty"` } +// ContainerGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ContainerGroupsCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ContainerGroupsCreateOrUpdateFuture) Result(client ContainerGroupsClient) (cg ContainerGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return cg, azure.NewAsyncOpIncompleteError("containerinstance.ContainerGroupsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + cg, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + cg, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + // ContainerPort the port exposed on the container instance. type ContainerPort struct { // Protocol - The protocol associated with the port. Possible values include: 'ContainerNetworkProtocolTCP', 'ContainerNetworkProtocolUDP' diff --git a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/startcontainer.go b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/startcontainer.go new file mode 100644 index 000000000000..a18e4b2d63d7 --- /dev/null +++ b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/startcontainer.go @@ -0,0 +1,111 @@ +package containerinstance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// StartContainerClient is the client for the StartContainer methods of the Containerinstance service. +type StartContainerClient struct { + BaseClient +} + +// NewStartContainerClient creates an instance of the StartContainerClient client. +func NewStartContainerClient(subscriptionID string) StartContainerClient { + return NewStartContainerClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewStartContainerClientWithBaseURI creates an instance of the StartContainerClient client. +func NewStartContainerClientWithBaseURI(baseURI string, subscriptionID string) StartContainerClient { + return StartContainerClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// LaunchExec starts the exec command for a specified container instance in a specified resource group and container +// group. +// +// resourceGroupName is the name of the resource group. containerGroupName is the name of the container group. +// containerName is the name of the container instance. containerExecRequest is the request for the exec command. +func (client StartContainerClient) LaunchExec(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, containerExecRequest ContainerExecRequest) (result ContainerExecResponse, err error) { + req, err := client.LaunchExecPreparer(ctx, resourceGroupName, containerGroupName, containerName, containerExecRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "LaunchExec", nil, "Failure preparing request") + return + } + + resp, err := client.LaunchExecSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "LaunchExec", resp, "Failure sending request") + return + } + + result, err = client.LaunchExecResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "LaunchExec", resp, "Failure responding to request") + } + + return +} + +// LaunchExecPreparer prepares the LaunchExec request. +func (client StartContainerClient) LaunchExecPreparer(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, containerExecRequest ContainerExecRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "containerGroupName": autorest.Encode("path", containerGroupName), + "containerName": autorest.Encode("path", containerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec", pathParameters), + autorest.WithJSON(containerExecRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// LaunchExecSender sends the LaunchExec request. The method will close the +// http.Response Body if it receives an error. +func (client StartContainerClient) LaunchExecSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// LaunchExecResponder handles the response to the LaunchExec request. The method always +// closes the http.Response Body. +func (client StartContainerClient) LaunchExecResponder(resp *http.Response) (result ContainerExecResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}