diff --git a/services/maps/mgmt/2017-01-01/maps/CHANGELOG.md b/services/maps/mgmt/2017-01-01/maps/CHANGELOG.md new file mode 100644 index 000000000000..23b82d065568 --- /dev/null +++ b/services/maps/mgmt/2017-01-01/maps/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased Content + diff --git a/services/maps/mgmt/2017-01-01/maps/_meta.json b/services/maps/mgmt/2017-01-01/maps/_meta.json new file mode 100644 index 000000000000..e4f6b6de2c26 --- /dev/null +++ b/services/maps/mgmt/2017-01-01/maps/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "99b8adf4630b1ed5fca9568316939c08bd226200", + "readme": "/_/azure-rest-api-specs/specification/maps/resource-manager/readme.md", + "tag": "package-2017-01", + "use": "@microsoft.azure/autorest.go@2.1.180", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.180 --tag=package-2017-01 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/maps/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/maps/mgmt/2017-01-01/maps/accounts.go b/services/maps/mgmt/2017-01-01/maps/accounts.go new file mode 100644 index 000000000000..c5a6e4f4df83 --- /dev/null +++ b/services/maps/mgmt/2017-01-01/maps/accounts.go @@ -0,0 +1,802 @@ +package maps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccountsClient is the azure Maps +type AccountsClient struct { + BaseClient +} + +// NewAccountsClient creates an instance of the AccountsClient client. +func NewAccountsClient(subscriptionID string) AccountsClient { + return NewAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccountsClientWithBaseURI creates an instance of the AccountsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient { + return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a Maps Account. A Maps Account holds the keys which allow access to the Maps REST +// APIs. +// Parameters: +// resourceGroupName - the name of the Azure Resource Group. +// accountName - the name of the Maps Account. +// mapsAccountCreateParameters - the new or updated parameters for the Maps Account. +func (client AccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, mapsAccountCreateParameters AccountCreateParameters) (result Account, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: mapsAccountCreateParameters, + Constraints: []validation.Constraint{{Target: "mapsAccountCreateParameters.Location", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "mapsAccountCreateParameters.Sku", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "mapsAccountCreateParameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("maps.AccountsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, mapsAccountCreateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AccountsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, mapsAccountCreateParameters AccountCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-01-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("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}", pathParameters), + autorest.WithJSON(mapsAccountCreateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AccountsClient) CreateOrUpdateResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a Maps Account. +// Parameters: +// resourceGroupName - the name of the Azure Resource Group. +// accountName - the name of the Maps Account. +func (client AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a Maps Account. +// Parameters: +// resourceGroupName - the name of the Azure Resource Group. +// accountName - the name of the Maps Account. +func (client AccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result Account, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}", 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 AccountsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AccountsClient) GetResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get all Maps Accounts in a Resource Group +// Parameters: +// resourceGroupName - the name of the Azure Resource Group. +func (client AccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result Accounts, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AccountsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AccountsClient) ListByResourceGroupResponder(resp *http.Response) (result Accounts, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription get all Maps Accounts in a Subscription +func (client AccountsClient) ListBySubscription(ctx context.Context) (result Accounts, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListBySubscription", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client AccountsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Maps/accounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client AccountsClient) ListBySubscriptionResponder(resp *http.Response) (result Accounts, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListKeys get the keys to use with the Maps APIs. A key is used to authenticate and authorize access to the Maps REST +// APIs. Only one key is needed at a time; two are given to provide seamless key regeneration. +// Parameters: +// resourceGroupName - the name of the Azure Resource Group. +// accountName - the name of the Maps Account. +func (client AccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result AccountKeys, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListKeysPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListKeys", resp, "Failure sending request") + return + } + + result, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListKeys", resp, "Failure responding to request") + return + } + + return +} + +// ListKeysPreparer prepares the ListKeys request. +func (client AccountsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/listKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysSender sends the ListKeys request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) ListKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysResponder handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (client AccountsClient) ListKeysResponder(resp *http.Response) (result AccountKeys, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListOperations list operations available for the Maps Resource Provider +func (client AccountsClient) ListOperations(ctx context.Context) (result Operations, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListOperations") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListOperationsPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListOperations", nil, "Failure preparing request") + return + } + + resp, err := client.ListOperationsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListOperations", resp, "Failure sending request") + return + } + + result, err = client.ListOperationsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListOperations", resp, "Failure responding to request") + return + } + + return +} + +// ListOperationsPreparer prepares the ListOperations request. +func (client AccountsClient) ListOperationsPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2017-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Maps/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListOperationsSender sends the ListOperations request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) ListOperationsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListOperationsResponder handles the response to the ListOperations request. The method always +// closes the http.Response Body. +func (client AccountsClient) ListOperationsResponder(resp *http.Response) (result Operations, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Move moves Maps Accounts from one ResourceGroup (or Subscription) to another +// Parameters: +// resourceGroupName - the name of the resource group that contains Maps Account to move. +// moveRequest - the details of the Maps Account move. +func (client AccountsClient) Move(ctx context.Context, resourceGroupName string, moveRequest AccountsMoveRequest) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Move") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: moveRequest, + Constraints: []validation.Constraint{{Target: "moveRequest.TargetResourceGroup", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "moveRequest.ResourceIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("maps.AccountsClient", "Move", err.Error()) + } + + req, err := client.MovePreparer(ctx, resourceGroupName, moveRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Move", nil, "Failure preparing request") + return + } + + resp, err := client.MoveSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Move", resp, "Failure sending request") + return + } + + result, err = client.MoveResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Move", resp, "Failure responding to request") + return + } + + return +} + +// MovePreparer prepares the Move request. +func (client AccountsClient) MovePreparer(ctx context.Context, resourceGroupName string, moveRequest AccountsMoveRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-01-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("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/moveResources", pathParameters), + autorest.WithJSON(moveRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MoveSender sends the Move request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) MoveSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// MoveResponder handles the response to the Move request. The method always +// closes the http.Response Body. +func (client AccountsClient) MoveResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// RegenerateKeys regenerate either the primary or secondary key for use with the Maps APIs. The old key will stop +// working immediately. +// Parameters: +// resourceGroupName - the name of the Azure Resource Group. +// accountName - the name of the Maps Account. +// keySpecification - which key to regenerate: primary or secondary. +func (client AccountsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, accountName string, keySpecification KeySpecification) (result AccountKeys, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.RegenerateKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RegenerateKeysPreparer(ctx, resourceGroupName, accountName, keySpecification) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "RegenerateKeys", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "RegenerateKeys", resp, "Failure sending request") + return + } + + result, err = client.RegenerateKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "RegenerateKeys", resp, "Failure responding to request") + return + } + + return +} + +// RegenerateKeysPreparer prepares the RegenerateKeys request. +func (client AccountsClient) RegenerateKeysPreparer(ctx context.Context, resourceGroupName string, accountName string, keySpecification KeySpecification) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-01-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("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/regenerateKey", pathParameters), + autorest.WithJSON(keySpecification), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateKeysSender sends the RegenerateKeys request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) RegenerateKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RegenerateKeysResponder handles the response to the RegenerateKeys request. The method always +// closes the http.Response Body. +func (client AccountsClient) RegenerateKeysResponder(resp *http.Response) (result AccountKeys, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a Maps Account. Only a subset of the parameters may be updated after creation, such as Sku and Tags. +// Parameters: +// resourceGroupName - the name of the Azure Resource Group. +// accountName - the name of the Maps Account. +// mapsAccountUpdateParameters - the updated parameters for the Maps Account. +func (client AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, mapsAccountUpdateParameters AccountUpdateParameters) (result Account, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, mapsAccountUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, mapsAccountUpdateParameters AccountUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}", pathParameters), + autorest.WithJSON(mapsAccountUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/maps/mgmt/2017-01-01/maps/client.go b/services/maps/mgmt/2017-01-01/maps/client.go new file mode 100644 index 000000000000..d8ddf780e4cd --- /dev/null +++ b/services/maps/mgmt/2017-01-01/maps/client.go @@ -0,0 +1,41 @@ +// Package maps implements the Azure ARM Maps service API version 2017-01-01-preview. +// +// Azure Maps +package maps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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 Maps + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Maps. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/maps/mgmt/2017-01-01/maps/enums.go b/services/maps/mgmt/2017-01-01/maps/enums.go new file mode 100644 index 000000000000..677f73fb7d98 --- /dev/null +++ b/services/maps/mgmt/2017-01-01/maps/enums.go @@ -0,0 +1,22 @@ +package maps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// KeyType enumerates the values for key type. +type KeyType string + +const ( + // Primary ... + Primary KeyType = "primary" + // Secondary ... + Secondary KeyType = "secondary" +) + +// PossibleKeyTypeValues returns an array of possible values for the KeyType const type. +func PossibleKeyTypeValues() []KeyType { + return []KeyType{Primary, Secondary} +} diff --git a/services/maps/mgmt/2017-01-01/maps/mapsapi/interfaces.go b/services/maps/mgmt/2017-01-01/maps/mapsapi/interfaces.go new file mode 100644 index 000000000000..c505dfa94569 --- /dev/null +++ b/services/maps/mgmt/2017-01-01/maps/mapsapi/interfaces.go @@ -0,0 +1,29 @@ +package mapsapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/azure-sdk-for-go/services/maps/mgmt/2017-01-01/maps" + "github.com/Azure/go-autorest/autorest" +) + +// AccountsClientAPI contains the set of methods on the AccountsClient type. +type AccountsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, mapsAccountCreateParameters maps.AccountCreateParameters) (result maps.Account, err error) + Delete(ctx context.Context, resourceGroupName string, accountName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, accountName string) (result maps.Account, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result maps.Accounts, err error) + ListBySubscription(ctx context.Context) (result maps.Accounts, err error) + ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result maps.AccountKeys, err error) + ListOperations(ctx context.Context) (result maps.Operations, err error) + Move(ctx context.Context, resourceGroupName string, moveRequest maps.AccountsMoveRequest) (result autorest.Response, err error) + RegenerateKeys(ctx context.Context, resourceGroupName string, accountName string, keySpecification maps.KeySpecification) (result maps.AccountKeys, err error) + Update(ctx context.Context, resourceGroupName string, accountName string, mapsAccountUpdateParameters maps.AccountUpdateParameters) (result maps.Account, err error) +} + +var _ AccountsClientAPI = (*maps.AccountsClient)(nil) diff --git a/services/maps/mgmt/2017-01-01/maps/models.go b/services/maps/mgmt/2017-01-01/maps/models.go new file mode 100644 index 000000000000..7971e5faa9a3 --- /dev/null +++ b/services/maps/mgmt/2017-01-01/maps/models.go @@ -0,0 +1,211 @@ +package maps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/maps/mgmt/2017-01-01/maps" + +// Account an Azure resource which represents access to a suite of Maps REST APIs. +type Account struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; The location of the resource. + Location *string `json:"location,omitempty"` + // Tags - READ-ONLY; Gets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. + Tags map[string]*string `json:"tags"` + // Sku - READ-ONLY; The SKU of this account. + Sku *Sku `json:"sku,omitempty"` + // Properties - READ-ONLY; The map account properties. + Properties *AccountProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The fully qualified Maps Account resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the Maps Account, which is unique within a Resource Group. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Account. +func (a Account) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// AccountCreateParameters parameters used to create a new Maps Account. +type AccountCreateParameters struct { + // Location - The location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. + Tags map[string]*string `json:"tags"` + // Sku - The SKU of this account. + Sku *Sku `json:"sku,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccountCreateParameters. +func (acp AccountCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if acp.Location != nil { + objectMap["location"] = acp.Location + } + if acp.Tags != nil { + objectMap["tags"] = acp.Tags + } + if acp.Sku != nil { + objectMap["sku"] = acp.Sku + } + return json.Marshal(objectMap) +} + +// AccountKeys the set of keys which can be used to access the Maps REST APIs. Two keys are provided for +// key rotation without interruption. +type AccountKeys struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The full Azure resource identifier of the Maps Account. + ID *string `json:"id,omitempty"` + // PrimaryKey - READ-ONLY; The primary key for accessing the Maps REST APIs. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - READ-ONLY; The secondary key for accessing the Maps REST APIs. + SecondaryKey *string `json:"secondaryKey,omitempty"` +} + +// AccountProperties additional Map account properties +type AccountProperties struct { + // XMsClientID - A unique identifier for the maps account + XMsClientID *string `json:"x-ms-client-id,omitempty"` +} + +// Accounts a list of Maps Accounts. +type Accounts struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; a Maps Account. + Value *[]Account `json:"value,omitempty"` +} + +// AccountsMoveRequest the description of what resources to move between resource groups. +type AccountsMoveRequest struct { + // TargetResourceGroup - The name of the destination resource group. + TargetResourceGroup *string `json:"targetResourceGroup,omitempty"` + // ResourceIds - A list of resource names to move from the source resource group. + ResourceIds *[]string `json:"resourceIds,omitempty"` +} + +// AccountUpdateParameters parameters used to update an existing Maps Account. +type AccountUpdateParameters struct { + // Tags - Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. + Tags map[string]*string `json:"tags"` + // Sku - The SKU of this account. + Sku *Sku `json:"sku,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccountUpdateParameters. +func (aup AccountUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aup.Tags != nil { + objectMap["tags"] = aup.Tags + } + if aup.Sku != nil { + objectMap["sku"] = aup.Sku + } + return json.Marshal(objectMap) +} + +// Error this object is returned when an error occurs in the Maps API +type Error struct { + // Code - READ-ONLY; Error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; If available, a human readable description of the error. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; If available, the component generating the error. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; If available, a list of additional details about the error. + Details *[]ErrorDetailsItem `json:"details,omitempty"` +} + +// ErrorDetailsItem ... +type ErrorDetailsItem struct { + // Code - READ-ONLY; Error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; If available, a human readable description of the error. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; If available, the component generating the error. + Target *string `json:"target,omitempty"` +} + +// KeySpecification whether the operation refers to the primary or secondary key. +type KeySpecification struct { + // KeyType - Whether the operation refers to the primary or secondary key. Possible values include: 'Primary', 'Secondary' + KeyType KeyType `json:"keyType,omitempty"` +} + +// Operations the set of operations available for Maps. +type Operations struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; An operation available for Maps. + Value *[]OperationsValueItem `json:"value,omitempty"` +} + +// OperationsValueItem ... +type OperationsValueItem struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // Display - The human-readable description of the operation. + Display *OperationsValueItemDisplay `json:"display,omitempty"` + // Origin - READ-ONLY; The origin of the operation. + Origin *string `json:"origin,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationsValueItem. +func (oI OperationsValueItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if oI.Display != nil { + objectMap["display"] = oI.Display + } + return json.Marshal(objectMap) +} + +// OperationsValueItemDisplay the human-readable description of the operation. +type OperationsValueItemDisplay struct { + // Provider - READ-ONLY; Service provider: Microsoft Maps. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; The action that users can perform, based on their permission level. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; The description of the operation. + Description *string `json:"description,omitempty"` +} + +// Resource an Azure resource +type Resource struct { + // ID - READ-ONLY; The fully qualified Maps Account resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the Maps Account, which is unique within a Resource Group. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type. + Type *string `json:"type,omitempty"` +} + +// Sku the SKU of the Maps Account. +type Sku struct { + // Name - The name of the SKU, in standard format (such as S0). + Name *string `json:"name,omitempty"` + // Tier - READ-ONLY; Gets the sku tier. This is based on the SKU name. + Tier *string `json:"tier,omitempty"` +} + +// MarshalJSON is the custom marshaler for Sku. +func (s Sku) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.Name != nil { + objectMap["name"] = s.Name + } + return json.Marshal(objectMap) +} diff --git a/services/maps/mgmt/2017-01-01/maps/version.go b/services/maps/mgmt/2017-01-01/maps/version.go new file mode 100644 index 000000000000..957407bafab3 --- /dev/null +++ b/services/maps/mgmt/2017-01-01/maps/version.go @@ -0,0 +1,19 @@ +package maps + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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() + " maps/2017-01-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}