diff --git a/profiles/latest/recoveryservices/mgmt/recoveryservices/models.go b/profiles/latest/recoveryservices/mgmt/recoveryservices/models.go index 490a9abc8a5c..4d0056a7d838 100644 --- a/profiles/latest/recoveryservices/mgmt/recoveryservices/models.go +++ b/profiles/latest/recoveryservices/mgmt/recoveryservices/models.go @@ -84,6 +84,7 @@ const ( type BaseClient = original.BaseClient type BasicResourceCertificateDetails = original.BasicResourceCertificateDetails type CertificateRequest = original.CertificateRequest +type CheckResourceNameAvailabilityClient = original.CheckResourceNameAvailabilityClient type ClientDiscoveryDisplay = original.ClientDiscoveryDisplay type ClientDiscoveryForLogSpecification = original.ClientDiscoveryForLogSpecification type ClientDiscoveryForProperties = original.ClientDiscoveryForProperties @@ -107,6 +108,9 @@ type Resource = original.Resource type ResourceCertificateAndAadDetails = original.ResourceCertificateAndAadDetails type ResourceCertificateAndAcsDetails = original.ResourceCertificateAndAcsDetails type ResourceCertificateDetails = original.ResourceCertificateDetails +type ResourceNameAvailabilityInput = original.ResourceNameAvailabilityInput +type ResourceNameAvailabilityResponse = original.ResourceNameAvailabilityResponse +type ResourceNameAvailabilityResponseResource = original.ResourceNameAvailabilityResponseResource type Sku = original.Sku type TrackedResource = original.TrackedResource type UpgradeDetails = original.UpgradeDetails @@ -128,6 +132,12 @@ type VaultsClient = original.VaultsClient func New(subscriptionID string) BaseClient { return original.New(subscriptionID) } +func NewCheckResourceNameAvailabilityClient(subscriptionID string) CheckResourceNameAvailabilityClient { + return original.NewCheckResourceNameAvailabilityClient(subscriptionID) +} +func NewCheckResourceNameAvailabilityClientWithBaseURI(baseURI string, subscriptionID string) CheckResourceNameAvailabilityClient { + return original.NewCheckResourceNameAvailabilityClientWithBaseURI(baseURI, subscriptionID) +} func NewClientDiscoveryResponseIterator(page ClientDiscoveryResponsePage) ClientDiscoveryResponseIterator { return original.NewClientDiscoveryResponseIterator(page) } diff --git a/profiles/preview/recoveryservices/mgmt/recoveryservices/models.go b/profiles/preview/recoveryservices/mgmt/recoveryservices/models.go index 028bc8e2187d..5f85036af4cc 100644 --- a/profiles/preview/recoveryservices/mgmt/recoveryservices/models.go +++ b/profiles/preview/recoveryservices/mgmt/recoveryservices/models.go @@ -84,6 +84,7 @@ const ( type BaseClient = original.BaseClient type BasicResourceCertificateDetails = original.BasicResourceCertificateDetails type CertificateRequest = original.CertificateRequest +type CheckResourceNameAvailabilityClient = original.CheckResourceNameAvailabilityClient type ClientDiscoveryDisplay = original.ClientDiscoveryDisplay type ClientDiscoveryForLogSpecification = original.ClientDiscoveryForLogSpecification type ClientDiscoveryForProperties = original.ClientDiscoveryForProperties @@ -107,6 +108,9 @@ type Resource = original.Resource type ResourceCertificateAndAadDetails = original.ResourceCertificateAndAadDetails type ResourceCertificateAndAcsDetails = original.ResourceCertificateAndAcsDetails type ResourceCertificateDetails = original.ResourceCertificateDetails +type ResourceNameAvailabilityInput = original.ResourceNameAvailabilityInput +type ResourceNameAvailabilityResponse = original.ResourceNameAvailabilityResponse +type ResourceNameAvailabilityResponseResource = original.ResourceNameAvailabilityResponseResource type Sku = original.Sku type TrackedResource = original.TrackedResource type UpgradeDetails = original.UpgradeDetails @@ -128,6 +132,12 @@ type VaultsClient = original.VaultsClient func New(subscriptionID string) BaseClient { return original.New(subscriptionID) } +func NewCheckResourceNameAvailabilityClient(subscriptionID string) CheckResourceNameAvailabilityClient { + return original.NewCheckResourceNameAvailabilityClient(subscriptionID) +} +func NewCheckResourceNameAvailabilityClientWithBaseURI(baseURI string, subscriptionID string) CheckResourceNameAvailabilityClient { + return original.NewCheckResourceNameAvailabilityClientWithBaseURI(baseURI, subscriptionID) +} func NewClientDiscoveryResponseIterator(page ClientDiscoveryResponsePage) ClientDiscoveryResponseIterator { return original.NewClientDiscoveryResponseIterator(page) } diff --git a/profiles/preview/recoveryservices/mgmt/recoveryservices/recoveryservicesapi/models.go b/profiles/preview/recoveryservices/mgmt/recoveryservices/recoveryservicesapi/models.go index b02ab93d03ba..647b81d36f07 100644 --- a/profiles/preview/recoveryservices/mgmt/recoveryservices/recoveryservicesapi/models.go +++ b/profiles/preview/recoveryservices/mgmt/recoveryservices/recoveryservicesapi/models.go @@ -21,6 +21,7 @@ package recoveryservicesapi import original "github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2016-06-01/recoveryservices/recoveryservicesapi" +type CheckResourceNameAvailabilityClientAPI = original.CheckResourceNameAvailabilityClientAPI type OperationsClientAPI = original.OperationsClientAPI type RegisteredIdentitiesClientAPI = original.RegisteredIdentitiesClientAPI type ReplicationUsagesClientAPI = original.ReplicationUsagesClientAPI diff --git a/services/recoveryservices/mgmt/2016-06-01/recoveryservices/checkresourcenameavailability.go b/services/recoveryservices/mgmt/2016-06-01/recoveryservices/checkresourcenameavailability.go new file mode 100644 index 000000000000..1d0736682bc8 --- /dev/null +++ b/services/recoveryservices/mgmt/2016-06-01/recoveryservices/checkresourcenameavailability.go @@ -0,0 +1,120 @@ +package recoveryservices + +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CheckResourceNameAvailabilityClient is the recovery Services Client +type CheckResourceNameAvailabilityClient struct { + BaseClient +} + +// NewCheckResourceNameAvailabilityClient creates an instance of the CheckResourceNameAvailabilityClient client. +func NewCheckResourceNameAvailabilityClient(subscriptionID string) CheckResourceNameAvailabilityClient { + return NewCheckResourceNameAvailabilityClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCheckResourceNameAvailabilityClientWithBaseURI creates an instance of the CheckResourceNameAvailabilityClient +// client. +func NewCheckResourceNameAvailabilityClientWithBaseURI(baseURI string, subscriptionID string) CheckResourceNameAvailabilityClient { + return CheckResourceNameAvailabilityClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Post sends the post request. +// Parameters: +// location - location of the resource +// input - contains information about Resource type and Resource name +func (client CheckResourceNameAvailabilityClient) Post(ctx context.Context, location string, input ResourceNameAvailabilityInput) (result ResourceNameAvailabilityResponseResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CheckResourceNameAvailabilityClient.Post") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.PostPreparer(ctx, location, input) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservices.CheckResourceNameAvailabilityClient", "Post", nil, "Failure preparing request") + return + } + + resp, err := client.PostSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservices.CheckResourceNameAvailabilityClient", "Post", resp, "Failure sending request") + return + } + + result, err = client.PostResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservices.CheckResourceNameAvailabilityClient", "Post", resp, "Failure responding to request") + } + + return +} + +// PostPreparer prepares the Post request. +func (client CheckResourceNameAvailabilityClient) PostPreparer(ctx context.Context, location string, input ResourceNameAvailabilityInput) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-06-01" + 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}/providers/Microsoft.RecoveryServices/locations/{location}/checkNameAvailability", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PostSender sends the Post request. The method will close the +// http.Response Body if it receives an error. +func (client CheckResourceNameAvailabilityClient) PostSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// PostResponder handles the response to the Post request. The method always +// closes the http.Response Body. +func (client CheckResourceNameAvailabilityClient) PostResponder(resp *http.Response) (result ResourceNameAvailabilityResponseResource, 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/recoveryservices/mgmt/2016-06-01/recoveryservices/models.go b/services/recoveryservices/mgmt/2016-06-01/recoveryservices/models.go index b8ef3152dcde..80494c829299 100644 --- a/services/recoveryservices/mgmt/2016-06-01/recoveryservices/models.go +++ b/services/recoveryservices/mgmt/2016-06-01/recoveryservices/models.go @@ -822,6 +822,37 @@ func (rcd ResourceCertificateDetails) AsBasicResourceCertificateDetails() (Basic return &rcd, true } +// ResourceNameAvailabilityInput resource information, as sent to the regional resource provider from +// Global RP. +type ResourceNameAvailabilityInput struct { + Type *string `json:"type,omitempty"` + Name *string `json:"name,omitempty"` +} + +// ResourceNameAvailabilityResponse response for check name availability API. Resource provider will set +// availability as true | false. +type ResourceNameAvailabilityResponse struct { + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *string `json:"reason,omitempty"` + Message *string `json:"message,omitempty"` +} + +// ResourceNameAvailabilityResponseResource response for check name availability API. Resource provider +// will set availability as true | false. +type ResourceNameAvailabilityResponseResource struct { + autorest.Response `json:"-"` + // Properties - ResourceNameAvailabilityResponseResource properties + Properties *ResourceNameAvailabilityResponse `json:"properties,omitempty"` + // ID - Resource Id represents the complete path to the resource. + ID *string `json:"id,omitempty"` + // Name - Resource name associated with the resource. + Name *string `json:"name,omitempty"` + // Type - Resource type represents the complete path of the form Namespace/ResourceType/ResourceType/... + Type *string `json:"type,omitempty"` + // ETag - Optional ETag. + ETag *string `json:"eTag,omitempty"` +} + // Sku identifies the unique system identifier for each Azure resource. type Sku struct { // Name - The Sku name. Possible values include: 'Standard', 'RS0' diff --git a/services/recoveryservices/mgmt/2016-06-01/recoveryservices/recoveryservicesapi/interfaces.go b/services/recoveryservices/mgmt/2016-06-01/recoveryservices/recoveryservicesapi/interfaces.go index 9a5ae70ee520..66147cf4f4e3 100644 --- a/services/recoveryservices/mgmt/2016-06-01/recoveryservices/recoveryservicesapi/interfaces.go +++ b/services/recoveryservices/mgmt/2016-06-01/recoveryservices/recoveryservicesapi/interfaces.go @@ -44,6 +44,13 @@ type ReplicationUsagesClientAPI interface { var _ ReplicationUsagesClientAPI = (*recoveryservices.ReplicationUsagesClient)(nil) +// CheckResourceNameAvailabilityClientAPI contains the set of methods on the CheckResourceNameAvailabilityClient type. +type CheckResourceNameAvailabilityClientAPI interface { + Post(ctx context.Context, location string, input recoveryservices.ResourceNameAvailabilityInput) (result recoveryservices.ResourceNameAvailabilityResponseResource, err error) +} + +var _ CheckResourceNameAvailabilityClientAPI = (*recoveryservices.CheckResourceNameAvailabilityClient)(nil) + // VaultsClientAPI contains the set of methods on the VaultsClient type. type VaultsClientAPI interface { CreateOrUpdate(ctx context.Context, resourceGroupName string, vaultName string, vault recoveryservices.Vault) (result recoveryservices.Vault, err error)