diff --git a/services/preview/subscription/mgmt/2019-10-01-preview/subscription/enums.go b/services/preview/subscription/mgmt/2019-10-01-preview/subscription/enums.go index ef5afc692989..1292284a1e27 100644 --- a/services/preview/subscription/mgmt/2019-10-01-preview/subscription/enums.go +++ b/services/preview/subscription/mgmt/2019-10-01-preview/subscription/enums.go @@ -32,6 +32,23 @@ func PossibleOfferTypeValues() []OfferType { return []OfferType{MSAZR0017P, MSAZR0148P} } +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Accepted ... + Accepted ProvisioningState = "Accepted" + // Failed ... + Failed ProvisioningState = "Failed" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Accepted, Failed, Succeeded} +} + // SpendingLimit enumerates the values for spending limit. type SpendingLimit string @@ -69,3 +86,18 @@ const ( func PossibleStateValues() []State { return []State{Deleted, Disabled, Enabled, PastDue, Warned} } + +// Workload enumerates the values for workload. +type Workload string + +const ( + // DevTest ... + DevTest Workload = "DevTest" + // Production ... + Production Workload = "Production" +) + +// PossibleWorkloadValues returns an array of possible values for the Workload const type. +func PossibleWorkloadValues() []Workload { + return []Workload{DevTest, Production} +} diff --git a/services/preview/subscription/mgmt/2019-10-01-preview/subscription/models.go b/services/preview/subscription/mgmt/2019-10-01-preview/subscription/models.go index 946b4c9dc617..8a5010908d5b 100644 --- a/services/preview/subscription/mgmt/2019-10-01-preview/subscription/models.go +++ b/services/preview/subscription/mgmt/2019-10-01-preview/subscription/models.go @@ -43,6 +43,34 @@ type CanceledSubscriptionID struct { Value *string `json:"value,omitempty"` } +// CreateAliasFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CreateAliasFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CreateAliasFuture) Result(client Client) (par PutAliasResponse, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.CreateAliasFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("subscription.CreateAliasFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if par.Response.Response, err = future.GetResult(sender); err == nil && par.Response.Response.StatusCode != http.StatusNoContent { + par, err = client.CreateAliasResponder(par.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.CreateAliasFuture", "Result", par.Response.Response, "Failure responding to request") + } + } + return +} + // CreateCspSubscriptionFuture an abstraction for monitoring and retrieving the results of a long-running // operation. type CreateCspSubscriptionFuture struct { @@ -187,6 +215,13 @@ type ErrorResponse struct { Message *string `json:"message,omitempty"` } +// ErrorResponseBody error response indicates that the service is not able to process the incoming request. The +// reason is provided in the error message. +type ErrorResponseBody struct { + // Error - The details of the error. + Error *ErrorResponse `json:"error,omitempty"` +} + // ListResult subscription list operation response. type ListResult struct { autorest.Response `json:"-"` @@ -489,6 +524,72 @@ type Policies struct { SpendingLimit SpendingLimit `json:"spendingLimit,omitempty"` } +// PutAliasListResult the list of aliases. +type PutAliasListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of alias. + Value *[]PutAliasResponse `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// PutAliasRequest the parameters required to create a new subscription. +type PutAliasRequest struct { + // Properties - Put alias request properties. + Properties *PutAliasRequestProperties `json:"properties,omitempty"` +} + +// PutAliasRequestProperties put subscription properties. +type PutAliasRequestProperties struct { + // DisplayName - The friendly name of the subscription. + DisplayName *string `json:"displayName,omitempty"` + // Workload - The workload type of the subscription. It can be either Production or DevTest. Possible values include: 'Production', 'DevTest' + Workload Workload `json:"workload,omitempty"` + // BillingScope - Determines whether subscription is fieldLed, partnerLed or LegacyEA + BillingScope *string `json:"billingScope,omitempty"` + // SubscriptionID - This parameter can be used to create alias for existing subscription Id + SubscriptionID *string `json:"subscriptionId,omitempty"` +} + +// PutAliasResponse subscription Information with the alias. +type PutAliasResponse struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Fully qualified ID for the alias resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Alias ID. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type, Microsoft.Subscription/aliases. + Type *string `json:"type,omitempty"` + // Properties - Put Alias response properties. + Properties *PutAliasResponseProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for PutAliasResponse. +func (par PutAliasResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if par.Properties != nil { + objectMap["properties"] = par.Properties + } + return json.Marshal(objectMap) +} + +// PutAliasResponseProperties put subscription creation result properties. +type PutAliasResponseProperties struct { + // SubscriptionID - READ-ONLY; Newly created subscription Id. + SubscriptionID *string `json:"subscriptionId,omitempty"` + // ProvisioningState - The provisioning state of the resource. Possible values include: 'Accepted', 'Succeeded', 'Failed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for PutAliasResponseProperties. +func (parp PutAliasResponseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if parp.ProvisioningState != "" { + objectMap["provisioningState"] = parp.ProvisioningState + } + return json.Marshal(objectMap) +} + // RenamedSubscriptionID the ID of the subscriptions that is being renamed type RenamedSubscriptionID struct { autorest.Response `json:"-"` diff --git a/services/preview/subscription/mgmt/2019-10-01-preview/subscription/subscription.go b/services/preview/subscription/mgmt/2019-10-01-preview/subscription/subscription.go index 01d3b21e2191..10d6c9d317a6 100644 --- a/services/preview/subscription/mgmt/2019-10-01-preview/subscription/subscription.go +++ b/services/preview/subscription/mgmt/2019-10-01-preview/subscription/subscription.go @@ -114,6 +114,89 @@ func (client Client) CancelResponder(resp *http.Response) (result CanceledSubscr return } +// CreateAlias create Alias Subscription. +// Parameters: +// aliasName - alias Name +func (client Client) CreateAlias(ctx context.Context, aliasName string, body PutAliasRequest) (result CreateAliasFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateAlias") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Properties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Properties.DisplayName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "body.Properties.BillingScope", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("subscription.Client", "CreateAlias", err.Error()) + } + + req, err := client.CreateAliasPreparer(ctx, aliasName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.Client", "CreateAlias", nil, "Failure preparing request") + return + } + + result, err = client.CreateAliasSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.Client", "CreateAlias", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateAliasPreparer prepares the CreateAlias request. +func (client Client) CreateAliasPreparer(ctx context.Context, aliasName string, body PutAliasRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "aliasName": autorest.Encode("path", aliasName), + } + + const APIVersion = "2019-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Subscription/aliases/{aliasName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateAliasSender sends the CreateAlias request. The method will close the +// http.Response Body if it receives an error. +func (client Client) CreateAliasSender(req *http.Request) (future CreateAliasFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateAliasResponder handles the response to the CreateAlias request. The method always +// closes the http.Response Body. +func (client Client) CreateAliasResponder(resp *http.Response) (result PutAliasResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // CreateCspSubscription the operation to create a new CSP subscription. // Parameters: // billingAccountName - the name of the Microsoft Customer Agreement billing account for which you want to @@ -365,6 +448,77 @@ func (client Client) CreateSubscriptionInEnrollmentAccountResponder(resp *http.R return } +// DeleteAlias delete Alias. +// Parameters: +// aliasName - alias Name +func (client Client) DeleteAlias(ctx context.Context, aliasName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.DeleteAlias") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteAliasPreparer(ctx, aliasName) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.Client", "DeleteAlias", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteAliasSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "subscription.Client", "DeleteAlias", resp, "Failure sending request") + return + } + + result, err = client.DeleteAliasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.Client", "DeleteAlias", resp, "Failure responding to request") + } + + return +} + +// DeleteAliasPreparer prepares the DeleteAlias request. +func (client Client) DeleteAliasPreparer(ctx context.Context, aliasName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "aliasName": autorest.Encode("path", aliasName), + } + + const APIVersion = "2019-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Subscription/aliases/{aliasName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteAliasSender sends the DeleteAlias request. The method will close the +// http.Response Body if it receives an error. +func (client Client) DeleteAliasSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteAliasResponder handles the response to the DeleteAlias request. The method always +// closes the http.Response Body. +func (client Client) DeleteAliasResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + // Enable the operation to enable a subscription // Parameters: // subscriptionID - subscription Id. @@ -437,6 +591,144 @@ func (client Client) EnableResponder(resp *http.Response) (result EnabledSubscri return } +// GetAlias get Alias Subscription. +// Parameters: +// aliasName - alias Name +func (client Client) GetAlias(ctx context.Context, aliasName string) (result PutAliasResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.GetAlias") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetAliasPreparer(ctx, aliasName) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.Client", "GetAlias", nil, "Failure preparing request") + return + } + + resp, err := client.GetAliasSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "subscription.Client", "GetAlias", resp, "Failure sending request") + return + } + + result, err = client.GetAliasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.Client", "GetAlias", resp, "Failure responding to request") + } + + return +} + +// GetAliasPreparer prepares the GetAlias request. +func (client Client) GetAliasPreparer(ctx context.Context, aliasName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "aliasName": autorest.Encode("path", aliasName), + } + + const APIVersion = "2019-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Subscription/aliases/{aliasName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetAliasSender sends the GetAlias request. The method will close the +// http.Response Body if it receives an error. +func (client Client) GetAliasSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetAliasResponder handles the response to the GetAlias request. The method always +// closes the http.Response Body. +func (client Client) GetAliasResponder(resp *http.Response) (result PutAliasResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListAlias get Alias Subscription. +func (client Client) ListAlias(ctx context.Context) (result PutAliasListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListAlias") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListAliasPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.Client", "ListAlias", nil, "Failure preparing request") + return + } + + resp, err := client.ListAliasSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "subscription.Client", "ListAlias", resp, "Failure sending request") + return + } + + result, err = client.ListAliasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.Client", "ListAlias", resp, "Failure responding to request") + } + + return +} + +// ListAliasPreparer prepares the ListAlias request. +func (client Client) ListAliasPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2019-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Subscription/aliases"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListAliasSender sends the ListAlias request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListAliasSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListAliasResponder handles the response to the ListAlias request. The method always +// closes the http.Response Body. +func (client Client) ListAliasResponder(resp *http.Response) (result PutAliasListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // Rename the operation to rename a subscription // Parameters: // subscriptionID - subscription Id. diff --git a/services/preview/subscription/mgmt/2019-10-01-preview/subscription/subscriptionapi/interfaces.go b/services/preview/subscription/mgmt/2019-10-01-preview/subscription/subscriptionapi/interfaces.go index 211bc4d88fa9..85dc0db1056b 100644 --- a/services/preview/subscription/mgmt/2019-10-01-preview/subscription/subscriptionapi/interfaces.go +++ b/services/preview/subscription/mgmt/2019-10-01-preview/subscription/subscriptionapi/interfaces.go @@ -20,6 +20,7 @@ package subscriptionapi import ( "context" "github.com/Azure/azure-sdk-for-go/services/preview/subscription/mgmt/2019-10-01-preview/subscription" + "github.com/Azure/go-autorest/autorest" ) // SubscriptionsClientAPI contains the set of methods on the SubscriptionsClient type. @@ -43,10 +44,14 @@ var _ TenantsClientAPI = (*subscription.TenantsClient)(nil) // ClientAPI contains the set of methods on the Client type. type ClientAPI interface { Cancel(ctx context.Context, subscriptionID string) (result subscription.CanceledSubscriptionID, err error) + CreateAlias(ctx context.Context, aliasName string, body subscription.PutAliasRequest) (result subscription.CreateAliasFuture, err error) CreateCspSubscription(ctx context.Context, billingAccountName string, customerName string, body subscription.ModernCspSubscriptionCreationParameters) (result subscription.CreateCspSubscriptionFuture, err error) CreateSubscription(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, body subscription.ModernSubscriptionCreationParameters) (result subscription.CreateSubscriptionFuture, err error) CreateSubscriptionInEnrollmentAccount(ctx context.Context, enrollmentAccountName string, body subscription.CreationParameters) (result subscription.CreateSubscriptionInEnrollmentAccountFuture, err error) + DeleteAlias(ctx context.Context, aliasName string) (result autorest.Response, err error) Enable(ctx context.Context, subscriptionID string) (result subscription.EnabledSubscriptionID, err error) + GetAlias(ctx context.Context, aliasName string) (result subscription.PutAliasResponse, err error) + ListAlias(ctx context.Context) (result subscription.PutAliasListResult, err error) Rename(ctx context.Context, subscriptionID string, body subscription.Name) (result subscription.RenamedSubscriptionID, err error) }