From 0af1b7cc0215110d9eb94f5671c17849356b8001 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 20 Mar 2018 14:46:39 -0700 Subject: [PATCH 1/3] Generated from 9a5ddb0a9715b1fcc0be692513773304b50122d3 (#1363) Getting the new stable subscriptions.json --- .../2018-03-01-preview/subscription/client.go | 49 ++++++ .../subscription/factory.go | 110 ++++++++++++ .../2018-03-01-preview/subscription/models.go | 164 ++++++++++++++++++ .../subscription/operations.go | 99 +++++++++++ .../subscription/operationsgroup.go | 99 +++++++++++ .../subscription/version.go | 30 ++++ 6 files changed, 551 insertions(+) create mode 100644 services/subscription/mgmt/2018-03-01-preview/subscription/client.go create mode 100644 services/subscription/mgmt/2018-03-01-preview/subscription/factory.go create mode 100644 services/subscription/mgmt/2018-03-01-preview/subscription/models.go create mode 100644 services/subscription/mgmt/2018-03-01-preview/subscription/operations.go create mode 100644 services/subscription/mgmt/2018-03-01-preview/subscription/operationsgroup.go create mode 100644 services/subscription/mgmt/2018-03-01-preview/subscription/version.go diff --git a/services/subscription/mgmt/2018-03-01-preview/subscription/client.go b/services/subscription/mgmt/2018-03-01-preview/subscription/client.go new file mode 100644 index 000000000000..6f23bddbef72 --- /dev/null +++ b/services/subscription/mgmt/2018-03-01-preview/subscription/client.go @@ -0,0 +1,49 @@ +// Package subscription implements the Azure ARM Subscription service API version 2018-03-01-preview. +// +// Subscription client provides an interface to create and manage Azure subscriptions programmatically. +package subscription + +// 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 ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Subscription + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Subscription. +type BaseClient struct { + autorest.Client + BaseURI string +} + +// New creates an instance of the BaseClient client. +func New() BaseClient { + return NewWithBaseURI(DefaultBaseURI) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + } +} diff --git a/services/subscription/mgmt/2018-03-01-preview/subscription/factory.go b/services/subscription/mgmt/2018-03-01-preview/subscription/factory.go new file mode 100644 index 000000000000..86ee7fc35524 --- /dev/null +++ b/services/subscription/mgmt/2018-03-01-preview/subscription/factory.go @@ -0,0 +1,110 @@ +package subscription + +// 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" +) + +// FactoryClient is the subscription client provides an interface to create and manage Azure subscriptions +// programmatically. +type FactoryClient struct { + BaseClient +} + +// NewFactoryClient creates an instance of the FactoryClient client. +func NewFactoryClient() FactoryClient { + return NewFactoryClientWithBaseURI(DefaultBaseURI) +} + +// NewFactoryClientWithBaseURI creates an instance of the FactoryClient client. +func NewFactoryClientWithBaseURI(baseURI string) FactoryClient { + return FactoryClient{NewWithBaseURI(baseURI)} +} + +// CreateSubscriptionInEnrollmentAccount creates an Azure subscription +// +// enrollmentAccountName is the name of the enrollment account to which the subscription will be billed. body is +// the subscription creation parameters. +func (client FactoryClient) CreateSubscriptionInEnrollmentAccount(ctx context.Context, enrollmentAccountName string, body CreationParameters) (result FactoryCreateSubscriptionInEnrollmentAccountFuture, err error) { + req, err := client.CreateSubscriptionInEnrollmentAccountPreparer(ctx, enrollmentAccountName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.FactoryClient", "CreateSubscriptionInEnrollmentAccount", nil, "Failure preparing request") + return + } + + result, err = client.CreateSubscriptionInEnrollmentAccountSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.FactoryClient", "CreateSubscriptionInEnrollmentAccount", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateSubscriptionInEnrollmentAccountPreparer prepares the CreateSubscriptionInEnrollmentAccount request. +func (client FactoryClient) CreateSubscriptionInEnrollmentAccountPreparer(ctx context.Context, enrollmentAccountName string, body CreationParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "enrollmentAccountName": autorest.Encode("path", enrollmentAccountName), + } + + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountName}/providers/Microsoft.Subscription/createSubscription", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSubscriptionInEnrollmentAccountSender sends the CreateSubscriptionInEnrollmentAccount request. The method will close the +// http.Response Body if it receives an error. +func (client FactoryClient) CreateSubscriptionInEnrollmentAccountSender(req *http.Request) (future FactoryCreateSubscriptionInEnrollmentAccountFuture, err error) { + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + 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.StatusAccepted)) + return +} + +// CreateSubscriptionInEnrollmentAccountResponder handles the response to the CreateSubscriptionInEnrollmentAccount request. The method always +// closes the http.Response Body. +func (client FactoryClient) CreateSubscriptionInEnrollmentAccountResponder(resp *http.Response) (result CreationResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/subscription/mgmt/2018-03-01-preview/subscription/models.go b/services/subscription/mgmt/2018-03-01-preview/subscription/models.go new file mode 100644 index 000000000000..84e918ed75d0 --- /dev/null +++ b/services/subscription/mgmt/2018-03-01-preview/subscription/models.go @@ -0,0 +1,164 @@ +package subscription + +// 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 ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OfferType enumerates the values for offer type. +type OfferType string + +const ( + // MSAZR0017P ... + MSAZR0017P OfferType = "MS-AZR-0017P" + // MSAZR0148P ... + MSAZR0148P OfferType = "MS-AZR-0148P" +) + +// PossibleOfferTypeValues returns an array of possible values for the OfferType const type. +func PossibleOfferTypeValues() []OfferType { + return []OfferType{MSAZR0017P, MSAZR0148P} +} + +// AdPrincipal active Directory Principal for subscription creation delegated permission +type AdPrincipal struct { + // ObjectID - Object id of the Principal + ObjectID *string `json:"objectId,omitempty"` +} + +// CreationParameters subscription Creation Parameters required to create a new Azure subscription. +type CreationParameters struct { + // DisplayName - The display name of the subscription. + DisplayName *string `json:"displayName,omitempty"` + // Owners - The list of principals that should be granted Owner access on the subscription. Principals should be of type User, Service Principal or Security Group. + Owners *[]AdPrincipal `json:"owners,omitempty"` + // OfferType - The offer type of the subscription. For example, MS-AZR-0017P (EnterpriseAgreement) and MS-AZR-0148P (EnterpriseAgreement devTest) are available. Only valid when creating a subscription in a enrollment account scope. Possible values include: 'MSAZR0017P', 'MSAZR0148P' + OfferType OfferType `json:"offerType,omitempty"` +} + +// CreationResult the created subscription object. +type CreationResult struct { + autorest.Response `json:"-"` + // SubscriptionLink - The link to the new subscription. + SubscriptionLink *string `json:"subscriptionLink,omitempty"` +} + +// ErrorResponse describes the format of Error response. +type ErrorResponse struct { + // Code - Error code + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// FactoryCreateSubscriptionInEnrollmentAccountFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type FactoryCreateSubscriptionInEnrollmentAccountFuture 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 FactoryCreateSubscriptionInEnrollmentAccountFuture) Result(client FactoryClient) (cr CreationResult, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.FactoryCreateSubscriptionInEnrollmentAccountFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return cr, azure.NewAsyncOpIncompleteError("subscription.FactoryCreateSubscriptionInEnrollmentAccountFuture") + } + if future.PollingMethod() == azure.PollingLocation { + cr, err = client.CreateSubscriptionInEnrollmentAccountResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.FactoryCreateSubscriptionInEnrollmentAccountFuture", "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, "subscription.FactoryCreateSubscriptionInEnrollmentAccountFuture", "Result", resp, "Failure sending request") + return + } + cr, err = client.CreateSubscriptionInEnrollmentAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.FactoryCreateSubscriptionInEnrollmentAccountFuture", "Result", resp, "Failure responding to request") + } + return +} + +// Operation REST API operation +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.Subscription + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: Profile, endpoint, etc. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult result of the request to list operations. It contains a list of operations and a URL link to +// get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of operations. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultType a list of pending subscription operations. +type OperationListResultType struct { + autorest.Response `json:"-"` + // Value - A list of pending SubscriptionOperations + Value *[]OperationType `json:"value,omitempty"` +} + +// OperationType status of the subscription POST operation. +type OperationType struct { + // ID - The operation Id. + ID *string `json:"id,omitempty"` + // Status - Status of the pending subscription + Status *string `json:"status,omitempty"` + // StatusDetail - Status Detail of the pending subscription + StatusDetail *string `json:"statusDetail,omitempty"` +} diff --git a/services/subscription/mgmt/2018-03-01-preview/subscription/operations.go b/services/subscription/mgmt/2018-03-01-preview/subscription/operations.go new file mode 100644 index 000000000000..31ad47bfad49 --- /dev/null +++ b/services/subscription/mgmt/2018-03-01-preview/subscription/operations.go @@ -0,0 +1,99 @@ +package subscription + +// 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" +) + +// OperationsClient is the subscription client provides an interface to create and manage Azure subscriptions +// programmatically. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient() OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI)} +} + +// List lists all of the available Microsoft.Subscription API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "subscription.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Subscription/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, 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/subscription/mgmt/2018-03-01-preview/subscription/operationsgroup.go b/services/subscription/mgmt/2018-03-01-preview/subscription/operationsgroup.go new file mode 100644 index 000000000000..c8b220cb535b --- /dev/null +++ b/services/subscription/mgmt/2018-03-01-preview/subscription/operationsgroup.go @@ -0,0 +1,99 @@ +package subscription + +// 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" +) + +// OperationsGroupClient is the subscription client provides an interface to create and manage Azure subscriptions +// programmatically. +type OperationsGroupClient struct { + BaseClient +} + +// NewOperationsGroupClient creates an instance of the OperationsGroupClient client. +func NewOperationsGroupClient() OperationsGroupClient { + return NewOperationsGroupClientWithBaseURI(DefaultBaseURI) +} + +// NewOperationsGroupClientWithBaseURI creates an instance of the OperationsGroupClient client. +func NewOperationsGroupClientWithBaseURI(baseURI string) OperationsGroupClient { + return OperationsGroupClient{NewWithBaseURI(baseURI)} +} + +// List lists all of the available pending Microsoft.Subscription API operations. +func (client OperationsGroupClient) List(ctx context.Context) (result OperationListResultType, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.OperationsGroupClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "subscription.OperationsGroupClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "subscription.OperationsGroupClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsGroupClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Subscription/subscriptionOperations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsGroupClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsGroupClient) ListResponder(resp *http.Response) (result OperationListResultType, 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/subscription/mgmt/2018-03-01-preview/subscription/version.go b/services/subscription/mgmt/2018-03-01-preview/subscription/version.go new file mode 100644 index 000000000000..e599f3c39cfe --- /dev/null +++ b/services/subscription/mgmt/2018-03-01-preview/subscription/version.go @@ -0,0 +1,30 @@ +package subscription + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " subscription/2018-03-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} From 8fb55ab97992a86389ce334bdceaff506458ea23 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 20 Mar 2018 14:56:14 -0700 Subject: [PATCH 2/3] Generated from 9a5ddb0a9715b1fcc0be692513773304b50122d3 (#1367) Getting the new stable subscriptions.json From 16ae0967750d6567c9d6f90c711c2cedd26a74ec Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 20 Mar 2018 14:57:35 -0700 Subject: [PATCH 3/3] Generated from 9a5ddb0a9715b1fcc0be692513773304b50122d3 (#1368) Getting the new stable subscriptions.json