From dd877f6340dcea23c2d3547cce77205e00f3128c Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 7 Mar 2018 00:54:37 +0000 Subject: [PATCH 1/4] Generated from a60b503fd362577f4fab95a5e2518b553ec284e9 fixing small syntax error --- .../asynccontainergroupoperation.go | 108 +++++++++++++++++ .../containerinstance/containergroups.go | 9 +- .../containerinstance/models.go | 58 +++++++++ .../containerinstance/startcontainer.go | 110 ++++++++++++++++++ 4 files changed, 279 insertions(+), 6 deletions(-) create mode 100644 services/containerinstance/mgmt/2018-02-01-preview/containerinstance/asynccontainergroupoperation.go create mode 100644 services/containerinstance/mgmt/2018-02-01-preview/containerinstance/startcontainer.go diff --git a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/asynccontainergroupoperation.go b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/asynccontainergroupoperation.go new file mode 100644 index 000000000000..be63388aa3d6 --- /dev/null +++ b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/asynccontainergroupoperation.go @@ -0,0 +1,108 @@ +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" +) + +// AsyncContainerGroupOperationClient is the client for the AsyncContainerGroupOperation methods of the +// Containerinstance service. +type AsyncContainerGroupOperationClient struct { + BaseClient +} + +// NewAsyncContainerGroupOperationClient creates an instance of the AsyncContainerGroupOperationClient client. +func NewAsyncContainerGroupOperationClient(subscriptionID string) AsyncContainerGroupOperationClient { + return NewAsyncContainerGroupOperationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAsyncContainerGroupOperationClientWithBaseURI creates an instance of the AsyncContainerGroupOperationClient +// client. +func NewAsyncContainerGroupOperationClientWithBaseURI(baseURI string, subscriptionID string) AsyncContainerGroupOperationClient { + return AsyncContainerGroupOperationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the usage for a subscription +// +// location is the identifier for the physical azure location. operationID is the operation Id. +func (client AsyncContainerGroupOperationClient) Get(ctx context.Context, location string, operationID string) (result AsyncOperation, err error) { + req, err := client.GetPreparer(ctx, location, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.AsyncContainerGroupOperationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerinstance.AsyncContainerGroupOperationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.AsyncContainerGroupOperationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AsyncContainerGroupOperationClient) GetPreparer(ctx context.Context, location string, operationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "operationId": autorest.Encode("path", operationID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/operations/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AsyncContainerGroupOperationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AsyncContainerGroupOperationClient) GetResponder(resp *http.Response) (result AsyncOperation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} 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..2c6665c1a0b8 100644 --- a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/containergroups.go +++ b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/containergroups.go @@ -447,7 +447,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 +470,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 +487,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..bd115df67b90 100644 --- a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/models.go +++ b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/models.go @@ -77,6 +77,27 @@ const ( User OperationsOrigin = "User" ) +// AsyncOperation azure async operation status. +type AsyncOperation struct { + autorest.Response `json:"-"` + // ID - Async operation id. + ID *string `json:"id,omitempty"` + // Status - Async operation status. + Status *string `json:"status,omitempty"` + // StartTime - The date time that the async operation started. + StartTime *date.Time `json:"startTime,omitempty"` + // Properties - this structure contains the detailed properties of the operation. + Properties *AsyncOperationProperties `json:"properties,omitempty"` + // Error - If the async operation fails, this structure contains the error details. + Error *AzureResourceExtendedErrorInfo `json:"error,omitempty"` +} + +// AsyncOperationProperties the properties of the async operation +type AsyncOperationProperties struct { + // Events - The events of the async operation. + Events *[]Event `json:"events,omitempty"` +} + // 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. @@ -89,6 +110,18 @@ type AzureFileVolume struct { StorageAccountKey *string `json:"storageAccountKey,omitempty"` } +// AzureResourceExtendedErrorInfo the error detail information for async operation +type AzureResourceExtendedErrorInfo struct { + // Code - The error code. + Code *string `json:"code,omitempty"` + // Target - The error target. + Target *string `json:"target,omitempty"` + // Message - The error message. + Message *string `json:"message,omitempty"` + // Details - An array containing error information. + Details *[]AzureResourceExtendedErrorInfo `json:"details,omitempty"` +} + // Container a container instance. type Container struct { // Name - The user-provided name of the container instance. @@ -130,6 +163,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:"-"` 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..e0aa109a9926 --- /dev/null +++ b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/startcontainer.go @@ -0,0 +1,110 @@ +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)} +} + +// Exec 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) Exec(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, containerExecRequest ContainerExecRequest) (result ContainerExecResponse, err error) { + req, err := client.ExecPreparer(ctx, resourceGroupName, containerGroupName, containerName, containerExecRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "Exec", nil, "Failure preparing request") + return + } + + resp, err := client.ExecSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "Exec", resp, "Failure sending request") + return + } + + result, err = client.ExecResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "Exec", resp, "Failure responding to request") + } + + return +} + +// ExecPreparer prepares the Exec request. +func (client StartContainerClient) ExecPreparer(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)) +} + +// ExecSender sends the Exec request. The method will close the +// http.Response Body if it receives an error. +func (client StartContainerClient) ExecSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ExecResponder handles the response to the Exec request. The method always +// closes the http.Response Body. +func (client StartContainerClient) ExecResponder(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 +} From f949bed8152b8616766bd2e211bdd4b24c5d1221 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 7 Mar 2018 18:37:41 +0000 Subject: [PATCH 2/4] Generated from 1ec1e3fd40e63a08d3262affca1203988f7407ef Updating correct examples for async operation --- .../containerinstance/models.go | 15 +++++++++++ .../containerinstance/models.go | 25 +++++++++++++++++++ .../containerinstance/models.go | 25 +++++++++++++++++++ .../asynccontainergroupoperation.go | 2 +- .../containerinstance/models.go | 25 +++++++++++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) 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/asynccontainergroupoperation.go b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/asynccontainergroupoperation.go index be63388aa3d6..bb136b2fa322 100644 --- a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/asynccontainergroupoperation.go +++ b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/asynccontainergroupoperation.go @@ -41,7 +41,7 @@ func NewAsyncContainerGroupOperationClientWithBaseURI(baseURI string, subscripti return AsyncContainerGroupOperationClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Get get the usage for a subscription +// Get get the container group async operation status. // // location is the identifier for the physical azure location. operationID is the operation Id. func (client AsyncContainerGroupOperationClient) Get(ctx context.Context, location string, operationID string) (result AsyncOperation, err error) { 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 bd115df67b90..967cf45ad2ba 100644 --- a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/models.go +++ b/services/containerinstance/mgmt/2018-02-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} +} + // AsyncOperation azure async operation status. type AsyncOperation struct { autorest.Response `json:"-"` From 2f66563307fb2a343d3459e230d2eb4448bb6efd Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 7 Mar 2018 21:29:54 +0000 Subject: [PATCH 3/4] Generated from 24d60116617096cd26598e974ac7e1fa00ec8169 fixing ARM header field --- .../containerinstance/containergroups.go | 26 +++++----- .../containerinstance/models.go | 50 +++++++++++++++++++ 2 files changed, 64 insertions(+), 12 deletions(-) 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 2c6665c1a0b8..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 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 967cf45ad2ba..efd5a515bcdf 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" @@ -456,6 +457,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' From a7cf6e03e862249ed1de4eda81f1bca7882d2d07 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 12 Mar 2018 18:14:32 +0000 Subject: [PATCH 4/4] Generated from 9fecbb9feb0b8ea3cbba6a02e84973b2bdf11378 remvoing extra async operations --- .../asynccontainergroupoperation.go | 108 ------------------ .../containerinstance/models.go | 33 ------ .../containerinstance/startcontainer.go | 29 ++--- 3 files changed, 15 insertions(+), 155 deletions(-) delete mode 100644 services/containerinstance/mgmt/2018-02-01-preview/containerinstance/asynccontainergroupoperation.go diff --git a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/asynccontainergroupoperation.go b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/asynccontainergroupoperation.go deleted file mode 100644 index bb136b2fa322..000000000000 --- a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/asynccontainergroupoperation.go +++ /dev/null @@ -1,108 +0,0 @@ -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" -) - -// AsyncContainerGroupOperationClient is the client for the AsyncContainerGroupOperation methods of the -// Containerinstance service. -type AsyncContainerGroupOperationClient struct { - BaseClient -} - -// NewAsyncContainerGroupOperationClient creates an instance of the AsyncContainerGroupOperationClient client. -func NewAsyncContainerGroupOperationClient(subscriptionID string) AsyncContainerGroupOperationClient { - return NewAsyncContainerGroupOperationClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewAsyncContainerGroupOperationClientWithBaseURI creates an instance of the AsyncContainerGroupOperationClient -// client. -func NewAsyncContainerGroupOperationClientWithBaseURI(baseURI string, subscriptionID string) AsyncContainerGroupOperationClient { - return AsyncContainerGroupOperationClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Get get the container group async operation status. -// -// location is the identifier for the physical azure location. operationID is the operation Id. -func (client AsyncContainerGroupOperationClient) Get(ctx context.Context, location string, operationID string) (result AsyncOperation, err error) { - req, err := client.GetPreparer(ctx, location, operationID) - if err != nil { - err = autorest.NewErrorWithError(err, "containerinstance.AsyncContainerGroupOperationClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerinstance.AsyncContainerGroupOperationClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerinstance.AsyncContainerGroupOperationClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client AsyncContainerGroupOperationClient) GetPreparer(ctx context.Context, location string, operationID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "location": autorest.Encode("path", location), - "operationId": autorest.Encode("path", operationID), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-02-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/operations/{operationId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client AsyncContainerGroupOperationClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client AsyncContainerGroupOperationClient) GetResponder(resp *http.Response) (result AsyncOperation, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} 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 efd5a515bcdf..af76e2c0f8f6 100644 --- a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/models.go +++ b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/models.go @@ -103,27 +103,6 @@ func PossibleOperationsOriginValues() [2]OperationsOrigin { return [2]OperationsOrigin{System, User} } -// AsyncOperation azure async operation status. -type AsyncOperation struct { - autorest.Response `json:"-"` - // ID - Async operation id. - ID *string `json:"id,omitempty"` - // Status - Async operation status. - Status *string `json:"status,omitempty"` - // StartTime - The date time that the async operation started. - StartTime *date.Time `json:"startTime,omitempty"` - // Properties - this structure contains the detailed properties of the operation. - Properties *AsyncOperationProperties `json:"properties,omitempty"` - // Error - If the async operation fails, this structure contains the error details. - Error *AzureResourceExtendedErrorInfo `json:"error,omitempty"` -} - -// AsyncOperationProperties the properties of the async operation -type AsyncOperationProperties struct { - // Events - The events of the async operation. - Events *[]Event `json:"events,omitempty"` -} - // 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. @@ -136,18 +115,6 @@ type AzureFileVolume struct { StorageAccountKey *string `json:"storageAccountKey,omitempty"` } -// AzureResourceExtendedErrorInfo the error detail information for async operation -type AzureResourceExtendedErrorInfo struct { - // Code - The error code. - Code *string `json:"code,omitempty"` - // Target - The error target. - Target *string `json:"target,omitempty"` - // Message - The error message. - Message *string `json:"message,omitempty"` - // Details - An array containing error information. - Details *[]AzureResourceExtendedErrorInfo `json:"details,omitempty"` -} - // Container a container instance. type Container struct { // Name - The user-provided name of the container instance. diff --git a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/startcontainer.go b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/startcontainer.go index e0aa109a9926..a18e4b2d63d7 100644 --- a/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/startcontainer.go +++ b/services/containerinstance/mgmt/2018-02-01-preview/containerinstance/startcontainer.go @@ -39,34 +39,35 @@ func NewStartContainerClientWithBaseURI(baseURI string, subscriptionID string) S return StartContainerClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Exec starts the exec command for a specified container instance in a specified resource group and container group. +// 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) Exec(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, containerExecRequest ContainerExecRequest) (result ContainerExecResponse, err error) { - req, err := client.ExecPreparer(ctx, resourceGroupName, containerGroupName, containerName, containerExecRequest) +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", "Exec", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "LaunchExec", nil, "Failure preparing request") return } - resp, err := client.ExecSender(req) + resp, err := client.LaunchExecSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "Exec", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "LaunchExec", resp, "Failure sending request") return } - result, err = client.ExecResponder(resp) + result, err = client.LaunchExecResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "Exec", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "LaunchExec", resp, "Failure responding to request") } return } -// ExecPreparer prepares the Exec request. -func (client StartContainerClient) ExecPreparer(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, containerExecRequest ContainerExecRequest) (*http.Request, error) { +// 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), @@ -89,16 +90,16 @@ func (client StartContainerClient) ExecPreparer(ctx context.Context, resourceGro return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// ExecSender sends the Exec request. The method will close the +// LaunchExecSender sends the LaunchExec request. The method will close the // http.Response Body if it receives an error. -func (client StartContainerClient) ExecSender(req *http.Request) (*http.Response, error) { +func (client StartContainerClient) LaunchExecSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client)) } -// ExecResponder handles the response to the Exec request. The method always +// LaunchExecResponder handles the response to the LaunchExec request. The method always // closes the http.Response Body. -func (client StartContainerClient) ExecResponder(resp *http.Response) (result ContainerExecResponse, err error) { +func (client StartContainerClient) LaunchExecResponder(resp *http.Response) (result ContainerExecResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(),