From acdbdc3bb0c728ebba7a3a77b62275229576d776 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot Date: Wed, 23 Oct 2019 06:34:21 +0000 Subject: [PATCH] Generated from 980a4a36c65ce19efc0707a489f0c94e8e291455 1. Make PUT and PATCH against App resource supports async. 2. Remove "Processing" enum from DeploymentResourceProperties's status property. 3. Rename "Processing" enum to "Updating" for DeploymentResourceProperties's provisioningState. --- .../appplatform/mgmt/appplatform/models.go | 13 +-- .../appplatform/appplatformapi/interfaces.go | 4 +- .../2019-05-01-preview/appplatform/apps.go | 56 ++++++------- .../2019-05-01-preview/appplatform/models.go | 81 ++++++++++++++++--- 4 files changed, 108 insertions(+), 46 deletions(-) diff --git a/profiles/preview/preview/appplatform/mgmt/appplatform/models.go b/profiles/preview/preview/appplatform/mgmt/appplatform/models.go index 00b3137c3d1c..099e9fa16a92 100644 --- a/profiles/preview/preview/appplatform/mgmt/appplatform/models.go +++ b/profiles/preview/preview/appplatform/mgmt/appplatform/models.go @@ -32,8 +32,10 @@ const ( type AppResourceProvisioningState = original.AppResourceProvisioningState const ( + Creating AppResourceProvisioningState = original.Creating Failed AppResourceProvisioningState = original.Failed Succeeded AppResourceProvisioningState = original.Succeeded + Updating AppResourceProvisioningState = original.Updating ) type ConfigServerState = original.ConfigServerState @@ -49,10 +51,10 @@ const ( type DeploymentResourceProvisioningState = original.DeploymentResourceProvisioningState const ( - DeploymentResourceProvisioningStateCreating DeploymentResourceProvisioningState = original.DeploymentResourceProvisioningStateCreating - DeploymentResourceProvisioningStateFailed DeploymentResourceProvisioningState = original.DeploymentResourceProvisioningStateFailed - DeploymentResourceProvisioningStateProcessing DeploymentResourceProvisioningState = original.DeploymentResourceProvisioningStateProcessing - DeploymentResourceProvisioningStateSucceeded DeploymentResourceProvisioningState = original.DeploymentResourceProvisioningStateSucceeded + DeploymentResourceProvisioningStateCreating DeploymentResourceProvisioningState = original.DeploymentResourceProvisioningStateCreating + DeploymentResourceProvisioningStateFailed DeploymentResourceProvisioningState = original.DeploymentResourceProvisioningStateFailed + DeploymentResourceProvisioningStateSucceeded DeploymentResourceProvisioningState = original.DeploymentResourceProvisioningStateSucceeded + DeploymentResourceProvisioningStateUpdating DeploymentResourceProvisioningState = original.DeploymentResourceProvisioningStateUpdating ) type DeploymentResourceStatus = original.DeploymentResourceStatus @@ -61,7 +63,6 @@ const ( DeploymentResourceStatusAllocating DeploymentResourceStatus = original.DeploymentResourceStatusAllocating DeploymentResourceStatusCompiling DeploymentResourceStatus = original.DeploymentResourceStatusCompiling DeploymentResourceStatusFailed DeploymentResourceStatus = original.DeploymentResourceStatusFailed - DeploymentResourceStatusProcessing DeploymentResourceStatus = original.DeploymentResourceStatusProcessing DeploymentResourceStatusRunning DeploymentResourceStatus = original.DeploymentResourceStatusRunning DeploymentResourceStatusStopped DeploymentResourceStatus = original.DeploymentResourceStatusStopped DeploymentResourceStatusUnknown DeploymentResourceStatus = original.DeploymentResourceStatusUnknown @@ -118,6 +119,8 @@ type AppResourceCollectionIterator = original.AppResourceCollectionIterator type AppResourceCollectionPage = original.AppResourceCollectionPage type AppResourceProperties = original.AppResourceProperties type AppsClient = original.AppsClient +type AppsCreateOrUpdateFuture = original.AppsCreateOrUpdateFuture +type AppsUpdateFuture = original.AppsUpdateFuture type AvailableOperations = original.AvailableOperations type AvailableOperationsIterator = original.AvailableOperationsIterator type AvailableOperationsPage = original.AvailableOperationsPage diff --git a/services/preview/appplatform/mgmt/2019-05-01-preview/appplatform/appplatformapi/interfaces.go b/services/preview/appplatform/mgmt/2019-05-01-preview/appplatform/appplatformapi/interfaces.go index 3c3a7feb6811..db69e51e29ce 100644 --- a/services/preview/appplatform/mgmt/2019-05-01-preview/appplatform/appplatformapi/interfaces.go +++ b/services/preview/appplatform/mgmt/2019-05-01-preview/appplatform/appplatformapi/interfaces.go @@ -42,12 +42,12 @@ var _ ServicesClientAPI = (*appplatform.ServicesClient)(nil) // AppsClientAPI contains the set of methods on the AppsClient type. type AppsClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, appName string, appResource *appplatform.AppResource) (result appplatform.AppResource, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, appName string, appResource *appplatform.AppResource) (result appplatform.AppsCreateOrUpdateFuture, err error) Delete(ctx context.Context, resourceGroupName string, serviceName string, appName string) (result autorest.Response, err error) Get(ctx context.Context, resourceGroupName string, serviceName string, appName string, syncStatus string) (result appplatform.AppResource, err error) GetResourceUploadURL(ctx context.Context, resourceGroupName string, serviceName string, appName string) (result appplatform.ResourceUploadDefinition, err error) List(ctx context.Context, resourceGroupName string, serviceName string) (result appplatform.AppResourceCollectionPage, err error) - Update(ctx context.Context, resourceGroupName string, serviceName string, appName string, appResource *appplatform.AppResource) (result appplatform.AppResource, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, appName string, appResource *appplatform.AppResource) (result appplatform.AppsUpdateFuture, err error) } var _ AppsClientAPI = (*appplatform.AppsClient)(nil) diff --git a/services/preview/appplatform/mgmt/2019-05-01-preview/appplatform/apps.go b/services/preview/appplatform/mgmt/2019-05-01-preview/appplatform/apps.go index 69d6141f9fb0..decc2c25efcc 100644 --- a/services/preview/appplatform/mgmt/2019-05-01-preview/appplatform/apps.go +++ b/services/preview/appplatform/mgmt/2019-05-01-preview/appplatform/apps.go @@ -48,13 +48,13 @@ func NewAppsClientWithBaseURI(baseURI string, subscriptionID string) AppsClient // serviceName - the name of the Service resource. // appName - the name of the App resource. // appResource - parameters for the create or update operation -func (client AppsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, appName string, appResource *AppResource) (result AppResource, err error) { +func (client AppsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, appName string, appResource *AppResource) (result AppsCreateOrUpdateFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.CreateOrUpdate") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.Response() != nil { + sc = result.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -90,18 +90,12 @@ func (client AppsClient) CreateOrUpdate(ctx context.Context, resourceGroupName s return } - resp, err := client.CreateOrUpdateSender(req) + result, err = client.CreateOrUpdateSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "CreateOrUpdate", result.Response(), "Failure sending request") return } - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - return } @@ -134,9 +128,15 @@ func (client AppsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGro // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the // http.Response Body if it receives an error. -func (client AppsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { +func (client AppsClient) CreateOrUpdateSender(req *http.Request) (future AppsCreateOrUpdateFuture, err error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return } // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always @@ -145,7 +145,7 @@ func (client AppsClient) CreateOrUpdateResponder(resp *http.Response) (result Ap err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -518,13 +518,13 @@ func (client AppsClient) ListComplete(ctx context.Context, resourceGroupName str // serviceName - the name of the Service resource. // appName - the name of the App resource. // appResource - parameters for the update operation -func (client AppsClient) Update(ctx context.Context, resourceGroupName string, serviceName string, appName string, appResource *AppResource) (result AppResource, err error) { +func (client AppsClient) Update(ctx context.Context, resourceGroupName string, serviceName string, appName string, appResource *AppResource) (result AppsUpdateFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.Update") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.Response() != nil { + sc = result.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -535,18 +535,12 @@ func (client AppsClient) Update(ctx context.Context, resourceGroupName string, s return } - resp, err := client.UpdateSender(req) + result, err = client.UpdateSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "Update", result.Response(), "Failure sending request") return } - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "Update", resp, "Failure responding to request") - } - return } @@ -579,9 +573,15 @@ func (client AppsClient) UpdatePreparer(ctx context.Context, resourceGroupName s // UpdateSender sends the Update request. The method will close the // http.Response Body if it receives an error. -func (client AppsClient) UpdateSender(req *http.Request) (*http.Response, error) { +func (client AppsClient) UpdateSender(req *http.Request) (future AppsUpdateFuture, err error) { sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return } // UpdateResponder handles the response to the Update request. The method always @@ -590,7 +590,7 @@ func (client AppsClient) UpdateResponder(resp *http.Response) (result AppResourc err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} diff --git a/services/preview/appplatform/mgmt/2019-05-01-preview/appplatform/models.go b/services/preview/appplatform/mgmt/2019-05-01-preview/appplatform/models.go index 5a94eb8e7f3b..cf8d8d68fd8a 100644 --- a/services/preview/appplatform/mgmt/2019-05-01-preview/appplatform/models.go +++ b/services/preview/appplatform/mgmt/2019-05-01-preview/appplatform/models.go @@ -35,15 +35,19 @@ const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/appplatform/mgm type AppResourceProvisioningState string const ( + // Creating ... + Creating AppResourceProvisioningState = "Creating" // Failed ... Failed AppResourceProvisioningState = "Failed" // Succeeded ... Succeeded AppResourceProvisioningState = "Succeeded" + // Updating ... + Updating AppResourceProvisioningState = "Updating" ) // PossibleAppResourceProvisioningStateValues returns an array of possible values for the AppResourceProvisioningState const type. func PossibleAppResourceProvisioningStateValues() []AppResourceProvisioningState { - return []AppResourceProvisioningState{Failed, Succeeded} + return []AppResourceProvisioningState{Creating, Failed, Succeeded, Updating} } // ConfigServerState enumerates the values for config server state. @@ -75,15 +79,15 @@ const ( DeploymentResourceProvisioningStateCreating DeploymentResourceProvisioningState = "Creating" // DeploymentResourceProvisioningStateFailed ... DeploymentResourceProvisioningStateFailed DeploymentResourceProvisioningState = "Failed" - // DeploymentResourceProvisioningStateProcessing ... - DeploymentResourceProvisioningStateProcessing DeploymentResourceProvisioningState = "Processing" // DeploymentResourceProvisioningStateSucceeded ... DeploymentResourceProvisioningStateSucceeded DeploymentResourceProvisioningState = "Succeeded" + // DeploymentResourceProvisioningStateUpdating ... + DeploymentResourceProvisioningStateUpdating DeploymentResourceProvisioningState = "Updating" ) // PossibleDeploymentResourceProvisioningStateValues returns an array of possible values for the DeploymentResourceProvisioningState const type. func PossibleDeploymentResourceProvisioningStateValues() []DeploymentResourceProvisioningState { - return []DeploymentResourceProvisioningState{DeploymentResourceProvisioningStateCreating, DeploymentResourceProvisioningStateFailed, DeploymentResourceProvisioningStateProcessing, DeploymentResourceProvisioningStateSucceeded} + return []DeploymentResourceProvisioningState{DeploymentResourceProvisioningStateCreating, DeploymentResourceProvisioningStateFailed, DeploymentResourceProvisioningStateSucceeded, DeploymentResourceProvisioningStateUpdating} } // DeploymentResourceStatus enumerates the values for deployment resource status. @@ -96,8 +100,6 @@ const ( DeploymentResourceStatusCompiling DeploymentResourceStatus = "Compiling" // DeploymentResourceStatusFailed ... DeploymentResourceStatusFailed DeploymentResourceStatus = "Failed" - // DeploymentResourceStatusProcessing ... - DeploymentResourceStatusProcessing DeploymentResourceStatus = "Processing" // DeploymentResourceStatusRunning ... DeploymentResourceStatusRunning DeploymentResourceStatus = "Running" // DeploymentResourceStatusStopped ... @@ -110,7 +112,7 @@ const ( // PossibleDeploymentResourceStatusValues returns an array of possible values for the DeploymentResourceStatus const type. func PossibleDeploymentResourceStatusValues() []DeploymentResourceStatus { - return []DeploymentResourceStatus{DeploymentResourceStatusAllocating, DeploymentResourceStatusCompiling, DeploymentResourceStatusFailed, DeploymentResourceStatusProcessing, DeploymentResourceStatusRunning, DeploymentResourceStatusStopped, DeploymentResourceStatusUnknown, DeploymentResourceStatusUpgrading} + return []DeploymentResourceStatus{DeploymentResourceStatusAllocating, DeploymentResourceStatusCompiling, DeploymentResourceStatusFailed, DeploymentResourceStatusRunning, DeploymentResourceStatusStopped, DeploymentResourceStatusUnknown, DeploymentResourceStatusUpgrading} } // ProvisioningState enumerates the values for provisioning state. @@ -372,7 +374,7 @@ type AppResourceProperties struct { Public *bool `json:"public,omitempty"` // URL - READ-ONLY; URL of the App URL *string `json:"url,omitempty"` - // ProvisioningState - READ-ONLY; Provisioning state of the App. Possible values include: 'Succeeded', 'Failed' + // ProvisioningState - READ-ONLY; Provisioning state of the App. Possible values include: 'Succeeded', 'Failed', 'Creating', 'Updating' ProvisioningState AppResourceProvisioningState `json:"provisioningState,omitempty"` // ActiveDeploymentName - Name of the active deployment of the App ActiveDeploymentName *string `json:"activeDeploymentName,omitempty"` @@ -384,6 +386,63 @@ type AppResourceProperties struct { PersistentDisk *PersistentDisk `json:"persistentDisk,omitempty"` } +// AppsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AppsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *AppsCreateOrUpdateFuture) Result(client AppsClient) (ar AppResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "appplatform.AppsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("appplatform.AppsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ar.Response.Response, err = future.GetResult(sender); err == nil && ar.Response.Response.StatusCode != http.StatusNoContent { + ar, err = client.CreateOrUpdateResponder(ar.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "appplatform.AppsCreateOrUpdateFuture", "Result", ar.Response.Response, "Failure responding to request") + } + } + return +} + +// AppsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type AppsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *AppsUpdateFuture) Result(client AppsClient) (ar AppResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "appplatform.AppsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("appplatform.AppsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ar.Response.Response, err = future.GetResult(sender); err == nil && ar.Response.Response.StatusCode != http.StatusNoContent { + ar, err = client.UpdateResponder(ar.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "appplatform.AppsUpdateFuture", "Result", ar.Response.Response, "Failure responding to request") + } + } + return +} + // AvailableOperations available operations of the service type AvailableOperations struct { autorest.Response `json:"-"` @@ -983,11 +1042,11 @@ type DeploymentResourceProperties struct { Source *UserSourceInfo `json:"source,omitempty"` // AppName - READ-ONLY; App name of the deployment AppName *string `json:"appName,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the Deployment. Possible values include: 'DeploymentResourceProvisioningStateCreating', 'DeploymentResourceProvisioningStateUpdating', 'DeploymentResourceProvisioningStateSucceeded', 'DeploymentResourceProvisioningStateFailed' + ProvisioningState DeploymentResourceProvisioningState `json:"provisioningState,omitempty"` // DeploymentSettings - Deployment settings of the Deployment DeploymentSettings *DeploymentSettings `json:"deploymentSettings,omitempty"` - // ProvisioningState - READ-ONLY; Provisioning state of the Deployment. Possible values include: 'DeploymentResourceProvisioningStateCreating', 'DeploymentResourceProvisioningStateProcessing', 'DeploymentResourceProvisioningStateSucceeded', 'DeploymentResourceProvisioningStateFailed' - ProvisioningState DeploymentResourceProvisioningState `json:"provisioningState,omitempty"` - // Status - READ-ONLY; Status of the Deployment. Possible values include: 'DeploymentResourceStatusUnknown', 'DeploymentResourceStatusStopped', 'DeploymentResourceStatusRunning', 'DeploymentResourceStatusFailed', 'DeploymentResourceStatusProcessing', 'DeploymentResourceStatusAllocating', 'DeploymentResourceStatusUpgrading', 'DeploymentResourceStatusCompiling' + // Status - READ-ONLY; Status of the Deployment. Possible values include: 'DeploymentResourceStatusUnknown', 'DeploymentResourceStatusStopped', 'DeploymentResourceStatusRunning', 'DeploymentResourceStatusFailed', 'DeploymentResourceStatusAllocating', 'DeploymentResourceStatusUpgrading', 'DeploymentResourceStatusCompiling' Status DeploymentResourceStatus `json:"status,omitempty"` // Active - READ-ONLY; Indicates whether the Deployment is active Active *bool `json:"active,omitempty"`