From 3fd08e2c0f6de12f2ed0765087bd6e0575b20222 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 18 May 2021 02:26:34 +0000 Subject: [PATCH] CodeGen from PR 14215 in Azure/azure-rest-api-specs add AVS 2021-06-01 API (#14215) * add AVS 2021-06-01 API * add cmdlets custom word * rename ScriptCmdlet cmdletDescription to description (#14218) * Adding optional to the script parameter (#14437) Co-authored-by: David Becher Co-authored-by: david becher Co-authored-by: David Becher --- services/avs/mgmt/2021-06-01/avs/CHANGELOG.md | 2 + services/avs/mgmt/2021-06-01/avs/_meta.json | 11 + services/avs/mgmt/2021-06-01/avs/addons.go | 430 + .../avs/mgmt/2021-06-01/avs/authorizations.go | 431 + .../mgmt/2021-06-01/avs/avsapi/interfaces.go | 207 + services/avs/mgmt/2021-06-01/avs/client.go | 41 + .../avs/mgmt/2021-06-01/avs/cloudlinks.go | 430 + services/avs/mgmt/2021-06-01/avs/clusters.go | 526 ++ .../avs/mgmt/2021-06-01/avs/datastores.go | 447 + services/avs/mgmt/2021-06-01/avs/enums.go | 676 ++ .../2021-06-01/avs/globalreachconnections.go | 431 + .../mgmt/2021-06-01/avs/hcxenterprisesites.go | 428 + services/avs/mgmt/2021-06-01/avs/locations.go | 192 + services/avs/mgmt/2021-06-01/avs/models.go | 8344 +++++++++++++++++ .../avs/mgmt/2021-06-01/avs/operations.go | 140 + .../avs/mgmt/2021-06-01/avs/privateclouds.go | 897 ++ .../avs/mgmt/2021-06-01/avs/scriptcmdlets.go | 253 + .../mgmt/2021-06-01/avs/scriptexecutions.go | 529 ++ .../avs/mgmt/2021-06-01/avs/scriptpackages.go | 248 + services/avs/mgmt/2021-06-01/avs/version.go | 19 + .../mgmt/2021-06-01/avs/workloadnetworks.go | 3809 ++++++++ 21 files changed, 18491 insertions(+) create mode 100644 services/avs/mgmt/2021-06-01/avs/CHANGELOG.md create mode 100644 services/avs/mgmt/2021-06-01/avs/_meta.json create mode 100644 services/avs/mgmt/2021-06-01/avs/addons.go create mode 100644 services/avs/mgmt/2021-06-01/avs/authorizations.go create mode 100644 services/avs/mgmt/2021-06-01/avs/avsapi/interfaces.go create mode 100644 services/avs/mgmt/2021-06-01/avs/client.go create mode 100644 services/avs/mgmt/2021-06-01/avs/cloudlinks.go create mode 100644 services/avs/mgmt/2021-06-01/avs/clusters.go create mode 100644 services/avs/mgmt/2021-06-01/avs/datastores.go create mode 100644 services/avs/mgmt/2021-06-01/avs/enums.go create mode 100644 services/avs/mgmt/2021-06-01/avs/globalreachconnections.go create mode 100644 services/avs/mgmt/2021-06-01/avs/hcxenterprisesites.go create mode 100644 services/avs/mgmt/2021-06-01/avs/locations.go create mode 100644 services/avs/mgmt/2021-06-01/avs/models.go create mode 100644 services/avs/mgmt/2021-06-01/avs/operations.go create mode 100644 services/avs/mgmt/2021-06-01/avs/privateclouds.go create mode 100644 services/avs/mgmt/2021-06-01/avs/scriptcmdlets.go create mode 100644 services/avs/mgmt/2021-06-01/avs/scriptexecutions.go create mode 100644 services/avs/mgmt/2021-06-01/avs/scriptpackages.go create mode 100644 services/avs/mgmt/2021-06-01/avs/version.go create mode 100644 services/avs/mgmt/2021-06-01/avs/workloadnetworks.go diff --git a/services/avs/mgmt/2021-06-01/avs/CHANGELOG.md b/services/avs/mgmt/2021-06-01/avs/CHANGELOG.md new file mode 100644 index 000000000000..23b82d065568 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased Content + diff --git a/services/avs/mgmt/2021-06-01/avs/_meta.json b/services/avs/mgmt/2021-06-01/avs/_meta.json new file mode 100644 index 000000000000..67adea65941b --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "1d53085a5bf835189b3ec91126edb093e1c24fee", + "readme": "/_/azure-rest-api-specs/specification/vmware/resource-manager/readme.md", + "tag": "package-2021-06-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-2021-06-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/vmware/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/avs/mgmt/2021-06-01/avs/addons.go b/services/avs/mgmt/2021-06-01/avs/addons.go new file mode 100644 index 000000000000..067753613b32 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/addons.go @@ -0,0 +1,430 @@ +package avs + +// 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" +) + +// AddonsClient is the azure VMware Solution API +type AddonsClient struct { + BaseClient +} + +// NewAddonsClient creates an instance of the AddonsClient client. +func NewAddonsClient(subscriptionID string) AddonsClient { + return NewAddonsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAddonsClientWithBaseURI creates an instance of the AddonsClient 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 NewAddonsClientWithBaseURI(baseURI string, subscriptionID string) AddonsClient { + return AddonsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// addonName - name of the addon for the private cloud +// addon - a addon in the private cloud +func (client AddonsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string, addon Addon) (result AddonsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AddonsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.AddonsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, addonName, addon) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AddonsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AddonsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AddonsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string, addon Addon) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "addonName": autorest.Encode("path", addonName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/addons/{addonName}", pathParameters), + autorest.WithJSON(addon), + 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 AddonsClient) CreateOrUpdateSender(req *http.Request) (future AddonsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AddonsClient) CreateOrUpdateResponder(resp *http.Response) (result Addon, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// addonName - name of the addon for the private cloud +func (client AddonsClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string) (result AddonsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AddonsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.AddonsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, addonName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AddonsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AddonsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AddonsClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "addonName": autorest.Encode("path", addonName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}", 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 AddonsClient) DeleteSender(req *http.Request) (future AddonsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AddonsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// addonName - name of the addon for the private cloud +func (client AddonsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string) (result Addon, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AddonsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.AddonsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, addonName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AddonsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.AddonsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AddonsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AddonsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "addonName": autorest.Encode("path", addonName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}", 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 AddonsClient) 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 AddonsClient) GetResponder(resp *http.Response) (result Addon, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client AddonsClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result AddonListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AddonsClient.List") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.AddonsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AddonsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.AddonsClient", "List", resp, "Failure sending request") + return + } + + result.al, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AddonsClient", "List", resp, "Failure responding to request") + return + } + if result.al.hasNextLink() && result.al.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client AddonsClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons", pathParameters), + 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 AddonsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AddonsClient) ListResponder(resp *http.Response) (result AddonList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AddonsClient) listNextResults(ctx context.Context, lastResults AddonList) (result AddonList, err error) { + req, err := lastResults.addonListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.AddonsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.AddonsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AddonsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AddonsClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result AddonListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AddonsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, privateCloudName) + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/authorizations.go b/services/avs/mgmt/2021-06-01/avs/authorizations.go new file mode 100644 index 000000000000..951118e88f30 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/authorizations.go @@ -0,0 +1,431 @@ +package avs + +// 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" +) + +// AuthorizationsClient is the azure VMware Solution API +type AuthorizationsClient struct { + BaseClient +} + +// NewAuthorizationsClient creates an instance of the AuthorizationsClient client. +func NewAuthorizationsClient(subscriptionID string) AuthorizationsClient { + return NewAuthorizationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAuthorizationsClientWithBaseURI creates an instance of the AuthorizationsClient 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 NewAuthorizationsClientWithBaseURI(baseURI string, subscriptionID string) AuthorizationsClient { + return AuthorizationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// authorizationName - name of the ExpressRoute Circuit Authorization in the private cloud +// authorization - an ExpressRoute Circuit Authorization +func (client AuthorizationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization ExpressRouteAuthorization) (result AuthorizationsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.AuthorizationsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, authorizationName, authorization) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AuthorizationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization ExpressRouteAuthorization) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationName": autorest.Encode("path", authorizationName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + authorization.ExpressRouteAuthorizationProperties = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", pathParameters), + autorest.WithJSON(authorization), + 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 AuthorizationsClient) CreateOrUpdateSender(req *http.Request) (future AuthorizationsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AuthorizationsClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteAuthorization, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// authorizationName - name of the ExpressRoute Circuit Authorization in the private cloud +func (client AuthorizationsClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result AuthorizationsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.AuthorizationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, authorizationName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AuthorizationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationName": autorest.Encode("path", authorizationName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", 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 AuthorizationsClient) DeleteSender(req *http.Request) (future AuthorizationsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AuthorizationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// authorizationName - name of the ExpressRoute Circuit Authorization in the private cloud +func (client AuthorizationsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result ExpressRouteAuthorization, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.AuthorizationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, authorizationName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AuthorizationsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationName": autorest.Encode("path", authorizationName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", 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 AuthorizationsClient) 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 AuthorizationsClient) GetResponder(resp *http.Response) (result ExpressRouteAuthorization, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client AuthorizationsClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result ExpressRouteAuthorizationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.List") + defer func() { + sc := -1 + if result.eral.Response.Response != nil { + sc = result.eral.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.AuthorizationsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.eral.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "List", resp, "Failure sending request") + return + } + + result.eral, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "List", resp, "Failure responding to request") + return + } + if result.eral.hasNextLink() && result.eral.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client AuthorizationsClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations", pathParameters), + 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 AuthorizationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AuthorizationsClient) ListResponder(resp *http.Response) (result ExpressRouteAuthorizationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AuthorizationsClient) listNextResults(ctx context.Context, lastResults ExpressRouteAuthorizationList) (result ExpressRouteAuthorizationList, err error) { + req, err := lastResults.expressRouteAuthorizationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AuthorizationsClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result ExpressRouteAuthorizationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, privateCloudName) + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/avsapi/interfaces.go b/services/avs/mgmt/2021-06-01/avs/avsapi/interfaces.go new file mode 100644 index 000000000000..0aa55ea4b4bf --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/avsapi/interfaces.go @@ -0,0 +1,207 @@ +package avsapi + +// 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/avs/mgmt/2021-06-01/avs" + "github.com/Azure/go-autorest/autorest" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result avs.OperationListPage, err error) + ListComplete(ctx context.Context) (result avs.OperationListIterator, err error) +} + +var _ OperationsClientAPI = (*avs.OperationsClient)(nil) + +// LocationsClientAPI contains the set of methods on the LocationsClient type. +type LocationsClientAPI interface { + CheckQuotaAvailability(ctx context.Context, location string) (result avs.Quota, err error) + CheckTrialAvailability(ctx context.Context, location string) (result avs.Trial, err error) +} + +var _ LocationsClientAPI = (*avs.LocationsClient)(nil) + +// PrivateCloudsClientAPI contains the set of methods on the PrivateCloudsClient type. +type PrivateCloudsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud avs.PrivateCloud) (result avs.PrivateCloudsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.PrivateCloudsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.PrivateCloud, err error) + List(ctx context.Context, resourceGroupName string) (result avs.PrivateCloudListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string) (result avs.PrivateCloudListIterator, err error) + ListAdminCredentials(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.AdminCredentials, err error) + ListInSubscription(ctx context.Context) (result avs.PrivateCloudListPage, err error) + ListInSubscriptionComplete(ctx context.Context) (result avs.PrivateCloudListIterator, err error) + RotateNsxtPassword(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.PrivateCloudsRotateNsxtPasswordFuture, err error) + RotateVcenterPassword(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.PrivateCloudsRotateVcenterPasswordFuture, err error) + Update(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate avs.PrivateCloudUpdate) (result avs.PrivateCloudsUpdateFuture, err error) +} + +var _ PrivateCloudsClientAPI = (*avs.PrivateCloudsClient)(nil) + +// ClustersClientAPI contains the set of methods on the ClustersClient type. +type ClustersClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster avs.Cluster) (result avs.ClustersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result avs.ClustersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result avs.Cluster, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ClusterListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ClusterListIterator, err error) + Update(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate avs.ClusterUpdate) (result avs.ClustersUpdateFuture, err error) +} + +var _ ClustersClientAPI = (*avs.ClustersClient)(nil) + +// DatastoresClientAPI contains the set of methods on the DatastoresClient type. +type DatastoresClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string, datastore avs.Datastore) (result avs.DatastoresCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string) (result avs.DatastoresDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string) (result avs.Datastore, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result avs.DatastoreListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result avs.DatastoreListIterator, err error) +} + +var _ DatastoresClientAPI = (*avs.DatastoresClient)(nil) + +// HcxEnterpriseSitesClientAPI contains the set of methods on the HcxEnterpriseSitesClient type. +type HcxEnterpriseSitesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite avs.HcxEnterpriseSite) (result avs.HcxEnterpriseSite, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result avs.HcxEnterpriseSite, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.HcxEnterpriseSiteListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.HcxEnterpriseSiteListIterator, err error) +} + +var _ HcxEnterpriseSitesClientAPI = (*avs.HcxEnterpriseSitesClient)(nil) + +// AuthorizationsClientAPI contains the set of methods on the AuthorizationsClient type. +type AuthorizationsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization avs.ExpressRouteAuthorization) (result avs.AuthorizationsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result avs.AuthorizationsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result avs.ExpressRouteAuthorization, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ExpressRouteAuthorizationListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ExpressRouteAuthorizationListIterator, err error) +} + +var _ AuthorizationsClientAPI = (*avs.AuthorizationsClient)(nil) + +// GlobalReachConnectionsClientAPI contains the set of methods on the GlobalReachConnectionsClient type. +type GlobalReachConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string, globalReachConnection avs.GlobalReachConnection) (result avs.GlobalReachConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string) (result avs.GlobalReachConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string) (result avs.GlobalReachConnection, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.GlobalReachConnectionListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.GlobalReachConnectionListIterator, err error) +} + +var _ GlobalReachConnectionsClientAPI = (*avs.GlobalReachConnectionsClient)(nil) + +// WorkloadNetworksClientAPI contains the set of methods on the WorkloadNetworksClient type. +type WorkloadNetworksClientAPI interface { + CreateDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp avs.WorkloadNetworkDhcp) (result avs.WorkloadNetworksCreateDhcpFuture, err error) + CreateDNSService(ctx context.Context, resourceGroupName string, privateCloudName string, DNSServiceID string, workloadNetworkDNSService avs.WorkloadNetworkDNSService) (result avs.WorkloadNetworksCreateDNSServiceFuture, err error) + CreateDNSZone(ctx context.Context, resourceGroupName string, privateCloudName string, DNSZoneID string, workloadNetworkDNSZone avs.WorkloadNetworkDNSZone) (result avs.WorkloadNetworksCreateDNSZoneFuture, err error) + CreatePortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring avs.WorkloadNetworkPortMirroring) (result avs.WorkloadNetworksCreatePortMirroringFuture, err error) + CreatePublicIP(ctx context.Context, resourceGroupName string, privateCloudName string, publicIPID string, workloadNetworkPublicIP avs.WorkloadNetworkPublicIP) (result avs.WorkloadNetworksCreatePublicIPFuture, err error) + CreateSegments(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, workloadNetworkSegment avs.WorkloadNetworkSegment) (result avs.WorkloadNetworksCreateSegmentsFuture, err error) + CreateVMGroup(ctx context.Context, resourceGroupName string, privateCloudName string, VMGroupID string, workloadNetworkVMGroup avs.WorkloadNetworkVMGroup) (result avs.WorkloadNetworksCreateVMGroupFuture, err error) + DeleteDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string) (result avs.WorkloadNetworksDeleteDhcpFuture, err error) + DeleteDNSService(ctx context.Context, resourceGroupName string, DNSServiceID string, privateCloudName string) (result avs.WorkloadNetworksDeleteDNSServiceFuture, err error) + DeleteDNSZone(ctx context.Context, resourceGroupName string, DNSZoneID string, privateCloudName string) (result avs.WorkloadNetworksDeleteDNSZoneFuture, err error) + DeletePortMirroring(ctx context.Context, resourceGroupName string, portMirroringID string, privateCloudName string) (result avs.WorkloadNetworksDeletePortMirroringFuture, err error) + DeletePublicIP(ctx context.Context, resourceGroupName string, publicIPID string, privateCloudName string) (result avs.WorkloadNetworksDeletePublicIPFuture, err error) + DeleteSegment(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string) (result avs.WorkloadNetworksDeleteSegmentFuture, err error) + DeleteVMGroup(ctx context.Context, resourceGroupName string, VMGroupID string, privateCloudName string) (result avs.WorkloadNetworksDeleteVMGroupFuture, err error) + GetDhcp(ctx context.Context, resourceGroupName string, dhcpID string, privateCloudName string) (result avs.WorkloadNetworkDhcp, err error) + GetDNSService(ctx context.Context, resourceGroupName string, privateCloudName string, DNSServiceID string) (result avs.WorkloadNetworkDNSService, err error) + GetDNSZone(ctx context.Context, resourceGroupName string, privateCloudName string, DNSZoneID string) (result avs.WorkloadNetworkDNSZone, err error) + GetGateway(ctx context.Context, resourceGroupName string, privateCloudName string, gatewayID string) (result avs.WorkloadNetworkGateway, err error) + GetPortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string) (result avs.WorkloadNetworkPortMirroring, err error) + GetPublicIP(ctx context.Context, resourceGroupName string, privateCloudName string, publicIPID string) (result avs.WorkloadNetworkPublicIP, err error) + GetSegment(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string) (result avs.WorkloadNetworkSegment, err error) + GetVirtualMachine(ctx context.Context, resourceGroupName string, privateCloudName string, virtualMachineID string) (result avs.WorkloadNetworkVirtualMachine, err error) + GetVMGroup(ctx context.Context, resourceGroupName string, privateCloudName string, VMGroupID string) (result avs.WorkloadNetworkVMGroup, err error) + ListDhcp(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkDhcpListPage, err error) + ListDhcpComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkDhcpListIterator, err error) + ListDNSServices(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkDNSServicesListPage, err error) + ListDNSServicesComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkDNSServicesListIterator, err error) + ListDNSZones(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkDNSZonesListPage, err error) + ListDNSZonesComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkDNSZonesListIterator, err error) + ListGateways(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkGatewayListPage, err error) + ListGatewaysComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkGatewayListIterator, err error) + ListPortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkPortMirroringListPage, err error) + ListPortMirroringComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkPortMirroringListIterator, err error) + ListPublicIPs(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkPublicIPsListPage, err error) + ListPublicIPsComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkPublicIPsListIterator, err error) + ListSegments(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkSegmentsListPage, err error) + ListSegmentsComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkSegmentsListIterator, err error) + ListVirtualMachines(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkVirtualMachinesListPage, err error) + ListVirtualMachinesComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkVirtualMachinesListIterator, err error) + ListVMGroups(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkVMGroupsListPage, err error) + ListVMGroupsComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.WorkloadNetworkVMGroupsListIterator, err error) + UpdateDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp avs.WorkloadNetworkDhcp) (result avs.WorkloadNetworksUpdateDhcpFuture, err error) + UpdateDNSService(ctx context.Context, resourceGroupName string, privateCloudName string, DNSServiceID string, workloadNetworkDNSService avs.WorkloadNetworkDNSService) (result avs.WorkloadNetworksUpdateDNSServiceFuture, err error) + UpdateDNSZone(ctx context.Context, resourceGroupName string, privateCloudName string, DNSZoneID string, workloadNetworkDNSZone avs.WorkloadNetworkDNSZone) (result avs.WorkloadNetworksUpdateDNSZoneFuture, err error) + UpdatePortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring avs.WorkloadNetworkPortMirroring) (result avs.WorkloadNetworksUpdatePortMirroringFuture, err error) + UpdateSegments(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, workloadNetworkSegment avs.WorkloadNetworkSegment) (result avs.WorkloadNetworksUpdateSegmentsFuture, err error) + UpdateVMGroup(ctx context.Context, resourceGroupName string, privateCloudName string, VMGroupID string, workloadNetworkVMGroup avs.WorkloadNetworkVMGroup) (result avs.WorkloadNetworksUpdateVMGroupFuture, err error) +} + +var _ WorkloadNetworksClientAPI = (*avs.WorkloadNetworksClient)(nil) + +// CloudLinksClientAPI contains the set of methods on the CloudLinksClient type. +type CloudLinksClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string, cloudLink avs.CloudLink) (result avs.CloudLinksCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string) (result avs.CloudLinksDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string) (result avs.CloudLink, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.CloudLinkListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.CloudLinkListIterator, err error) +} + +var _ CloudLinksClientAPI = (*avs.CloudLinksClient)(nil) + +// AddonsClientAPI contains the set of methods on the AddonsClient type. +type AddonsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string, addon avs.Addon) (result avs.AddonsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string) (result avs.AddonsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string, addonName string) (result avs.Addon, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.AddonListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.AddonListIterator, err error) +} + +var _ AddonsClientAPI = (*avs.AddonsClient)(nil) + +// ScriptPackagesClientAPI contains the set of methods on the ScriptPackagesClient type. +type ScriptPackagesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string) (result avs.ScriptPackage, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ScriptPackagesListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ScriptPackagesListIterator, err error) +} + +var _ ScriptPackagesClientAPI = (*avs.ScriptPackagesClient)(nil) + +// ScriptCmdletsClientAPI contains the set of methods on the ScriptCmdletsClient type. +type ScriptCmdletsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string, scriptCmdletName string) (result avs.ScriptCmdlet, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string) (result avs.ScriptCmdletsListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string) (result avs.ScriptCmdletsListIterator, err error) +} + +var _ ScriptCmdletsClientAPI = (*avs.ScriptCmdletsClient)(nil) + +// ScriptExecutionsClientAPI contains the set of methods on the ScriptExecutionsClient type. +type ScriptExecutionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, scriptExecution avs.ScriptExecution) (result avs.ScriptExecutionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string) (result avs.ScriptExecutionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string) (result avs.ScriptExecution, err error) + GetExecutionLogs(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, scriptOutputStreamType []avs.ScriptOutputStreamType) (result avs.ScriptExecution, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ScriptExecutionsListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ScriptExecutionsListIterator, err error) +} + +var _ ScriptExecutionsClientAPI = (*avs.ScriptExecutionsClient)(nil) diff --git a/services/avs/mgmt/2021-06-01/avs/client.go b/services/avs/mgmt/2021-06-01/avs/client.go new file mode 100644 index 000000000000..91f6cd9ee29b --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/client.go @@ -0,0 +1,41 @@ +// Package avs implements the Azure ARM Avs service API version 2021-06-01. +// +// Azure VMware Solution API +package avs + +// 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 Avs + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Avs. +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/avs/mgmt/2021-06-01/avs/cloudlinks.go b/services/avs/mgmt/2021-06-01/avs/cloudlinks.go new file mode 100644 index 000000000000..d7ef6991f68b --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/cloudlinks.go @@ -0,0 +1,430 @@ +package avs + +// 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" +) + +// CloudLinksClient is the azure VMware Solution API +type CloudLinksClient struct { + BaseClient +} + +// NewCloudLinksClient creates an instance of the CloudLinksClient client. +func NewCloudLinksClient(subscriptionID string) CloudLinksClient { + return NewCloudLinksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCloudLinksClientWithBaseURI creates an instance of the CloudLinksClient 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 NewCloudLinksClientWithBaseURI(baseURI string, subscriptionID string) CloudLinksClient { + return CloudLinksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// cloudLinkName - name of the cloud link resource +// cloudLink - a cloud link in the private cloud +func (client CloudLinksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string, cloudLink CloudLink) (result CloudLinksCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudLinksClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.CloudLinksClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, cloudLinkName, cloudLink) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.CloudLinksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.CloudLinksClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CloudLinksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string, cloudLink CloudLink) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cloudLinkName": autorest.Encode("path", cloudLinkName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}", pathParameters), + autorest.WithJSON(cloudLink), + 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 CloudLinksClient) CreateOrUpdateSender(req *http.Request) (future CloudLinksCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CloudLinksClient) CreateOrUpdateResponder(resp *http.Response) (result CloudLink, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// cloudLinkName - name of the cloud link resource +func (client CloudLinksClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string) (result CloudLinksDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudLinksClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.CloudLinksClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, cloudLinkName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.CloudLinksClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.CloudLinksClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CloudLinksClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cloudLinkName": autorest.Encode("path", cloudLinkName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}", 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 CloudLinksClient) DeleteSender(req *http.Request) (future CloudLinksDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CloudLinksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// cloudLinkName - name of the cloud link resource +func (client CloudLinksClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string) (result CloudLink, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudLinksClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.CloudLinksClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, cloudLinkName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.CloudLinksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.CloudLinksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.CloudLinksClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client CloudLinksClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, cloudLinkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cloudLinkName": autorest.Encode("path", cloudLinkName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}", 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 CloudLinksClient) 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 CloudLinksClient) GetResponder(resp *http.Response) (result CloudLink, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client CloudLinksClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result CloudLinkListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudLinksClient.List") + defer func() { + sc := -1 + if result.cll.Response.Response != nil { + sc = result.cll.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.CloudLinksClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.CloudLinksClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cll.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.CloudLinksClient", "List", resp, "Failure sending request") + return + } + + result.cll, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.CloudLinksClient", "List", resp, "Failure responding to request") + return + } + if result.cll.hasNextLink() && result.cll.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client CloudLinksClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks", pathParameters), + 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 CloudLinksClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client CloudLinksClient) ListResponder(resp *http.Response) (result CloudLinkList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client CloudLinksClient) listNextResults(ctx context.Context, lastResults CloudLinkList) (result CloudLinkList, err error) { + req, err := lastResults.cloudLinkListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.CloudLinksClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.CloudLinksClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.CloudLinksClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client CloudLinksClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result CloudLinkListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudLinksClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, privateCloudName) + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/clusters.go b/services/avs/mgmt/2021-06-01/avs/clusters.go new file mode 100644 index 000000000000..034b23088152 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/clusters.go @@ -0,0 +1,526 @@ +package avs + +// 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" +) + +// ClustersClient is the azure VMware Solution API +type ClustersClient struct { + BaseClient +} + +// NewClustersClient creates an instance of the ClustersClient client. +func NewClustersClient(subscriptionID string) ClustersClient { + return NewClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClustersClientWithBaseURI creates an instance of the ClustersClient 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 NewClustersClientWithBaseURI(baseURI string, subscriptionID string) ClustersClient { + return ClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// clusterName - name of the cluster in the private cloud +// cluster - a cluster in the private cloud +func (client ClustersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster Cluster) (result ClustersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: cluster, + Constraints: []validation.Constraint{{Target: "cluster.Sku", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "cluster.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("avs.ClustersClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, clusterName, cluster) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ClustersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster Cluster) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", pathParameters), + autorest.WithJSON(cluster), + 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 ClustersClient) CreateOrUpdateSender(req *http.Request) (future ClustersCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ClustersClient) CreateOrUpdateResponder(resp *http.Response) (result Cluster, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +func (client ClustersClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result ClustersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ClustersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", 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 ClustersClient) DeleteSender(req *http.Request) (future ClustersDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +func (client ClustersClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result Cluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ClustersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", 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 ClustersClient) 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 ClustersClient) GetResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client ClustersClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result ClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.List") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ClustersClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "List", resp, "Failure sending request") + return + } + + result.cl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "List", resp, "Failure responding to request") + return + } + if result.cl.hasNextLink() && result.cl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ClustersClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters", pathParameters), + 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 ClustersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ClustersClient) ListResponder(resp *http.Response) (result ClusterList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ClustersClient) listNextResults(ctx context.Context, lastResults ClusterList) (result ClusterList, err error) { + req, err := lastResults.clusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.ClustersClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.ClustersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ClustersClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result ClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, privateCloudName) + return +} + +// Update sends the update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +// clusterUpdate - the cluster properties to be updated +func (client ClustersClient) Update(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate ClusterUpdate) (result ClustersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ClustersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, privateCloudName, clusterName, clusterUpdate) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate ClusterUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", pathParameters), + autorest.WithJSON(clusterUpdate), + 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 ClustersClient) UpdateSender(req *http.Request) (future ClustersUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ClustersClient) UpdateResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/datastores.go b/services/avs/mgmt/2021-06-01/avs/datastores.go new file mode 100644 index 000000000000..70562ca6323d --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/datastores.go @@ -0,0 +1,447 @@ +package avs + +// 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" +) + +// DatastoresClient is the azure VMware Solution API +type DatastoresClient struct { + BaseClient +} + +// NewDatastoresClient creates an instance of the DatastoresClient client. +func NewDatastoresClient(subscriptionID string) DatastoresClient { + return NewDatastoresClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatastoresClientWithBaseURI creates an instance of the DatastoresClient 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 NewDatastoresClientWithBaseURI(baseURI string, subscriptionID string) DatastoresClient { + return DatastoresClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +// datastoreName - name of the datastore in the private cloud cluster +// datastore - a datastore in a private cloud cluster +func (client DatastoresClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string, datastore Datastore) (result DatastoresCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatastoresClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: datastore, + Constraints: []validation.Constraint{{Target: "datastore.DatastoreProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "datastore.DatastoreProperties.NetAppVolume", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "datastore.DatastoreProperties.NetAppVolume.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "datastore.DatastoreProperties.DiskPoolVolume", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "datastore.DatastoreProperties.DiskPoolVolume.TargetID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "datastore.DatastoreProperties.DiskPoolVolume.LunName", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("avs.DatastoresClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, clusterName, datastoreName, datastore) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.DatastoresClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.DatastoresClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatastoresClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string, datastore Datastore) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "datastoreName": autorest.Encode("path", datastoreName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}", pathParameters), + autorest.WithJSON(datastore), + 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 DatastoresClient) CreateOrUpdateSender(req *http.Request) (future DatastoresCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatastoresClient) CreateOrUpdateResponder(resp *http.Response) (result Datastore, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +// datastoreName - name of the datastore in the private cloud cluster +func (client DatastoresClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string) (result DatastoresDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatastoresClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.DatastoresClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, clusterName, datastoreName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.DatastoresClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.DatastoresClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatastoresClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "datastoreName": autorest.Encode("path", datastoreName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}", 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 DatastoresClient) DeleteSender(req *http.Request) (future DatastoresDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatastoresClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +// datastoreName - name of the datastore in the private cloud cluster +func (client DatastoresClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string) (result Datastore, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatastoresClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.DatastoresClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, clusterName, datastoreName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.DatastoresClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.DatastoresClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.DatastoresClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatastoresClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, datastoreName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "datastoreName": autorest.Encode("path", datastoreName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}", 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 DatastoresClient) 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 DatastoresClient) GetResponder(resp *http.Response) (result Datastore, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +func (client DatastoresClient) List(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result DatastoreListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatastoresClient.List") + defer func() { + sc := -1 + if result.dl.Response.Response != nil { + sc = result.dl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.DatastoresClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.DatastoresClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.dl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.DatastoresClient", "List", resp, "Failure sending request") + return + } + + result.dl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.DatastoresClient", "List", resp, "Failure responding to request") + return + } + if result.dl.hasNextLink() && result.dl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client DatastoresClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores", pathParameters), + 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 DatastoresClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DatastoresClient) ListResponder(resp *http.Response) (result DatastoreList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client DatastoresClient) listNextResults(ctx context.Context, lastResults DatastoreList) (result DatastoreList, err error) { + req, err := lastResults.datastoreListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.DatastoresClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.DatastoresClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.DatastoresClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatastoresClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result DatastoreListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatastoresClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, privateCloudName, clusterName) + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/enums.go b/services/avs/mgmt/2021-06-01/avs/enums.go new file mode 100644 index 000000000000..0e9498735349 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/enums.go @@ -0,0 +1,676 @@ +package avs + +// 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. + +// AddonProvisioningState enumerates the values for addon provisioning state. +type AddonProvisioningState string + +const ( + // Building ... + Building AddonProvisioningState = "Building" + // Cancelled ... + Cancelled AddonProvisioningState = "Cancelled" + // Deleting ... + Deleting AddonProvisioningState = "Deleting" + // Failed ... + Failed AddonProvisioningState = "Failed" + // Succeeded ... + Succeeded AddonProvisioningState = "Succeeded" + // Updating ... + Updating AddonProvisioningState = "Updating" +) + +// PossibleAddonProvisioningStateValues returns an array of possible values for the AddonProvisioningState const type. +func PossibleAddonProvisioningStateValues() []AddonProvisioningState { + return []AddonProvisioningState{Building, Cancelled, Deleting, Failed, Succeeded, Updating} +} + +// AddonType enumerates the values for addon type. +type AddonType string + +const ( + // AddonTypeAddonProperties ... + AddonTypeAddonProperties AddonType = "AddonProperties" + // AddonTypeHCX ... + AddonTypeHCX AddonType = "HCX" + // AddonTypeSRM ... + AddonTypeSRM AddonType = "SRM" + // AddonTypeVR ... + AddonTypeVR AddonType = "VR" +) + +// PossibleAddonTypeValues returns an array of possible values for the AddonType const type. +func PossibleAddonTypeValues() []AddonType { + return []AddonType{AddonTypeAddonProperties, AddonTypeHCX, AddonTypeSRM, AddonTypeVR} +} + +// CloudLinkStatus enumerates the values for cloud link status. +type CloudLinkStatus string + +const ( + // CloudLinkStatusActive ... + CloudLinkStatusActive CloudLinkStatus = "Active" + // CloudLinkStatusBuilding ... + CloudLinkStatusBuilding CloudLinkStatus = "Building" + // CloudLinkStatusDeleting ... + CloudLinkStatusDeleting CloudLinkStatus = "Deleting" + // CloudLinkStatusDisconnected ... + CloudLinkStatusDisconnected CloudLinkStatus = "Disconnected" + // CloudLinkStatusFailed ... + CloudLinkStatusFailed CloudLinkStatus = "Failed" +) + +// PossibleCloudLinkStatusValues returns an array of possible values for the CloudLinkStatus const type. +func PossibleCloudLinkStatusValues() []CloudLinkStatus { + return []CloudLinkStatus{CloudLinkStatusActive, CloudLinkStatusBuilding, CloudLinkStatusDeleting, CloudLinkStatusDisconnected, CloudLinkStatusFailed} +} + +// ClusterProvisioningState enumerates the values for cluster provisioning state. +type ClusterProvisioningState string + +const ( + // ClusterProvisioningStateCancelled ... + ClusterProvisioningStateCancelled ClusterProvisioningState = "Cancelled" + // ClusterProvisioningStateDeleting ... + ClusterProvisioningStateDeleting ClusterProvisioningState = "Deleting" + // ClusterProvisioningStateFailed ... + ClusterProvisioningStateFailed ClusterProvisioningState = "Failed" + // ClusterProvisioningStateSucceeded ... + ClusterProvisioningStateSucceeded ClusterProvisioningState = "Succeeded" + // ClusterProvisioningStateUpdating ... + ClusterProvisioningStateUpdating ClusterProvisioningState = "Updating" +) + +// PossibleClusterProvisioningStateValues returns an array of possible values for the ClusterProvisioningState const type. +func PossibleClusterProvisioningStateValues() []ClusterProvisioningState { + return []ClusterProvisioningState{ClusterProvisioningStateCancelled, ClusterProvisioningStateDeleting, ClusterProvisioningStateFailed, ClusterProvisioningStateSucceeded, ClusterProvisioningStateUpdating} +} + +// DatastoreProvisioningState enumerates the values for datastore provisioning state. +type DatastoreProvisioningState string + +const ( + // DatastoreProvisioningStateCancelled ... + DatastoreProvisioningStateCancelled DatastoreProvisioningState = "Cancelled" + // DatastoreProvisioningStateCreating ... + DatastoreProvisioningStateCreating DatastoreProvisioningState = "Creating" + // DatastoreProvisioningStateDeleting ... + DatastoreProvisioningStateDeleting DatastoreProvisioningState = "Deleting" + // DatastoreProvisioningStateFailed ... + DatastoreProvisioningStateFailed DatastoreProvisioningState = "Failed" + // DatastoreProvisioningStatePending ... + DatastoreProvisioningStatePending DatastoreProvisioningState = "Pending" + // DatastoreProvisioningStateSucceeded ... + DatastoreProvisioningStateSucceeded DatastoreProvisioningState = "Succeeded" + // DatastoreProvisioningStateUpdating ... + DatastoreProvisioningStateUpdating DatastoreProvisioningState = "Updating" +) + +// PossibleDatastoreProvisioningStateValues returns an array of possible values for the DatastoreProvisioningState const type. +func PossibleDatastoreProvisioningStateValues() []DatastoreProvisioningState { + return []DatastoreProvisioningState{DatastoreProvisioningStateCancelled, DatastoreProvisioningStateCreating, DatastoreProvisioningStateDeleting, DatastoreProvisioningStateFailed, DatastoreProvisioningStatePending, DatastoreProvisioningStateSucceeded, DatastoreProvisioningStateUpdating} +} + +// DhcpType enumerates the values for dhcp type. +type DhcpType string + +const ( + // DhcpTypeRELAY ... + DhcpTypeRELAY DhcpType = "RELAY" + // DhcpTypeSERVER ... + DhcpTypeSERVER DhcpType = "SERVER" + // DhcpTypeWorkloadNetworkDhcpEntity ... + DhcpTypeWorkloadNetworkDhcpEntity DhcpType = "WorkloadNetworkDhcpEntity" +) + +// PossibleDhcpTypeValues returns an array of possible values for the DhcpType const type. +func PossibleDhcpTypeValues() []DhcpType { + return []DhcpType{DhcpTypeRELAY, DhcpTypeSERVER, DhcpTypeWorkloadNetworkDhcpEntity} +} + +// DNSServiceLogLevelEnum enumerates the values for dns service log level enum. +type DNSServiceLogLevelEnum string + +const ( + // DEBUG ... + DEBUG DNSServiceLogLevelEnum = "DEBUG" + // ERROR ... + ERROR DNSServiceLogLevelEnum = "ERROR" + // FATAL ... + FATAL DNSServiceLogLevelEnum = "FATAL" + // INFO ... + INFO DNSServiceLogLevelEnum = "INFO" + // WARNING ... + WARNING DNSServiceLogLevelEnum = "WARNING" +) + +// PossibleDNSServiceLogLevelEnumValues returns an array of possible values for the DNSServiceLogLevelEnum const type. +func PossibleDNSServiceLogLevelEnumValues() []DNSServiceLogLevelEnum { + return []DNSServiceLogLevelEnum{DEBUG, ERROR, FATAL, INFO, WARNING} +} + +// DNSServiceStatusEnum enumerates the values for dns service status enum. +type DNSServiceStatusEnum string + +const ( + // FAILURE ... + FAILURE DNSServiceStatusEnum = "FAILURE" + // SUCCESS ... + SUCCESS DNSServiceStatusEnum = "SUCCESS" +) + +// PossibleDNSServiceStatusEnumValues returns an array of possible values for the DNSServiceStatusEnum const type. +func PossibleDNSServiceStatusEnumValues() []DNSServiceStatusEnum { + return []DNSServiceStatusEnum{FAILURE, SUCCESS} +} + +// ExpressRouteAuthorizationProvisioningState enumerates the values for express route authorization +// provisioning state. +type ExpressRouteAuthorizationProvisioningState string + +const ( + // ExpressRouteAuthorizationProvisioningStateFailed ... + ExpressRouteAuthorizationProvisioningStateFailed ExpressRouteAuthorizationProvisioningState = "Failed" + // ExpressRouteAuthorizationProvisioningStateSucceeded ... + ExpressRouteAuthorizationProvisioningStateSucceeded ExpressRouteAuthorizationProvisioningState = "Succeeded" + // ExpressRouteAuthorizationProvisioningStateUpdating ... + ExpressRouteAuthorizationProvisioningStateUpdating ExpressRouteAuthorizationProvisioningState = "Updating" +) + +// PossibleExpressRouteAuthorizationProvisioningStateValues returns an array of possible values for the ExpressRouteAuthorizationProvisioningState const type. +func PossibleExpressRouteAuthorizationProvisioningStateValues() []ExpressRouteAuthorizationProvisioningState { + return []ExpressRouteAuthorizationProvisioningState{ExpressRouteAuthorizationProvisioningStateFailed, ExpressRouteAuthorizationProvisioningStateSucceeded, ExpressRouteAuthorizationProvisioningStateUpdating} +} + +// GlobalReachConnectionProvisioningState enumerates the values for global reach connection provisioning state. +type GlobalReachConnectionProvisioningState string + +const ( + // GlobalReachConnectionProvisioningStateFailed ... + GlobalReachConnectionProvisioningStateFailed GlobalReachConnectionProvisioningState = "Failed" + // GlobalReachConnectionProvisioningStateSucceeded ... + GlobalReachConnectionProvisioningStateSucceeded GlobalReachConnectionProvisioningState = "Succeeded" + // GlobalReachConnectionProvisioningStateUpdating ... + GlobalReachConnectionProvisioningStateUpdating GlobalReachConnectionProvisioningState = "Updating" +) + +// PossibleGlobalReachConnectionProvisioningStateValues returns an array of possible values for the GlobalReachConnectionProvisioningState const type. +func PossibleGlobalReachConnectionProvisioningStateValues() []GlobalReachConnectionProvisioningState { + return []GlobalReachConnectionProvisioningState{GlobalReachConnectionProvisioningStateFailed, GlobalReachConnectionProvisioningStateSucceeded, GlobalReachConnectionProvisioningStateUpdating} +} + +// GlobalReachConnectionStatus enumerates the values for global reach connection status. +type GlobalReachConnectionStatus string + +const ( + // Connected ... + Connected GlobalReachConnectionStatus = "Connected" + // Connecting ... + Connecting GlobalReachConnectionStatus = "Connecting" + // Disconnected ... + Disconnected GlobalReachConnectionStatus = "Disconnected" +) + +// PossibleGlobalReachConnectionStatusValues returns an array of possible values for the GlobalReachConnectionStatus const type. +func PossibleGlobalReachConnectionStatusValues() []GlobalReachConnectionStatus { + return []GlobalReachConnectionStatus{Connected, Connecting, Disconnected} +} + +// HcxEnterpriseSiteStatus enumerates the values for hcx enterprise site status. +type HcxEnterpriseSiteStatus string + +const ( + // Available ... + Available HcxEnterpriseSiteStatus = "Available" + // Consumed ... + Consumed HcxEnterpriseSiteStatus = "Consumed" + // Deactivated ... + Deactivated HcxEnterpriseSiteStatus = "Deactivated" + // Deleted ... + Deleted HcxEnterpriseSiteStatus = "Deleted" +) + +// PossibleHcxEnterpriseSiteStatusValues returns an array of possible values for the HcxEnterpriseSiteStatus const type. +func PossibleHcxEnterpriseSiteStatusValues() []HcxEnterpriseSiteStatus { + return []HcxEnterpriseSiteStatus{Available, Consumed, Deactivated, Deleted} +} + +// InternetEnum enumerates the values for internet enum. +type InternetEnum string + +const ( + // Disabled ... + Disabled InternetEnum = "Disabled" + // Enabled ... + Enabled InternetEnum = "Enabled" +) + +// PossibleInternetEnumValues returns an array of possible values for the InternetEnum const type. +func PossibleInternetEnumValues() []InternetEnum { + return []InternetEnum{Disabled, Enabled} +} + +// MountOptionEnum enumerates the values for mount option enum. +type MountOptionEnum string + +const ( + // ATTACH ... + ATTACH MountOptionEnum = "ATTACH" + // MOUNT ... + MOUNT MountOptionEnum = "MOUNT" +) + +// PossibleMountOptionEnumValues returns an array of possible values for the MountOptionEnum const type. +func PossibleMountOptionEnumValues() []MountOptionEnum { + return []MountOptionEnum{ATTACH, MOUNT} +} + +// OptionalParamEnum enumerates the values for optional param enum. +type OptionalParamEnum string + +const ( + // Optional ... + Optional OptionalParamEnum = "Optional" + // Required ... + Required OptionalParamEnum = "Required" +) + +// PossibleOptionalParamEnumValues returns an array of possible values for the OptionalParamEnum const type. +func PossibleOptionalParamEnumValues() []OptionalParamEnum { + return []OptionalParamEnum{Optional, Required} +} + +// PortMirroringDirectionEnum enumerates the values for port mirroring direction enum. +type PortMirroringDirectionEnum string + +const ( + // INGRESSEGRESSBIDIRECTIONAL ... + INGRESSEGRESSBIDIRECTIONAL PortMirroringDirectionEnum = "INGRESS, EGRESS, BIDIRECTIONAL" +) + +// PossiblePortMirroringDirectionEnumValues returns an array of possible values for the PortMirroringDirectionEnum const type. +func PossiblePortMirroringDirectionEnumValues() []PortMirroringDirectionEnum { + return []PortMirroringDirectionEnum{INGRESSEGRESSBIDIRECTIONAL} +} + +// PortMirroringStatusEnum enumerates the values for port mirroring status enum. +type PortMirroringStatusEnum string + +const ( + // SUCCESSFAILURE ... + SUCCESSFAILURE PortMirroringStatusEnum = "SUCCESS, FAILURE" +) + +// PossiblePortMirroringStatusEnumValues returns an array of possible values for the PortMirroringStatusEnum const type. +func PossiblePortMirroringStatusEnumValues() []PortMirroringStatusEnum { + return []PortMirroringStatusEnum{SUCCESSFAILURE} +} + +// PrivateCloudProvisioningState enumerates the values for private cloud provisioning state. +type PrivateCloudProvisioningState string + +const ( + // PrivateCloudProvisioningStateBuilding ... + PrivateCloudProvisioningStateBuilding PrivateCloudProvisioningState = "Building" + // PrivateCloudProvisioningStateCancelled ... + PrivateCloudProvisioningStateCancelled PrivateCloudProvisioningState = "Cancelled" + // PrivateCloudProvisioningStateDeleting ... + PrivateCloudProvisioningStateDeleting PrivateCloudProvisioningState = "Deleting" + // PrivateCloudProvisioningStateFailed ... + PrivateCloudProvisioningStateFailed PrivateCloudProvisioningState = "Failed" + // PrivateCloudProvisioningStatePending ... + PrivateCloudProvisioningStatePending PrivateCloudProvisioningState = "Pending" + // PrivateCloudProvisioningStateSucceeded ... + PrivateCloudProvisioningStateSucceeded PrivateCloudProvisioningState = "Succeeded" + // PrivateCloudProvisioningStateUpdating ... + PrivateCloudProvisioningStateUpdating PrivateCloudProvisioningState = "Updating" +) + +// PossiblePrivateCloudProvisioningStateValues returns an array of possible values for the PrivateCloudProvisioningState const type. +func PossiblePrivateCloudProvisioningStateValues() []PrivateCloudProvisioningState { + return []PrivateCloudProvisioningState{PrivateCloudProvisioningStateBuilding, PrivateCloudProvisioningStateCancelled, PrivateCloudProvisioningStateDeleting, PrivateCloudProvisioningStateFailed, PrivateCloudProvisioningStatePending, PrivateCloudProvisioningStateSucceeded, PrivateCloudProvisioningStateUpdating} +} + +// QuotaEnabled enumerates the values for quota enabled. +type QuotaEnabled string + +const ( + // QuotaEnabledDisabled ... + QuotaEnabledDisabled QuotaEnabled = "Disabled" + // QuotaEnabledEnabled ... + QuotaEnabledEnabled QuotaEnabled = "Enabled" +) + +// PossibleQuotaEnabledValues returns an array of possible values for the QuotaEnabled const type. +func PossibleQuotaEnabledValues() []QuotaEnabled { + return []QuotaEnabled{QuotaEnabledDisabled, QuotaEnabledEnabled} +} + +// ScriptExecutionProvisioningState enumerates the values for script execution provisioning state. +type ScriptExecutionProvisioningState string + +const ( + // ScriptExecutionProvisioningStateCancelled ... + ScriptExecutionProvisioningStateCancelled ScriptExecutionProvisioningState = "Cancelled" + // ScriptExecutionProvisioningStateCancelling ... + ScriptExecutionProvisioningStateCancelling ScriptExecutionProvisioningState = "Cancelling" + // ScriptExecutionProvisioningStateDeleting ... + ScriptExecutionProvisioningStateDeleting ScriptExecutionProvisioningState = "Deleting" + // ScriptExecutionProvisioningStateFailed ... + ScriptExecutionProvisioningStateFailed ScriptExecutionProvisioningState = "Failed" + // ScriptExecutionProvisioningStatePending ... + ScriptExecutionProvisioningStatePending ScriptExecutionProvisioningState = "Pending" + // ScriptExecutionProvisioningStateRunning ... + ScriptExecutionProvisioningStateRunning ScriptExecutionProvisioningState = "Running" + // ScriptExecutionProvisioningStateSucceeded ... + ScriptExecutionProvisioningStateSucceeded ScriptExecutionProvisioningState = "Succeeded" +) + +// PossibleScriptExecutionProvisioningStateValues returns an array of possible values for the ScriptExecutionProvisioningState const type. +func PossibleScriptExecutionProvisioningStateValues() []ScriptExecutionProvisioningState { + return []ScriptExecutionProvisioningState{ScriptExecutionProvisioningStateCancelled, ScriptExecutionProvisioningStateCancelling, ScriptExecutionProvisioningStateDeleting, ScriptExecutionProvisioningStateFailed, ScriptExecutionProvisioningStatePending, ScriptExecutionProvisioningStateRunning, ScriptExecutionProvisioningStateSucceeded} +} + +// ScriptOutputStreamType enumerates the values for script output stream type. +type ScriptOutputStreamType string + +const ( + // Error ... + Error ScriptOutputStreamType = "Error" + // Information ... + Information ScriptOutputStreamType = "Information" + // Output ... + Output ScriptOutputStreamType = "Output" + // Warning ... + Warning ScriptOutputStreamType = "Warning" +) + +// PossibleScriptOutputStreamTypeValues returns an array of possible values for the ScriptOutputStreamType const type. +func PossibleScriptOutputStreamTypeValues() []ScriptOutputStreamType { + return []ScriptOutputStreamType{Error, Information, Output, Warning} +} + +// ScriptParameterTypes enumerates the values for script parameter types. +type ScriptParameterTypes string + +const ( + // Bool ... + Bool ScriptParameterTypes = "Bool" + // Credential ... + Credential ScriptParameterTypes = "Credential" + // Float ... + Float ScriptParameterTypes = "Float" + // Int ... + Int ScriptParameterTypes = "Int" + // SecureString ... + SecureString ScriptParameterTypes = "SecureString" + // String ... + String ScriptParameterTypes = "String" +) + +// PossibleScriptParameterTypesValues returns an array of possible values for the ScriptParameterTypes const type. +func PossibleScriptParameterTypesValues() []ScriptParameterTypes { + return []ScriptParameterTypes{Bool, Credential, Float, Int, SecureString, String} +} + +// SegmentStatusEnum enumerates the values for segment status enum. +type SegmentStatusEnum string + +const ( + // SegmentStatusEnumSUCCESSFAILURE ... + SegmentStatusEnumSUCCESSFAILURE SegmentStatusEnum = "SUCCESS, FAILURE" +) + +// PossibleSegmentStatusEnumValues returns an array of possible values for the SegmentStatusEnum const type. +func PossibleSegmentStatusEnumValues() []SegmentStatusEnum { + return []SegmentStatusEnum{SegmentStatusEnumSUCCESSFAILURE} +} + +// SslEnum enumerates the values for ssl enum. +type SslEnum string + +const ( + // SslEnumDisabled ... + SslEnumDisabled SslEnum = "Disabled" + // SslEnumEnabled ... + SslEnumEnabled SslEnum = "Enabled" +) + +// PossibleSslEnumValues returns an array of possible values for the SslEnum const type. +func PossibleSslEnumValues() []SslEnum { + return []SslEnum{SslEnumDisabled, SslEnumEnabled} +} + +// TrialStatus enumerates the values for trial status. +type TrialStatus string + +const ( + // TrialAvailable ... + TrialAvailable TrialStatus = "TrialAvailable" + // TrialDisabled ... + TrialDisabled TrialStatus = "TrialDisabled" + // TrialUsed ... + TrialUsed TrialStatus = "TrialUsed" +) + +// PossibleTrialStatusValues returns an array of possible values for the TrialStatus const type. +func PossibleTrialStatusValues() []TrialStatus { + return []TrialStatus{TrialAvailable, TrialDisabled, TrialUsed} +} + +// Type enumerates the values for type. +type Type string + +const ( + // TypeCredential ... + TypeCredential Type = "Credential" + // TypeScriptExecutionParameter ... + TypeScriptExecutionParameter Type = "ScriptExecutionParameter" + // TypeSecureValue ... + TypeSecureValue Type = "SecureValue" + // TypeValue ... + TypeValue Type = "Value" +) + +// PossibleTypeValues returns an array of possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{TypeCredential, TypeScriptExecutionParameter, TypeSecureValue, TypeValue} +} + +// VisibilityParameterEnum enumerates the values for visibility parameter enum. +type VisibilityParameterEnum string + +const ( + // Hidden ... + Hidden VisibilityParameterEnum = "Hidden" + // Visible ... + Visible VisibilityParameterEnum = "Visible" +) + +// PossibleVisibilityParameterEnumValues returns an array of possible values for the VisibilityParameterEnum const type. +func PossibleVisibilityParameterEnumValues() []VisibilityParameterEnum { + return []VisibilityParameterEnum{Hidden, Visible} +} + +// VMGroupStatusEnum enumerates the values for vm group status enum. +type VMGroupStatusEnum string + +const ( + // VMGroupStatusEnumSUCCESSFAILURE ... + VMGroupStatusEnumSUCCESSFAILURE VMGroupStatusEnum = "SUCCESS, FAILURE" +) + +// PossibleVMGroupStatusEnumValues returns an array of possible values for the VMGroupStatusEnum const type. +func PossibleVMGroupStatusEnumValues() []VMGroupStatusEnum { + return []VMGroupStatusEnum{VMGroupStatusEnumSUCCESSFAILURE} +} + +// VMTypeEnum enumerates the values for vm type enum. +type VMTypeEnum string + +const ( + // REGULAREDGESERVICE ... + REGULAREDGESERVICE VMTypeEnum = "REGULAR, EDGE, SERVICE" +) + +// PossibleVMTypeEnumValues returns an array of possible values for the VMTypeEnum const type. +func PossibleVMTypeEnumValues() []VMTypeEnum { + return []VMTypeEnum{REGULAREDGESERVICE} +} + +// WorkloadNetworkDhcpProvisioningState enumerates the values for workload network dhcp provisioning state. +type WorkloadNetworkDhcpProvisioningState string + +const ( + // WorkloadNetworkDhcpProvisioningStateBuilding ... + WorkloadNetworkDhcpProvisioningStateBuilding WorkloadNetworkDhcpProvisioningState = "Building" + // WorkloadNetworkDhcpProvisioningStateDeleting ... + WorkloadNetworkDhcpProvisioningStateDeleting WorkloadNetworkDhcpProvisioningState = "Deleting" + // WorkloadNetworkDhcpProvisioningStateFailed ... + WorkloadNetworkDhcpProvisioningStateFailed WorkloadNetworkDhcpProvisioningState = "Failed" + // WorkloadNetworkDhcpProvisioningStateSucceeded ... + WorkloadNetworkDhcpProvisioningStateSucceeded WorkloadNetworkDhcpProvisioningState = "Succeeded" + // WorkloadNetworkDhcpProvisioningStateUpdating ... + WorkloadNetworkDhcpProvisioningStateUpdating WorkloadNetworkDhcpProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkDhcpProvisioningStateValues returns an array of possible values for the WorkloadNetworkDhcpProvisioningState const type. +func PossibleWorkloadNetworkDhcpProvisioningStateValues() []WorkloadNetworkDhcpProvisioningState { + return []WorkloadNetworkDhcpProvisioningState{WorkloadNetworkDhcpProvisioningStateBuilding, WorkloadNetworkDhcpProvisioningStateDeleting, WorkloadNetworkDhcpProvisioningStateFailed, WorkloadNetworkDhcpProvisioningStateSucceeded, WorkloadNetworkDhcpProvisioningStateUpdating} +} + +// WorkloadNetworkDNSServiceProvisioningState enumerates the values for workload network dns service +// provisioning state. +type WorkloadNetworkDNSServiceProvisioningState string + +const ( + // WorkloadNetworkDNSServiceProvisioningStateBuilding ... + WorkloadNetworkDNSServiceProvisioningStateBuilding WorkloadNetworkDNSServiceProvisioningState = "Building" + // WorkloadNetworkDNSServiceProvisioningStateDeleting ... + WorkloadNetworkDNSServiceProvisioningStateDeleting WorkloadNetworkDNSServiceProvisioningState = "Deleting" + // WorkloadNetworkDNSServiceProvisioningStateFailed ... + WorkloadNetworkDNSServiceProvisioningStateFailed WorkloadNetworkDNSServiceProvisioningState = "Failed" + // WorkloadNetworkDNSServiceProvisioningStateSucceeded ... + WorkloadNetworkDNSServiceProvisioningStateSucceeded WorkloadNetworkDNSServiceProvisioningState = "Succeeded" + // WorkloadNetworkDNSServiceProvisioningStateUpdating ... + WorkloadNetworkDNSServiceProvisioningStateUpdating WorkloadNetworkDNSServiceProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkDNSServiceProvisioningStateValues returns an array of possible values for the WorkloadNetworkDNSServiceProvisioningState const type. +func PossibleWorkloadNetworkDNSServiceProvisioningStateValues() []WorkloadNetworkDNSServiceProvisioningState { + return []WorkloadNetworkDNSServiceProvisioningState{WorkloadNetworkDNSServiceProvisioningStateBuilding, WorkloadNetworkDNSServiceProvisioningStateDeleting, WorkloadNetworkDNSServiceProvisioningStateFailed, WorkloadNetworkDNSServiceProvisioningStateSucceeded, WorkloadNetworkDNSServiceProvisioningStateUpdating} +} + +// WorkloadNetworkDNSZoneProvisioningState enumerates the values for workload network dns zone provisioning +// state. +type WorkloadNetworkDNSZoneProvisioningState string + +const ( + // WorkloadNetworkDNSZoneProvisioningStateBuilding ... + WorkloadNetworkDNSZoneProvisioningStateBuilding WorkloadNetworkDNSZoneProvisioningState = "Building" + // WorkloadNetworkDNSZoneProvisioningStateDeleting ... + WorkloadNetworkDNSZoneProvisioningStateDeleting WorkloadNetworkDNSZoneProvisioningState = "Deleting" + // WorkloadNetworkDNSZoneProvisioningStateFailed ... + WorkloadNetworkDNSZoneProvisioningStateFailed WorkloadNetworkDNSZoneProvisioningState = "Failed" + // WorkloadNetworkDNSZoneProvisioningStateSucceeded ... + WorkloadNetworkDNSZoneProvisioningStateSucceeded WorkloadNetworkDNSZoneProvisioningState = "Succeeded" + // WorkloadNetworkDNSZoneProvisioningStateUpdating ... + WorkloadNetworkDNSZoneProvisioningStateUpdating WorkloadNetworkDNSZoneProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkDNSZoneProvisioningStateValues returns an array of possible values for the WorkloadNetworkDNSZoneProvisioningState const type. +func PossibleWorkloadNetworkDNSZoneProvisioningStateValues() []WorkloadNetworkDNSZoneProvisioningState { + return []WorkloadNetworkDNSZoneProvisioningState{WorkloadNetworkDNSZoneProvisioningStateBuilding, WorkloadNetworkDNSZoneProvisioningStateDeleting, WorkloadNetworkDNSZoneProvisioningStateFailed, WorkloadNetworkDNSZoneProvisioningStateSucceeded, WorkloadNetworkDNSZoneProvisioningStateUpdating} +} + +// WorkloadNetworkPortMirroringProvisioningState enumerates the values for workload network port mirroring +// provisioning state. +type WorkloadNetworkPortMirroringProvisioningState string + +const ( + // WorkloadNetworkPortMirroringProvisioningStateBuilding ... + WorkloadNetworkPortMirroringProvisioningStateBuilding WorkloadNetworkPortMirroringProvisioningState = "Building" + // WorkloadNetworkPortMirroringProvisioningStateDeleting ... + WorkloadNetworkPortMirroringProvisioningStateDeleting WorkloadNetworkPortMirroringProvisioningState = "Deleting" + // WorkloadNetworkPortMirroringProvisioningStateFailed ... + WorkloadNetworkPortMirroringProvisioningStateFailed WorkloadNetworkPortMirroringProvisioningState = "Failed" + // WorkloadNetworkPortMirroringProvisioningStateSucceeded ... + WorkloadNetworkPortMirroringProvisioningStateSucceeded WorkloadNetworkPortMirroringProvisioningState = "Succeeded" + // WorkloadNetworkPortMirroringProvisioningStateUpdating ... + WorkloadNetworkPortMirroringProvisioningStateUpdating WorkloadNetworkPortMirroringProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkPortMirroringProvisioningStateValues returns an array of possible values for the WorkloadNetworkPortMirroringProvisioningState const type. +func PossibleWorkloadNetworkPortMirroringProvisioningStateValues() []WorkloadNetworkPortMirroringProvisioningState { + return []WorkloadNetworkPortMirroringProvisioningState{WorkloadNetworkPortMirroringProvisioningStateBuilding, WorkloadNetworkPortMirroringProvisioningStateDeleting, WorkloadNetworkPortMirroringProvisioningStateFailed, WorkloadNetworkPortMirroringProvisioningStateSucceeded, WorkloadNetworkPortMirroringProvisioningStateUpdating} +} + +// WorkloadNetworkPublicIPProvisioningState enumerates the values for workload network public ip provisioning +// state. +type WorkloadNetworkPublicIPProvisioningState string + +const ( + // WorkloadNetworkPublicIPProvisioningStateBuilding ... + WorkloadNetworkPublicIPProvisioningStateBuilding WorkloadNetworkPublicIPProvisioningState = "Building" + // WorkloadNetworkPublicIPProvisioningStateDeleting ... + WorkloadNetworkPublicIPProvisioningStateDeleting WorkloadNetworkPublicIPProvisioningState = "Deleting" + // WorkloadNetworkPublicIPProvisioningStateFailed ... + WorkloadNetworkPublicIPProvisioningStateFailed WorkloadNetworkPublicIPProvisioningState = "Failed" + // WorkloadNetworkPublicIPProvisioningStateSucceeded ... + WorkloadNetworkPublicIPProvisioningStateSucceeded WorkloadNetworkPublicIPProvisioningState = "Succeeded" + // WorkloadNetworkPublicIPProvisioningStateUpdating ... + WorkloadNetworkPublicIPProvisioningStateUpdating WorkloadNetworkPublicIPProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkPublicIPProvisioningStateValues returns an array of possible values for the WorkloadNetworkPublicIPProvisioningState const type. +func PossibleWorkloadNetworkPublicIPProvisioningStateValues() []WorkloadNetworkPublicIPProvisioningState { + return []WorkloadNetworkPublicIPProvisioningState{WorkloadNetworkPublicIPProvisioningStateBuilding, WorkloadNetworkPublicIPProvisioningStateDeleting, WorkloadNetworkPublicIPProvisioningStateFailed, WorkloadNetworkPublicIPProvisioningStateSucceeded, WorkloadNetworkPublicIPProvisioningStateUpdating} +} + +// WorkloadNetworkSegmentProvisioningState enumerates the values for workload network segment provisioning +// state. +type WorkloadNetworkSegmentProvisioningState string + +const ( + // WorkloadNetworkSegmentProvisioningStateBuilding ... + WorkloadNetworkSegmentProvisioningStateBuilding WorkloadNetworkSegmentProvisioningState = "Building" + // WorkloadNetworkSegmentProvisioningStateDeleting ... + WorkloadNetworkSegmentProvisioningStateDeleting WorkloadNetworkSegmentProvisioningState = "Deleting" + // WorkloadNetworkSegmentProvisioningStateFailed ... + WorkloadNetworkSegmentProvisioningStateFailed WorkloadNetworkSegmentProvisioningState = "Failed" + // WorkloadNetworkSegmentProvisioningStateSucceeded ... + WorkloadNetworkSegmentProvisioningStateSucceeded WorkloadNetworkSegmentProvisioningState = "Succeeded" + // WorkloadNetworkSegmentProvisioningStateUpdating ... + WorkloadNetworkSegmentProvisioningStateUpdating WorkloadNetworkSegmentProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkSegmentProvisioningStateValues returns an array of possible values for the WorkloadNetworkSegmentProvisioningState const type. +func PossibleWorkloadNetworkSegmentProvisioningStateValues() []WorkloadNetworkSegmentProvisioningState { + return []WorkloadNetworkSegmentProvisioningState{WorkloadNetworkSegmentProvisioningStateBuilding, WorkloadNetworkSegmentProvisioningStateDeleting, WorkloadNetworkSegmentProvisioningStateFailed, WorkloadNetworkSegmentProvisioningStateSucceeded, WorkloadNetworkSegmentProvisioningStateUpdating} +} + +// WorkloadNetworkVMGroupProvisioningState enumerates the values for workload network vm group provisioning +// state. +type WorkloadNetworkVMGroupProvisioningState string + +const ( + // WorkloadNetworkVMGroupProvisioningStateBuilding ... + WorkloadNetworkVMGroupProvisioningStateBuilding WorkloadNetworkVMGroupProvisioningState = "Building" + // WorkloadNetworkVMGroupProvisioningStateDeleting ... + WorkloadNetworkVMGroupProvisioningStateDeleting WorkloadNetworkVMGroupProvisioningState = "Deleting" + // WorkloadNetworkVMGroupProvisioningStateFailed ... + WorkloadNetworkVMGroupProvisioningStateFailed WorkloadNetworkVMGroupProvisioningState = "Failed" + // WorkloadNetworkVMGroupProvisioningStateSucceeded ... + WorkloadNetworkVMGroupProvisioningStateSucceeded WorkloadNetworkVMGroupProvisioningState = "Succeeded" + // WorkloadNetworkVMGroupProvisioningStateUpdating ... + WorkloadNetworkVMGroupProvisioningStateUpdating WorkloadNetworkVMGroupProvisioningState = "Updating" +) + +// PossibleWorkloadNetworkVMGroupProvisioningStateValues returns an array of possible values for the WorkloadNetworkVMGroupProvisioningState const type. +func PossibleWorkloadNetworkVMGroupProvisioningStateValues() []WorkloadNetworkVMGroupProvisioningState { + return []WorkloadNetworkVMGroupProvisioningState{WorkloadNetworkVMGroupProvisioningStateBuilding, WorkloadNetworkVMGroupProvisioningStateDeleting, WorkloadNetworkVMGroupProvisioningStateFailed, WorkloadNetworkVMGroupProvisioningStateSucceeded, WorkloadNetworkVMGroupProvisioningStateUpdating} +} diff --git a/services/avs/mgmt/2021-06-01/avs/globalreachconnections.go b/services/avs/mgmt/2021-06-01/avs/globalreachconnections.go new file mode 100644 index 000000000000..0539d1eee681 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/globalreachconnections.go @@ -0,0 +1,431 @@ +package avs + +// 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" +) + +// GlobalReachConnectionsClient is the azure VMware Solution API +type GlobalReachConnectionsClient struct { + BaseClient +} + +// NewGlobalReachConnectionsClient creates an instance of the GlobalReachConnectionsClient client. +func NewGlobalReachConnectionsClient(subscriptionID string) GlobalReachConnectionsClient { + return NewGlobalReachConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGlobalReachConnectionsClientWithBaseURI creates an instance of the GlobalReachConnectionsClient 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 NewGlobalReachConnectionsClientWithBaseURI(baseURI string, subscriptionID string) GlobalReachConnectionsClient { + return GlobalReachConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// globalReachConnectionName - name of the global reach connection in the private cloud +// globalReachConnection - a global reach connection in the private cloud +func (client GlobalReachConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string, globalReachConnection GlobalReachConnection) (result GlobalReachConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GlobalReachConnectionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.GlobalReachConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, globalReachConnectionName, globalReachConnection) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client GlobalReachConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string, globalReachConnection GlobalReachConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "globalReachConnectionName": autorest.Encode("path", globalReachConnectionName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}", pathParameters), + autorest.WithJSON(globalReachConnection), + 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 GlobalReachConnectionsClient) CreateOrUpdateSender(req *http.Request) (future GlobalReachConnectionsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GlobalReachConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result GlobalReachConnection, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// globalReachConnectionName - name of the global reach connection in the private cloud +func (client GlobalReachConnectionsClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string) (result GlobalReachConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GlobalReachConnectionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.GlobalReachConnectionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, globalReachConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client GlobalReachConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "globalReachConnectionName": autorest.Encode("path", globalReachConnectionName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}", 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 GlobalReachConnectionsClient) DeleteSender(req *http.Request) (future GlobalReachConnectionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client GlobalReachConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// globalReachConnectionName - name of the global reach connection in the private cloud +func (client GlobalReachConnectionsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string) (result GlobalReachConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GlobalReachConnectionsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.GlobalReachConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, globalReachConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client GlobalReachConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, globalReachConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "globalReachConnectionName": autorest.Encode("path", globalReachConnectionName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}", 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 GlobalReachConnectionsClient) 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 GlobalReachConnectionsClient) GetResponder(resp *http.Response) (result GlobalReachConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client GlobalReachConnectionsClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result GlobalReachConnectionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GlobalReachConnectionsClient.List") + defer func() { + sc := -1 + if result.grcl.Response.Response != nil { + sc = result.grcl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.GlobalReachConnectionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.grcl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "List", resp, "Failure sending request") + return + } + + result.grcl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "List", resp, "Failure responding to request") + return + } + if result.grcl.hasNextLink() && result.grcl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client GlobalReachConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections", pathParameters), + 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 GlobalReachConnectionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client GlobalReachConnectionsClient) ListResponder(resp *http.Response) (result GlobalReachConnectionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client GlobalReachConnectionsClient) listNextResults(ctx context.Context, lastResults GlobalReachConnectionList) (result GlobalReachConnectionList, err error) { + req, err := lastResults.globalReachConnectionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client GlobalReachConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result GlobalReachConnectionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GlobalReachConnectionsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, privateCloudName) + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/hcxenterprisesites.go b/services/avs/mgmt/2021-06-01/avs/hcxenterprisesites.go new file mode 100644 index 000000000000..a67cf1bf27e9 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/hcxenterprisesites.go @@ -0,0 +1,428 @@ +package avs + +// 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" +) + +// HcxEnterpriseSitesClient is the azure VMware Solution API +type HcxEnterpriseSitesClient struct { + BaseClient +} + +// NewHcxEnterpriseSitesClient creates an instance of the HcxEnterpriseSitesClient client. +func NewHcxEnterpriseSitesClient(subscriptionID string) HcxEnterpriseSitesClient { + return NewHcxEnterpriseSitesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewHcxEnterpriseSitesClientWithBaseURI creates an instance of the HcxEnterpriseSitesClient 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 NewHcxEnterpriseSitesClientWithBaseURI(baseURI string, subscriptionID string) HcxEnterpriseSitesClient { + return HcxEnterpriseSitesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// hcxEnterpriseSiteName - name of the HCX Enterprise Site in the private cloud +// hcxEnterpriseSite - the HCX Enterprise Site +func (client HcxEnterpriseSitesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite HcxEnterpriseSite) (result HcxEnterpriseSite, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.HcxEnterpriseSitesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName, hcxEnterpriseSite) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client HcxEnterpriseSitesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite HcxEnterpriseSite) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hcxEnterpriseSiteName": autorest.Encode("path", hcxEnterpriseSiteName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + hcxEnterpriseSite.HcxEnterpriseSiteProperties = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", pathParameters), + autorest.WithJSON(hcxEnterpriseSite), + 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 HcxEnterpriseSitesClient) 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 HcxEnterpriseSitesClient) CreateOrUpdateResponder(resp *http.Response) (result HcxEnterpriseSite, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// hcxEnterpriseSiteName - name of the HCX Enterprise Site in the private cloud +func (client HcxEnterpriseSitesClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.HcxEnterpriseSitesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client HcxEnterpriseSitesClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hcxEnterpriseSiteName": autorest.Encode("path", hcxEnterpriseSiteName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", 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 HcxEnterpriseSitesClient) 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 HcxEnterpriseSitesClient) 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 sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// hcxEnterpriseSiteName - name of the HCX Enterprise Site in the private cloud +func (client HcxEnterpriseSitesClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result HcxEnterpriseSite, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.HcxEnterpriseSitesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client HcxEnterpriseSitesClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hcxEnterpriseSiteName": autorest.Encode("path", hcxEnterpriseSiteName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", 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 HcxEnterpriseSitesClient) 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 HcxEnterpriseSitesClient) GetResponder(resp *http.Response) (result HcxEnterpriseSite, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client HcxEnterpriseSitesClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result HcxEnterpriseSiteListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.List") + defer func() { + sc := -1 + if result.hesl.Response.Response != nil { + sc = result.hesl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.HcxEnterpriseSitesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.hesl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "List", resp, "Failure sending request") + return + } + + result.hesl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "List", resp, "Failure responding to request") + return + } + if result.hesl.hasNextLink() && result.hesl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client HcxEnterpriseSitesClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites", pathParameters), + 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 HcxEnterpriseSitesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client HcxEnterpriseSitesClient) ListResponder(resp *http.Response) (result HcxEnterpriseSiteList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client HcxEnterpriseSitesClient) listNextResults(ctx context.Context, lastResults HcxEnterpriseSiteList) (result HcxEnterpriseSiteList, err error) { + req, err := lastResults.hcxEnterpriseSiteListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client HcxEnterpriseSitesClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result HcxEnterpriseSiteListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, privateCloudName) + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/locations.go b/services/avs/mgmt/2021-06-01/avs/locations.go new file mode 100644 index 000000000000..9a5cda271a5f --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/locations.go @@ -0,0 +1,192 @@ +package avs + +// 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" +) + +// LocationsClient is the azure VMware Solution API +type LocationsClient struct { + BaseClient +} + +// NewLocationsClient creates an instance of the LocationsClient client. +func NewLocationsClient(subscriptionID string) LocationsClient { + return NewLocationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLocationsClientWithBaseURI creates an instance of the LocationsClient 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 NewLocationsClientWithBaseURI(baseURI string, subscriptionID string) LocationsClient { + return LocationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckQuotaAvailability return quota for subscription by region +// Parameters: +// location - azure region +func (client LocationsClient) CheckQuotaAvailability(ctx context.Context, location string) (result Quota, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.CheckQuotaAvailability") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.LocationsClient", "CheckQuotaAvailability", err.Error()) + } + + req, err := client.CheckQuotaAvailabilityPreparer(ctx, location) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckQuotaAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckQuotaAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckQuotaAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckQuotaAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckQuotaAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckQuotaAvailabilityPreparer prepares the CheckQuotaAvailability request. +func (client LocationsClient) CheckQuotaAvailabilityPreparer(ctx context.Context, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkQuotaAvailability", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckQuotaAvailabilitySender sends the CheckQuotaAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client LocationsClient) CheckQuotaAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckQuotaAvailabilityResponder handles the response to the CheckQuotaAvailability request. The method always +// closes the http.Response Body. +func (client LocationsClient) CheckQuotaAvailabilityResponder(resp *http.Response) (result Quota, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CheckTrialAvailability return trial status for subscription by region +// Parameters: +// location - azure region +func (client LocationsClient) CheckTrialAvailability(ctx context.Context, location string) (result Trial, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.CheckTrialAvailability") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.LocationsClient", "CheckTrialAvailability", err.Error()) + } + + req, err := client.CheckTrialAvailabilityPreparer(ctx, location) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckTrialAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckTrialAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckTrialAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckTrialAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckTrialAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckTrialAvailabilityPreparer prepares the CheckTrialAvailability request. +func (client LocationsClient) CheckTrialAvailabilityPreparer(ctx context.Context, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkTrialAvailability", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckTrialAvailabilitySender sends the CheckTrialAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client LocationsClient) CheckTrialAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckTrialAvailabilityResponder handles the response to the CheckTrialAvailability request. The method always +// closes the http.Response Body. +func (client LocationsClient) CheckTrialAvailabilityResponder(resp *http.Response) (result Trial, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/models.go b/services/avs/mgmt/2021-06-01/avs/models.go new file mode 100644 index 000000000000..7b70105bda26 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/models.go @@ -0,0 +1,8344 @@ +package avs + +// 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" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2021-06-01/avs" + +// Addon an addon resource +type Addon struct { + autorest.Response `json:"-"` + // Properties - The properties of an addon resource + Properties BasicAddonProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Addon. +func (a Addon) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["properties"] = a.Properties + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Addon struct. +func (a *Addon) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + properties, err := unmarshalBasicAddonProperties(*v) + if err != nil { + return err + } + a.Properties = properties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + } + } + + return nil +} + +// AddonHcxProperties the properties of an HCX addon +type AddonHcxProperties struct { + // Offer - The HCX offer, example VMware MaaS Cloud Provider (Enterprise) + Offer *string `json:"offer,omitempty"` + // ProvisioningState - READ-ONLY; The state of the addon provisioning. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Building', 'Deleting', 'Updating' + ProvisioningState AddonProvisioningState `json:"provisioningState,omitempty"` + // AddonType - Possible values include: 'AddonTypeAddonProperties', 'AddonTypeSRM', 'AddonTypeVR', 'AddonTypeHCX' + AddonType AddonType `json:"addonType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AddonHcxProperties. +func (ahp AddonHcxProperties) MarshalJSON() ([]byte, error) { + ahp.AddonType = AddonTypeHCX + objectMap := make(map[string]interface{}) + if ahp.Offer != nil { + objectMap["offer"] = ahp.Offer + } + if ahp.AddonType != "" { + objectMap["addonType"] = ahp.AddonType + } + return json.Marshal(objectMap) +} + +// AsAddonSrmProperties is the BasicAddonProperties implementation for AddonHcxProperties. +func (ahp AddonHcxProperties) AsAddonSrmProperties() (*AddonSrmProperties, bool) { + return nil, false +} + +// AsAddonVrProperties is the BasicAddonProperties implementation for AddonHcxProperties. +func (ahp AddonHcxProperties) AsAddonVrProperties() (*AddonVrProperties, bool) { + return nil, false +} + +// AsAddonHcxProperties is the BasicAddonProperties implementation for AddonHcxProperties. +func (ahp AddonHcxProperties) AsAddonHcxProperties() (*AddonHcxProperties, bool) { + return &ahp, true +} + +// AsAddonProperties is the BasicAddonProperties implementation for AddonHcxProperties. +func (ahp AddonHcxProperties) AsAddonProperties() (*AddonProperties, bool) { + return nil, false +} + +// AsBasicAddonProperties is the BasicAddonProperties implementation for AddonHcxProperties. +func (ahp AddonHcxProperties) AsBasicAddonProperties() (BasicAddonProperties, bool) { + return &ahp, true +} + +// AddonList a paged list of addons +type AddonList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]Addon `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// AddonListIterator provides access to a complete listing of Addon values. +type AddonListIterator struct { + i int + page AddonListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AddonListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AddonListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AddonListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AddonListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AddonListIterator) Response() AddonList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AddonListIterator) Value() Addon { + if !iter.page.NotDone() { + return Addon{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AddonListIterator type. +func NewAddonListIterator(page AddonListPage) AddonListIterator { + return AddonListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (al AddonList) IsEmpty() bool { + return al.Value == nil || len(*al.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (al AddonList) hasNextLink() bool { + return al.NextLink != nil && len(*al.NextLink) != 0 +} + +// addonListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (al AddonList) addonListPreparer(ctx context.Context) (*http.Request, error) { + if !al.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(al.NextLink))) +} + +// AddonListPage contains a page of Addon values. +type AddonListPage struct { + fn func(context.Context, AddonList) (AddonList, error) + al AddonList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AddonListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AddonListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.al) + if err != nil { + return err + } + page.al = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AddonListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AddonListPage) NotDone() bool { + return !page.al.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AddonListPage) Response() AddonList { + return page.al +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AddonListPage) Values() []Addon { + if page.al.IsEmpty() { + return nil + } + return *page.al.Value +} + +// Creates a new instance of the AddonListPage type. +func NewAddonListPage(cur AddonList, getNextPage func(context.Context, AddonList) (AddonList, error)) AddonListPage { + return AddonListPage{ + fn: getNextPage, + al: cur, + } +} + +// BasicAddonProperties the properties of an addon +type BasicAddonProperties interface { + AsAddonSrmProperties() (*AddonSrmProperties, bool) + AsAddonVrProperties() (*AddonVrProperties, bool) + AsAddonHcxProperties() (*AddonHcxProperties, bool) + AsAddonProperties() (*AddonProperties, bool) +} + +// AddonProperties the properties of an addon +type AddonProperties struct { + // ProvisioningState - READ-ONLY; The state of the addon provisioning. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Building', 'Deleting', 'Updating' + ProvisioningState AddonProvisioningState `json:"provisioningState,omitempty"` + // AddonType - Possible values include: 'AddonTypeAddonProperties', 'AddonTypeSRM', 'AddonTypeVR', 'AddonTypeHCX' + AddonType AddonType `json:"addonType,omitempty"` +} + +func unmarshalBasicAddonProperties(body []byte) (BasicAddonProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["addonType"] { + case string(AddonTypeSRM): + var asp AddonSrmProperties + err := json.Unmarshal(body, &asp) + return asp, err + case string(AddonTypeVR): + var avp AddonVrProperties + err := json.Unmarshal(body, &avp) + return avp, err + case string(AddonTypeHCX): + var ahp AddonHcxProperties + err := json.Unmarshal(body, &ahp) + return ahp, err + default: + var ap AddonProperties + err := json.Unmarshal(body, &ap) + return ap, err + } +} +func unmarshalBasicAddonPropertiesArray(body []byte) ([]BasicAddonProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + apArray := make([]BasicAddonProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + ap, err := unmarshalBasicAddonProperties(*rawMessage) + if err != nil { + return nil, err + } + apArray[index] = ap + } + return apArray, nil +} + +// MarshalJSON is the custom marshaler for AddonProperties. +func (ap AddonProperties) MarshalJSON() ([]byte, error) { + ap.AddonType = AddonTypeAddonProperties + objectMap := make(map[string]interface{}) + if ap.AddonType != "" { + objectMap["addonType"] = ap.AddonType + } + return json.Marshal(objectMap) +} + +// AsAddonSrmProperties is the BasicAddonProperties implementation for AddonProperties. +func (ap AddonProperties) AsAddonSrmProperties() (*AddonSrmProperties, bool) { + return nil, false +} + +// AsAddonVrProperties is the BasicAddonProperties implementation for AddonProperties. +func (ap AddonProperties) AsAddonVrProperties() (*AddonVrProperties, bool) { + return nil, false +} + +// AsAddonHcxProperties is the BasicAddonProperties implementation for AddonProperties. +func (ap AddonProperties) AsAddonHcxProperties() (*AddonHcxProperties, bool) { + return nil, false +} + +// AsAddonProperties is the BasicAddonProperties implementation for AddonProperties. +func (ap AddonProperties) AsAddonProperties() (*AddonProperties, bool) { + return &ap, true +} + +// AsBasicAddonProperties is the BasicAddonProperties implementation for AddonProperties. +func (ap AddonProperties) AsBasicAddonProperties() (BasicAddonProperties, bool) { + return &ap, true +} + +// AddonsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AddonsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(AddonsClient) (Addon, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *AddonsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for AddonsCreateOrUpdateFuture.Result. +func (future *AddonsCreateOrUpdateFuture) result(client AddonsClient) (a Addon, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AddonsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + a.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.AddonsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if a.Response.Response, err = future.GetResult(sender); err == nil && a.Response.Response.StatusCode != http.StatusNoContent { + a, err = client.CreateOrUpdateResponder(a.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AddonsCreateOrUpdateFuture", "Result", a.Response.Response, "Failure responding to request") + } + } + return +} + +// AddonsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type AddonsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(AddonsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *AddonsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for AddonsDeleteFuture.Result. +func (future *AddonsDeleteFuture) result(client AddonsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AddonsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.AddonsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// AddonSrmProperties the properties of a Site Recovery Manager (SRM) addon +type AddonSrmProperties struct { + // LicenseKey - The Site Recovery Manager (SRM) license + LicenseKey *string `json:"licenseKey,omitempty"` + // ProvisioningState - READ-ONLY; The state of the addon provisioning. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Building', 'Deleting', 'Updating' + ProvisioningState AddonProvisioningState `json:"provisioningState,omitempty"` + // AddonType - Possible values include: 'AddonTypeAddonProperties', 'AddonTypeSRM', 'AddonTypeVR', 'AddonTypeHCX' + AddonType AddonType `json:"addonType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AddonSrmProperties. +func (asp AddonSrmProperties) MarshalJSON() ([]byte, error) { + asp.AddonType = AddonTypeSRM + objectMap := make(map[string]interface{}) + if asp.LicenseKey != nil { + objectMap["licenseKey"] = asp.LicenseKey + } + if asp.AddonType != "" { + objectMap["addonType"] = asp.AddonType + } + return json.Marshal(objectMap) +} + +// AsAddonSrmProperties is the BasicAddonProperties implementation for AddonSrmProperties. +func (asp AddonSrmProperties) AsAddonSrmProperties() (*AddonSrmProperties, bool) { + return &asp, true +} + +// AsAddonVrProperties is the BasicAddonProperties implementation for AddonSrmProperties. +func (asp AddonSrmProperties) AsAddonVrProperties() (*AddonVrProperties, bool) { + return nil, false +} + +// AsAddonHcxProperties is the BasicAddonProperties implementation for AddonSrmProperties. +func (asp AddonSrmProperties) AsAddonHcxProperties() (*AddonHcxProperties, bool) { + return nil, false +} + +// AsAddonProperties is the BasicAddonProperties implementation for AddonSrmProperties. +func (asp AddonSrmProperties) AsAddonProperties() (*AddonProperties, bool) { + return nil, false +} + +// AsBasicAddonProperties is the BasicAddonProperties implementation for AddonSrmProperties. +func (asp AddonSrmProperties) AsBasicAddonProperties() (BasicAddonProperties, bool) { + return &asp, true +} + +// AddonVrProperties the properties of a vSphere Replication (VR) addon +type AddonVrProperties struct { + // VrsCount - The vSphere Replication Server (VRS) count + VrsCount *int32 `json:"vrsCount,omitempty"` + // ProvisioningState - READ-ONLY; The state of the addon provisioning. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Building', 'Deleting', 'Updating' + ProvisioningState AddonProvisioningState `json:"provisioningState,omitempty"` + // AddonType - Possible values include: 'AddonTypeAddonProperties', 'AddonTypeSRM', 'AddonTypeVR', 'AddonTypeHCX' + AddonType AddonType `json:"addonType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AddonVrProperties. +func (avp AddonVrProperties) MarshalJSON() ([]byte, error) { + avp.AddonType = AddonTypeVR + objectMap := make(map[string]interface{}) + if avp.VrsCount != nil { + objectMap["vrsCount"] = avp.VrsCount + } + if avp.AddonType != "" { + objectMap["addonType"] = avp.AddonType + } + return json.Marshal(objectMap) +} + +// AsAddonSrmProperties is the BasicAddonProperties implementation for AddonVrProperties. +func (avp AddonVrProperties) AsAddonSrmProperties() (*AddonSrmProperties, bool) { + return nil, false +} + +// AsAddonVrProperties is the BasicAddonProperties implementation for AddonVrProperties. +func (avp AddonVrProperties) AsAddonVrProperties() (*AddonVrProperties, bool) { + return &avp, true +} + +// AsAddonHcxProperties is the BasicAddonProperties implementation for AddonVrProperties. +func (avp AddonVrProperties) AsAddonHcxProperties() (*AddonHcxProperties, bool) { + return nil, false +} + +// AsAddonProperties is the BasicAddonProperties implementation for AddonVrProperties. +func (avp AddonVrProperties) AsAddonProperties() (*AddonProperties, bool) { + return nil, false +} + +// AsBasicAddonProperties is the BasicAddonProperties implementation for AddonVrProperties. +func (avp AddonVrProperties) AsBasicAddonProperties() (BasicAddonProperties, bool) { + return &avp, true +} + +// AdminCredentials administrative credentials for accessing vCenter and NSX-T +type AdminCredentials struct { + autorest.Response `json:"-"` + // NsxtUsername - READ-ONLY; NSX-T Manager username + NsxtUsername *string `json:"nsxtUsername,omitempty"` + // NsxtPassword - READ-ONLY; NSX-T Manager password + NsxtPassword *string `json:"nsxtPassword,omitempty"` + // VcenterUsername - READ-ONLY; vCenter admin username + VcenterUsername *string `json:"vcenterUsername,omitempty"` + // VcenterPassword - READ-ONLY; vCenter admin password + VcenterPassword *string `json:"vcenterPassword,omitempty"` +} + +// AuthorizationsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type AuthorizationsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(AuthorizationsClient) (ExpressRouteAuthorization, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *AuthorizationsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for AuthorizationsCreateOrUpdateFuture.Result. +func (future *AuthorizationsCreateOrUpdateFuture) result(client AuthorizationsClient) (era ExpressRouteAuthorization, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + era.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.AuthorizationsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if era.Response.Response, err = future.GetResult(sender); err == nil && era.Response.Response.StatusCode != http.StatusNoContent { + era, err = client.CreateOrUpdateResponder(era.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsCreateOrUpdateFuture", "Result", era.Response.Response, "Failure responding to request") + } + } + return +} + +// AuthorizationsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AuthorizationsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(AuthorizationsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *AuthorizationsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for AuthorizationsDeleteFuture.Result. +func (future *AuthorizationsDeleteFuture) result(client AuthorizationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.AuthorizationsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// Circuit an ExpressRoute Circuit +type Circuit struct { + // PrimarySubnet - READ-ONLY; CIDR of primary subnet + PrimarySubnet *string `json:"primarySubnet,omitempty"` + // SecondarySubnet - READ-ONLY; CIDR of secondary subnet + SecondarySubnet *string `json:"secondarySubnet,omitempty"` + // ExpressRouteID - READ-ONLY; Identifier of the ExpressRoute Circuit (Microsoft Colo only) + ExpressRouteID *string `json:"expressRouteID,omitempty"` + // ExpressRoutePrivatePeeringID - READ-ONLY; ExpressRoute Circuit private peering identifier + ExpressRoutePrivatePeeringID *string `json:"expressRoutePrivatePeeringID,omitempty"` +} + +// CloudError API error response +type CloudError struct { + // Error - An error returned by the API + Error *ErrorResponse `json:"error,omitempty"` +} + +// CloudLink a cloud link resource +type CloudLink struct { + autorest.Response `json:"-"` + // CloudLinkProperties - The properties of a cloud link. + *CloudLinkProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for CloudLink. +func (cl CloudLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cl.CloudLinkProperties != nil { + objectMap["properties"] = cl.CloudLinkProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CloudLink struct. +func (cl *CloudLink) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var cloudLinkProperties CloudLinkProperties + err = json.Unmarshal(*v, &cloudLinkProperties) + if err != nil { + return err + } + cl.CloudLinkProperties = &cloudLinkProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cl.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cl.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cl.Type = &typeVar + } + } + } + + return nil +} + +// CloudLinkList a paged list of cloud links +type CloudLinkList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]CloudLink `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// CloudLinkListIterator provides access to a complete listing of CloudLink values. +type CloudLinkListIterator struct { + i int + page CloudLinkListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *CloudLinkListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudLinkListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *CloudLinkListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CloudLinkListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter CloudLinkListIterator) Response() CloudLinkList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter CloudLinkListIterator) Value() CloudLink { + if !iter.page.NotDone() { + return CloudLink{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CloudLinkListIterator type. +func NewCloudLinkListIterator(page CloudLinkListPage) CloudLinkListIterator { + return CloudLinkListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cll CloudLinkList) IsEmpty() bool { + return cll.Value == nil || len(*cll.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cll CloudLinkList) hasNextLink() bool { + return cll.NextLink != nil && len(*cll.NextLink) != 0 +} + +// cloudLinkListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cll CloudLinkList) cloudLinkListPreparer(ctx context.Context) (*http.Request, error) { + if !cll.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cll.NextLink))) +} + +// CloudLinkListPage contains a page of CloudLink values. +type CloudLinkListPage struct { + fn func(context.Context, CloudLinkList) (CloudLinkList, error) + cll CloudLinkList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *CloudLinkListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudLinkListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.cll) + if err != nil { + return err + } + page.cll = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *CloudLinkListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CloudLinkListPage) NotDone() bool { + return !page.cll.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CloudLinkListPage) Response() CloudLinkList { + return page.cll +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CloudLinkListPage) Values() []CloudLink { + if page.cll.IsEmpty() { + return nil + } + return *page.cll.Value +} + +// Creates a new instance of the CloudLinkListPage type. +func NewCloudLinkListPage(cur CloudLinkList, getNextPage func(context.Context, CloudLinkList) (CloudLinkList, error)) CloudLinkListPage { + return CloudLinkListPage{ + fn: getNextPage, + cll: cur, + } +} + +// CloudLinkProperties the properties of a cloud link. +type CloudLinkProperties struct { + // Status - READ-ONLY; The state of the cloud link. Possible values include: 'CloudLinkStatusActive', 'CloudLinkStatusBuilding', 'CloudLinkStatusDeleting', 'CloudLinkStatusFailed', 'CloudLinkStatusDisconnected' + Status CloudLinkStatus `json:"status,omitempty"` + // LinkedCloud - Identifier of the other private cloud participating in the link. + LinkedCloud *string `json:"linkedCloud,omitempty"` +} + +// MarshalJSON is the custom marshaler for CloudLinkProperties. +func (clp CloudLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if clp.LinkedCloud != nil { + objectMap["linkedCloud"] = clp.LinkedCloud + } + return json.Marshal(objectMap) +} + +// CloudLinksCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CloudLinksCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CloudLinksClient) (CloudLink, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CloudLinksCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CloudLinksCreateOrUpdateFuture.Result. +func (future *CloudLinksCreateOrUpdateFuture) result(client CloudLinksClient) (cl CloudLink, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.CloudLinksCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + cl.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.CloudLinksCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if cl.Response.Response, err = future.GetResult(sender); err == nil && cl.Response.Response.StatusCode != http.StatusNoContent { + cl, err = client.CreateOrUpdateResponder(cl.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.CloudLinksCreateOrUpdateFuture", "Result", cl.Response.Response, "Failure responding to request") + } + } + return +} + +// CloudLinksDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CloudLinksDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CloudLinksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CloudLinksDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CloudLinksDeleteFuture.Result. +func (future *CloudLinksDeleteFuture) result(client CloudLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.CloudLinksDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.CloudLinksDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// Cluster a cluster resource +type Cluster struct { + autorest.Response `json:"-"` + // Sku - The cluster SKU + Sku *Sku `json:"sku,omitempty"` + // ClusterProperties - The properties of a cluster resource + *ClusterProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Cluster. +func (c Cluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.Sku != nil { + objectMap["sku"] = c.Sku + } + if c.ClusterProperties != nil { + objectMap["properties"] = c.ClusterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Cluster struct. +func (c *Cluster) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + c.Sku = &sku + } + case "properties": + if v != nil { + var clusterProperties ClusterProperties + err = json.Unmarshal(*v, &clusterProperties) + if err != nil { + return err + } + c.ClusterProperties = &clusterProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ClusterList a paged list of clusters +type ClusterList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]Cluster `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// ClusterListIterator provides access to a complete listing of Cluster values. +type ClusterListIterator struct { + i int + page ClusterListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ClusterListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ClusterListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ClusterListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ClusterListIterator) Response() ClusterList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ClusterListIterator) Value() Cluster { + if !iter.page.NotDone() { + return Cluster{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ClusterListIterator type. +func NewClusterListIterator(page ClusterListPage) ClusterListIterator { + return ClusterListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cl ClusterList) IsEmpty() bool { + return cl.Value == nil || len(*cl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cl ClusterList) hasNextLink() bool { + return cl.NextLink != nil && len(*cl.NextLink) != 0 +} + +// clusterListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cl ClusterList) clusterListPreparer(ctx context.Context) (*http.Request, error) { + if !cl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cl.NextLink))) +} + +// ClusterListPage contains a page of Cluster values. +type ClusterListPage struct { + fn func(context.Context, ClusterList) (ClusterList, error) + cl ClusterList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ClusterListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.cl) + if err != nil { + return err + } + page.cl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ClusterListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ClusterListPage) NotDone() bool { + return !page.cl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ClusterListPage) Response() ClusterList { + return page.cl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ClusterListPage) Values() []Cluster { + if page.cl.IsEmpty() { + return nil + } + return *page.cl.Value +} + +// Creates a new instance of the ClusterListPage type. +func NewClusterListPage(cur ClusterList, getNextPage func(context.Context, ClusterList) (ClusterList, error)) ClusterListPage { + return ClusterListPage{ + fn: getNextPage, + cl: cur, + } +} + +// ClusterProperties the properties of a cluster +type ClusterProperties struct { + // ProvisioningState - The state of the cluster provisioning. Possible values include: 'ClusterProvisioningStateSucceeded', 'ClusterProvisioningStateFailed', 'ClusterProvisioningStateCancelled', 'ClusterProvisioningStateDeleting', 'ClusterProvisioningStateUpdating' + ProvisioningState ClusterProvisioningState `json:"provisioningState,omitempty"` + // ClusterSize - The cluster size + ClusterSize *int32 `json:"clusterSize,omitempty"` + // ClusterID - READ-ONLY; The identity + ClusterID *int32 `json:"clusterId,omitempty"` + // Hosts - READ-ONLY; The hosts + Hosts *[]string `json:"hosts,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterProperties. +func (cp ClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.ProvisioningState != "" { + objectMap["provisioningState"] = cp.ProvisioningState + } + if cp.ClusterSize != nil { + objectMap["clusterSize"] = cp.ClusterSize + } + return json.Marshal(objectMap) +} + +// ClustersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ClustersCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ClustersClient) (Cluster, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ClustersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ClustersCreateOrUpdateFuture.Result. +func (future *ClustersCreateOrUpdateFuture) result(client ClustersClient) (c Cluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + c.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.ClustersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.CreateOrUpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersCreateOrUpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// ClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ClustersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ClustersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ClustersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ClustersDeleteFuture.Result. +func (future *ClustersDeleteFuture) result(client ClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.ClustersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ClustersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ClustersClient) (Cluster, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ClustersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ClustersUpdateFuture.Result. +func (future *ClustersUpdateFuture) result(client ClustersClient) (c Cluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + c.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.ClustersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.UpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersUpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// ClusterUpdate an update of a cluster resource +type ClusterUpdate struct { + // ClusterUpdateProperties - The properties of a cluster resource that may be updated + *ClusterUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterUpdate. +func (cu ClusterUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cu.ClusterUpdateProperties != nil { + objectMap["properties"] = cu.ClusterUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ClusterUpdate struct. +func (cu *ClusterUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var clusterUpdateProperties ClusterUpdateProperties + err = json.Unmarshal(*v, &clusterUpdateProperties) + if err != nil { + return err + } + cu.ClusterUpdateProperties = &clusterUpdateProperties + } + } + } + + return nil +} + +// ClusterUpdateProperties the properties of a cluster that may be updated +type ClusterUpdateProperties struct { + // ClusterSize - The cluster size + ClusterSize *int32 `json:"clusterSize,omitempty"` +} + +// CommonClusterProperties the common properties of a cluster +type CommonClusterProperties struct { + // ProvisioningState - The state of the cluster provisioning. Possible values include: 'ClusterProvisioningStateSucceeded', 'ClusterProvisioningStateFailed', 'ClusterProvisioningStateCancelled', 'ClusterProvisioningStateDeleting', 'ClusterProvisioningStateUpdating' + ProvisioningState ClusterProvisioningState `json:"provisioningState,omitempty"` + // ClusterSize - The cluster size + ClusterSize *int32 `json:"clusterSize,omitempty"` + // ClusterID - READ-ONLY; The identity + ClusterID *int32 `json:"clusterId,omitempty"` + // Hosts - READ-ONLY; The hosts + Hosts *[]string `json:"hosts,omitempty"` +} + +// MarshalJSON is the custom marshaler for CommonClusterProperties. +func (ccp CommonClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccp.ProvisioningState != "" { + objectMap["provisioningState"] = ccp.ProvisioningState + } + if ccp.ClusterSize != nil { + objectMap["clusterSize"] = ccp.ClusterSize + } + return json.Marshal(objectMap) +} + +// Datastore a datastore resource +type Datastore struct { + autorest.Response `json:"-"` + // DatastoreProperties - The properties of a datastore resource + *DatastoreProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Datastore. +func (d Datastore) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.DatastoreProperties != nil { + objectMap["properties"] = d.DatastoreProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Datastore struct. +func (d *Datastore) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var datastoreProperties DatastoreProperties + err = json.Unmarshal(*v, &datastoreProperties) + if err != nil { + return err + } + d.DatastoreProperties = &datastoreProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + } + } + + return nil +} + +// DatastoreList a paged list of datastores +type DatastoreList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]Datastore `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// DatastoreListIterator provides access to a complete listing of Datastore values. +type DatastoreListIterator struct { + i int + page DatastoreListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatastoreListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatastoreListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatastoreListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatastoreListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DatastoreListIterator) Response() DatastoreList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DatastoreListIterator) Value() Datastore { + if !iter.page.NotDone() { + return Datastore{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatastoreListIterator type. +func NewDatastoreListIterator(page DatastoreListPage) DatastoreListIterator { + return DatastoreListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dl DatastoreList) IsEmpty() bool { + return dl.Value == nil || len(*dl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dl DatastoreList) hasNextLink() bool { + return dl.NextLink != nil && len(*dl.NextLink) != 0 +} + +// datastoreListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dl DatastoreList) datastoreListPreparer(ctx context.Context) (*http.Request, error) { + if !dl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dl.NextLink))) +} + +// DatastoreListPage contains a page of Datastore values. +type DatastoreListPage struct { + fn func(context.Context, DatastoreList) (DatastoreList, error) + dl DatastoreList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatastoreListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatastoreListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dl) + if err != nil { + return err + } + page.dl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DatastoreListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatastoreListPage) NotDone() bool { + return !page.dl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatastoreListPage) Response() DatastoreList { + return page.dl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatastoreListPage) Values() []Datastore { + if page.dl.IsEmpty() { + return nil + } + return *page.dl.Value +} + +// Creates a new instance of the DatastoreListPage type. +func NewDatastoreListPage(cur DatastoreList, getNextPage func(context.Context, DatastoreList) (DatastoreList, error)) DatastoreListPage { + return DatastoreListPage{ + fn: getNextPage, + dl: cur, + } +} + +// DatastoreProperties the properties of a datastore +type DatastoreProperties struct { + // ProvisioningState - READ-ONLY; The state of the datastore provisioning. Possible values include: 'DatastoreProvisioningStateSucceeded', 'DatastoreProvisioningStateFailed', 'DatastoreProvisioningStateCancelled', 'DatastoreProvisioningStatePending', 'DatastoreProvisioningStateCreating', 'DatastoreProvisioningStateUpdating', 'DatastoreProvisioningStateDeleting' + ProvisioningState DatastoreProvisioningState `json:"provisioningState,omitempty"` + // NetAppVolume - An Azure NetApp Files volume + NetAppVolume *NetAppVolume `json:"netAppVolume,omitempty"` + // DiskPoolVolume - An iSCSI volume + DiskPoolVolume *DiskPoolVolume `json:"diskPoolVolume,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatastoreProperties. +func (dp DatastoreProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dp.NetAppVolume != nil { + objectMap["netAppVolume"] = dp.NetAppVolume + } + if dp.DiskPoolVolume != nil { + objectMap["diskPoolVolume"] = dp.DiskPoolVolume + } + return json.Marshal(objectMap) +} + +// DatastoresCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatastoresCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatastoresClient) (Datastore, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatastoresCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatastoresCreateOrUpdateFuture.Result. +func (future *DatastoresCreateOrUpdateFuture) result(client DatastoresClient) (d Datastore, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.DatastoresCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.DatastoresCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.CreateOrUpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.DatastoresCreateOrUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatastoresDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatastoresDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatastoresClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatastoresDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatastoresDeleteFuture.Result. +func (future *DatastoresDeleteFuture) result(client DatastoresClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.DatastoresDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.DatastoresDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// DiskPoolVolume an iSCSI volume from Microsoft.StoragePool provider +type DiskPoolVolume struct { + // TargetID - Azure resource ID of the iSCSI target + TargetID *string `json:"targetId,omitempty"` + // LunName - Name of the LUN to be used for datastore + LunName *string `json:"lunName,omitempty"` + // MountOption - Mode that describes whether the LUN has to be mounted as a datastore or attached as a LUN. Possible values include: 'MOUNT', 'ATTACH' + MountOption MountOptionEnum `json:"mountOption,omitempty"` + // Path - READ-ONLY; Device path + Path *string `json:"path,omitempty"` +} + +// MarshalJSON is the custom marshaler for DiskPoolVolume. +func (dpv DiskPoolVolume) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dpv.TargetID != nil { + objectMap["targetId"] = dpv.TargetID + } + if dpv.LunName != nil { + objectMap["lunName"] = dpv.LunName + } + if dpv.MountOption != "" { + objectMap["mountOption"] = dpv.MountOption + } + return json.Marshal(objectMap) +} + +// Endpoints endpoint addresses +type Endpoints struct { + // NsxtManager - READ-ONLY; Endpoint for the NSX-T Data Center manager + NsxtManager *string `json:"nsxtManager,omitempty"` + // Vcsa - READ-ONLY; Endpoint for Virtual Center Server Appliance + Vcsa *string `json:"vcsa,omitempty"` + // HcxCloudManager - READ-ONLY; Endpoint for the HCX Cloud Manager + HcxCloudManager *string `json:"hcxCloudManager,omitempty"` +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.) +type ErrorResponse struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorResponse `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// ExpressRouteAuthorization expressRoute Circuit Authorization +type ExpressRouteAuthorization struct { + autorest.Response `json:"-"` + // ExpressRouteAuthorizationProperties - READ-ONLY; The properties of an ExpressRoute Circuit Authorization resource + *ExpressRouteAuthorizationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExpressRouteAuthorization. +func (era ExpressRouteAuthorization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ExpressRouteAuthorization struct. +func (era *ExpressRouteAuthorization) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var expressRouteAuthorizationProperties ExpressRouteAuthorizationProperties + err = json.Unmarshal(*v, &expressRouteAuthorizationProperties) + if err != nil { + return err + } + era.ExpressRouteAuthorizationProperties = &expressRouteAuthorizationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + era.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + era.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + era.Type = &typeVar + } + } + } + + return nil +} + +// ExpressRouteAuthorizationList a paged list of ExpressRoute Circuit Authorizations +type ExpressRouteAuthorizationList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]ExpressRouteAuthorization `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// ExpressRouteAuthorizationListIterator provides access to a complete listing of ExpressRouteAuthorization +// values. +type ExpressRouteAuthorizationListIterator struct { + i int + page ExpressRouteAuthorizationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ExpressRouteAuthorizationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteAuthorizationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ExpressRouteAuthorizationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ExpressRouteAuthorizationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ExpressRouteAuthorizationListIterator) Response() ExpressRouteAuthorizationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ExpressRouteAuthorizationListIterator) Value() ExpressRouteAuthorization { + if !iter.page.NotDone() { + return ExpressRouteAuthorization{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ExpressRouteAuthorizationListIterator type. +func NewExpressRouteAuthorizationListIterator(page ExpressRouteAuthorizationListPage) ExpressRouteAuthorizationListIterator { + return ExpressRouteAuthorizationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (eral ExpressRouteAuthorizationList) IsEmpty() bool { + return eral.Value == nil || len(*eral.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (eral ExpressRouteAuthorizationList) hasNextLink() bool { + return eral.NextLink != nil && len(*eral.NextLink) != 0 +} + +// expressRouteAuthorizationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eral ExpressRouteAuthorizationList) expressRouteAuthorizationListPreparer(ctx context.Context) (*http.Request, error) { + if !eral.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eral.NextLink))) +} + +// ExpressRouteAuthorizationListPage contains a page of ExpressRouteAuthorization values. +type ExpressRouteAuthorizationListPage struct { + fn func(context.Context, ExpressRouteAuthorizationList) (ExpressRouteAuthorizationList, error) + eral ExpressRouteAuthorizationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ExpressRouteAuthorizationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteAuthorizationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.eral) + if err != nil { + return err + } + page.eral = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ExpressRouteAuthorizationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ExpressRouteAuthorizationListPage) NotDone() bool { + return !page.eral.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ExpressRouteAuthorizationListPage) Response() ExpressRouteAuthorizationList { + return page.eral +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ExpressRouteAuthorizationListPage) Values() []ExpressRouteAuthorization { + if page.eral.IsEmpty() { + return nil + } + return *page.eral.Value +} + +// Creates a new instance of the ExpressRouteAuthorizationListPage type. +func NewExpressRouteAuthorizationListPage(cur ExpressRouteAuthorizationList, getNextPage func(context.Context, ExpressRouteAuthorizationList) (ExpressRouteAuthorizationList, error)) ExpressRouteAuthorizationListPage { + return ExpressRouteAuthorizationListPage{ + fn: getNextPage, + eral: cur, + } +} + +// ExpressRouteAuthorizationProperties the properties of an ExpressRoute Circuit Authorization resource +type ExpressRouteAuthorizationProperties struct { + // ProvisioningState - READ-ONLY; The state of the ExpressRoute Circuit Authorization provisioning. Possible values include: 'ExpressRouteAuthorizationProvisioningStateSucceeded', 'ExpressRouteAuthorizationProvisioningStateFailed', 'ExpressRouteAuthorizationProvisioningStateUpdating' + ProvisioningState ExpressRouteAuthorizationProvisioningState `json:"provisioningState,omitempty"` + // ExpressRouteAuthorizationID - READ-ONLY; The ID of the ExpressRoute Circuit Authorization + ExpressRouteAuthorizationID *string `json:"expressRouteAuthorizationId,omitempty"` + // ExpressRouteAuthorizationKey - READ-ONLY; The key of the ExpressRoute Circuit Authorization + ExpressRouteAuthorizationKey *string `json:"expressRouteAuthorizationKey,omitempty"` +} + +// GlobalReachConnection a global reach connection resource +type GlobalReachConnection struct { + autorest.Response `json:"-"` + // GlobalReachConnectionProperties - The properties of a global reach connection resource + *GlobalReachConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for GlobalReachConnection. +func (grc GlobalReachConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if grc.GlobalReachConnectionProperties != nil { + objectMap["properties"] = grc.GlobalReachConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GlobalReachConnection struct. +func (grc *GlobalReachConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var globalReachConnectionProperties GlobalReachConnectionProperties + err = json.Unmarshal(*v, &globalReachConnectionProperties) + if err != nil { + return err + } + grc.GlobalReachConnectionProperties = &globalReachConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + grc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + grc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + grc.Type = &typeVar + } + } + } + + return nil +} + +// GlobalReachConnectionList a paged list of global reach connections +type GlobalReachConnectionList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]GlobalReachConnection `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// GlobalReachConnectionListIterator provides access to a complete listing of GlobalReachConnection values. +type GlobalReachConnectionListIterator struct { + i int + page GlobalReachConnectionListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *GlobalReachConnectionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GlobalReachConnectionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *GlobalReachConnectionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter GlobalReachConnectionListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter GlobalReachConnectionListIterator) Response() GlobalReachConnectionList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter GlobalReachConnectionListIterator) Value() GlobalReachConnection { + if !iter.page.NotDone() { + return GlobalReachConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the GlobalReachConnectionListIterator type. +func NewGlobalReachConnectionListIterator(page GlobalReachConnectionListPage) GlobalReachConnectionListIterator { + return GlobalReachConnectionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (grcl GlobalReachConnectionList) IsEmpty() bool { + return grcl.Value == nil || len(*grcl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (grcl GlobalReachConnectionList) hasNextLink() bool { + return grcl.NextLink != nil && len(*grcl.NextLink) != 0 +} + +// globalReachConnectionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (grcl GlobalReachConnectionList) globalReachConnectionListPreparer(ctx context.Context) (*http.Request, error) { + if !grcl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(grcl.NextLink))) +} + +// GlobalReachConnectionListPage contains a page of GlobalReachConnection values. +type GlobalReachConnectionListPage struct { + fn func(context.Context, GlobalReachConnectionList) (GlobalReachConnectionList, error) + grcl GlobalReachConnectionList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *GlobalReachConnectionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GlobalReachConnectionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.grcl) + if err != nil { + return err + } + page.grcl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *GlobalReachConnectionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page GlobalReachConnectionListPage) NotDone() bool { + return !page.grcl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page GlobalReachConnectionListPage) Response() GlobalReachConnectionList { + return page.grcl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page GlobalReachConnectionListPage) Values() []GlobalReachConnection { + if page.grcl.IsEmpty() { + return nil + } + return *page.grcl.Value +} + +// Creates a new instance of the GlobalReachConnectionListPage type. +func NewGlobalReachConnectionListPage(cur GlobalReachConnectionList, getNextPage func(context.Context, GlobalReachConnectionList) (GlobalReachConnectionList, error)) GlobalReachConnectionListPage { + return GlobalReachConnectionListPage{ + fn: getNextPage, + grcl: cur, + } +} + +// GlobalReachConnectionProperties the properties of a global reach connection +type GlobalReachConnectionProperties struct { + // ProvisioningState - READ-ONLY; The state of the ExpressRoute Circuit Authorization provisioning. Possible values include: 'GlobalReachConnectionProvisioningStateSucceeded', 'GlobalReachConnectionProvisioningStateFailed', 'GlobalReachConnectionProvisioningStateUpdating' + ProvisioningState GlobalReachConnectionProvisioningState `json:"provisioningState,omitempty"` + // AddressPrefix - READ-ONLY; The network used for global reach carved out from the original network block provided for the private cloud + AddressPrefix *string `json:"addressPrefix,omitempty"` + // AuthorizationKey - Authorization key from the peer express route used for the global reach connection + AuthorizationKey *string `json:"authorizationKey,omitempty"` + // CircuitConnectionStatus - READ-ONLY; The connection status of the global reach connection. Possible values include: 'Connected', 'Connecting', 'Disconnected' + CircuitConnectionStatus GlobalReachConnectionStatus `json:"circuitConnectionStatus,omitempty"` + // PeerExpressRouteCircuit - Identifier of the ExpressRoute Circuit to peer with in the global reach connection + PeerExpressRouteCircuit *string `json:"peerExpressRouteCircuit,omitempty"` +} + +// MarshalJSON is the custom marshaler for GlobalReachConnectionProperties. +func (grcp GlobalReachConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if grcp.AuthorizationKey != nil { + objectMap["authorizationKey"] = grcp.AuthorizationKey + } + if grcp.PeerExpressRouteCircuit != nil { + objectMap["peerExpressRouteCircuit"] = grcp.PeerExpressRouteCircuit + } + return json.Marshal(objectMap) +} + +// GlobalReachConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type GlobalReachConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GlobalReachConnectionsClient) (GlobalReachConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GlobalReachConnectionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GlobalReachConnectionsCreateOrUpdateFuture.Result. +func (future *GlobalReachConnectionsCreateOrUpdateFuture) result(client GlobalReachConnectionsClient) (grc GlobalReachConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + grc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.GlobalReachConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if grc.Response.Response, err = future.GetResult(sender); err == nil && grc.Response.Response.StatusCode != http.StatusNoContent { + grc, err = client.CreateOrUpdateResponder(grc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsCreateOrUpdateFuture", "Result", grc.Response.Response, "Failure responding to request") + } + } + return +} + +// GlobalReachConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type GlobalReachConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GlobalReachConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GlobalReachConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GlobalReachConnectionsDeleteFuture.Result. +func (future *GlobalReachConnectionsDeleteFuture) result(client GlobalReachConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.GlobalReachConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.GlobalReachConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// HcxEnterpriseSite an HCX Enterprise Site resource +type HcxEnterpriseSite struct { + autorest.Response `json:"-"` + // HcxEnterpriseSiteProperties - READ-ONLY; The properties of an HCX Enterprise Site resource + *HcxEnterpriseSiteProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for HcxEnterpriseSite. +func (hes HcxEnterpriseSite) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for HcxEnterpriseSite struct. +func (hes *HcxEnterpriseSite) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var hcxEnterpriseSiteProperties HcxEnterpriseSiteProperties + err = json.Unmarshal(*v, &hcxEnterpriseSiteProperties) + if err != nil { + return err + } + hes.HcxEnterpriseSiteProperties = &hcxEnterpriseSiteProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + hes.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + hes.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + hes.Type = &typeVar + } + } + } + + return nil +} + +// HcxEnterpriseSiteList a paged list of HCX Enterprise Sites +type HcxEnterpriseSiteList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]HcxEnterpriseSite `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// HcxEnterpriseSiteListIterator provides access to a complete listing of HcxEnterpriseSite values. +type HcxEnterpriseSiteListIterator struct { + i int + page HcxEnterpriseSiteListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *HcxEnterpriseSiteListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSiteListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *HcxEnterpriseSiteListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter HcxEnterpriseSiteListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter HcxEnterpriseSiteListIterator) Response() HcxEnterpriseSiteList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter HcxEnterpriseSiteListIterator) Value() HcxEnterpriseSite { + if !iter.page.NotDone() { + return HcxEnterpriseSite{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the HcxEnterpriseSiteListIterator type. +func NewHcxEnterpriseSiteListIterator(page HcxEnterpriseSiteListPage) HcxEnterpriseSiteListIterator { + return HcxEnterpriseSiteListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (hesl HcxEnterpriseSiteList) IsEmpty() bool { + return hesl.Value == nil || len(*hesl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (hesl HcxEnterpriseSiteList) hasNextLink() bool { + return hesl.NextLink != nil && len(*hesl.NextLink) != 0 +} + +// hcxEnterpriseSiteListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (hesl HcxEnterpriseSiteList) hcxEnterpriseSiteListPreparer(ctx context.Context) (*http.Request, error) { + if !hesl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(hesl.NextLink))) +} + +// HcxEnterpriseSiteListPage contains a page of HcxEnterpriseSite values. +type HcxEnterpriseSiteListPage struct { + fn func(context.Context, HcxEnterpriseSiteList) (HcxEnterpriseSiteList, error) + hesl HcxEnterpriseSiteList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *HcxEnterpriseSiteListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSiteListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.hesl) + if err != nil { + return err + } + page.hesl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *HcxEnterpriseSiteListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page HcxEnterpriseSiteListPage) NotDone() bool { + return !page.hesl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page HcxEnterpriseSiteListPage) Response() HcxEnterpriseSiteList { + return page.hesl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page HcxEnterpriseSiteListPage) Values() []HcxEnterpriseSite { + if page.hesl.IsEmpty() { + return nil + } + return *page.hesl.Value +} + +// Creates a new instance of the HcxEnterpriseSiteListPage type. +func NewHcxEnterpriseSiteListPage(cur HcxEnterpriseSiteList, getNextPage func(context.Context, HcxEnterpriseSiteList) (HcxEnterpriseSiteList, error)) HcxEnterpriseSiteListPage { + return HcxEnterpriseSiteListPage{ + fn: getNextPage, + hesl: cur, + } +} + +// HcxEnterpriseSiteProperties the properties of an HCX Enterprise Site +type HcxEnterpriseSiteProperties struct { + // ActivationKey - READ-ONLY; The activation key + ActivationKey *string `json:"activationKey,omitempty"` + // Status - READ-ONLY; The status of the HCX Enterprise Site. Possible values include: 'Available', 'Consumed', 'Deactivated', 'Deleted' + Status HcxEnterpriseSiteStatus `json:"status,omitempty"` +} + +// IdentitySource vCenter Single Sign On Identity Source +type IdentitySource struct { + // Name - The name of the identity source + Name *string `json:"name,omitempty"` + // Alias - The domain's NetBIOS name + Alias *string `json:"alias,omitempty"` + // Domain - The domain's dns name + Domain *string `json:"domain,omitempty"` + // BaseUserDN - The base distinguished name for users + BaseUserDN *string `json:"baseUserDN,omitempty"` + // BaseGroupDN - The base distinguished name for groups + BaseGroupDN *string `json:"baseGroupDN,omitempty"` + // PrimaryServer - Primary server URL + PrimaryServer *string `json:"primaryServer,omitempty"` + // SecondaryServer - Secondary server URL + SecondaryServer *string `json:"secondaryServer,omitempty"` + // Ssl - Protect LDAP communication using SSL certificate (LDAPS). Possible values include: 'SslEnumEnabled', 'SslEnumDisabled' + Ssl SslEnum `json:"ssl,omitempty"` + // Username - The ID of an Active Directory user with a minimum of read-only access to Base DN for users and group + Username *string `json:"username,omitempty"` + // Password - The password of the Active Directory user with a minimum of read-only access to Base DN for users and groups. + Password *string `json:"password,omitempty"` +} + +// LogSpecification specifications of the Log for Azure Monitoring +type LogSpecification struct { + // Name - Name of the log + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the log + DisplayName *string `json:"displayName,omitempty"` + // BlobDuration - Blob duration of the log + BlobDuration *string `json:"blobDuration,omitempty"` +} + +// ManagementCluster the properties of a management cluster +type ManagementCluster struct { + // ProvisioningState - The state of the cluster provisioning. Possible values include: 'ClusterProvisioningStateSucceeded', 'ClusterProvisioningStateFailed', 'ClusterProvisioningStateCancelled', 'ClusterProvisioningStateDeleting', 'ClusterProvisioningStateUpdating' + ProvisioningState ClusterProvisioningState `json:"provisioningState,omitempty"` + // ClusterSize - The cluster size + ClusterSize *int32 `json:"clusterSize,omitempty"` + // ClusterID - READ-ONLY; The identity + ClusterID *int32 `json:"clusterId,omitempty"` + // Hosts - READ-ONLY; The hosts + Hosts *[]string `json:"hosts,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagementCluster. +func (mc ManagementCluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mc.ProvisioningState != "" { + objectMap["provisioningState"] = mc.ProvisioningState + } + if mc.ClusterSize != nil { + objectMap["clusterSize"] = mc.ClusterSize + } + return json.Marshal(objectMap) +} + +// MetricDimension specifications of the Dimension of metrics +type MetricDimension struct { + // Name - Name of the dimension + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the dimension + DisplayName *string `json:"displayName,omitempty"` + // InternalName - Name of the dimension as it appears in MDM + InternalName *string `json:"internalName,omitempty"` + // ToBeExportedForShoebox - A boolean flag indicating whether this dimension should be included for the shoebox export scenario + ToBeExportedForShoebox *bool `json:"toBeExportedForShoebox,omitempty"` +} + +// MetricSpecification specifications of the Metrics for Azure Monitoring +type MetricSpecification struct { + // Name - Name of the metric + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the metric + DisplayName *string `json:"displayName,omitempty"` + // DisplayDescription - Localized friendly description of the metric + DisplayDescription *string `json:"displayDescription,omitempty"` + // Unit - Unit that makes sense for the metric + Unit *string `json:"unit,omitempty"` + // Category - Name of the metric category that the metric belongs to. A metric can only belong to a single category. + Category *string `json:"category,omitempty"` + // AggregationType - Only provide one value for this field. Valid values: Average, Minimum, Maximum, Total, Count. + AggregationType *string `json:"aggregationType,omitempty"` + // SupportedAggregationTypes - Supported aggregation types + SupportedAggregationTypes *[]string `json:"supportedAggregationTypes,omitempty"` + // SupportedTimeGrainTypes - Supported time grain types + SupportedTimeGrainTypes *[]string `json:"supportedTimeGrainTypes,omitempty"` + // FillGapWithZero - Optional. If set to true, then zero will be returned for time duration where no metric is emitted/published. + FillGapWithZero *bool `json:"fillGapWithZero,omitempty"` + // Dimensions - Dimensions of the metric + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // EnableRegionalMdmAccount - Whether or not the service is using regional MDM accounts. + EnableRegionalMdmAccount *string `json:"enableRegionalMdmAccount,omitempty"` + // SourceMdmAccount - The name of the MDM account. + SourceMdmAccount *string `json:"sourceMdmAccount,omitempty"` + // SourceMdmNamespace - The name of the MDM namespace. + SourceMdmNamespace *string `json:"sourceMdmNamespace,omitempty"` +} + +// NetAppVolume an Azure NetApp Files volume from Microsoft.NetApp provider +type NetAppVolume struct { + // ID - Azure resource ID of the NetApp volume + ID *string `json:"id,omitempty"` +} + +// Operation a REST API operation +type Operation struct { + // Name - READ-ONLY; Name of the operation being performed on this object + Name *string `json:"name,omitempty"` + // Display - READ-ONLY; Contains the localized display information for this operation + Display *OperationDisplay `json:"display,omitempty"` + // IsDataAction - Gets or sets a value indicating whether the operation is a data action or not + IsDataAction *bool `json:"isDataAction,omitempty"` + // Origin - Origin of the operation + Origin *string `json:"origin,omitempty"` + // Properties - Properties of the operation + Properties *OperationProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.IsDataAction != nil { + objectMap["isDataAction"] = o.IsDataAction + } + if o.Origin != nil { + objectMap["origin"] = o.Origin + } + if o.Properties != nil { + objectMap["properties"] = o.Properties + } + return json.Marshal(objectMap) +} + +// OperationDisplay contains the localized display information for this operation +type OperationDisplay struct { + // Provider - READ-ONLY; Localized friendly form of the resource provider name + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Localized friendly form of the resource type related to this operation + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Localized friendly name for the operation + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Localized friendly description for the operation + Description *string `json:"description,omitempty"` +} + +// OperationList pageable list of operations +type OperationList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of operations + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListIterator provides access to a complete listing of Operation values. +type OperationListIterator struct { + i int + page OperationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListIterator) Response() OperationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListIterator type. +func NewOperationListIterator(page OperationListPage) OperationListIterator { + return OperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OperationList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ol OperationList) hasNextLink() bool { + return ol.NextLink != nil && len(*ol.NextLink) != 0 +} + +// operationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { + if !ol.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OperationListPage contains a page of Operation values. +type OperationListPage struct { + fn func(context.Context, OperationList) (OperationList, error) + ol OperationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ol) + if err != nil { + return err + } + page.ol = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListPage) Response() OperationList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListPage) Values() []Operation { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OperationListPage type. +func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { + return OperationListPage{ + fn: getNextPage, + ol: cur, + } +} + +// OperationProperties extra Operation properties +type OperationProperties struct { + // ServiceSpecification - Service specifications of the operation + ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// PrivateCloud a private cloud resource +type PrivateCloud struct { + autorest.Response `json:"-"` + // Sku - The private cloud SKU + Sku *Sku `json:"sku,omitempty"` + // PrivateCloudProperties - The properties of a private cloud resource + *PrivateCloudProperties `json:"properties,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateCloud. +func (pc PrivateCloud) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pc.Sku != nil { + objectMap["sku"] = pc.Sku + } + if pc.PrivateCloudProperties != nil { + objectMap["properties"] = pc.PrivateCloudProperties + } + if pc.Location != nil { + objectMap["location"] = pc.Location + } + if pc.Tags != nil { + objectMap["tags"] = pc.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateCloud struct. +func (pc *PrivateCloud) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + pc.Sku = &sku + } + case "properties": + if v != nil { + var privateCloudProperties PrivateCloudProperties + err = json.Unmarshal(*v, &privateCloudProperties) + if err != nil { + return err + } + pc.PrivateCloudProperties = &privateCloudProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + pc.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + pc.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pc.Type = &typeVar + } + } + } + + return nil +} + +// PrivateCloudList a paged list of private clouds +type PrivateCloudList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on the page + Value *[]PrivateCloud `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// PrivateCloudListIterator provides access to a complete listing of PrivateCloud values. +type PrivateCloudListIterator struct { + i int + page PrivateCloudListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateCloudListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateCloudListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateCloudListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateCloudListIterator) Response() PrivateCloudList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateCloudListIterator) Value() PrivateCloud { + if !iter.page.NotDone() { + return PrivateCloud{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateCloudListIterator type. +func NewPrivateCloudListIterator(page PrivateCloudListPage) PrivateCloudListIterator { + return PrivateCloudListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (pcl PrivateCloudList) IsEmpty() bool { + return pcl.Value == nil || len(*pcl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (pcl PrivateCloudList) hasNextLink() bool { + return pcl.NextLink != nil && len(*pcl.NextLink) != 0 +} + +// privateCloudListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (pcl PrivateCloudList) privateCloudListPreparer(ctx context.Context) (*http.Request, error) { + if !pcl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(pcl.NextLink))) +} + +// PrivateCloudListPage contains a page of PrivateCloud values. +type PrivateCloudListPage struct { + fn func(context.Context, PrivateCloudList) (PrivateCloudList, error) + pcl PrivateCloudList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateCloudListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.pcl) + if err != nil { + return err + } + page.pcl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateCloudListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateCloudListPage) NotDone() bool { + return !page.pcl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateCloudListPage) Response() PrivateCloudList { + return page.pcl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateCloudListPage) Values() []PrivateCloud { + if page.pcl.IsEmpty() { + return nil + } + return *page.pcl.Value +} + +// Creates a new instance of the PrivateCloudListPage type. +func NewPrivateCloudListPage(cur PrivateCloudList, getNextPage func(context.Context, PrivateCloudList) (PrivateCloudList, error)) PrivateCloudListPage { + return PrivateCloudListPage{ + fn: getNextPage, + pcl: cur, + } +} + +// PrivateCloudProperties the properties of a private cloud resource +type PrivateCloudProperties struct { + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'PrivateCloudProvisioningStateSucceeded', 'PrivateCloudProvisioningStateFailed', 'PrivateCloudProvisioningStateCancelled', 'PrivateCloudProvisioningStatePending', 'PrivateCloudProvisioningStateBuilding', 'PrivateCloudProvisioningStateDeleting', 'PrivateCloudProvisioningStateUpdating' + ProvisioningState PrivateCloudProvisioningState `json:"provisioningState,omitempty"` + // Circuit - An ExpressRoute Circuit + Circuit *Circuit `json:"circuit,omitempty"` + // Endpoints - READ-ONLY; The endpoints + Endpoints *Endpoints `json:"endpoints,omitempty"` + // NetworkBlock - The block of addresses should be unique across VNet in your subscription as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where A,B,C,D are between 0 and 255, and X is between 0 and 22 + NetworkBlock *string `json:"networkBlock,omitempty"` + // ExternalCloudLinks - READ-ONLY; Array of cloud link IDs from other clouds that connect to this one + ExternalCloudLinks *[]string `json:"externalCloudLinks,omitempty"` + // ManagementNetwork - READ-ONLY; Network used to access vCenter Server and NSX-T Manager + ManagementNetwork *string `json:"managementNetwork,omitempty"` + // ProvisioningNetwork - READ-ONLY; Used for virtual machine cold migration, cloning, and snapshot migration + ProvisioningNetwork *string `json:"provisioningNetwork,omitempty"` + // VmotionNetwork - READ-ONLY; Used for live migration of virtual machines + VmotionNetwork *string `json:"vmotionNetwork,omitempty"` + // VcenterPassword - Optionally, set the vCenter admin password when the private cloud is created + VcenterPassword *string `json:"vcenterPassword,omitempty"` + // NsxtPassword - Optionally, set the NSX-T Manager password when the private cloud is created + NsxtPassword *string `json:"nsxtPassword,omitempty"` + // VcenterCertificateThumbprint - READ-ONLY; Thumbprint of the vCenter Server SSL certificate + VcenterCertificateThumbprint *string `json:"vcenterCertificateThumbprint,omitempty"` + // NsxtCertificateThumbprint - READ-ONLY; Thumbprint of the NSX-T Manager SSL certificate + NsxtCertificateThumbprint *string `json:"nsxtCertificateThumbprint,omitempty"` + // ManagementCluster - The default cluster used for management + ManagementCluster *ManagementCluster `json:"managementCluster,omitempty"` + // Internet - Connectivity to internet is enabled or disabled. Possible values include: 'Enabled', 'Disabled' + Internet InternetEnum `json:"internet,omitempty"` + // IdentitySources - vCenter Single Sign On Identity Sources + IdentitySources *[]IdentitySource `json:"identitySources,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateCloudProperties. +func (pcp PrivateCloudProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pcp.Circuit != nil { + objectMap["circuit"] = pcp.Circuit + } + if pcp.NetworkBlock != nil { + objectMap["networkBlock"] = pcp.NetworkBlock + } + if pcp.VcenterPassword != nil { + objectMap["vcenterPassword"] = pcp.VcenterPassword + } + if pcp.NsxtPassword != nil { + objectMap["nsxtPassword"] = pcp.NsxtPassword + } + if pcp.ManagementCluster != nil { + objectMap["managementCluster"] = pcp.ManagementCluster + } + if pcp.Internet != "" { + objectMap["internet"] = pcp.Internet + } + if pcp.IdentitySources != nil { + objectMap["identitySources"] = pcp.IdentitySources + } + return json.Marshal(objectMap) +} + +// PrivateCloudsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateCloudsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateCloudsClient) (PrivateCloud, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateCloudsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateCloudsCreateOrUpdateFuture.Result. +func (future *PrivateCloudsCreateOrUpdateFuture) result(client PrivateCloudsClient) (pc PrivateCloud, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pc.Response.Response, err = future.GetResult(sender); err == nil && pc.Response.Response.StatusCode != http.StatusNoContent { + pc, err = client.CreateOrUpdateResponder(pc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsCreateOrUpdateFuture", "Result", pc.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateCloudsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PrivateCloudsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateCloudsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateCloudsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateCloudsDeleteFuture.Result. +func (future *PrivateCloudsDeleteFuture) result(client PrivateCloudsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateCloudsRotateNsxtPasswordFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateCloudsRotateNsxtPasswordFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateCloudsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateCloudsRotateNsxtPasswordFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateCloudsRotateNsxtPasswordFuture.Result. +func (future *PrivateCloudsRotateNsxtPasswordFuture) result(client PrivateCloudsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsRotateNsxtPasswordFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsRotateNsxtPasswordFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateCloudsRotateVcenterPasswordFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateCloudsRotateVcenterPasswordFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateCloudsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateCloudsRotateVcenterPasswordFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateCloudsRotateVcenterPasswordFuture.Result. +func (future *PrivateCloudsRotateVcenterPasswordFuture) result(client PrivateCloudsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsRotateVcenterPasswordFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsRotateVcenterPasswordFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateCloudsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PrivateCloudsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateCloudsClient) (PrivateCloud, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateCloudsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateCloudsUpdateFuture.Result. +func (future *PrivateCloudsUpdateFuture) result(client PrivateCloudsClient) (pc PrivateCloud, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pc.Response.Response, err = future.GetResult(sender); err == nil && pc.Response.Response.StatusCode != http.StatusNoContent { + pc, err = client.UpdateResponder(pc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsUpdateFuture", "Result", pc.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateCloudUpdate an update to a private cloud resource +type PrivateCloudUpdate struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // PrivateCloudUpdateProperties - The updatable properties of a private cloud resource + *PrivateCloudUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateCloudUpdate. +func (pcu PrivateCloudUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pcu.Tags != nil { + objectMap["tags"] = pcu.Tags + } + if pcu.PrivateCloudUpdateProperties != nil { + objectMap["properties"] = pcu.PrivateCloudUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateCloudUpdate struct. +func (pcu *PrivateCloudUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + pcu.Tags = tags + } + case "properties": + if v != nil { + var privateCloudUpdateProperties PrivateCloudUpdateProperties + err = json.Unmarshal(*v, &privateCloudUpdateProperties) + if err != nil { + return err + } + pcu.PrivateCloudUpdateProperties = &privateCloudUpdateProperties + } + } + } + + return nil +} + +// PrivateCloudUpdateProperties the properties of a private cloud resource that may be updated +type PrivateCloudUpdateProperties struct { + // ManagementCluster - The default cluster used for management + ManagementCluster *ManagementCluster `json:"managementCluster,omitempty"` + // Internet - Connectivity to internet is enabled or disabled. Possible values include: 'Enabled', 'Disabled' + Internet InternetEnum `json:"internet,omitempty"` + // IdentitySources - vCenter Single Sign On Identity Sources + IdentitySources *[]IdentitySource `json:"identitySources,omitempty"` +} + +// ProxyResource the resource model definition for a ARM proxy resource +type ProxyResource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// PSCredentialExecutionParameter a powershell credential object +type PSCredentialExecutionParameter struct { + // Username - username for login + Username *string `json:"username,omitempty"` + // Password - password for login + Password *string `json:"password,omitempty"` + // Name - The parameter name + Name *string `json:"name,omitempty"` + // Type - Possible values include: 'TypeScriptExecutionParameter', 'TypeSecureValue', 'TypeValue', 'TypeCredential' + Type Type `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PSCredentialExecutionParameter. +func (pcep PSCredentialExecutionParameter) MarshalJSON() ([]byte, error) { + pcep.Type = TypeCredential + objectMap := make(map[string]interface{}) + if pcep.Username != nil { + objectMap["username"] = pcep.Username + } + if pcep.Password != nil { + objectMap["password"] = pcep.Password + } + if pcep.Name != nil { + objectMap["name"] = pcep.Name + } + if pcep.Type != "" { + objectMap["type"] = pcep.Type + } + return json.Marshal(objectMap) +} + +// AsScriptSecureStringExecutionParameter is the BasicScriptExecutionParameter implementation for PSCredentialExecutionParameter. +func (pcep PSCredentialExecutionParameter) AsScriptSecureStringExecutionParameter() (*ScriptSecureStringExecutionParameter, bool) { + return nil, false +} + +// AsScriptStringExecutionParameter is the BasicScriptExecutionParameter implementation for PSCredentialExecutionParameter. +func (pcep PSCredentialExecutionParameter) AsScriptStringExecutionParameter() (*ScriptStringExecutionParameter, bool) { + return nil, false +} + +// AsPSCredentialExecutionParameter is the BasicScriptExecutionParameter implementation for PSCredentialExecutionParameter. +func (pcep PSCredentialExecutionParameter) AsPSCredentialExecutionParameter() (*PSCredentialExecutionParameter, bool) { + return &pcep, true +} + +// AsScriptExecutionParameter is the BasicScriptExecutionParameter implementation for PSCredentialExecutionParameter. +func (pcep PSCredentialExecutionParameter) AsScriptExecutionParameter() (*ScriptExecutionParameter, bool) { + return nil, false +} + +// AsBasicScriptExecutionParameter is the BasicScriptExecutionParameter implementation for PSCredentialExecutionParameter. +func (pcep PSCredentialExecutionParameter) AsBasicScriptExecutionParameter() (BasicScriptExecutionParameter, bool) { + return &pcep, true +} + +// Quota subscription quotas +type Quota struct { + autorest.Response `json:"-"` + // HostsRemaining - READ-ONLY; Remaining hosts quota by sku type + HostsRemaining map[string]*int32 `json:"hostsRemaining"` + // QuotaEnabled - READ-ONLY; Host quota is active for current subscription. Possible values include: 'QuotaEnabledEnabled', 'QuotaEnabledDisabled' + QuotaEnabled QuotaEnabled `json:"quotaEnabled,omitempty"` +} + +// MarshalJSON is the custom marshaler for Quota. +func (q Quota) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource the core properties of ARM resources +type Resource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// ScriptCmdlet a cmdlet available for script execution +type ScriptCmdlet struct { + autorest.Response `json:"-"` + // ScriptCmdletProperties - The properties of a script cmdlet resource + *ScriptCmdletProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScriptCmdlet. +func (sc ScriptCmdlet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sc.ScriptCmdletProperties != nil { + objectMap["properties"] = sc.ScriptCmdletProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ScriptCmdlet struct. +func (sc *ScriptCmdlet) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var scriptCmdletProperties ScriptCmdletProperties + err = json.Unmarshal(*v, &scriptCmdletProperties) + if err != nil { + return err + } + sc.ScriptCmdletProperties = &scriptCmdletProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sc.Type = &typeVar + } + } + } + + return nil +} + +// ScriptCmdletProperties properties of a pre-canned script +type ScriptCmdletProperties struct { + // Description - READ-ONLY; Description of the scripts functionality + Description *string `json:"description,omitempty"` + // Timeout - READ-ONLY; Recommended time limit for execution + Timeout *string `json:"timeout,omitempty"` + // Parameters - READ-ONLY; Parameters the script will accept + Parameters *[]ScriptParameter `json:"parameters,omitempty"` +} + +// ScriptCmdletsList pageable list of scripts/cmdlets +type ScriptCmdletsList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of scripts + Value *[]ScriptCmdlet `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// ScriptCmdletsListIterator provides access to a complete listing of ScriptCmdlet values. +type ScriptCmdletsListIterator struct { + i int + page ScriptCmdletsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ScriptCmdletsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptCmdletsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ScriptCmdletsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ScriptCmdletsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ScriptCmdletsListIterator) Response() ScriptCmdletsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ScriptCmdletsListIterator) Value() ScriptCmdlet { + if !iter.page.NotDone() { + return ScriptCmdlet{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ScriptCmdletsListIterator type. +func NewScriptCmdletsListIterator(page ScriptCmdletsListPage) ScriptCmdletsListIterator { + return ScriptCmdletsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (scl ScriptCmdletsList) IsEmpty() bool { + return scl.Value == nil || len(*scl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (scl ScriptCmdletsList) hasNextLink() bool { + return scl.NextLink != nil && len(*scl.NextLink) != 0 +} + +// scriptCmdletsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (scl ScriptCmdletsList) scriptCmdletsListPreparer(ctx context.Context) (*http.Request, error) { + if !scl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(scl.NextLink))) +} + +// ScriptCmdletsListPage contains a page of ScriptCmdlet values. +type ScriptCmdletsListPage struct { + fn func(context.Context, ScriptCmdletsList) (ScriptCmdletsList, error) + scl ScriptCmdletsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ScriptCmdletsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptCmdletsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.scl) + if err != nil { + return err + } + page.scl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ScriptCmdletsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ScriptCmdletsListPage) NotDone() bool { + return !page.scl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ScriptCmdletsListPage) Response() ScriptCmdletsList { + return page.scl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ScriptCmdletsListPage) Values() []ScriptCmdlet { + if page.scl.IsEmpty() { + return nil + } + return *page.scl.Value +} + +// Creates a new instance of the ScriptCmdletsListPage type. +func NewScriptCmdletsListPage(cur ScriptCmdletsList, getNextPage func(context.Context, ScriptCmdletsList) (ScriptCmdletsList, error)) ScriptCmdletsListPage { + return ScriptCmdletsListPage{ + fn: getNextPage, + scl: cur, + } +} + +// ScriptExecution an instance of a script executed by a user - custom or AVS +type ScriptExecution struct { + autorest.Response `json:"-"` + // ScriptExecutionProperties - The properties of a script execution resource + *ScriptExecutionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScriptExecution. +func (se ScriptExecution) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if se.ScriptExecutionProperties != nil { + objectMap["properties"] = se.ScriptExecutionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ScriptExecution struct. +func (se *ScriptExecution) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var scriptExecutionProperties ScriptExecutionProperties + err = json.Unmarshal(*v, &scriptExecutionProperties) + if err != nil { + return err + } + se.ScriptExecutionProperties = &scriptExecutionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + se.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + se.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + se.Type = &typeVar + } + } + } + + return nil +} + +// BasicScriptExecutionParameter the arguments passed in to the execution +type BasicScriptExecutionParameter interface { + AsScriptSecureStringExecutionParameter() (*ScriptSecureStringExecutionParameter, bool) + AsScriptStringExecutionParameter() (*ScriptStringExecutionParameter, bool) + AsPSCredentialExecutionParameter() (*PSCredentialExecutionParameter, bool) + AsScriptExecutionParameter() (*ScriptExecutionParameter, bool) +} + +// ScriptExecutionParameter the arguments passed in to the execution +type ScriptExecutionParameter struct { + // Name - The parameter name + Name *string `json:"name,omitempty"` + // Type - Possible values include: 'TypeScriptExecutionParameter', 'TypeSecureValue', 'TypeValue', 'TypeCredential' + Type Type `json:"type,omitempty"` +} + +func unmarshalBasicScriptExecutionParameter(body []byte) (BasicScriptExecutionParameter, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["type"] { + case string(TypeSecureValue): + var sssep ScriptSecureStringExecutionParameter + err := json.Unmarshal(body, &sssep) + return sssep, err + case string(TypeValue): + var ssep ScriptStringExecutionParameter + err := json.Unmarshal(body, &ssep) + return ssep, err + case string(TypeCredential): + var pcep PSCredentialExecutionParameter + err := json.Unmarshal(body, &pcep) + return pcep, err + default: + var sep ScriptExecutionParameter + err := json.Unmarshal(body, &sep) + return sep, err + } +} +func unmarshalBasicScriptExecutionParameterArray(body []byte) ([]BasicScriptExecutionParameter, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + sepArray := make([]BasicScriptExecutionParameter, len(rawMessages)) + + for index, rawMessage := range rawMessages { + sep, err := unmarshalBasicScriptExecutionParameter(*rawMessage) + if err != nil { + return nil, err + } + sepArray[index] = sep + } + return sepArray, nil +} + +// MarshalJSON is the custom marshaler for ScriptExecutionParameter. +func (sep ScriptExecutionParameter) MarshalJSON() ([]byte, error) { + sep.Type = TypeScriptExecutionParameter + objectMap := make(map[string]interface{}) + if sep.Name != nil { + objectMap["name"] = sep.Name + } + if sep.Type != "" { + objectMap["type"] = sep.Type + } + return json.Marshal(objectMap) +} + +// AsScriptSecureStringExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptExecutionParameter. +func (sep ScriptExecutionParameter) AsScriptSecureStringExecutionParameter() (*ScriptSecureStringExecutionParameter, bool) { + return nil, false +} + +// AsScriptStringExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptExecutionParameter. +func (sep ScriptExecutionParameter) AsScriptStringExecutionParameter() (*ScriptStringExecutionParameter, bool) { + return nil, false +} + +// AsPSCredentialExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptExecutionParameter. +func (sep ScriptExecutionParameter) AsPSCredentialExecutionParameter() (*PSCredentialExecutionParameter, bool) { + return nil, false +} + +// AsScriptExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptExecutionParameter. +func (sep ScriptExecutionParameter) AsScriptExecutionParameter() (*ScriptExecutionParameter, bool) { + return &sep, true +} + +// AsBasicScriptExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptExecutionParameter. +func (sep ScriptExecutionParameter) AsBasicScriptExecutionParameter() (BasicScriptExecutionParameter, bool) { + return &sep, true +} + +// ScriptExecutionProperties properties of a user-invoked script +type ScriptExecutionProperties struct { + // ScriptCmdletID - A reference to the script cmdlet resource if user is running a AVS script + ScriptCmdletID *string `json:"scriptCmdletId,omitempty"` + // Parameters - Parameters the script will accept + Parameters *[]BasicScriptExecutionParameter `json:"parameters,omitempty"` + // HiddenParameters - Parameters that will be hidden/not visible to ARM, such as passwords and credentials + HiddenParameters *[]BasicScriptExecutionParameter `json:"hiddenParameters,omitempty"` + // FailureReason - Error message if the script was able to run, but if the script itself had errors or powershell threw an exception + FailureReason *string `json:"failureReason,omitempty"` + // Timeout - Time limit for execution + Timeout *string `json:"timeout,omitempty"` + // Retention - Time to live for the resource. If not provided, will be available for 60 days + Retention *string `json:"retention,omitempty"` + // SubmittedAt - READ-ONLY; Time the script execution was submitted + SubmittedAt *date.Time `json:"submittedAt,omitempty"` + // StartedAt - READ-ONLY; Time the script execution was started + StartedAt *date.Time `json:"startedAt,omitempty"` + // FinishedAt - READ-ONLY; Time the script execution was finished + FinishedAt *date.Time `json:"finishedAt,omitempty"` + // ProvisioningState - READ-ONLY; The state of the script execution resource. Possible values include: 'ScriptExecutionProvisioningStatePending', 'ScriptExecutionProvisioningStateRunning', 'ScriptExecutionProvisioningStateSucceeded', 'ScriptExecutionProvisioningStateFailed', 'ScriptExecutionProvisioningStateCancelling', 'ScriptExecutionProvisioningStateCancelled', 'ScriptExecutionProvisioningStateDeleting' + ProvisioningState ScriptExecutionProvisioningState `json:"provisioningState,omitempty"` + // Output - Standard output stream from the powershell execution + Output *[]string `json:"output,omitempty"` + // NamedOutputs - User-defined dictionary. + NamedOutputs map[string]interface{} `json:"namedOutputs"` + // Information - READ-ONLY; Standard information out stream from the powershell execution + Information *[]string `json:"information,omitempty"` + // Warnings - READ-ONLY; Standard warning out stream from the powershell execution + Warnings *[]string `json:"warnings,omitempty"` + // Errors - READ-ONLY; Standard error output stream from the powershell execution + Errors *[]string `json:"errors,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScriptExecutionProperties. +func (sep ScriptExecutionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sep.ScriptCmdletID != nil { + objectMap["scriptCmdletId"] = sep.ScriptCmdletID + } + if sep.Parameters != nil { + objectMap["parameters"] = sep.Parameters + } + if sep.HiddenParameters != nil { + objectMap["hiddenParameters"] = sep.HiddenParameters + } + if sep.FailureReason != nil { + objectMap["failureReason"] = sep.FailureReason + } + if sep.Timeout != nil { + objectMap["timeout"] = sep.Timeout + } + if sep.Retention != nil { + objectMap["retention"] = sep.Retention + } + if sep.Output != nil { + objectMap["output"] = sep.Output + } + if sep.NamedOutputs != nil { + objectMap["namedOutputs"] = sep.NamedOutputs + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ScriptExecutionProperties struct. +func (sep *ScriptExecutionProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "scriptCmdletId": + if v != nil { + var scriptCmdletID string + err = json.Unmarshal(*v, &scriptCmdletID) + if err != nil { + return err + } + sep.ScriptCmdletID = &scriptCmdletID + } + case "parameters": + if v != nil { + parameters, err := unmarshalBasicScriptExecutionParameterArray(*v) + if err != nil { + return err + } + sep.Parameters = ¶meters + } + case "hiddenParameters": + if v != nil { + hiddenParameters, err := unmarshalBasicScriptExecutionParameterArray(*v) + if err != nil { + return err + } + sep.HiddenParameters = &hiddenParameters + } + case "failureReason": + if v != nil { + var failureReason string + err = json.Unmarshal(*v, &failureReason) + if err != nil { + return err + } + sep.FailureReason = &failureReason + } + case "timeout": + if v != nil { + var timeout string + err = json.Unmarshal(*v, &timeout) + if err != nil { + return err + } + sep.Timeout = &timeout + } + case "retention": + if v != nil { + var retention string + err = json.Unmarshal(*v, &retention) + if err != nil { + return err + } + sep.Retention = &retention + } + case "submittedAt": + if v != nil { + var submittedAt date.Time + err = json.Unmarshal(*v, &submittedAt) + if err != nil { + return err + } + sep.SubmittedAt = &submittedAt + } + case "startedAt": + if v != nil { + var startedAt date.Time + err = json.Unmarshal(*v, &startedAt) + if err != nil { + return err + } + sep.StartedAt = &startedAt + } + case "finishedAt": + if v != nil { + var finishedAt date.Time + err = json.Unmarshal(*v, &finishedAt) + if err != nil { + return err + } + sep.FinishedAt = &finishedAt + } + case "provisioningState": + if v != nil { + var provisioningState ScriptExecutionProvisioningState + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + sep.ProvisioningState = provisioningState + } + case "output": + if v != nil { + var output []string + err = json.Unmarshal(*v, &output) + if err != nil { + return err + } + sep.Output = &output + } + case "namedOutputs": + if v != nil { + var namedOutputs map[string]interface{} + err = json.Unmarshal(*v, &namedOutputs) + if err != nil { + return err + } + sep.NamedOutputs = namedOutputs + } + case "information": + if v != nil { + var information []string + err = json.Unmarshal(*v, &information) + if err != nil { + return err + } + sep.Information = &information + } + case "warnings": + if v != nil { + var warnings []string + err = json.Unmarshal(*v, &warnings) + if err != nil { + return err + } + sep.Warnings = &warnings + } + case "errors": + if v != nil { + var errorsVar []string + err = json.Unmarshal(*v, &errorsVar) + if err != nil { + return err + } + sep.Errors = &errorsVar + } + } + } + + return nil +} + +// ScriptExecutionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ScriptExecutionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ScriptExecutionsClient) (ScriptExecution, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ScriptExecutionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ScriptExecutionsCreateOrUpdateFuture.Result. +func (future *ScriptExecutionsCreateOrUpdateFuture) result(client ScriptExecutionsClient) (se ScriptExecution, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + se.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.ScriptExecutionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if se.Response.Response, err = future.GetResult(sender); err == nil && se.Response.Response.StatusCode != http.StatusNoContent { + se, err = client.CreateOrUpdateResponder(se.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsCreateOrUpdateFuture", "Result", se.Response.Response, "Failure responding to request") + } + } + return +} + +// ScriptExecutionsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ScriptExecutionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ScriptExecutionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ScriptExecutionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ScriptExecutionsDeleteFuture.Result. +func (future *ScriptExecutionsDeleteFuture) result(client ScriptExecutionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.ScriptExecutionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ScriptExecutionsList pageable list of script executions +type ScriptExecutionsList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of scripts + Value *[]ScriptExecution `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// ScriptExecutionsListIterator provides access to a complete listing of ScriptExecution values. +type ScriptExecutionsListIterator struct { + i int + page ScriptExecutionsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ScriptExecutionsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptExecutionsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ScriptExecutionsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ScriptExecutionsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ScriptExecutionsListIterator) Response() ScriptExecutionsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ScriptExecutionsListIterator) Value() ScriptExecution { + if !iter.page.NotDone() { + return ScriptExecution{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ScriptExecutionsListIterator type. +func NewScriptExecutionsListIterator(page ScriptExecutionsListPage) ScriptExecutionsListIterator { + return ScriptExecutionsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sel ScriptExecutionsList) IsEmpty() bool { + return sel.Value == nil || len(*sel.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sel ScriptExecutionsList) hasNextLink() bool { + return sel.NextLink != nil && len(*sel.NextLink) != 0 +} + +// scriptExecutionsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sel ScriptExecutionsList) scriptExecutionsListPreparer(ctx context.Context) (*http.Request, error) { + if !sel.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sel.NextLink))) +} + +// ScriptExecutionsListPage contains a page of ScriptExecution values. +type ScriptExecutionsListPage struct { + fn func(context.Context, ScriptExecutionsList) (ScriptExecutionsList, error) + sel ScriptExecutionsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ScriptExecutionsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptExecutionsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sel) + if err != nil { + return err + } + page.sel = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ScriptExecutionsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ScriptExecutionsListPage) NotDone() bool { + return !page.sel.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ScriptExecutionsListPage) Response() ScriptExecutionsList { + return page.sel +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ScriptExecutionsListPage) Values() []ScriptExecution { + if page.sel.IsEmpty() { + return nil + } + return *page.sel.Value +} + +// Creates a new instance of the ScriptExecutionsListPage type. +func NewScriptExecutionsListPage(cur ScriptExecutionsList, getNextPage func(context.Context, ScriptExecutionsList) (ScriptExecutionsList, error)) ScriptExecutionsListPage { + return ScriptExecutionsListPage{ + fn: getNextPage, + sel: cur, + } +} + +// ScriptPackage script Package resources available for execution +type ScriptPackage struct { + autorest.Response `json:"-"` + // ScriptPackageProperties - ScriptPackage resource properties + *ScriptPackageProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScriptPackage. +func (sp ScriptPackage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.ScriptPackageProperties != nil { + objectMap["properties"] = sp.ScriptPackageProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ScriptPackage struct. +func (sp *ScriptPackage) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var scriptPackageProperties ScriptPackageProperties + err = json.Unmarshal(*v, &scriptPackageProperties) + if err != nil { + return err + } + sp.ScriptPackageProperties = &scriptPackageProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sp.Type = &typeVar + } + } + } + + return nil +} + +// ScriptPackageProperties properties of a Script Package subresource +type ScriptPackageProperties struct { + // Description - READ-ONLY; User friendly description of the package + Description *string `json:"description,omitempty"` + // Version - READ-ONLY; Module version + Version *string `json:"version,omitempty"` +} + +// ScriptPackagesList a list of the available script packages +type ScriptPackagesList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of script package resources + Value *[]ScriptPackage `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// ScriptPackagesListIterator provides access to a complete listing of ScriptPackage values. +type ScriptPackagesListIterator struct { + i int + page ScriptPackagesListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ScriptPackagesListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptPackagesListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ScriptPackagesListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ScriptPackagesListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ScriptPackagesListIterator) Response() ScriptPackagesList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ScriptPackagesListIterator) Value() ScriptPackage { + if !iter.page.NotDone() { + return ScriptPackage{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ScriptPackagesListIterator type. +func NewScriptPackagesListIterator(page ScriptPackagesListPage) ScriptPackagesListIterator { + return ScriptPackagesListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (spl ScriptPackagesList) IsEmpty() bool { + return spl.Value == nil || len(*spl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (spl ScriptPackagesList) hasNextLink() bool { + return spl.NextLink != nil && len(*spl.NextLink) != 0 +} + +// scriptPackagesListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (spl ScriptPackagesList) scriptPackagesListPreparer(ctx context.Context) (*http.Request, error) { + if !spl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(spl.NextLink))) +} + +// ScriptPackagesListPage contains a page of ScriptPackage values. +type ScriptPackagesListPage struct { + fn func(context.Context, ScriptPackagesList) (ScriptPackagesList, error) + spl ScriptPackagesList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ScriptPackagesListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptPackagesListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.spl) + if err != nil { + return err + } + page.spl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ScriptPackagesListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ScriptPackagesListPage) NotDone() bool { + return !page.spl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ScriptPackagesListPage) Response() ScriptPackagesList { + return page.spl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ScriptPackagesListPage) Values() []ScriptPackage { + if page.spl.IsEmpty() { + return nil + } + return *page.spl.Value +} + +// Creates a new instance of the ScriptPackagesListPage type. +func NewScriptPackagesListPage(cur ScriptPackagesList, getNextPage func(context.Context, ScriptPackagesList) (ScriptPackagesList, error)) ScriptPackagesListPage { + return ScriptPackagesListPage{ + fn: getNextPage, + spl: cur, + } +} + +// ScriptParameter an parameter that the script will accept +type ScriptParameter struct { + // Type - READ-ONLY; The type of parameter the script is expecting. psCredential is a PSCredentialObject. Possible values include: 'String', 'SecureString', 'Credential', 'Int', 'Bool', 'Float' + Type ScriptParameterTypes `json:"type,omitempty"` + // Name - The parameter name that the script will expect a parameter value for + Name *string `json:"name,omitempty"` + // Description - READ-ONLY; User friendly description of the parameter + Description *string `json:"description,omitempty"` + // Visibility - READ-ONLY; Should this parameter be visible to arm and passed in the parameters argument when executing. Possible values include: 'Visible', 'Hidden' + Visibility VisibilityParameterEnum `json:"visibility,omitempty"` + // Optional - READ-ONLY; Is this parameter required or optional. Possible values include: 'Optional', 'Required' + Optional OptionalParamEnum `json:"optional,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScriptParameter. +func (sp ScriptParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.Name != nil { + objectMap["name"] = sp.Name + } + return json.Marshal(objectMap) +} + +// ScriptSecureStringExecutionParameter a plain text value execution parameter +type ScriptSecureStringExecutionParameter struct { + // SecureValue - A secure value for the passed parameter, not to be stored in logs + SecureValue *string `json:"secureValue,omitempty"` + // Name - The parameter name + Name *string `json:"name,omitempty"` + // Type - Possible values include: 'TypeScriptExecutionParameter', 'TypeSecureValue', 'TypeValue', 'TypeCredential' + Type Type `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScriptSecureStringExecutionParameter. +func (sssep ScriptSecureStringExecutionParameter) MarshalJSON() ([]byte, error) { + sssep.Type = TypeSecureValue + objectMap := make(map[string]interface{}) + if sssep.SecureValue != nil { + objectMap["secureValue"] = sssep.SecureValue + } + if sssep.Name != nil { + objectMap["name"] = sssep.Name + } + if sssep.Type != "" { + objectMap["type"] = sssep.Type + } + return json.Marshal(objectMap) +} + +// AsScriptSecureStringExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptSecureStringExecutionParameter. +func (sssep ScriptSecureStringExecutionParameter) AsScriptSecureStringExecutionParameter() (*ScriptSecureStringExecutionParameter, bool) { + return &sssep, true +} + +// AsScriptStringExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptSecureStringExecutionParameter. +func (sssep ScriptSecureStringExecutionParameter) AsScriptStringExecutionParameter() (*ScriptStringExecutionParameter, bool) { + return nil, false +} + +// AsPSCredentialExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptSecureStringExecutionParameter. +func (sssep ScriptSecureStringExecutionParameter) AsPSCredentialExecutionParameter() (*PSCredentialExecutionParameter, bool) { + return nil, false +} + +// AsScriptExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptSecureStringExecutionParameter. +func (sssep ScriptSecureStringExecutionParameter) AsScriptExecutionParameter() (*ScriptExecutionParameter, bool) { + return nil, false +} + +// AsBasicScriptExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptSecureStringExecutionParameter. +func (sssep ScriptSecureStringExecutionParameter) AsBasicScriptExecutionParameter() (BasicScriptExecutionParameter, bool) { + return &sssep, true +} + +// ScriptStringExecutionParameter a plain text value execution parameter +type ScriptStringExecutionParameter struct { + // Value - The value for the passed parameter + Value *string `json:"value,omitempty"` + // Name - The parameter name + Name *string `json:"name,omitempty"` + // Type - Possible values include: 'TypeScriptExecutionParameter', 'TypeSecureValue', 'TypeValue', 'TypeCredential' + Type Type `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScriptStringExecutionParameter. +func (ssep ScriptStringExecutionParameter) MarshalJSON() ([]byte, error) { + ssep.Type = TypeValue + objectMap := make(map[string]interface{}) + if ssep.Value != nil { + objectMap["value"] = ssep.Value + } + if ssep.Name != nil { + objectMap["name"] = ssep.Name + } + if ssep.Type != "" { + objectMap["type"] = ssep.Type + } + return json.Marshal(objectMap) +} + +// AsScriptSecureStringExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptStringExecutionParameter. +func (ssep ScriptStringExecutionParameter) AsScriptSecureStringExecutionParameter() (*ScriptSecureStringExecutionParameter, bool) { + return nil, false +} + +// AsScriptStringExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptStringExecutionParameter. +func (ssep ScriptStringExecutionParameter) AsScriptStringExecutionParameter() (*ScriptStringExecutionParameter, bool) { + return &ssep, true +} + +// AsPSCredentialExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptStringExecutionParameter. +func (ssep ScriptStringExecutionParameter) AsPSCredentialExecutionParameter() (*PSCredentialExecutionParameter, bool) { + return nil, false +} + +// AsScriptExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptStringExecutionParameter. +func (ssep ScriptStringExecutionParameter) AsScriptExecutionParameter() (*ScriptExecutionParameter, bool) { + return nil, false +} + +// AsBasicScriptExecutionParameter is the BasicScriptExecutionParameter implementation for ScriptStringExecutionParameter. +func (ssep ScriptStringExecutionParameter) AsBasicScriptExecutionParameter() (BasicScriptExecutionParameter, bool) { + return &ssep, true +} + +// ServiceSpecification service specification payload +type ServiceSpecification struct { + // LogSpecifications - Specifications of the Log for Azure Monitoring + LogSpecifications *[]LogSpecification `json:"logSpecifications,omitempty"` + // MetricSpecifications - Specifications of the Metrics for Azure Monitoring + MetricSpecifications *[]MetricSpecification `json:"metricSpecifications,omitempty"` +} + +// Sku the resource model definition representing SKU +type Sku struct { + // Name - The name of the SKU. + Name *string `json:"name,omitempty"` +} + +// TrackedResource the resource model definition for a ARM tracked top level resource +type TrackedResource struct { + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// Trial subscription trial availability +type Trial struct { + autorest.Response `json:"-"` + // Status - READ-ONLY; Trial status. Possible values include: 'TrialAvailable', 'TrialUsed', 'TrialDisabled' + Status TrialStatus `json:"status,omitempty"` + // AvailableHosts - READ-ONLY; Number of trial hosts available + AvailableHosts *int32 `json:"availableHosts,omitempty"` +} + +// WorkloadNetworkDhcp NSX DHCP +type WorkloadNetworkDhcp struct { + autorest.Response `json:"-"` + // Properties - DHCP properties. + Properties BasicWorkloadNetworkDhcpEntity `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkDhcp. +func (wnd WorkloadNetworkDhcp) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["properties"] = wnd.Properties + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadNetworkDhcp struct. +func (wnd *WorkloadNetworkDhcp) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + properties, err := unmarshalBasicWorkloadNetworkDhcpEntity(*v) + if err != nil { + return err + } + wnd.Properties = properties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wnd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wnd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wnd.Type = &typeVar + } + } + } + + return nil +} + +// BasicWorkloadNetworkDhcpEntity base class for WorkloadNetworkDhcpServer and WorkloadNetworkDhcpRelay to inherit from +type BasicWorkloadNetworkDhcpEntity interface { + AsWorkloadNetworkDhcpServer() (*WorkloadNetworkDhcpServer, bool) + AsWorkloadNetworkDhcpRelay() (*WorkloadNetworkDhcpRelay, bool) + AsWorkloadNetworkDhcpEntity() (*WorkloadNetworkDhcpEntity, bool) +} + +// WorkloadNetworkDhcpEntity base class for WorkloadNetworkDhcpServer and WorkloadNetworkDhcpRelay to inherit +// from +type WorkloadNetworkDhcpEntity struct { + // DisplayName - Display name of the DHCP entity. + DisplayName *string `json:"displayName,omitempty"` + // Segments - READ-ONLY; NSX Segments consuming DHCP. + Segments *[]string `json:"segments,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'WorkloadNetworkDhcpProvisioningStateSucceeded', 'WorkloadNetworkDhcpProvisioningStateFailed', 'WorkloadNetworkDhcpProvisioningStateBuilding', 'WorkloadNetworkDhcpProvisioningStateDeleting', 'WorkloadNetworkDhcpProvisioningStateUpdating' + ProvisioningState WorkloadNetworkDhcpProvisioningState `json:"provisioningState,omitempty"` + // Revision - NSX revision number. + Revision *int64 `json:"revision,omitempty"` + // DhcpType - Possible values include: 'DhcpTypeWorkloadNetworkDhcpEntity', 'DhcpTypeSERVER', 'DhcpTypeRELAY' + DhcpType DhcpType `json:"dhcpType,omitempty"` +} + +func unmarshalBasicWorkloadNetworkDhcpEntity(body []byte) (BasicWorkloadNetworkDhcpEntity, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["dhcpType"] { + case string(DhcpTypeSERVER): + var wnds WorkloadNetworkDhcpServer + err := json.Unmarshal(body, &wnds) + return wnds, err + case string(DhcpTypeRELAY): + var wndr WorkloadNetworkDhcpRelay + err := json.Unmarshal(body, &wndr) + return wndr, err + default: + var wnde WorkloadNetworkDhcpEntity + err := json.Unmarshal(body, &wnde) + return wnde, err + } +} +func unmarshalBasicWorkloadNetworkDhcpEntityArray(body []byte) ([]BasicWorkloadNetworkDhcpEntity, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + wndeArray := make([]BasicWorkloadNetworkDhcpEntity, len(rawMessages)) + + for index, rawMessage := range rawMessages { + wnde, err := unmarshalBasicWorkloadNetworkDhcpEntity(*rawMessage) + if err != nil { + return nil, err + } + wndeArray[index] = wnde + } + return wndeArray, nil +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkDhcpEntity. +func (wnde WorkloadNetworkDhcpEntity) MarshalJSON() ([]byte, error) { + wnde.DhcpType = DhcpTypeWorkloadNetworkDhcpEntity + objectMap := make(map[string]interface{}) + if wnde.DisplayName != nil { + objectMap["displayName"] = wnde.DisplayName + } + if wnde.Revision != nil { + objectMap["revision"] = wnde.Revision + } + if wnde.DhcpType != "" { + objectMap["dhcpType"] = wnde.DhcpType + } + return json.Marshal(objectMap) +} + +// AsWorkloadNetworkDhcpServer is the BasicWorkloadNetworkDhcpEntity implementation for WorkloadNetworkDhcpEntity. +func (wnde WorkloadNetworkDhcpEntity) AsWorkloadNetworkDhcpServer() (*WorkloadNetworkDhcpServer, bool) { + return nil, false +} + +// AsWorkloadNetworkDhcpRelay is the BasicWorkloadNetworkDhcpEntity implementation for WorkloadNetworkDhcpEntity. +func (wnde WorkloadNetworkDhcpEntity) AsWorkloadNetworkDhcpRelay() (*WorkloadNetworkDhcpRelay, bool) { + return nil, false +} + +// AsWorkloadNetworkDhcpEntity is the BasicWorkloadNetworkDhcpEntity implementation for WorkloadNetworkDhcpEntity. +func (wnde WorkloadNetworkDhcpEntity) AsWorkloadNetworkDhcpEntity() (*WorkloadNetworkDhcpEntity, bool) { + return &wnde, true +} + +// AsBasicWorkloadNetworkDhcpEntity is the BasicWorkloadNetworkDhcpEntity implementation for WorkloadNetworkDhcpEntity. +func (wnde WorkloadNetworkDhcpEntity) AsBasicWorkloadNetworkDhcpEntity() (BasicWorkloadNetworkDhcpEntity, bool) { + return &wnde, true +} + +// WorkloadNetworkDhcpList a list of NSX dhcp entities +type WorkloadNetworkDhcpList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on the page + Value *[]WorkloadNetworkDhcp `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// WorkloadNetworkDhcpListIterator provides access to a complete listing of WorkloadNetworkDhcp values. +type WorkloadNetworkDhcpListIterator struct { + i int + page WorkloadNetworkDhcpListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkloadNetworkDhcpListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkDhcpListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadNetworkDhcpListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadNetworkDhcpListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkloadNetworkDhcpListIterator) Response() WorkloadNetworkDhcpList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkloadNetworkDhcpListIterator) Value() WorkloadNetworkDhcp { + if !iter.page.NotDone() { + return WorkloadNetworkDhcp{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadNetworkDhcpListIterator type. +func NewWorkloadNetworkDhcpListIterator(page WorkloadNetworkDhcpListPage) WorkloadNetworkDhcpListIterator { + return WorkloadNetworkDhcpListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wndl WorkloadNetworkDhcpList) IsEmpty() bool { + return wndl.Value == nil || len(*wndl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wndl WorkloadNetworkDhcpList) hasNextLink() bool { + return wndl.NextLink != nil && len(*wndl.NextLink) != 0 +} + +// workloadNetworkDhcpListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wndl WorkloadNetworkDhcpList) workloadNetworkDhcpListPreparer(ctx context.Context) (*http.Request, error) { + if !wndl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wndl.NextLink))) +} + +// WorkloadNetworkDhcpListPage contains a page of WorkloadNetworkDhcp values. +type WorkloadNetworkDhcpListPage struct { + fn func(context.Context, WorkloadNetworkDhcpList) (WorkloadNetworkDhcpList, error) + wndl WorkloadNetworkDhcpList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkloadNetworkDhcpListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkDhcpListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wndl) + if err != nil { + return err + } + page.wndl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadNetworkDhcpListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadNetworkDhcpListPage) NotDone() bool { + return !page.wndl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadNetworkDhcpListPage) Response() WorkloadNetworkDhcpList { + return page.wndl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadNetworkDhcpListPage) Values() []WorkloadNetworkDhcp { + if page.wndl.IsEmpty() { + return nil + } + return *page.wndl.Value +} + +// Creates a new instance of the WorkloadNetworkDhcpListPage type. +func NewWorkloadNetworkDhcpListPage(cur WorkloadNetworkDhcpList, getNextPage func(context.Context, WorkloadNetworkDhcpList) (WorkloadNetworkDhcpList, error)) WorkloadNetworkDhcpListPage { + return WorkloadNetworkDhcpListPage{ + fn: getNextPage, + wndl: cur, + } +} + +// WorkloadNetworkDhcpRelay NSX DHCP Relay +type WorkloadNetworkDhcpRelay struct { + // ServerAddresses - DHCP Relay Addresses. Max 3. + ServerAddresses *[]string `json:"serverAddresses,omitempty"` + // DisplayName - Display name of the DHCP entity. + DisplayName *string `json:"displayName,omitempty"` + // Segments - READ-ONLY; NSX Segments consuming DHCP. + Segments *[]string `json:"segments,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'WorkloadNetworkDhcpProvisioningStateSucceeded', 'WorkloadNetworkDhcpProvisioningStateFailed', 'WorkloadNetworkDhcpProvisioningStateBuilding', 'WorkloadNetworkDhcpProvisioningStateDeleting', 'WorkloadNetworkDhcpProvisioningStateUpdating' + ProvisioningState WorkloadNetworkDhcpProvisioningState `json:"provisioningState,omitempty"` + // Revision - NSX revision number. + Revision *int64 `json:"revision,omitempty"` + // DhcpType - Possible values include: 'DhcpTypeWorkloadNetworkDhcpEntity', 'DhcpTypeSERVER', 'DhcpTypeRELAY' + DhcpType DhcpType `json:"dhcpType,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkDhcpRelay. +func (wndr WorkloadNetworkDhcpRelay) MarshalJSON() ([]byte, error) { + wndr.DhcpType = DhcpTypeRELAY + objectMap := make(map[string]interface{}) + if wndr.ServerAddresses != nil { + objectMap["serverAddresses"] = wndr.ServerAddresses + } + if wndr.DisplayName != nil { + objectMap["displayName"] = wndr.DisplayName + } + if wndr.Revision != nil { + objectMap["revision"] = wndr.Revision + } + if wndr.DhcpType != "" { + objectMap["dhcpType"] = wndr.DhcpType + } + return json.Marshal(objectMap) +} + +// AsWorkloadNetworkDhcpServer is the BasicWorkloadNetworkDhcpEntity implementation for WorkloadNetworkDhcpRelay. +func (wndr WorkloadNetworkDhcpRelay) AsWorkloadNetworkDhcpServer() (*WorkloadNetworkDhcpServer, bool) { + return nil, false +} + +// AsWorkloadNetworkDhcpRelay is the BasicWorkloadNetworkDhcpEntity implementation for WorkloadNetworkDhcpRelay. +func (wndr WorkloadNetworkDhcpRelay) AsWorkloadNetworkDhcpRelay() (*WorkloadNetworkDhcpRelay, bool) { + return &wndr, true +} + +// AsWorkloadNetworkDhcpEntity is the BasicWorkloadNetworkDhcpEntity implementation for WorkloadNetworkDhcpRelay. +func (wndr WorkloadNetworkDhcpRelay) AsWorkloadNetworkDhcpEntity() (*WorkloadNetworkDhcpEntity, bool) { + return nil, false +} + +// AsBasicWorkloadNetworkDhcpEntity is the BasicWorkloadNetworkDhcpEntity implementation for WorkloadNetworkDhcpRelay. +func (wndr WorkloadNetworkDhcpRelay) AsBasicWorkloadNetworkDhcpEntity() (BasicWorkloadNetworkDhcpEntity, bool) { + return &wndr, true +} + +// WorkloadNetworkDhcpServer NSX DHCP Server +type WorkloadNetworkDhcpServer struct { + // ServerAddress - DHCP Server Address. + ServerAddress *string `json:"serverAddress,omitempty"` + // LeaseTime - DHCP Server Lease Time. + LeaseTime *int64 `json:"leaseTime,omitempty"` + // DisplayName - Display name of the DHCP entity. + DisplayName *string `json:"displayName,omitempty"` + // Segments - READ-ONLY; NSX Segments consuming DHCP. + Segments *[]string `json:"segments,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'WorkloadNetworkDhcpProvisioningStateSucceeded', 'WorkloadNetworkDhcpProvisioningStateFailed', 'WorkloadNetworkDhcpProvisioningStateBuilding', 'WorkloadNetworkDhcpProvisioningStateDeleting', 'WorkloadNetworkDhcpProvisioningStateUpdating' + ProvisioningState WorkloadNetworkDhcpProvisioningState `json:"provisioningState,omitempty"` + // Revision - NSX revision number. + Revision *int64 `json:"revision,omitempty"` + // DhcpType - Possible values include: 'DhcpTypeWorkloadNetworkDhcpEntity', 'DhcpTypeSERVER', 'DhcpTypeRELAY' + DhcpType DhcpType `json:"dhcpType,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkDhcpServer. +func (wnds WorkloadNetworkDhcpServer) MarshalJSON() ([]byte, error) { + wnds.DhcpType = DhcpTypeSERVER + objectMap := make(map[string]interface{}) + if wnds.ServerAddress != nil { + objectMap["serverAddress"] = wnds.ServerAddress + } + if wnds.LeaseTime != nil { + objectMap["leaseTime"] = wnds.LeaseTime + } + if wnds.DisplayName != nil { + objectMap["displayName"] = wnds.DisplayName + } + if wnds.Revision != nil { + objectMap["revision"] = wnds.Revision + } + if wnds.DhcpType != "" { + objectMap["dhcpType"] = wnds.DhcpType + } + return json.Marshal(objectMap) +} + +// AsWorkloadNetworkDhcpServer is the BasicWorkloadNetworkDhcpEntity implementation for WorkloadNetworkDhcpServer. +func (wnds WorkloadNetworkDhcpServer) AsWorkloadNetworkDhcpServer() (*WorkloadNetworkDhcpServer, bool) { + return &wnds, true +} + +// AsWorkloadNetworkDhcpRelay is the BasicWorkloadNetworkDhcpEntity implementation for WorkloadNetworkDhcpServer. +func (wnds WorkloadNetworkDhcpServer) AsWorkloadNetworkDhcpRelay() (*WorkloadNetworkDhcpRelay, bool) { + return nil, false +} + +// AsWorkloadNetworkDhcpEntity is the BasicWorkloadNetworkDhcpEntity implementation for WorkloadNetworkDhcpServer. +func (wnds WorkloadNetworkDhcpServer) AsWorkloadNetworkDhcpEntity() (*WorkloadNetworkDhcpEntity, bool) { + return nil, false +} + +// AsBasicWorkloadNetworkDhcpEntity is the BasicWorkloadNetworkDhcpEntity implementation for WorkloadNetworkDhcpServer. +func (wnds WorkloadNetworkDhcpServer) AsBasicWorkloadNetworkDhcpEntity() (BasicWorkloadNetworkDhcpEntity, bool) { + return &wnds, true +} + +// WorkloadNetworkDNSService NSX DNS Service +type WorkloadNetworkDNSService struct { + autorest.Response `json:"-"` + // WorkloadNetworkDNSServiceProperties - DNS Service properties + *WorkloadNetworkDNSServiceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkDNSService. +func (wnds WorkloadNetworkDNSService) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wnds.WorkloadNetworkDNSServiceProperties != nil { + objectMap["properties"] = wnds.WorkloadNetworkDNSServiceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadNetworkDNSService struct. +func (wnds *WorkloadNetworkDNSService) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workloadNetworkDNSServiceProperties WorkloadNetworkDNSServiceProperties + err = json.Unmarshal(*v, &workloadNetworkDNSServiceProperties) + if err != nil { + return err + } + wnds.WorkloadNetworkDNSServiceProperties = &workloadNetworkDNSServiceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wnds.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wnds.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wnds.Type = &typeVar + } + } + } + + return nil +} + +// WorkloadNetworkDNSServiceProperties NSX DNS Service Properties +type WorkloadNetworkDNSServiceProperties struct { + // DisplayName - Display name of the DNS Service. + DisplayName *string `json:"displayName,omitempty"` + // DNSServiceIP - DNS service IP of the DNS Service. + DNSServiceIP *string `json:"dnsServiceIp,omitempty"` + // DefaultDNSZone - Default DNS zone of the DNS Service. + DefaultDNSZone *string `json:"defaultDnsZone,omitempty"` + // FqdnZones - FQDN zones of the DNS Service. + FqdnZones *[]string `json:"fqdnZones,omitempty"` + // LogLevel - DNS Service log level. Possible values include: 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'FATAL' + LogLevel DNSServiceLogLevelEnum `json:"logLevel,omitempty"` + // Status - READ-ONLY; DNS Service status. Possible values include: 'SUCCESS', 'FAILURE' + Status DNSServiceStatusEnum `json:"status,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'WorkloadNetworkDNSServiceProvisioningStateSucceeded', 'WorkloadNetworkDNSServiceProvisioningStateFailed', 'WorkloadNetworkDNSServiceProvisioningStateBuilding', 'WorkloadNetworkDNSServiceProvisioningStateDeleting', 'WorkloadNetworkDNSServiceProvisioningStateUpdating' + ProvisioningState WorkloadNetworkDNSServiceProvisioningState `json:"provisioningState,omitempty"` + // Revision - NSX revision number. + Revision *int64 `json:"revision,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkDNSServiceProperties. +func (wndsp WorkloadNetworkDNSServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wndsp.DisplayName != nil { + objectMap["displayName"] = wndsp.DisplayName + } + if wndsp.DNSServiceIP != nil { + objectMap["dnsServiceIp"] = wndsp.DNSServiceIP + } + if wndsp.DefaultDNSZone != nil { + objectMap["defaultDnsZone"] = wndsp.DefaultDNSZone + } + if wndsp.FqdnZones != nil { + objectMap["fqdnZones"] = wndsp.FqdnZones + } + if wndsp.LogLevel != "" { + objectMap["logLevel"] = wndsp.LogLevel + } + if wndsp.Revision != nil { + objectMap["revision"] = wndsp.Revision + } + return json.Marshal(objectMap) +} + +// WorkloadNetworkDNSServicesList a list of NSX DNS Services +type WorkloadNetworkDNSServicesList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on the page + Value *[]WorkloadNetworkDNSService `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// WorkloadNetworkDNSServicesListIterator provides access to a complete listing of +// WorkloadNetworkDNSService values. +type WorkloadNetworkDNSServicesListIterator struct { + i int + page WorkloadNetworkDNSServicesListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkloadNetworkDNSServicesListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkDNSServicesListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadNetworkDNSServicesListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadNetworkDNSServicesListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkloadNetworkDNSServicesListIterator) Response() WorkloadNetworkDNSServicesList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkloadNetworkDNSServicesListIterator) Value() WorkloadNetworkDNSService { + if !iter.page.NotDone() { + return WorkloadNetworkDNSService{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadNetworkDNSServicesListIterator type. +func NewWorkloadNetworkDNSServicesListIterator(page WorkloadNetworkDNSServicesListPage) WorkloadNetworkDNSServicesListIterator { + return WorkloadNetworkDNSServicesListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wndsl WorkloadNetworkDNSServicesList) IsEmpty() bool { + return wndsl.Value == nil || len(*wndsl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wndsl WorkloadNetworkDNSServicesList) hasNextLink() bool { + return wndsl.NextLink != nil && len(*wndsl.NextLink) != 0 +} + +// workloadNetworkDNSServicesListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wndsl WorkloadNetworkDNSServicesList) workloadNetworkDNSServicesListPreparer(ctx context.Context) (*http.Request, error) { + if !wndsl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wndsl.NextLink))) +} + +// WorkloadNetworkDNSServicesListPage contains a page of WorkloadNetworkDNSService values. +type WorkloadNetworkDNSServicesListPage struct { + fn func(context.Context, WorkloadNetworkDNSServicesList) (WorkloadNetworkDNSServicesList, error) + wndsl WorkloadNetworkDNSServicesList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkloadNetworkDNSServicesListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkDNSServicesListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wndsl) + if err != nil { + return err + } + page.wndsl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadNetworkDNSServicesListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadNetworkDNSServicesListPage) NotDone() bool { + return !page.wndsl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadNetworkDNSServicesListPage) Response() WorkloadNetworkDNSServicesList { + return page.wndsl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadNetworkDNSServicesListPage) Values() []WorkloadNetworkDNSService { + if page.wndsl.IsEmpty() { + return nil + } + return *page.wndsl.Value +} + +// Creates a new instance of the WorkloadNetworkDNSServicesListPage type. +func NewWorkloadNetworkDNSServicesListPage(cur WorkloadNetworkDNSServicesList, getNextPage func(context.Context, WorkloadNetworkDNSServicesList) (WorkloadNetworkDNSServicesList, error)) WorkloadNetworkDNSServicesListPage { + return WorkloadNetworkDNSServicesListPage{ + fn: getNextPage, + wndsl: cur, + } +} + +// WorkloadNetworkDNSZone NSX DNS Zone +type WorkloadNetworkDNSZone struct { + autorest.Response `json:"-"` + // WorkloadNetworkDNSZoneProperties - DNS Zone properties + *WorkloadNetworkDNSZoneProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkDNSZone. +func (wndz WorkloadNetworkDNSZone) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wndz.WorkloadNetworkDNSZoneProperties != nil { + objectMap["properties"] = wndz.WorkloadNetworkDNSZoneProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadNetworkDNSZone struct. +func (wndz *WorkloadNetworkDNSZone) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workloadNetworkDNSZoneProperties WorkloadNetworkDNSZoneProperties + err = json.Unmarshal(*v, &workloadNetworkDNSZoneProperties) + if err != nil { + return err + } + wndz.WorkloadNetworkDNSZoneProperties = &workloadNetworkDNSZoneProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wndz.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wndz.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wndz.Type = &typeVar + } + } + } + + return nil +} + +// WorkloadNetworkDNSZoneProperties NSX DNS Zone Properties +type WorkloadNetworkDNSZoneProperties struct { + // DisplayName - Display name of the DNS Zone. + DisplayName *string `json:"displayName,omitempty"` + // Domain - Domain names of the DNS Zone. + Domain *[]string `json:"domain,omitempty"` + // DNSServerIps - DNS Server IP array of the DNS Zone. + DNSServerIps *[]string `json:"dnsServerIps,omitempty"` + // SourceIP - Source IP of the DNS Zone. + SourceIP *string `json:"sourceIp,omitempty"` + // DNSServices - Number of DNS Services using the DNS zone. + DNSServices *int64 `json:"dnsServices,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'WorkloadNetworkDNSZoneProvisioningStateSucceeded', 'WorkloadNetworkDNSZoneProvisioningStateFailed', 'WorkloadNetworkDNSZoneProvisioningStateBuilding', 'WorkloadNetworkDNSZoneProvisioningStateDeleting', 'WorkloadNetworkDNSZoneProvisioningStateUpdating' + ProvisioningState WorkloadNetworkDNSZoneProvisioningState `json:"provisioningState,omitempty"` + // Revision - NSX revision number. + Revision *int64 `json:"revision,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkDNSZoneProperties. +func (wndzp WorkloadNetworkDNSZoneProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wndzp.DisplayName != nil { + objectMap["displayName"] = wndzp.DisplayName + } + if wndzp.Domain != nil { + objectMap["domain"] = wndzp.Domain + } + if wndzp.DNSServerIps != nil { + objectMap["dnsServerIps"] = wndzp.DNSServerIps + } + if wndzp.SourceIP != nil { + objectMap["sourceIp"] = wndzp.SourceIP + } + if wndzp.DNSServices != nil { + objectMap["dnsServices"] = wndzp.DNSServices + } + if wndzp.Revision != nil { + objectMap["revision"] = wndzp.Revision + } + return json.Marshal(objectMap) +} + +// WorkloadNetworkDNSZonesList a list of NSX DNS Zones +type WorkloadNetworkDNSZonesList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on the page + Value *[]WorkloadNetworkDNSZone `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// WorkloadNetworkDNSZonesListIterator provides access to a complete listing of WorkloadNetworkDNSZone +// values. +type WorkloadNetworkDNSZonesListIterator struct { + i int + page WorkloadNetworkDNSZonesListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkloadNetworkDNSZonesListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkDNSZonesListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadNetworkDNSZonesListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadNetworkDNSZonesListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkloadNetworkDNSZonesListIterator) Response() WorkloadNetworkDNSZonesList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkloadNetworkDNSZonesListIterator) Value() WorkloadNetworkDNSZone { + if !iter.page.NotDone() { + return WorkloadNetworkDNSZone{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadNetworkDNSZonesListIterator type. +func NewWorkloadNetworkDNSZonesListIterator(page WorkloadNetworkDNSZonesListPage) WorkloadNetworkDNSZonesListIterator { + return WorkloadNetworkDNSZonesListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wndzl WorkloadNetworkDNSZonesList) IsEmpty() bool { + return wndzl.Value == nil || len(*wndzl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wndzl WorkloadNetworkDNSZonesList) hasNextLink() bool { + return wndzl.NextLink != nil && len(*wndzl.NextLink) != 0 +} + +// workloadNetworkDNSZonesListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wndzl WorkloadNetworkDNSZonesList) workloadNetworkDNSZonesListPreparer(ctx context.Context) (*http.Request, error) { + if !wndzl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wndzl.NextLink))) +} + +// WorkloadNetworkDNSZonesListPage contains a page of WorkloadNetworkDNSZone values. +type WorkloadNetworkDNSZonesListPage struct { + fn func(context.Context, WorkloadNetworkDNSZonesList) (WorkloadNetworkDNSZonesList, error) + wndzl WorkloadNetworkDNSZonesList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkloadNetworkDNSZonesListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkDNSZonesListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wndzl) + if err != nil { + return err + } + page.wndzl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadNetworkDNSZonesListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadNetworkDNSZonesListPage) NotDone() bool { + return !page.wndzl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadNetworkDNSZonesListPage) Response() WorkloadNetworkDNSZonesList { + return page.wndzl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadNetworkDNSZonesListPage) Values() []WorkloadNetworkDNSZone { + if page.wndzl.IsEmpty() { + return nil + } + return *page.wndzl.Value +} + +// Creates a new instance of the WorkloadNetworkDNSZonesListPage type. +func NewWorkloadNetworkDNSZonesListPage(cur WorkloadNetworkDNSZonesList, getNextPage func(context.Context, WorkloadNetworkDNSZonesList) (WorkloadNetworkDNSZonesList, error)) WorkloadNetworkDNSZonesListPage { + return WorkloadNetworkDNSZonesListPage{ + fn: getNextPage, + wndzl: cur, + } +} + +// WorkloadNetworkGateway NSX Gateway. +type WorkloadNetworkGateway struct { + autorest.Response `json:"-"` + // WorkloadNetworkGatewayProperties - Gateway properties. + *WorkloadNetworkGatewayProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkGateway. +func (wng WorkloadNetworkGateway) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wng.WorkloadNetworkGatewayProperties != nil { + objectMap["properties"] = wng.WorkloadNetworkGatewayProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadNetworkGateway struct. +func (wng *WorkloadNetworkGateway) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workloadNetworkGatewayProperties WorkloadNetworkGatewayProperties + err = json.Unmarshal(*v, &workloadNetworkGatewayProperties) + if err != nil { + return err + } + wng.WorkloadNetworkGatewayProperties = &workloadNetworkGatewayProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wng.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wng.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wng.Type = &typeVar + } + } + } + + return nil +} + +// WorkloadNetworkGatewayList a list of NSX Gateways +type WorkloadNetworkGatewayList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on the page + Value *[]WorkloadNetworkGateway `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// WorkloadNetworkGatewayListIterator provides access to a complete listing of WorkloadNetworkGateway +// values. +type WorkloadNetworkGatewayListIterator struct { + i int + page WorkloadNetworkGatewayListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkloadNetworkGatewayListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkGatewayListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadNetworkGatewayListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadNetworkGatewayListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkloadNetworkGatewayListIterator) Response() WorkloadNetworkGatewayList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkloadNetworkGatewayListIterator) Value() WorkloadNetworkGateway { + if !iter.page.NotDone() { + return WorkloadNetworkGateway{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadNetworkGatewayListIterator type. +func NewWorkloadNetworkGatewayListIterator(page WorkloadNetworkGatewayListPage) WorkloadNetworkGatewayListIterator { + return WorkloadNetworkGatewayListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wngl WorkloadNetworkGatewayList) IsEmpty() bool { + return wngl.Value == nil || len(*wngl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wngl WorkloadNetworkGatewayList) hasNextLink() bool { + return wngl.NextLink != nil && len(*wngl.NextLink) != 0 +} + +// workloadNetworkGatewayListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wngl WorkloadNetworkGatewayList) workloadNetworkGatewayListPreparer(ctx context.Context) (*http.Request, error) { + if !wngl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wngl.NextLink))) +} + +// WorkloadNetworkGatewayListPage contains a page of WorkloadNetworkGateway values. +type WorkloadNetworkGatewayListPage struct { + fn func(context.Context, WorkloadNetworkGatewayList) (WorkloadNetworkGatewayList, error) + wngl WorkloadNetworkGatewayList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkloadNetworkGatewayListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkGatewayListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wngl) + if err != nil { + return err + } + page.wngl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadNetworkGatewayListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadNetworkGatewayListPage) NotDone() bool { + return !page.wngl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadNetworkGatewayListPage) Response() WorkloadNetworkGatewayList { + return page.wngl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadNetworkGatewayListPage) Values() []WorkloadNetworkGateway { + if page.wngl.IsEmpty() { + return nil + } + return *page.wngl.Value +} + +// Creates a new instance of the WorkloadNetworkGatewayListPage type. +func NewWorkloadNetworkGatewayListPage(cur WorkloadNetworkGatewayList, getNextPage func(context.Context, WorkloadNetworkGatewayList) (WorkloadNetworkGatewayList, error)) WorkloadNetworkGatewayListPage { + return WorkloadNetworkGatewayListPage{ + fn: getNextPage, + wngl: cur, + } +} + +// WorkloadNetworkGatewayProperties properties of a NSX Gateway. +type WorkloadNetworkGatewayProperties struct { + // DisplayName - Display name of the DHCP entity. + DisplayName *string `json:"displayName,omitempty"` + // Path - READ-ONLY; NSX Gateway Path. + Path *string `json:"path,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkGatewayProperties. +func (wngp WorkloadNetworkGatewayProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wngp.DisplayName != nil { + objectMap["displayName"] = wngp.DisplayName + } + return json.Marshal(objectMap) +} + +// WorkloadNetworkPortMirroring NSX Port Mirroring +type WorkloadNetworkPortMirroring struct { + autorest.Response `json:"-"` + // WorkloadNetworkPortMirroringProperties - Port Mirroring Properties. + *WorkloadNetworkPortMirroringProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkPortMirroring. +func (wnpm WorkloadNetworkPortMirroring) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wnpm.WorkloadNetworkPortMirroringProperties != nil { + objectMap["properties"] = wnpm.WorkloadNetworkPortMirroringProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadNetworkPortMirroring struct. +func (wnpm *WorkloadNetworkPortMirroring) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workloadNetworkPortMirroringProperties WorkloadNetworkPortMirroringProperties + err = json.Unmarshal(*v, &workloadNetworkPortMirroringProperties) + if err != nil { + return err + } + wnpm.WorkloadNetworkPortMirroringProperties = &workloadNetworkPortMirroringProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wnpm.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wnpm.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wnpm.Type = &typeVar + } + } + } + + return nil +} + +// WorkloadNetworkPortMirroringList a list of NSX Port Mirroring +type WorkloadNetworkPortMirroringList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on the page + Value *[]WorkloadNetworkPortMirroring `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// WorkloadNetworkPortMirroringListIterator provides access to a complete listing of +// WorkloadNetworkPortMirroring values. +type WorkloadNetworkPortMirroringListIterator struct { + i int + page WorkloadNetworkPortMirroringListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkloadNetworkPortMirroringListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkPortMirroringListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadNetworkPortMirroringListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadNetworkPortMirroringListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkloadNetworkPortMirroringListIterator) Response() WorkloadNetworkPortMirroringList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkloadNetworkPortMirroringListIterator) Value() WorkloadNetworkPortMirroring { + if !iter.page.NotDone() { + return WorkloadNetworkPortMirroring{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadNetworkPortMirroringListIterator type. +func NewWorkloadNetworkPortMirroringListIterator(page WorkloadNetworkPortMirroringListPage) WorkloadNetworkPortMirroringListIterator { + return WorkloadNetworkPortMirroringListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wnpml WorkloadNetworkPortMirroringList) IsEmpty() bool { + return wnpml.Value == nil || len(*wnpml.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wnpml WorkloadNetworkPortMirroringList) hasNextLink() bool { + return wnpml.NextLink != nil && len(*wnpml.NextLink) != 0 +} + +// workloadNetworkPortMirroringListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wnpml WorkloadNetworkPortMirroringList) workloadNetworkPortMirroringListPreparer(ctx context.Context) (*http.Request, error) { + if !wnpml.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wnpml.NextLink))) +} + +// WorkloadNetworkPortMirroringListPage contains a page of WorkloadNetworkPortMirroring values. +type WorkloadNetworkPortMirroringListPage struct { + fn func(context.Context, WorkloadNetworkPortMirroringList) (WorkloadNetworkPortMirroringList, error) + wnpml WorkloadNetworkPortMirroringList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkloadNetworkPortMirroringListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkPortMirroringListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wnpml) + if err != nil { + return err + } + page.wnpml = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadNetworkPortMirroringListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadNetworkPortMirroringListPage) NotDone() bool { + return !page.wnpml.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadNetworkPortMirroringListPage) Response() WorkloadNetworkPortMirroringList { + return page.wnpml +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadNetworkPortMirroringListPage) Values() []WorkloadNetworkPortMirroring { + if page.wnpml.IsEmpty() { + return nil + } + return *page.wnpml.Value +} + +// Creates a new instance of the WorkloadNetworkPortMirroringListPage type. +func NewWorkloadNetworkPortMirroringListPage(cur WorkloadNetworkPortMirroringList, getNextPage func(context.Context, WorkloadNetworkPortMirroringList) (WorkloadNetworkPortMirroringList, error)) WorkloadNetworkPortMirroringListPage { + return WorkloadNetworkPortMirroringListPage{ + fn: getNextPage, + wnpml: cur, + } +} + +// WorkloadNetworkPortMirroringProperties NSX Port Mirroring Properties +type WorkloadNetworkPortMirroringProperties struct { + // DisplayName - Display name of the port mirroring profile. + DisplayName *string `json:"displayName,omitempty"` + // Direction - Direction of port mirroring profile. Possible values include: 'INGRESSEGRESSBIDIRECTIONAL' + Direction PortMirroringDirectionEnum `json:"direction,omitempty"` + // Source - Source VM Group. + Source *string `json:"source,omitempty"` + // Destination - Destination VM Group. + Destination *string `json:"destination,omitempty"` + // Status - READ-ONLY; Port Mirroring Status. Possible values include: 'SUCCESSFAILURE' + Status PortMirroringStatusEnum `json:"status,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'WorkloadNetworkPortMirroringProvisioningStateSucceeded', 'WorkloadNetworkPortMirroringProvisioningStateFailed', 'WorkloadNetworkPortMirroringProvisioningStateBuilding', 'WorkloadNetworkPortMirroringProvisioningStateDeleting', 'WorkloadNetworkPortMirroringProvisioningStateUpdating' + ProvisioningState WorkloadNetworkPortMirroringProvisioningState `json:"provisioningState,omitempty"` + // Revision - NSX revision number. + Revision *int64 `json:"revision,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkPortMirroringProperties. +func (wnpmp WorkloadNetworkPortMirroringProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wnpmp.DisplayName != nil { + objectMap["displayName"] = wnpmp.DisplayName + } + if wnpmp.Direction != "" { + objectMap["direction"] = wnpmp.Direction + } + if wnpmp.Source != nil { + objectMap["source"] = wnpmp.Source + } + if wnpmp.Destination != nil { + objectMap["destination"] = wnpmp.Destination + } + if wnpmp.Revision != nil { + objectMap["revision"] = wnpmp.Revision + } + return json.Marshal(objectMap) +} + +// WorkloadNetworkPublicIP NSX Public IP Block +type WorkloadNetworkPublicIP struct { + autorest.Response `json:"-"` + // WorkloadNetworkPublicIPProperties - Public IP Block properties + *WorkloadNetworkPublicIPProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkPublicIP. +func (wnpi WorkloadNetworkPublicIP) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wnpi.WorkloadNetworkPublicIPProperties != nil { + objectMap["properties"] = wnpi.WorkloadNetworkPublicIPProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadNetworkPublicIP struct. +func (wnpi *WorkloadNetworkPublicIP) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workloadNetworkPublicIPProperties WorkloadNetworkPublicIPProperties + err = json.Unmarshal(*v, &workloadNetworkPublicIPProperties) + if err != nil { + return err + } + wnpi.WorkloadNetworkPublicIPProperties = &workloadNetworkPublicIPProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wnpi.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wnpi.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wnpi.Type = &typeVar + } + } + } + + return nil +} + +// WorkloadNetworkPublicIPProperties NSX Public IP Block Properties +type WorkloadNetworkPublicIPProperties struct { + // DisplayName - Display name of the Public IP Block. + DisplayName *string `json:"displayName,omitempty"` + // NumberOfPublicIPs - Number of Public IPs requested. + NumberOfPublicIPs *int64 `json:"numberOfPublicIPs,omitempty"` + // PublicIPBlock - READ-ONLY; CIDR Block of the Public IP Block. + PublicIPBlock *string `json:"publicIPBlock,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'WorkloadNetworkPublicIPProvisioningStateSucceeded', 'WorkloadNetworkPublicIPProvisioningStateFailed', 'WorkloadNetworkPublicIPProvisioningStateBuilding', 'WorkloadNetworkPublicIPProvisioningStateDeleting', 'WorkloadNetworkPublicIPProvisioningStateUpdating' + ProvisioningState WorkloadNetworkPublicIPProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkPublicIPProperties. +func (wnpip WorkloadNetworkPublicIPProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wnpip.DisplayName != nil { + objectMap["displayName"] = wnpip.DisplayName + } + if wnpip.NumberOfPublicIPs != nil { + objectMap["numberOfPublicIPs"] = wnpip.NumberOfPublicIPs + } + return json.Marshal(objectMap) +} + +// WorkloadNetworkPublicIPsList a list of NSX Public IP Blocks +type WorkloadNetworkPublicIPsList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on the page + Value *[]WorkloadNetworkPublicIP `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// WorkloadNetworkPublicIPsListIterator provides access to a complete listing of WorkloadNetworkPublicIP +// values. +type WorkloadNetworkPublicIPsListIterator struct { + i int + page WorkloadNetworkPublicIPsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkloadNetworkPublicIPsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkPublicIPsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadNetworkPublicIPsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadNetworkPublicIPsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkloadNetworkPublicIPsListIterator) Response() WorkloadNetworkPublicIPsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkloadNetworkPublicIPsListIterator) Value() WorkloadNetworkPublicIP { + if !iter.page.NotDone() { + return WorkloadNetworkPublicIP{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadNetworkPublicIPsListIterator type. +func NewWorkloadNetworkPublicIPsListIterator(page WorkloadNetworkPublicIPsListPage) WorkloadNetworkPublicIPsListIterator { + return WorkloadNetworkPublicIPsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wnpipl WorkloadNetworkPublicIPsList) IsEmpty() bool { + return wnpipl.Value == nil || len(*wnpipl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wnpipl WorkloadNetworkPublicIPsList) hasNextLink() bool { + return wnpipl.NextLink != nil && len(*wnpipl.NextLink) != 0 +} + +// workloadNetworkPublicIPsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wnpipl WorkloadNetworkPublicIPsList) workloadNetworkPublicIPsListPreparer(ctx context.Context) (*http.Request, error) { + if !wnpipl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wnpipl.NextLink))) +} + +// WorkloadNetworkPublicIPsListPage contains a page of WorkloadNetworkPublicIP values. +type WorkloadNetworkPublicIPsListPage struct { + fn func(context.Context, WorkloadNetworkPublicIPsList) (WorkloadNetworkPublicIPsList, error) + wnpipl WorkloadNetworkPublicIPsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkloadNetworkPublicIPsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkPublicIPsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wnpipl) + if err != nil { + return err + } + page.wnpipl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadNetworkPublicIPsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadNetworkPublicIPsListPage) NotDone() bool { + return !page.wnpipl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadNetworkPublicIPsListPage) Response() WorkloadNetworkPublicIPsList { + return page.wnpipl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadNetworkPublicIPsListPage) Values() []WorkloadNetworkPublicIP { + if page.wnpipl.IsEmpty() { + return nil + } + return *page.wnpipl.Value +} + +// Creates a new instance of the WorkloadNetworkPublicIPsListPage type. +func NewWorkloadNetworkPublicIPsListPage(cur WorkloadNetworkPublicIPsList, getNextPage func(context.Context, WorkloadNetworkPublicIPsList) (WorkloadNetworkPublicIPsList, error)) WorkloadNetworkPublicIPsListPage { + return WorkloadNetworkPublicIPsListPage{ + fn: getNextPage, + wnpipl: cur, + } +} + +// WorkloadNetworksCreateDhcpFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksCreateDhcpFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkDhcp, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksCreateDhcpFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksCreateDhcpFuture.Result. +func (future *WorkloadNetworksCreateDhcpFuture) result(client WorkloadNetworksClient) (wnd WorkloadNetworkDhcp, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreateDhcpFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wnd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksCreateDhcpFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wnd.Response.Response, err = future.GetResult(sender); err == nil && wnd.Response.Response.StatusCode != http.StatusNoContent { + wnd, err = client.CreateDhcpResponder(wnd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreateDhcpFuture", "Result", wnd.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworksCreateDNSServiceFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksCreateDNSServiceFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkDNSService, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksCreateDNSServiceFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksCreateDNSServiceFuture.Result. +func (future *WorkloadNetworksCreateDNSServiceFuture) result(client WorkloadNetworksClient) (wnds WorkloadNetworkDNSService, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreateDNSServiceFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wnds.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksCreateDNSServiceFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wnds.Response.Response, err = future.GetResult(sender); err == nil && wnds.Response.Response.StatusCode != http.StatusNoContent { + wnds, err = client.CreateDNSServiceResponder(wnds.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreateDNSServiceFuture", "Result", wnds.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworksCreateDNSZoneFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksCreateDNSZoneFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkDNSZone, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksCreateDNSZoneFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksCreateDNSZoneFuture.Result. +func (future *WorkloadNetworksCreateDNSZoneFuture) result(client WorkloadNetworksClient) (wndz WorkloadNetworkDNSZone, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreateDNSZoneFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wndz.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksCreateDNSZoneFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wndz.Response.Response, err = future.GetResult(sender); err == nil && wndz.Response.Response.StatusCode != http.StatusNoContent { + wndz, err = client.CreateDNSZoneResponder(wndz.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreateDNSZoneFuture", "Result", wndz.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworksCreatePortMirroringFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksCreatePortMirroringFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkPortMirroring, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksCreatePortMirroringFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksCreatePortMirroringFuture.Result. +func (future *WorkloadNetworksCreatePortMirroringFuture) result(client WorkloadNetworksClient) (wnpm WorkloadNetworkPortMirroring, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreatePortMirroringFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wnpm.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksCreatePortMirroringFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wnpm.Response.Response, err = future.GetResult(sender); err == nil && wnpm.Response.Response.StatusCode != http.StatusNoContent { + wnpm, err = client.CreatePortMirroringResponder(wnpm.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreatePortMirroringFuture", "Result", wnpm.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworksCreatePublicIPFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksCreatePublicIPFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkPublicIP, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksCreatePublicIPFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksCreatePublicIPFuture.Result. +func (future *WorkloadNetworksCreatePublicIPFuture) result(client WorkloadNetworksClient) (wnpi WorkloadNetworkPublicIP, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreatePublicIPFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wnpi.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksCreatePublicIPFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wnpi.Response.Response, err = future.GetResult(sender); err == nil && wnpi.Response.Response.StatusCode != http.StatusNoContent { + wnpi, err = client.CreatePublicIPResponder(wnpi.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreatePublicIPFuture", "Result", wnpi.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworksCreateSegmentsFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksCreateSegmentsFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkSegment, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksCreateSegmentsFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksCreateSegmentsFuture.Result. +func (future *WorkloadNetworksCreateSegmentsFuture) result(client WorkloadNetworksClient) (wns WorkloadNetworkSegment, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreateSegmentsFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wns.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksCreateSegmentsFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wns.Response.Response, err = future.GetResult(sender); err == nil && wns.Response.Response.StatusCode != http.StatusNoContent { + wns, err = client.CreateSegmentsResponder(wns.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreateSegmentsFuture", "Result", wns.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworksCreateVMGroupFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksCreateVMGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkVMGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksCreateVMGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksCreateVMGroupFuture.Result. +func (future *WorkloadNetworksCreateVMGroupFuture) result(client WorkloadNetworksClient) (wnvg WorkloadNetworkVMGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreateVMGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wnvg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksCreateVMGroupFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wnvg.Response.Response, err = future.GetResult(sender); err == nil && wnvg.Response.Response.StatusCode != http.StatusNoContent { + wnvg, err = client.CreateVMGroupResponder(wnvg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksCreateVMGroupFuture", "Result", wnvg.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworksDeleteDhcpFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksDeleteDhcpFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksDeleteDhcpFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksDeleteDhcpFuture.Result. +func (future *WorkloadNetworksDeleteDhcpFuture) result(client WorkloadNetworksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksDeleteDhcpFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksDeleteDhcpFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkloadNetworksDeleteDNSServiceFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksDeleteDNSServiceFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksDeleteDNSServiceFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksDeleteDNSServiceFuture.Result. +func (future *WorkloadNetworksDeleteDNSServiceFuture) result(client WorkloadNetworksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksDeleteDNSServiceFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksDeleteDNSServiceFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkloadNetworksDeleteDNSZoneFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksDeleteDNSZoneFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksDeleteDNSZoneFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksDeleteDNSZoneFuture.Result. +func (future *WorkloadNetworksDeleteDNSZoneFuture) result(client WorkloadNetworksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksDeleteDNSZoneFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksDeleteDNSZoneFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkloadNetworksDeletePortMirroringFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksDeletePortMirroringFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksDeletePortMirroringFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksDeletePortMirroringFuture.Result. +func (future *WorkloadNetworksDeletePortMirroringFuture) result(client WorkloadNetworksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksDeletePortMirroringFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksDeletePortMirroringFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkloadNetworksDeletePublicIPFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksDeletePublicIPFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksDeletePublicIPFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksDeletePublicIPFuture.Result. +func (future *WorkloadNetworksDeletePublicIPFuture) result(client WorkloadNetworksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksDeletePublicIPFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksDeletePublicIPFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkloadNetworksDeleteSegmentFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksDeleteSegmentFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksDeleteSegmentFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksDeleteSegmentFuture.Result. +func (future *WorkloadNetworksDeleteSegmentFuture) result(client WorkloadNetworksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksDeleteSegmentFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksDeleteSegmentFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkloadNetworksDeleteVMGroupFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksDeleteVMGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksDeleteVMGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksDeleteVMGroupFuture.Result. +func (future *WorkloadNetworksDeleteVMGroupFuture) result(client WorkloadNetworksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksDeleteVMGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksDeleteVMGroupFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkloadNetworkSegment NSX Segment +type WorkloadNetworkSegment struct { + autorest.Response `json:"-"` + // WorkloadNetworkSegmentProperties - The properties of a Workload Segment proxy resource. + *WorkloadNetworkSegmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkSegment. +func (wns WorkloadNetworkSegment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wns.WorkloadNetworkSegmentProperties != nil { + objectMap["properties"] = wns.WorkloadNetworkSegmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadNetworkSegment struct. +func (wns *WorkloadNetworkSegment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workloadNetworkSegmentProperties WorkloadNetworkSegmentProperties + err = json.Unmarshal(*v, &workloadNetworkSegmentProperties) + if err != nil { + return err + } + wns.WorkloadNetworkSegmentProperties = &workloadNetworkSegmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wns.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wns.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wns.Type = &typeVar + } + } + } + + return nil +} + +// WorkloadNetworkSegmentPortVif ports and any VIF attached to segment. +type WorkloadNetworkSegmentPortVif struct { + // PortName - Name of port or VIF attached to segment. + PortName *string `json:"portName,omitempty"` +} + +// WorkloadNetworkSegmentProperties NSX Segment Properties +type WorkloadNetworkSegmentProperties struct { + // DisplayName - Display name of the segment. + DisplayName *string `json:"displayName,omitempty"` + // ConnectedGateway - Gateway which to connect segment to. + ConnectedGateway *string `json:"connectedGateway,omitempty"` + // Subnet - Subnet which to connect segment to. + Subnet *WorkloadNetworkSegmentSubnet `json:"subnet,omitempty"` + // PortVif - READ-ONLY; Port Vif which segment is associated with. + PortVif *[]WorkloadNetworkSegmentPortVif `json:"portVif,omitempty"` + // Status - READ-ONLY; Segment status. Possible values include: 'SegmentStatusEnumSUCCESSFAILURE' + Status SegmentStatusEnum `json:"status,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'WorkloadNetworkSegmentProvisioningStateSucceeded', 'WorkloadNetworkSegmentProvisioningStateFailed', 'WorkloadNetworkSegmentProvisioningStateBuilding', 'WorkloadNetworkSegmentProvisioningStateDeleting', 'WorkloadNetworkSegmentProvisioningStateUpdating' + ProvisioningState WorkloadNetworkSegmentProvisioningState `json:"provisioningState,omitempty"` + // Revision - NSX revision number. + Revision *int64 `json:"revision,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkSegmentProperties. +func (wnsp WorkloadNetworkSegmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wnsp.DisplayName != nil { + objectMap["displayName"] = wnsp.DisplayName + } + if wnsp.ConnectedGateway != nil { + objectMap["connectedGateway"] = wnsp.ConnectedGateway + } + if wnsp.Subnet != nil { + objectMap["subnet"] = wnsp.Subnet + } + if wnsp.Revision != nil { + objectMap["revision"] = wnsp.Revision + } + return json.Marshal(objectMap) +} + +// WorkloadNetworkSegmentsList a list of NSX Segments +type WorkloadNetworkSegmentsList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on the page + Value *[]WorkloadNetworkSegment `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// WorkloadNetworkSegmentsListIterator provides access to a complete listing of WorkloadNetworkSegment +// values. +type WorkloadNetworkSegmentsListIterator struct { + i int + page WorkloadNetworkSegmentsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkloadNetworkSegmentsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkSegmentsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadNetworkSegmentsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadNetworkSegmentsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkloadNetworkSegmentsListIterator) Response() WorkloadNetworkSegmentsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkloadNetworkSegmentsListIterator) Value() WorkloadNetworkSegment { + if !iter.page.NotDone() { + return WorkloadNetworkSegment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadNetworkSegmentsListIterator type. +func NewWorkloadNetworkSegmentsListIterator(page WorkloadNetworkSegmentsListPage) WorkloadNetworkSegmentsListIterator { + return WorkloadNetworkSegmentsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wnsl WorkloadNetworkSegmentsList) IsEmpty() bool { + return wnsl.Value == nil || len(*wnsl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wnsl WorkloadNetworkSegmentsList) hasNextLink() bool { + return wnsl.NextLink != nil && len(*wnsl.NextLink) != 0 +} + +// workloadNetworkSegmentsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wnsl WorkloadNetworkSegmentsList) workloadNetworkSegmentsListPreparer(ctx context.Context) (*http.Request, error) { + if !wnsl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wnsl.NextLink))) +} + +// WorkloadNetworkSegmentsListPage contains a page of WorkloadNetworkSegment values. +type WorkloadNetworkSegmentsListPage struct { + fn func(context.Context, WorkloadNetworkSegmentsList) (WorkloadNetworkSegmentsList, error) + wnsl WorkloadNetworkSegmentsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkloadNetworkSegmentsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkSegmentsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wnsl) + if err != nil { + return err + } + page.wnsl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadNetworkSegmentsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadNetworkSegmentsListPage) NotDone() bool { + return !page.wnsl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadNetworkSegmentsListPage) Response() WorkloadNetworkSegmentsList { + return page.wnsl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadNetworkSegmentsListPage) Values() []WorkloadNetworkSegment { + if page.wnsl.IsEmpty() { + return nil + } + return *page.wnsl.Value +} + +// Creates a new instance of the WorkloadNetworkSegmentsListPage type. +func NewWorkloadNetworkSegmentsListPage(cur WorkloadNetworkSegmentsList, getNextPage func(context.Context, WorkloadNetworkSegmentsList) (WorkloadNetworkSegmentsList, error)) WorkloadNetworkSegmentsListPage { + return WorkloadNetworkSegmentsListPage{ + fn: getNextPage, + wnsl: cur, + } +} + +// WorkloadNetworkSegmentSubnet subnet configuration for segment +type WorkloadNetworkSegmentSubnet struct { + // DhcpRanges - DHCP Range assigned for subnet. + DhcpRanges *[]string `json:"dhcpRanges,omitempty"` + // GatewayAddress - Gateway address. + GatewayAddress *string `json:"gatewayAddress,omitempty"` +} + +// WorkloadNetworksUpdateDhcpFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksUpdateDhcpFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkDhcp, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksUpdateDhcpFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksUpdateDhcpFuture.Result. +func (future *WorkloadNetworksUpdateDhcpFuture) result(client WorkloadNetworksClient) (wnd WorkloadNetworkDhcp, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksUpdateDhcpFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wnd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksUpdateDhcpFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wnd.Response.Response, err = future.GetResult(sender); err == nil && wnd.Response.Response.StatusCode != http.StatusNoContent { + wnd, err = client.UpdateDhcpResponder(wnd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksUpdateDhcpFuture", "Result", wnd.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworksUpdateDNSServiceFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksUpdateDNSServiceFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkDNSService, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksUpdateDNSServiceFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksUpdateDNSServiceFuture.Result. +func (future *WorkloadNetworksUpdateDNSServiceFuture) result(client WorkloadNetworksClient) (wnds WorkloadNetworkDNSService, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksUpdateDNSServiceFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wnds.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksUpdateDNSServiceFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wnds.Response.Response, err = future.GetResult(sender); err == nil && wnds.Response.Response.StatusCode != http.StatusNoContent { + wnds, err = client.UpdateDNSServiceResponder(wnds.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksUpdateDNSServiceFuture", "Result", wnds.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworksUpdateDNSZoneFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksUpdateDNSZoneFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkDNSZone, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksUpdateDNSZoneFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksUpdateDNSZoneFuture.Result. +func (future *WorkloadNetworksUpdateDNSZoneFuture) result(client WorkloadNetworksClient) (wndz WorkloadNetworkDNSZone, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksUpdateDNSZoneFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wndz.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksUpdateDNSZoneFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wndz.Response.Response, err = future.GetResult(sender); err == nil && wndz.Response.Response.StatusCode != http.StatusNoContent { + wndz, err = client.UpdateDNSZoneResponder(wndz.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksUpdateDNSZoneFuture", "Result", wndz.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworksUpdatePortMirroringFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksUpdatePortMirroringFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkPortMirroring, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksUpdatePortMirroringFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksUpdatePortMirroringFuture.Result. +func (future *WorkloadNetworksUpdatePortMirroringFuture) result(client WorkloadNetworksClient) (wnpm WorkloadNetworkPortMirroring, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksUpdatePortMirroringFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wnpm.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksUpdatePortMirroringFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wnpm.Response.Response, err = future.GetResult(sender); err == nil && wnpm.Response.Response.StatusCode != http.StatusNoContent { + wnpm, err = client.UpdatePortMirroringResponder(wnpm.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksUpdatePortMirroringFuture", "Result", wnpm.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworksUpdateSegmentsFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksUpdateSegmentsFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkSegment, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksUpdateSegmentsFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksUpdateSegmentsFuture.Result. +func (future *WorkloadNetworksUpdateSegmentsFuture) result(client WorkloadNetworksClient) (wns WorkloadNetworkSegment, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksUpdateSegmentsFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wns.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksUpdateSegmentsFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wns.Response.Response, err = future.GetResult(sender); err == nil && wns.Response.Response.StatusCode != http.StatusNoContent { + wns, err = client.UpdateSegmentsResponder(wns.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksUpdateSegmentsFuture", "Result", wns.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworksUpdateVMGroupFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksUpdateVMGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadNetworksClient) (WorkloadNetworkVMGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadNetworksUpdateVMGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadNetworksUpdateVMGroupFuture.Result. +func (future *WorkloadNetworksUpdateVMGroupFuture) result(client WorkloadNetworksClient) (wnvg WorkloadNetworkVMGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksUpdateVMGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wnvg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksUpdateVMGroupFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wnvg.Response.Response, err = future.GetResult(sender); err == nil && wnvg.Response.Response.StatusCode != http.StatusNoContent { + wnvg, err = client.UpdateVMGroupResponder(wnvg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksUpdateVMGroupFuture", "Result", wnvg.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadNetworkVirtualMachine NSX Virtual Machine +type WorkloadNetworkVirtualMachine struct { + autorest.Response `json:"-"` + // WorkloadNetworkVirtualMachineProperties - Virtual machine properties. + *WorkloadNetworkVirtualMachineProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkVirtualMachine. +func (wnvm WorkloadNetworkVirtualMachine) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wnvm.WorkloadNetworkVirtualMachineProperties != nil { + objectMap["properties"] = wnvm.WorkloadNetworkVirtualMachineProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadNetworkVirtualMachine struct. +func (wnvm *WorkloadNetworkVirtualMachine) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workloadNetworkVirtualMachineProperties WorkloadNetworkVirtualMachineProperties + err = json.Unmarshal(*v, &workloadNetworkVirtualMachineProperties) + if err != nil { + return err + } + wnvm.WorkloadNetworkVirtualMachineProperties = &workloadNetworkVirtualMachineProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wnvm.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wnvm.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wnvm.Type = &typeVar + } + } + } + + return nil +} + +// WorkloadNetworkVirtualMachineProperties NSX Virtual Machine Properties +type WorkloadNetworkVirtualMachineProperties struct { + // DisplayName - Display name of the VM. + DisplayName *string `json:"displayName,omitempty"` + // VMType - READ-ONLY; Virtual machine type. Possible values include: 'REGULAREDGESERVICE' + VMType VMTypeEnum `json:"vmType,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkVirtualMachineProperties. +func (wnvmp WorkloadNetworkVirtualMachineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wnvmp.DisplayName != nil { + objectMap["displayName"] = wnvmp.DisplayName + } + return json.Marshal(objectMap) +} + +// WorkloadNetworkVirtualMachinesList a list of NSX Virtual Machines +type WorkloadNetworkVirtualMachinesList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on the page + Value *[]WorkloadNetworkVirtualMachine `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// WorkloadNetworkVirtualMachinesListIterator provides access to a complete listing of +// WorkloadNetworkVirtualMachine values. +type WorkloadNetworkVirtualMachinesListIterator struct { + i int + page WorkloadNetworkVirtualMachinesListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkloadNetworkVirtualMachinesListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkVirtualMachinesListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadNetworkVirtualMachinesListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadNetworkVirtualMachinesListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkloadNetworkVirtualMachinesListIterator) Response() WorkloadNetworkVirtualMachinesList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkloadNetworkVirtualMachinesListIterator) Value() WorkloadNetworkVirtualMachine { + if !iter.page.NotDone() { + return WorkloadNetworkVirtualMachine{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadNetworkVirtualMachinesListIterator type. +func NewWorkloadNetworkVirtualMachinesListIterator(page WorkloadNetworkVirtualMachinesListPage) WorkloadNetworkVirtualMachinesListIterator { + return WorkloadNetworkVirtualMachinesListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wnvml WorkloadNetworkVirtualMachinesList) IsEmpty() bool { + return wnvml.Value == nil || len(*wnvml.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wnvml WorkloadNetworkVirtualMachinesList) hasNextLink() bool { + return wnvml.NextLink != nil && len(*wnvml.NextLink) != 0 +} + +// workloadNetworkVirtualMachinesListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wnvml WorkloadNetworkVirtualMachinesList) workloadNetworkVirtualMachinesListPreparer(ctx context.Context) (*http.Request, error) { + if !wnvml.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wnvml.NextLink))) +} + +// WorkloadNetworkVirtualMachinesListPage contains a page of WorkloadNetworkVirtualMachine values. +type WorkloadNetworkVirtualMachinesListPage struct { + fn func(context.Context, WorkloadNetworkVirtualMachinesList) (WorkloadNetworkVirtualMachinesList, error) + wnvml WorkloadNetworkVirtualMachinesList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkloadNetworkVirtualMachinesListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkVirtualMachinesListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wnvml) + if err != nil { + return err + } + page.wnvml = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadNetworkVirtualMachinesListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadNetworkVirtualMachinesListPage) NotDone() bool { + return !page.wnvml.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadNetworkVirtualMachinesListPage) Response() WorkloadNetworkVirtualMachinesList { + return page.wnvml +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadNetworkVirtualMachinesListPage) Values() []WorkloadNetworkVirtualMachine { + if page.wnvml.IsEmpty() { + return nil + } + return *page.wnvml.Value +} + +// Creates a new instance of the WorkloadNetworkVirtualMachinesListPage type. +func NewWorkloadNetworkVirtualMachinesListPage(cur WorkloadNetworkVirtualMachinesList, getNextPage func(context.Context, WorkloadNetworkVirtualMachinesList) (WorkloadNetworkVirtualMachinesList, error)) WorkloadNetworkVirtualMachinesListPage { + return WorkloadNetworkVirtualMachinesListPage{ + fn: getNextPage, + wnvml: cur, + } +} + +// WorkloadNetworkVMGroup NSX VM Group +type WorkloadNetworkVMGroup struct { + autorest.Response `json:"-"` + // WorkloadNetworkVMGroupProperties - VM Group properties. + *WorkloadNetworkVMGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkVMGroup. +func (wnvg WorkloadNetworkVMGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wnvg.WorkloadNetworkVMGroupProperties != nil { + objectMap["properties"] = wnvg.WorkloadNetworkVMGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadNetworkVMGroup struct. +func (wnvg *WorkloadNetworkVMGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workloadNetworkVMGroupProperties WorkloadNetworkVMGroupProperties + err = json.Unmarshal(*v, &workloadNetworkVMGroupProperties) + if err != nil { + return err + } + wnvg.WorkloadNetworkVMGroupProperties = &workloadNetworkVMGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wnvg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wnvg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wnvg.Type = &typeVar + } + } + } + + return nil +} + +// WorkloadNetworkVMGroupProperties NSX VM Group Properties +type WorkloadNetworkVMGroupProperties struct { + // DisplayName - Display name of the VM group. + DisplayName *string `json:"displayName,omitempty"` + // Members - Virtual machine members of this group. + Members *[]string `json:"members,omitempty"` + // Status - READ-ONLY; VM Group status. Possible values include: 'VMGroupStatusEnumSUCCESSFAILURE' + Status VMGroupStatusEnum `json:"status,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'WorkloadNetworkVMGroupProvisioningStateSucceeded', 'WorkloadNetworkVMGroupProvisioningStateFailed', 'WorkloadNetworkVMGroupProvisioningStateBuilding', 'WorkloadNetworkVMGroupProvisioningStateDeleting', 'WorkloadNetworkVMGroupProvisioningStateUpdating' + ProvisioningState WorkloadNetworkVMGroupProvisioningState `json:"provisioningState,omitempty"` + // Revision - NSX revision number. + Revision *int64 `json:"revision,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadNetworkVMGroupProperties. +func (wnvgp WorkloadNetworkVMGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wnvgp.DisplayName != nil { + objectMap["displayName"] = wnvgp.DisplayName + } + if wnvgp.Members != nil { + objectMap["members"] = wnvgp.Members + } + if wnvgp.Revision != nil { + objectMap["revision"] = wnvgp.Revision + } + return json.Marshal(objectMap) +} + +// WorkloadNetworkVMGroupsList a list of NSX VM Groups +type WorkloadNetworkVMGroupsList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on the page + Value *[]WorkloadNetworkVMGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// WorkloadNetworkVMGroupsListIterator provides access to a complete listing of WorkloadNetworkVMGroup +// values. +type WorkloadNetworkVMGroupsListIterator struct { + i int + page WorkloadNetworkVMGroupsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkloadNetworkVMGroupsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkVMGroupsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadNetworkVMGroupsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadNetworkVMGroupsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkloadNetworkVMGroupsListIterator) Response() WorkloadNetworkVMGroupsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkloadNetworkVMGroupsListIterator) Value() WorkloadNetworkVMGroup { + if !iter.page.NotDone() { + return WorkloadNetworkVMGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadNetworkVMGroupsListIterator type. +func NewWorkloadNetworkVMGroupsListIterator(page WorkloadNetworkVMGroupsListPage) WorkloadNetworkVMGroupsListIterator { + return WorkloadNetworkVMGroupsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wnvgl WorkloadNetworkVMGroupsList) IsEmpty() bool { + return wnvgl.Value == nil || len(*wnvgl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wnvgl WorkloadNetworkVMGroupsList) hasNextLink() bool { + return wnvgl.NextLink != nil && len(*wnvgl.NextLink) != 0 +} + +// workloadNetworkVMGroupsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wnvgl WorkloadNetworkVMGroupsList) workloadNetworkVMGroupsListPreparer(ctx context.Context) (*http.Request, error) { + if !wnvgl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wnvgl.NextLink))) +} + +// WorkloadNetworkVMGroupsListPage contains a page of WorkloadNetworkVMGroup values. +type WorkloadNetworkVMGroupsListPage struct { + fn func(context.Context, WorkloadNetworkVMGroupsList) (WorkloadNetworkVMGroupsList, error) + wnvgl WorkloadNetworkVMGroupsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkloadNetworkVMGroupsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworkVMGroupsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wnvgl) + if err != nil { + return err + } + page.wnvgl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadNetworkVMGroupsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadNetworkVMGroupsListPage) NotDone() bool { + return !page.wnvgl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadNetworkVMGroupsListPage) Response() WorkloadNetworkVMGroupsList { + return page.wnvgl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadNetworkVMGroupsListPage) Values() []WorkloadNetworkVMGroup { + if page.wnvgl.IsEmpty() { + return nil + } + return *page.wnvgl.Value +} + +// Creates a new instance of the WorkloadNetworkVMGroupsListPage type. +func NewWorkloadNetworkVMGroupsListPage(cur WorkloadNetworkVMGroupsList, getNextPage func(context.Context, WorkloadNetworkVMGroupsList) (WorkloadNetworkVMGroupsList, error)) WorkloadNetworkVMGroupsListPage { + return WorkloadNetworkVMGroupsListPage{ + fn: getNextPage, + wnvgl: cur, + } +} diff --git a/services/avs/mgmt/2021-06-01/avs/operations.go b/services/avs/mgmt/2021-06-01/avs/operations.go new file mode 100644 index 000000000000..4e4c0a19836c --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/operations.go @@ -0,0 +1,140 @@ +package avs + +// 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/tracing" + "net/http" +) + +// OperationsClient is the azure VMware Solution API +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient 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 NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available operations +func (client OperationsClient) List(ctx context.Context) (result OperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.ol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.ol.hasNextLink() && result.ol.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.AVS/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 client.Send(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 OperationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) { + req, err := lastResults.operationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/privateclouds.go b/services/avs/mgmt/2021-06-01/avs/privateclouds.go new file mode 100644 index 000000000000..af91670c8d26 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/privateclouds.go @@ -0,0 +1,897 @@ +package avs + +// 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" +) + +// PrivateCloudsClient is the azure VMware Solution API +type PrivateCloudsClient struct { + BaseClient +} + +// NewPrivateCloudsClient creates an instance of the PrivateCloudsClient client. +func NewPrivateCloudsClient(subscriptionID string) PrivateCloudsClient { + return NewPrivateCloudsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateCloudsClientWithBaseURI creates an instance of the PrivateCloudsClient 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 NewPrivateCloudsClientWithBaseURI(baseURI string, subscriptionID string) PrivateCloudsClient { + return PrivateCloudsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// privateCloud - the private cloud +func (client PrivateCloudsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud PrivateCloud) (result PrivateCloudsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: privateCloud, + Constraints: []validation.Constraint{{Target: "privateCloud.Sku", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "privateCloud.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "privateCloud.PrivateCloudProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateCloud.PrivateCloudProperties.NetworkBlock", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, privateCloud) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateCloudsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud PrivateCloud) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}", pathParameters), + autorest.WithJSON(privateCloud), + 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 PrivateCloudsClient) CreateOrUpdateSender(req *http.Request) (future PrivateCloudsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateCloud, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client PrivateCloudsClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string) (result PrivateCloudsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateCloudsClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", 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 PrivateCloudsClient) DeleteSender(req *http.Request) (future PrivateCloudsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client PrivateCloudsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string) (result PrivateCloud, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateCloudsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", 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 PrivateCloudsClient) 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 PrivateCloudsClient) GetResponder(resp *http.Response) (result PrivateCloud, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client PrivateCloudsClient) List(ctx context.Context, resourceGroupName string) (result PrivateCloudListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.List") + defer func() { + sc := -1 + if result.pcl.Response.Response != nil { + sc = result.pcl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.pcl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "List", resp, "Failure sending request") + return + } + + result.pcl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "List", resp, "Failure responding to request") + return + } + if result.pcl.hasNextLink() && result.pcl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateCloudsClient) ListPreparer(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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds", pathParameters), + 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 PrivateCloudsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) ListResponder(resp *http.Response) (result PrivateCloudList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateCloudsClient) listNextResults(ctx context.Context, lastResults PrivateCloudList) (result PrivateCloudList, err error) { + req, err := lastResults.privateCloudListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateCloudsClient) ListComplete(ctx context.Context, resourceGroupName string) (result PrivateCloudListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName) + return +} + +// ListAdminCredentials sends the list admin credentials request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client PrivateCloudsClient) ListAdminCredentials(ctx context.Context, resourceGroupName string, privateCloudName string) (result AdminCredentials, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.ListAdminCredentials") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "ListAdminCredentials", err.Error()) + } + + req, err := client.ListAdminCredentialsPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListAdminCredentials", nil, "Failure preparing request") + return + } + + resp, err := client.ListAdminCredentialsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListAdminCredentials", resp, "Failure sending request") + return + } + + result, err = client.ListAdminCredentialsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListAdminCredentials", resp, "Failure responding to request") + return + } + + return +} + +// ListAdminCredentialsPreparer prepares the ListAdminCredentials request. +func (client PrivateCloudsClient) ListAdminCredentialsPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/listAdminCredentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListAdminCredentialsSender sends the ListAdminCredentials request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateCloudsClient) ListAdminCredentialsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListAdminCredentialsResponder handles the response to the ListAdminCredentials request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) ListAdminCredentialsResponder(resp *http.Response) (result AdminCredentials, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListInSubscription sends the list in subscription request. +func (client PrivateCloudsClient) ListInSubscription(ctx context.Context) (result PrivateCloudListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.ListInSubscription") + defer func() { + sc := -1 + if result.pcl.Response.Response != nil { + sc = result.pcl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "ListInSubscription", err.Error()) + } + + result.fn = client.listInSubscriptionNextResults + req, err := client.ListInSubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListInSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListInSubscriptionSender(req) + if err != nil { + result.pcl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListInSubscription", resp, "Failure sending request") + return + } + + result.pcl, err = client.ListInSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListInSubscription", resp, "Failure responding to request") + return + } + if result.pcl.hasNextLink() && result.pcl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListInSubscriptionPreparer prepares the ListInSubscription request. +func (client PrivateCloudsClient) ListInSubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AVS/privateClouds", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListInSubscriptionSender sends the ListInSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateCloudsClient) ListInSubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListInSubscriptionResponder handles the response to the ListInSubscription request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) ListInSubscriptionResponder(resp *http.Response) (result PrivateCloudList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listInSubscriptionNextResults retrieves the next set of results, if any. +func (client PrivateCloudsClient) listInSubscriptionNextResults(ctx context.Context, lastResults PrivateCloudList) (result PrivateCloudList, err error) { + req, err := lastResults.privateCloudListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listInSubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListInSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listInSubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListInSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listInSubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListInSubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateCloudsClient) ListInSubscriptionComplete(ctx context.Context) (result PrivateCloudListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.ListInSubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListInSubscription(ctx) + return +} + +// RotateNsxtPassword sends the rotate nsxt password request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client PrivateCloudsClient) RotateNsxtPassword(ctx context.Context, resourceGroupName string, privateCloudName string) (result PrivateCloudsRotateNsxtPasswordFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.RotateNsxtPassword") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "RotateNsxtPassword", err.Error()) + } + + req, err := client.RotateNsxtPasswordPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "RotateNsxtPassword", nil, "Failure preparing request") + return + } + + result, err = client.RotateNsxtPasswordSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "RotateNsxtPassword", nil, "Failure sending request") + return + } + + return +} + +// RotateNsxtPasswordPreparer prepares the RotateNsxtPassword request. +func (client PrivateCloudsClient) RotateNsxtPasswordPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateNsxtPassword", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RotateNsxtPasswordSender sends the RotateNsxtPassword request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateCloudsClient) RotateNsxtPasswordSender(req *http.Request) (future PrivateCloudsRotateNsxtPasswordFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RotateNsxtPasswordResponder handles the response to the RotateNsxtPassword request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) RotateNsxtPasswordResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// RotateVcenterPassword sends the rotate vcenter password request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client PrivateCloudsClient) RotateVcenterPassword(ctx context.Context, resourceGroupName string, privateCloudName string) (result PrivateCloudsRotateVcenterPasswordFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.RotateVcenterPassword") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "RotateVcenterPassword", err.Error()) + } + + req, err := client.RotateVcenterPasswordPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "RotateVcenterPassword", nil, "Failure preparing request") + return + } + + result, err = client.RotateVcenterPasswordSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "RotateVcenterPassword", nil, "Failure sending request") + return + } + + return +} + +// RotateVcenterPasswordPreparer prepares the RotateVcenterPassword request. +func (client PrivateCloudsClient) RotateVcenterPasswordPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateVcenterPassword", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RotateVcenterPasswordSender sends the RotateVcenterPassword request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateCloudsClient) RotateVcenterPasswordSender(req *http.Request) (future PrivateCloudsRotateVcenterPasswordFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RotateVcenterPasswordResponder handles the response to the RotateVcenterPassword request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) RotateVcenterPasswordResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update sends the update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// privateCloudUpdate - the private cloud properties to be updated +func (client PrivateCloudsClient) Update(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate PrivateCloudUpdate) (result PrivateCloudsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, privateCloudName, privateCloudUpdate) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateCloudsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate PrivateCloudUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}", pathParameters), + autorest.WithJSON(privateCloudUpdate), + 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 PrivateCloudsClient) UpdateSender(req *http.Request) (future PrivateCloudsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) UpdateResponder(resp *http.Response) (result PrivateCloud, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/scriptcmdlets.go b/services/avs/mgmt/2021-06-01/avs/scriptcmdlets.go new file mode 100644 index 000000000000..6f911f163b7c --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/scriptcmdlets.go @@ -0,0 +1,253 @@ +package avs + +// 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" +) + +// ScriptCmdletsClient is the azure VMware Solution API +type ScriptCmdletsClient struct { + BaseClient +} + +// NewScriptCmdletsClient creates an instance of the ScriptCmdletsClient client. +func NewScriptCmdletsClient(subscriptionID string) ScriptCmdletsClient { + return NewScriptCmdletsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewScriptCmdletsClientWithBaseURI creates an instance of the ScriptCmdletsClient 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 NewScriptCmdletsClientWithBaseURI(baseURI string, subscriptionID string) ScriptCmdletsClient { + return ScriptCmdletsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get return information about a script cmdlet resource in a specific package on a private cloud +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// scriptPackageName - name of the script package in the private cloud +// scriptCmdletName - name of the script cmdlet resource in the script package in the private cloud +func (client ScriptCmdletsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string, scriptCmdletName string) (result ScriptCmdlet, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptCmdletsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ScriptCmdletsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, scriptPackageName, scriptCmdletName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptCmdletsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ScriptCmdletsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptCmdletsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ScriptCmdletsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string, scriptCmdletName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scriptCmdletName": autorest.Encode("path", scriptCmdletName), + "scriptPackageName": autorest.Encode("path", scriptPackageName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets/{scriptCmdletName}", 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 ScriptCmdletsClient) 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 ScriptCmdletsClient) GetResponder(resp *http.Response) (result ScriptCmdlet, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List return script cmdlet resources available for a private cloud to create a script execution resource on their +// Private Cloud +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// scriptPackageName - name of the script package in the private cloud +func (client ScriptCmdletsClient) List(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string) (result ScriptCmdletsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptCmdletsClient.List") + defer func() { + sc := -1 + if result.scl.Response.Response != nil { + sc = result.scl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ScriptCmdletsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName, scriptPackageName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptCmdletsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.scl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ScriptCmdletsClient", "List", resp, "Failure sending request") + return + } + + result.scl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptCmdletsClient", "List", resp, "Failure responding to request") + return + } + if result.scl.hasNextLink() && result.scl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ScriptCmdletsClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scriptPackageName": autorest.Encode("path", scriptPackageName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets", pathParameters), + 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 ScriptCmdletsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ScriptCmdletsClient) ListResponder(resp *http.Response) (result ScriptCmdletsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ScriptCmdletsClient) listNextResults(ctx context.Context, lastResults ScriptCmdletsList) (result ScriptCmdletsList, err error) { + req, err := lastResults.scriptCmdletsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.ScriptCmdletsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.ScriptCmdletsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptCmdletsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ScriptCmdletsClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string) (result ScriptCmdletsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptCmdletsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, privateCloudName, scriptPackageName) + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/scriptexecutions.go b/services/avs/mgmt/2021-06-01/avs/scriptexecutions.go new file mode 100644 index 000000000000..4a4413dd5915 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/scriptexecutions.go @@ -0,0 +1,529 @@ +package avs + +// 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" +) + +// ScriptExecutionsClient is the azure VMware Solution API +type ScriptExecutionsClient struct { + BaseClient +} + +// NewScriptExecutionsClient creates an instance of the ScriptExecutionsClient client. +func NewScriptExecutionsClient(subscriptionID string) ScriptExecutionsClient { + return NewScriptExecutionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewScriptExecutionsClientWithBaseURI creates an instance of the ScriptExecutionsClient 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 NewScriptExecutionsClientWithBaseURI(baseURI string, subscriptionID string) ScriptExecutionsClient { + return ScriptExecutionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// scriptExecutionName - name of the user-invoked script execution resource +// scriptExecution - a script running in the private cloud +func (client ScriptExecutionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, scriptExecution ScriptExecution) (result ScriptExecutionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptExecutionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: scriptExecution, + Constraints: []validation.Constraint{{Target: "scriptExecution.ScriptExecutionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "scriptExecution.ScriptExecutionProperties.Timeout", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("avs.ScriptExecutionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, scriptExecutionName, scriptExecution) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ScriptExecutionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, scriptExecution ScriptExecution) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scriptExecutionName": autorest.Encode("path", scriptExecutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}", pathParameters), + autorest.WithJSON(scriptExecution), + 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 ScriptExecutionsClient) CreateOrUpdateSender(req *http.Request) (future ScriptExecutionsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ScriptExecutionsClient) CreateOrUpdateResponder(resp *http.Response) (result ScriptExecution, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// scriptExecutionName - name of the user-invoked script execution resource +func (client ScriptExecutionsClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string) (result ScriptExecutionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptExecutionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ScriptExecutionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, scriptExecutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ScriptExecutionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scriptExecutionName": autorest.Encode("path", scriptExecutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}", 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 ScriptExecutionsClient) DeleteSender(req *http.Request) (future ScriptExecutionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ScriptExecutionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// scriptExecutionName - name of the user-invoked script execution resource +func (client ScriptExecutionsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string) (result ScriptExecution, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptExecutionsClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ScriptExecutionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, scriptExecutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ScriptExecutionsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scriptExecutionName": autorest.Encode("path", scriptExecutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}", 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 ScriptExecutionsClient) 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 ScriptExecutionsClient) GetResponder(resp *http.Response) (result ScriptExecution, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetExecutionLogs return the logs for a script execution resource +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// scriptExecutionName - name of the user-invoked script execution resource +// scriptOutputStreamType - name of the desired output stream to return. If not provided, will return all. An +// empty array will return nothing +func (client ScriptExecutionsClient) GetExecutionLogs(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, scriptOutputStreamType []ScriptOutputStreamType) (result ScriptExecution, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptExecutionsClient.GetExecutionLogs") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ScriptExecutionsClient", "GetExecutionLogs", err.Error()) + } + + req, err := client.GetExecutionLogsPreparer(ctx, resourceGroupName, privateCloudName, scriptExecutionName, scriptOutputStreamType) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "GetExecutionLogs", nil, "Failure preparing request") + return + } + + resp, err := client.GetExecutionLogsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "GetExecutionLogs", resp, "Failure sending request") + return + } + + result, err = client.GetExecutionLogsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "GetExecutionLogs", resp, "Failure responding to request") + return + } + + return +} + +// GetExecutionLogsPreparer prepares the GetExecutionLogs request. +func (client ScriptExecutionsClient) GetExecutionLogsPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, scriptOutputStreamType []ScriptOutputStreamType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scriptExecutionName": autorest.Encode("path", scriptExecutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}/getExecutionLogs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if scriptOutputStreamType != nil && len(scriptOutputStreamType) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(scriptOutputStreamType)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetExecutionLogsSender sends the GetExecutionLogs request. The method will close the +// http.Response Body if it receives an error. +func (client ScriptExecutionsClient) GetExecutionLogsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetExecutionLogsResponder handles the response to the GetExecutionLogs request. The method always +// closes the http.Response Body. +func (client ScriptExecutionsClient) GetExecutionLogsResponder(resp *http.Response) (result ScriptExecution, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client ScriptExecutionsClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result ScriptExecutionsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptExecutionsClient.List") + defer func() { + sc := -1 + if result.sel.Response.Response != nil { + sc = result.sel.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ScriptExecutionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sel.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "List", resp, "Failure sending request") + return + } + + result.sel, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "List", resp, "Failure responding to request") + return + } + if result.sel.hasNextLink() && result.sel.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ScriptExecutionsClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions", pathParameters), + 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 ScriptExecutionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ScriptExecutionsClient) ListResponder(resp *http.Response) (result ScriptExecutionsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ScriptExecutionsClient) listNextResults(ctx context.Context, lastResults ScriptExecutionsList) (result ScriptExecutionsList, err error) { + req, err := lastResults.scriptExecutionsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptExecutionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ScriptExecutionsClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result ScriptExecutionsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptExecutionsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, privateCloudName) + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/scriptpackages.go b/services/avs/mgmt/2021-06-01/avs/scriptpackages.go new file mode 100644 index 000000000000..08dec413d408 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/scriptpackages.go @@ -0,0 +1,248 @@ +package avs + +// 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" +) + +// ScriptPackagesClient is the azure VMware Solution API +type ScriptPackagesClient struct { + BaseClient +} + +// NewScriptPackagesClient creates an instance of the ScriptPackagesClient client. +func NewScriptPackagesClient(subscriptionID string) ScriptPackagesClient { + return NewScriptPackagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewScriptPackagesClientWithBaseURI creates an instance of the ScriptPackagesClient 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 NewScriptPackagesClientWithBaseURI(baseURI string, subscriptionID string) ScriptPackagesClient { + return ScriptPackagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get return script package available to run on an Private Cloud +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// scriptPackageName - name of the script package in the private cloud +func (client ScriptPackagesClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string) (result ScriptPackage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptPackagesClient.Get") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ScriptPackagesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, scriptPackageName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptPackagesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ScriptPackagesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptPackagesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ScriptPackagesClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, scriptPackageName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scriptPackageName": autorest.Encode("path", scriptPackageName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}", 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 ScriptPackagesClient) 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 ScriptPackagesClient) GetResponder(resp *http.Response) (result ScriptPackage, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List return script packages available for a private cloud to run on their Private Cloud +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client ScriptPackagesClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result ScriptPackagesListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptPackagesClient.List") + defer func() { + sc := -1 + if result.spl.Response.Response != nil { + sc = result.spl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ScriptPackagesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptPackagesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.spl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ScriptPackagesClient", "List", resp, "Failure sending request") + return + } + + result.spl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptPackagesClient", "List", resp, "Failure responding to request") + return + } + if result.spl.hasNextLink() && result.spl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ScriptPackagesClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages", pathParameters), + 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 ScriptPackagesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ScriptPackagesClient) ListResponder(resp *http.Response) (result ScriptPackagesList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ScriptPackagesClient) listNextResults(ctx context.Context, lastResults ScriptPackagesList) (result ScriptPackagesList, err error) { + req, err := lastResults.scriptPackagesListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.ScriptPackagesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.ScriptPackagesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ScriptPackagesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ScriptPackagesClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result ScriptPackagesListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScriptPackagesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, privateCloudName) + return +} diff --git a/services/avs/mgmt/2021-06-01/avs/version.go b/services/avs/mgmt/2021-06-01/avs/version.go new file mode 100644 index 000000000000..fb334c41a9d6 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/version.go @@ -0,0 +1,19 @@ +package avs + +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() + " avs/2021-06-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/avs/mgmt/2021-06-01/avs/workloadnetworks.go b/services/avs/mgmt/2021-06-01/avs/workloadnetworks.go new file mode 100644 index 000000000000..72ba5dfa55c6 --- /dev/null +++ b/services/avs/mgmt/2021-06-01/avs/workloadnetworks.go @@ -0,0 +1,3809 @@ +package avs + +// 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" +) + +// WorkloadNetworksClient is the azure VMware Solution API +type WorkloadNetworksClient struct { + BaseClient +} + +// NewWorkloadNetworksClient creates an instance of the WorkloadNetworksClient client. +func NewWorkloadNetworksClient(subscriptionID string) WorkloadNetworksClient { + return NewWorkloadNetworksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkloadNetworksClientWithBaseURI creates an instance of the WorkloadNetworksClient 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 NewWorkloadNetworksClientWithBaseURI(baseURI string, subscriptionID string) WorkloadNetworksClient { + return WorkloadNetworksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateDhcp sends the create dhcp request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// dhcpID - NSX DHCP identifier. Generally the same as the DHCP display name +// workloadNetworkDhcp - NSX DHCP +func (client WorkloadNetworksClient) CreateDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp WorkloadNetworkDhcp) (result WorkloadNetworksCreateDhcpFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.CreateDhcp") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "CreateDhcp", err.Error()) + } + + req, err := client.CreateDhcpPreparer(ctx, resourceGroupName, privateCloudName, dhcpID, workloadNetworkDhcp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreateDhcp", nil, "Failure preparing request") + return + } + + result, err = client.CreateDhcpSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreateDhcp", nil, "Failure sending request") + return + } + + return +} + +// CreateDhcpPreparer prepares the CreateDhcp request. +func (client WorkloadNetworksClient) CreateDhcpPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp WorkloadNetworkDhcp) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dhcpId": autorest.Encode("path", dhcpID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}", pathParameters), + autorest.WithJSON(workloadNetworkDhcp), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateDhcpSender sends the CreateDhcp request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) CreateDhcpSender(req *http.Request) (future WorkloadNetworksCreateDhcpFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateDhcpResponder handles the response to the CreateDhcp request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) CreateDhcpResponder(resp *http.Response) (result WorkloadNetworkDhcp, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateDNSService sends the create dns service request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// DNSServiceID - NSX DNS Service identifier. Generally the same as the DNS Service's display name +// workloadNetworkDNSService - NSX DNS Service +func (client WorkloadNetworksClient) CreateDNSService(ctx context.Context, resourceGroupName string, privateCloudName string, DNSServiceID string, workloadNetworkDNSService WorkloadNetworkDNSService) (result WorkloadNetworksCreateDNSServiceFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.CreateDNSService") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "CreateDNSService", err.Error()) + } + + req, err := client.CreateDNSServicePreparer(ctx, resourceGroupName, privateCloudName, DNSServiceID, workloadNetworkDNSService) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreateDNSService", nil, "Failure preparing request") + return + } + + result, err = client.CreateDNSServiceSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreateDNSService", nil, "Failure sending request") + return + } + + return +} + +// CreateDNSServicePreparer prepares the CreateDNSService request. +func (client WorkloadNetworksClient) CreateDNSServicePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, DNSServiceID string, workloadNetworkDNSService WorkloadNetworkDNSService) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsServiceId": autorest.Encode("path", DNSServiceID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}", pathParameters), + autorest.WithJSON(workloadNetworkDNSService), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateDNSServiceSender sends the CreateDNSService request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) CreateDNSServiceSender(req *http.Request) (future WorkloadNetworksCreateDNSServiceFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateDNSServiceResponder handles the response to the CreateDNSService request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) CreateDNSServiceResponder(resp *http.Response) (result WorkloadNetworkDNSService, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateDNSZone sends the create dns zone request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// DNSZoneID - NSX DNS Zone identifier. Generally the same as the DNS Zone's display name +// workloadNetworkDNSZone - NSX DNS Zone +func (client WorkloadNetworksClient) CreateDNSZone(ctx context.Context, resourceGroupName string, privateCloudName string, DNSZoneID string, workloadNetworkDNSZone WorkloadNetworkDNSZone) (result WorkloadNetworksCreateDNSZoneFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.CreateDNSZone") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "CreateDNSZone", err.Error()) + } + + req, err := client.CreateDNSZonePreparer(ctx, resourceGroupName, privateCloudName, DNSZoneID, workloadNetworkDNSZone) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreateDNSZone", nil, "Failure preparing request") + return + } + + result, err = client.CreateDNSZoneSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreateDNSZone", nil, "Failure sending request") + return + } + + return +} + +// CreateDNSZonePreparer prepares the CreateDNSZone request. +func (client WorkloadNetworksClient) CreateDNSZonePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, DNSZoneID string, workloadNetworkDNSZone WorkloadNetworkDNSZone) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsZoneId": autorest.Encode("path", DNSZoneID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}", pathParameters), + autorest.WithJSON(workloadNetworkDNSZone), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateDNSZoneSender sends the CreateDNSZone request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) CreateDNSZoneSender(req *http.Request) (future WorkloadNetworksCreateDNSZoneFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateDNSZoneResponder handles the response to the CreateDNSZone request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) CreateDNSZoneResponder(resp *http.Response) (result WorkloadNetworkDNSZone, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreatePortMirroring sends the create port mirroring request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// portMirroringID - NSX Port Mirroring identifier. Generally the same as the Port Mirroring display name +// workloadNetworkPortMirroring - NSX port mirroring +func (client WorkloadNetworksClient) CreatePortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring WorkloadNetworkPortMirroring) (result WorkloadNetworksCreatePortMirroringFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.CreatePortMirroring") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "CreatePortMirroring", err.Error()) + } + + req, err := client.CreatePortMirroringPreparer(ctx, resourceGroupName, privateCloudName, portMirroringID, workloadNetworkPortMirroring) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreatePortMirroring", nil, "Failure preparing request") + return + } + + result, err = client.CreatePortMirroringSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreatePortMirroring", nil, "Failure sending request") + return + } + + return +} + +// CreatePortMirroringPreparer prepares the CreatePortMirroring request. +func (client WorkloadNetworksClient) CreatePortMirroringPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring WorkloadNetworkPortMirroring) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "portMirroringId": autorest.Encode("path", portMirroringID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}", pathParameters), + autorest.WithJSON(workloadNetworkPortMirroring), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreatePortMirroringSender sends the CreatePortMirroring request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) CreatePortMirroringSender(req *http.Request) (future WorkloadNetworksCreatePortMirroringFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreatePortMirroringResponder handles the response to the CreatePortMirroring request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) CreatePortMirroringResponder(resp *http.Response) (result WorkloadNetworkPortMirroring, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreatePublicIP sends the create public ip request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// publicIPID - NSX Public IP Block identifier. Generally the same as the Public IP Block's display name +// workloadNetworkPublicIP - NSX Public IP Block +func (client WorkloadNetworksClient) CreatePublicIP(ctx context.Context, resourceGroupName string, privateCloudName string, publicIPID string, workloadNetworkPublicIP WorkloadNetworkPublicIP) (result WorkloadNetworksCreatePublicIPFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.CreatePublicIP") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "CreatePublicIP", err.Error()) + } + + req, err := client.CreatePublicIPPreparer(ctx, resourceGroupName, privateCloudName, publicIPID, workloadNetworkPublicIP) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreatePublicIP", nil, "Failure preparing request") + return + } + + result, err = client.CreatePublicIPSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreatePublicIP", nil, "Failure sending request") + return + } + + return +} + +// CreatePublicIPPreparer prepares the CreatePublicIP request. +func (client WorkloadNetworksClient) CreatePublicIPPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, publicIPID string, workloadNetworkPublicIP WorkloadNetworkPublicIP) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "publicIPId": autorest.Encode("path", publicIPID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}", pathParameters), + autorest.WithJSON(workloadNetworkPublicIP), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreatePublicIPSender sends the CreatePublicIP request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) CreatePublicIPSender(req *http.Request) (future WorkloadNetworksCreatePublicIPFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreatePublicIPResponder handles the response to the CreatePublicIP request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) CreatePublicIPResponder(resp *http.Response) (result WorkloadNetworkPublicIP, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateSegments sends the create segments request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// segmentID - NSX Segment identifier. Generally the same as the Segment's display name +// workloadNetworkSegment - NSX Segment +func (client WorkloadNetworksClient) CreateSegments(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, workloadNetworkSegment WorkloadNetworkSegment) (result WorkloadNetworksCreateSegmentsFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.CreateSegments") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "CreateSegments", err.Error()) + } + + req, err := client.CreateSegmentsPreparer(ctx, resourceGroupName, privateCloudName, segmentID, workloadNetworkSegment) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreateSegments", nil, "Failure preparing request") + return + } + + result, err = client.CreateSegmentsSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreateSegments", nil, "Failure sending request") + return + } + + return +} + +// CreateSegmentsPreparer prepares the CreateSegments request. +func (client WorkloadNetworksClient) CreateSegmentsPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, workloadNetworkSegment WorkloadNetworkSegment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "segmentId": autorest.Encode("path", segmentID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}", pathParameters), + autorest.WithJSON(workloadNetworkSegment), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSegmentsSender sends the CreateSegments request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) CreateSegmentsSender(req *http.Request) (future WorkloadNetworksCreateSegmentsFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateSegmentsResponder handles the response to the CreateSegments request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) CreateSegmentsResponder(resp *http.Response) (result WorkloadNetworkSegment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateVMGroup sends the create vm group request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// VMGroupID - NSX VM Group identifier. Generally the same as the VM Group's display name +// workloadNetworkVMGroup - NSX VM Group +func (client WorkloadNetworksClient) CreateVMGroup(ctx context.Context, resourceGroupName string, privateCloudName string, VMGroupID string, workloadNetworkVMGroup WorkloadNetworkVMGroup) (result WorkloadNetworksCreateVMGroupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.CreateVMGroup") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "CreateVMGroup", err.Error()) + } + + req, err := client.CreateVMGroupPreparer(ctx, resourceGroupName, privateCloudName, VMGroupID, workloadNetworkVMGroup) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreateVMGroup", nil, "Failure preparing request") + return + } + + result, err = client.CreateVMGroupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "CreateVMGroup", nil, "Failure sending request") + return + } + + return +} + +// CreateVMGroupPreparer prepares the CreateVMGroup request. +func (client WorkloadNetworksClient) CreateVMGroupPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, VMGroupID string, workloadNetworkVMGroup WorkloadNetworkVMGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmGroupId": autorest.Encode("path", VMGroupID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}", pathParameters), + autorest.WithJSON(workloadNetworkVMGroup), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateVMGroupSender sends the CreateVMGroup request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) CreateVMGroupSender(req *http.Request) (future WorkloadNetworksCreateVMGroupFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateVMGroupResponder handles the response to the CreateVMGroup request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) CreateVMGroupResponder(resp *http.Response) (result WorkloadNetworkVMGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteDhcp sends the delete dhcp request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// dhcpID - NSX DHCP identifier. Generally the same as the DHCP display name +func (client WorkloadNetworksClient) DeleteDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string) (result WorkloadNetworksDeleteDhcpFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.DeleteDhcp") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "DeleteDhcp", err.Error()) + } + + req, err := client.DeleteDhcpPreparer(ctx, resourceGroupName, privateCloudName, dhcpID) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeleteDhcp", nil, "Failure preparing request") + return + } + + result, err = client.DeleteDhcpSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeleteDhcp", nil, "Failure sending request") + return + } + + return +} + +// DeleteDhcpPreparer prepares the DeleteDhcp request. +func (client WorkloadNetworksClient) DeleteDhcpPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dhcpId": autorest.Encode("path", dhcpID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteDhcpSender sends the DeleteDhcp request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) DeleteDhcpSender(req *http.Request) (future WorkloadNetworksDeleteDhcpFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteDhcpResponder handles the response to the DeleteDhcp request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) DeleteDhcpResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteDNSService sends the delete dns service request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// DNSServiceID - NSX DNS Service identifier. Generally the same as the DNS Service's display name +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) DeleteDNSService(ctx context.Context, resourceGroupName string, DNSServiceID string, privateCloudName string) (result WorkloadNetworksDeleteDNSServiceFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.DeleteDNSService") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "DeleteDNSService", err.Error()) + } + + req, err := client.DeleteDNSServicePreparer(ctx, resourceGroupName, DNSServiceID, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeleteDNSService", nil, "Failure preparing request") + return + } + + result, err = client.DeleteDNSServiceSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeleteDNSService", nil, "Failure sending request") + return + } + + return +} + +// DeleteDNSServicePreparer prepares the DeleteDNSService request. +func (client WorkloadNetworksClient) DeleteDNSServicePreparer(ctx context.Context, resourceGroupName string, DNSServiceID string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsServiceId": autorest.Encode("path", DNSServiceID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteDNSServiceSender sends the DeleteDNSService request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) DeleteDNSServiceSender(req *http.Request) (future WorkloadNetworksDeleteDNSServiceFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteDNSServiceResponder handles the response to the DeleteDNSService request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) DeleteDNSServiceResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteDNSZone sends the delete dns zone request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// DNSZoneID - NSX DNS Zone identifier. Generally the same as the DNS Zone's display name +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) DeleteDNSZone(ctx context.Context, resourceGroupName string, DNSZoneID string, privateCloudName string) (result WorkloadNetworksDeleteDNSZoneFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.DeleteDNSZone") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "DeleteDNSZone", err.Error()) + } + + req, err := client.DeleteDNSZonePreparer(ctx, resourceGroupName, DNSZoneID, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeleteDNSZone", nil, "Failure preparing request") + return + } + + result, err = client.DeleteDNSZoneSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeleteDNSZone", nil, "Failure sending request") + return + } + + return +} + +// DeleteDNSZonePreparer prepares the DeleteDNSZone request. +func (client WorkloadNetworksClient) DeleteDNSZonePreparer(ctx context.Context, resourceGroupName string, DNSZoneID string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsZoneId": autorest.Encode("path", DNSZoneID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteDNSZoneSender sends the DeleteDNSZone request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) DeleteDNSZoneSender(req *http.Request) (future WorkloadNetworksDeleteDNSZoneFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteDNSZoneResponder handles the response to the DeleteDNSZone request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) DeleteDNSZoneResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeletePortMirroring sends the delete port mirroring request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// portMirroringID - NSX Port Mirroring identifier. Generally the same as the Port Mirroring display name +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) DeletePortMirroring(ctx context.Context, resourceGroupName string, portMirroringID string, privateCloudName string) (result WorkloadNetworksDeletePortMirroringFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.DeletePortMirroring") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "DeletePortMirroring", err.Error()) + } + + req, err := client.DeletePortMirroringPreparer(ctx, resourceGroupName, portMirroringID, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeletePortMirroring", nil, "Failure preparing request") + return + } + + result, err = client.DeletePortMirroringSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeletePortMirroring", nil, "Failure sending request") + return + } + + return +} + +// DeletePortMirroringPreparer prepares the DeletePortMirroring request. +func (client WorkloadNetworksClient) DeletePortMirroringPreparer(ctx context.Context, resourceGroupName string, portMirroringID string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "portMirroringId": autorest.Encode("path", portMirroringID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeletePortMirroringSender sends the DeletePortMirroring request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) DeletePortMirroringSender(req *http.Request) (future WorkloadNetworksDeletePortMirroringFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeletePortMirroringResponder handles the response to the DeletePortMirroring request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) DeletePortMirroringResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeletePublicIP sends the delete public ip request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// publicIPID - NSX Public IP Block identifier. Generally the same as the Public IP Block's display name +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) DeletePublicIP(ctx context.Context, resourceGroupName string, publicIPID string, privateCloudName string) (result WorkloadNetworksDeletePublicIPFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.DeletePublicIP") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "DeletePublicIP", err.Error()) + } + + req, err := client.DeletePublicIPPreparer(ctx, resourceGroupName, publicIPID, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeletePublicIP", nil, "Failure preparing request") + return + } + + result, err = client.DeletePublicIPSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeletePublicIP", nil, "Failure sending request") + return + } + + return +} + +// DeletePublicIPPreparer prepares the DeletePublicIP request. +func (client WorkloadNetworksClient) DeletePublicIPPreparer(ctx context.Context, resourceGroupName string, publicIPID string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "publicIPId": autorest.Encode("path", publicIPID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeletePublicIPSender sends the DeletePublicIP request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) DeletePublicIPSender(req *http.Request) (future WorkloadNetworksDeletePublicIPFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeletePublicIPResponder handles the response to the DeletePublicIP request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) DeletePublicIPResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSegment sends the delete segment request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// segmentID - NSX Segment identifier. Generally the same as the Segment's display name +func (client WorkloadNetworksClient) DeleteSegment(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string) (result WorkloadNetworksDeleteSegmentFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.DeleteSegment") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "DeleteSegment", err.Error()) + } + + req, err := client.DeleteSegmentPreparer(ctx, resourceGroupName, privateCloudName, segmentID) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeleteSegment", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSegmentSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeleteSegment", nil, "Failure sending request") + return + } + + return +} + +// DeleteSegmentPreparer prepares the DeleteSegment request. +func (client WorkloadNetworksClient) DeleteSegmentPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "segmentId": autorest.Encode("path", segmentID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSegmentSender sends the DeleteSegment request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) DeleteSegmentSender(req *http.Request) (future WorkloadNetworksDeleteSegmentFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteSegmentResponder handles the response to the DeleteSegment request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) DeleteSegmentResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteVMGroup sends the delete vm group request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// VMGroupID - NSX VM Group identifier. Generally the same as the VM Group's display name +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) DeleteVMGroup(ctx context.Context, resourceGroupName string, VMGroupID string, privateCloudName string) (result WorkloadNetworksDeleteVMGroupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.DeleteVMGroup") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "DeleteVMGroup", err.Error()) + } + + req, err := client.DeleteVMGroupPreparer(ctx, resourceGroupName, VMGroupID, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeleteVMGroup", nil, "Failure preparing request") + return + } + + result, err = client.DeleteVMGroupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "DeleteVMGroup", nil, "Failure sending request") + return + } + + return +} + +// DeleteVMGroupPreparer prepares the DeleteVMGroup request. +func (client WorkloadNetworksClient) DeleteVMGroupPreparer(ctx context.Context, resourceGroupName string, VMGroupID string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmGroupId": autorest.Encode("path", VMGroupID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteVMGroupSender sends the DeleteVMGroup request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) DeleteVMGroupSender(req *http.Request) (future WorkloadNetworksDeleteVMGroupFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteVMGroupResponder handles the response to the DeleteVMGroup request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) DeleteVMGroupResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetDhcp sends the get dhcp request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dhcpID - NSX DHCP identifier. Generally the same as the DHCP display name +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) GetDhcp(ctx context.Context, resourceGroupName string, dhcpID string, privateCloudName string) (result WorkloadNetworkDhcp, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.GetDhcp") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "GetDhcp", err.Error()) + } + + req, err := client.GetDhcpPreparer(ctx, resourceGroupName, dhcpID, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetDhcp", nil, "Failure preparing request") + return + } + + resp, err := client.GetDhcpSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetDhcp", resp, "Failure sending request") + return + } + + result, err = client.GetDhcpResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetDhcp", resp, "Failure responding to request") + return + } + + return +} + +// GetDhcpPreparer prepares the GetDhcp request. +func (client WorkloadNetworksClient) GetDhcpPreparer(ctx context.Context, resourceGroupName string, dhcpID string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dhcpId": autorest.Encode("path", dhcpID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetDhcpSender sends the GetDhcp request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) GetDhcpSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetDhcpResponder handles the response to the GetDhcp request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) GetDhcpResponder(resp *http.Response) (result WorkloadNetworkDhcp, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetDNSService sends the get dns service request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// DNSServiceID - NSX DNS Service identifier. Generally the same as the DNS Service's display name +func (client WorkloadNetworksClient) GetDNSService(ctx context.Context, resourceGroupName string, privateCloudName string, DNSServiceID string) (result WorkloadNetworkDNSService, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.GetDNSService") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "GetDNSService", err.Error()) + } + + req, err := client.GetDNSServicePreparer(ctx, resourceGroupName, privateCloudName, DNSServiceID) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetDNSService", nil, "Failure preparing request") + return + } + + resp, err := client.GetDNSServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetDNSService", resp, "Failure sending request") + return + } + + result, err = client.GetDNSServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetDNSService", resp, "Failure responding to request") + return + } + + return +} + +// GetDNSServicePreparer prepares the GetDNSService request. +func (client WorkloadNetworksClient) GetDNSServicePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, DNSServiceID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsServiceId": autorest.Encode("path", DNSServiceID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetDNSServiceSender sends the GetDNSService request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) GetDNSServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetDNSServiceResponder handles the response to the GetDNSService request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) GetDNSServiceResponder(resp *http.Response) (result WorkloadNetworkDNSService, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetDNSZone sends the get dns zone request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// DNSZoneID - NSX DNS Zone identifier. Generally the same as the DNS Zone's display name +func (client WorkloadNetworksClient) GetDNSZone(ctx context.Context, resourceGroupName string, privateCloudName string, DNSZoneID string) (result WorkloadNetworkDNSZone, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.GetDNSZone") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "GetDNSZone", err.Error()) + } + + req, err := client.GetDNSZonePreparer(ctx, resourceGroupName, privateCloudName, DNSZoneID) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetDNSZone", nil, "Failure preparing request") + return + } + + resp, err := client.GetDNSZoneSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetDNSZone", resp, "Failure sending request") + return + } + + result, err = client.GetDNSZoneResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetDNSZone", resp, "Failure responding to request") + return + } + + return +} + +// GetDNSZonePreparer prepares the GetDNSZone request. +func (client WorkloadNetworksClient) GetDNSZonePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, DNSZoneID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsZoneId": autorest.Encode("path", DNSZoneID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetDNSZoneSender sends the GetDNSZone request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) GetDNSZoneSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetDNSZoneResponder handles the response to the GetDNSZone request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) GetDNSZoneResponder(resp *http.Response) (result WorkloadNetworkDNSZone, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetGateway sends the get gateway request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// gatewayID - NSX Gateway identifier. Generally the same as the Gateway's display name +func (client WorkloadNetworksClient) GetGateway(ctx context.Context, resourceGroupName string, privateCloudName string, gatewayID string) (result WorkloadNetworkGateway, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.GetGateway") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "GetGateway", err.Error()) + } + + req, err := client.GetGatewayPreparer(ctx, resourceGroupName, privateCloudName, gatewayID) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetGateway", nil, "Failure preparing request") + return + } + + resp, err := client.GetGatewaySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetGateway", resp, "Failure sending request") + return + } + + result, err = client.GetGatewayResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetGateway", resp, "Failure responding to request") + return + } + + return +} + +// GetGatewayPreparer prepares the GetGateway request. +func (client WorkloadNetworksClient) GetGatewayPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, gatewayID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways/{gatewayId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetGatewaySender sends the GetGateway request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) GetGatewaySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetGatewayResponder handles the response to the GetGateway request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) GetGatewayResponder(resp *http.Response) (result WorkloadNetworkGateway, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetPortMirroring sends the get port mirroring request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// portMirroringID - NSX Port Mirroring identifier. Generally the same as the Port Mirroring display name +func (client WorkloadNetworksClient) GetPortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string) (result WorkloadNetworkPortMirroring, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.GetPortMirroring") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "GetPortMirroring", err.Error()) + } + + req, err := client.GetPortMirroringPreparer(ctx, resourceGroupName, privateCloudName, portMirroringID) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetPortMirroring", nil, "Failure preparing request") + return + } + + resp, err := client.GetPortMirroringSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetPortMirroring", resp, "Failure sending request") + return + } + + result, err = client.GetPortMirroringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetPortMirroring", resp, "Failure responding to request") + return + } + + return +} + +// GetPortMirroringPreparer prepares the GetPortMirroring request. +func (client WorkloadNetworksClient) GetPortMirroringPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "portMirroringId": autorest.Encode("path", portMirroringID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetPortMirroringSender sends the GetPortMirroring request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) GetPortMirroringSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetPortMirroringResponder handles the response to the GetPortMirroring request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) GetPortMirroringResponder(resp *http.Response) (result WorkloadNetworkPortMirroring, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetPublicIP sends the get public ip request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// publicIPID - NSX Public IP Block identifier. Generally the same as the Public IP Block's display name +func (client WorkloadNetworksClient) GetPublicIP(ctx context.Context, resourceGroupName string, privateCloudName string, publicIPID string) (result WorkloadNetworkPublicIP, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.GetPublicIP") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "GetPublicIP", err.Error()) + } + + req, err := client.GetPublicIPPreparer(ctx, resourceGroupName, privateCloudName, publicIPID) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetPublicIP", nil, "Failure preparing request") + return + } + + resp, err := client.GetPublicIPSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetPublicIP", resp, "Failure sending request") + return + } + + result, err = client.GetPublicIPResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetPublicIP", resp, "Failure responding to request") + return + } + + return +} + +// GetPublicIPPreparer prepares the GetPublicIP request. +func (client WorkloadNetworksClient) GetPublicIPPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, publicIPID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "publicIPId": autorest.Encode("path", publicIPID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetPublicIPSender sends the GetPublicIP request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) GetPublicIPSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetPublicIPResponder handles the response to the GetPublicIP request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) GetPublicIPResponder(resp *http.Response) (result WorkloadNetworkPublicIP, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSegment sends the get segment request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// segmentID - NSX Segment identifier. Generally the same as the Segment's display name +func (client WorkloadNetworksClient) GetSegment(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string) (result WorkloadNetworkSegment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.GetSegment") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "GetSegment", err.Error()) + } + + req, err := client.GetSegmentPreparer(ctx, resourceGroupName, privateCloudName, segmentID) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetSegment", nil, "Failure preparing request") + return + } + + resp, err := client.GetSegmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetSegment", resp, "Failure sending request") + return + } + + result, err = client.GetSegmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetSegment", resp, "Failure responding to request") + return + } + + return +} + +// GetSegmentPreparer prepares the GetSegment request. +func (client WorkloadNetworksClient) GetSegmentPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "segmentId": autorest.Encode("path", segmentID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSegmentSender sends the GetSegment request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) GetSegmentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSegmentResponder handles the response to the GetSegment request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) GetSegmentResponder(resp *http.Response) (result WorkloadNetworkSegment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetVirtualMachine sends the get virtual machine request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// virtualMachineID - virtual Machine identifier +func (client WorkloadNetworksClient) GetVirtualMachine(ctx context.Context, resourceGroupName string, privateCloudName string, virtualMachineID string) (result WorkloadNetworkVirtualMachine, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.GetVirtualMachine") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "GetVirtualMachine", err.Error()) + } + + req, err := client.GetVirtualMachinePreparer(ctx, resourceGroupName, privateCloudName, virtualMachineID) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetVirtualMachine", nil, "Failure preparing request") + return + } + + resp, err := client.GetVirtualMachineSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetVirtualMachine", resp, "Failure sending request") + return + } + + result, err = client.GetVirtualMachineResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetVirtualMachine", resp, "Failure responding to request") + return + } + + return +} + +// GetVirtualMachinePreparer prepares the GetVirtualMachine request. +func (client WorkloadNetworksClient) GetVirtualMachinePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, virtualMachineID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualMachineId": autorest.Encode("path", virtualMachineID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines/{virtualMachineId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetVirtualMachineSender sends the GetVirtualMachine request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) GetVirtualMachineSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetVirtualMachineResponder handles the response to the GetVirtualMachine request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) GetVirtualMachineResponder(resp *http.Response) (result WorkloadNetworkVirtualMachine, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetVMGroup sends the get vm group request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// VMGroupID - NSX VM Group identifier. Generally the same as the VM Group's display name +func (client WorkloadNetworksClient) GetVMGroup(ctx context.Context, resourceGroupName string, privateCloudName string, VMGroupID string) (result WorkloadNetworkVMGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.GetVMGroup") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "GetVMGroup", err.Error()) + } + + req, err := client.GetVMGroupPreparer(ctx, resourceGroupName, privateCloudName, VMGroupID) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetVMGroup", nil, "Failure preparing request") + return + } + + resp, err := client.GetVMGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetVMGroup", resp, "Failure sending request") + return + } + + result, err = client.GetVMGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "GetVMGroup", resp, "Failure responding to request") + return + } + + return +} + +// GetVMGroupPreparer prepares the GetVMGroup request. +func (client WorkloadNetworksClient) GetVMGroupPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, VMGroupID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmGroupId": autorest.Encode("path", VMGroupID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetVMGroupSender sends the GetVMGroup request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) GetVMGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetVMGroupResponder handles the response to the GetVMGroup request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) GetVMGroupResponder(resp *http.Response) (result WorkloadNetworkVMGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListDhcp sends the list dhcp request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) ListDhcp(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkDhcpListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListDhcp") + defer func() { + sc := -1 + if result.wndl.Response.Response != nil { + sc = result.wndl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "ListDhcp", err.Error()) + } + + result.fn = client.listDhcpNextResults + req, err := client.ListDhcpPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListDhcp", nil, "Failure preparing request") + return + } + + resp, err := client.ListDhcpSender(req) + if err != nil { + result.wndl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListDhcp", resp, "Failure sending request") + return + } + + result.wndl, err = client.ListDhcpResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListDhcp", resp, "Failure responding to request") + return + } + if result.wndl.hasNextLink() && result.wndl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListDhcpPreparer prepares the ListDhcp request. +func (client WorkloadNetworksClient) ListDhcpPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListDhcpSender sends the ListDhcp request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) ListDhcpSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListDhcpResponder handles the response to the ListDhcp request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) ListDhcpResponder(resp *http.Response) (result WorkloadNetworkDhcpList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listDhcpNextResults retrieves the next set of results, if any. +func (client WorkloadNetworksClient) listDhcpNextResults(ctx context.Context, lastResults WorkloadNetworkDhcpList) (result WorkloadNetworkDhcpList, err error) { + req, err := lastResults.workloadNetworkDhcpListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listDhcpNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListDhcpSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listDhcpNextResults", resp, "Failure sending next results request") + } + result, err = client.ListDhcpResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listDhcpNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListDhcpComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadNetworksClient) ListDhcpComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkDhcpListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListDhcp") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListDhcp(ctx, resourceGroupName, privateCloudName) + return +} + +// ListDNSServices sends the list dns services request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) ListDNSServices(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkDNSServicesListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListDNSServices") + defer func() { + sc := -1 + if result.wndsl.Response.Response != nil { + sc = result.wndsl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "ListDNSServices", err.Error()) + } + + result.fn = client.listDNSServicesNextResults + req, err := client.ListDNSServicesPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListDNSServices", nil, "Failure preparing request") + return + } + + resp, err := client.ListDNSServicesSender(req) + if err != nil { + result.wndsl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListDNSServices", resp, "Failure sending request") + return + } + + result.wndsl, err = client.ListDNSServicesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListDNSServices", resp, "Failure responding to request") + return + } + if result.wndsl.hasNextLink() && result.wndsl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListDNSServicesPreparer prepares the ListDNSServices request. +func (client WorkloadNetworksClient) ListDNSServicesPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListDNSServicesSender sends the ListDNSServices request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) ListDNSServicesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListDNSServicesResponder handles the response to the ListDNSServices request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) ListDNSServicesResponder(resp *http.Response) (result WorkloadNetworkDNSServicesList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listDNSServicesNextResults retrieves the next set of results, if any. +func (client WorkloadNetworksClient) listDNSServicesNextResults(ctx context.Context, lastResults WorkloadNetworkDNSServicesList) (result WorkloadNetworkDNSServicesList, err error) { + req, err := lastResults.workloadNetworkDNSServicesListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listDNSServicesNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListDNSServicesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listDNSServicesNextResults", resp, "Failure sending next results request") + } + result, err = client.ListDNSServicesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listDNSServicesNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListDNSServicesComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadNetworksClient) ListDNSServicesComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkDNSServicesListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListDNSServices") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListDNSServices(ctx, resourceGroupName, privateCloudName) + return +} + +// ListDNSZones sends the list dns zones request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) ListDNSZones(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkDNSZonesListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListDNSZones") + defer func() { + sc := -1 + if result.wndzl.Response.Response != nil { + sc = result.wndzl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "ListDNSZones", err.Error()) + } + + result.fn = client.listDNSZonesNextResults + req, err := client.ListDNSZonesPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListDNSZones", nil, "Failure preparing request") + return + } + + resp, err := client.ListDNSZonesSender(req) + if err != nil { + result.wndzl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListDNSZones", resp, "Failure sending request") + return + } + + result.wndzl, err = client.ListDNSZonesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListDNSZones", resp, "Failure responding to request") + return + } + if result.wndzl.hasNextLink() && result.wndzl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListDNSZonesPreparer prepares the ListDNSZones request. +func (client WorkloadNetworksClient) ListDNSZonesPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListDNSZonesSender sends the ListDNSZones request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) ListDNSZonesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListDNSZonesResponder handles the response to the ListDNSZones request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) ListDNSZonesResponder(resp *http.Response) (result WorkloadNetworkDNSZonesList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listDNSZonesNextResults retrieves the next set of results, if any. +func (client WorkloadNetworksClient) listDNSZonesNextResults(ctx context.Context, lastResults WorkloadNetworkDNSZonesList) (result WorkloadNetworkDNSZonesList, err error) { + req, err := lastResults.workloadNetworkDNSZonesListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listDNSZonesNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListDNSZonesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listDNSZonesNextResults", resp, "Failure sending next results request") + } + result, err = client.ListDNSZonesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listDNSZonesNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListDNSZonesComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadNetworksClient) ListDNSZonesComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkDNSZonesListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListDNSZones") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListDNSZones(ctx, resourceGroupName, privateCloudName) + return +} + +// ListGateways sends the list gateways request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) ListGateways(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkGatewayListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListGateways") + defer func() { + sc := -1 + if result.wngl.Response.Response != nil { + sc = result.wngl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "ListGateways", err.Error()) + } + + result.fn = client.listGatewaysNextResults + req, err := client.ListGatewaysPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListGateways", nil, "Failure preparing request") + return + } + + resp, err := client.ListGatewaysSender(req) + if err != nil { + result.wngl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListGateways", resp, "Failure sending request") + return + } + + result.wngl, err = client.ListGatewaysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListGateways", resp, "Failure responding to request") + return + } + if result.wngl.hasNextLink() && result.wngl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListGatewaysPreparer prepares the ListGateways request. +func (client WorkloadNetworksClient) ListGatewaysPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListGatewaysSender sends the ListGateways request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) ListGatewaysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListGatewaysResponder handles the response to the ListGateways request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) ListGatewaysResponder(resp *http.Response) (result WorkloadNetworkGatewayList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listGatewaysNextResults retrieves the next set of results, if any. +func (client WorkloadNetworksClient) listGatewaysNextResults(ctx context.Context, lastResults WorkloadNetworkGatewayList) (result WorkloadNetworkGatewayList, err error) { + req, err := lastResults.workloadNetworkGatewayListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listGatewaysNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListGatewaysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listGatewaysNextResults", resp, "Failure sending next results request") + } + result, err = client.ListGatewaysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listGatewaysNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListGatewaysComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadNetworksClient) ListGatewaysComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkGatewayListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListGateways") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListGateways(ctx, resourceGroupName, privateCloudName) + return +} + +// ListPortMirroring sends the list port mirroring request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) ListPortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkPortMirroringListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListPortMirroring") + defer func() { + sc := -1 + if result.wnpml.Response.Response != nil { + sc = result.wnpml.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "ListPortMirroring", err.Error()) + } + + result.fn = client.listPortMirroringNextResults + req, err := client.ListPortMirroringPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListPortMirroring", nil, "Failure preparing request") + return + } + + resp, err := client.ListPortMirroringSender(req) + if err != nil { + result.wnpml.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListPortMirroring", resp, "Failure sending request") + return + } + + result.wnpml, err = client.ListPortMirroringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListPortMirroring", resp, "Failure responding to request") + return + } + if result.wnpml.hasNextLink() && result.wnpml.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPortMirroringPreparer prepares the ListPortMirroring request. +func (client WorkloadNetworksClient) ListPortMirroringPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListPortMirroringSender sends the ListPortMirroring request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) ListPortMirroringSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListPortMirroringResponder handles the response to the ListPortMirroring request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) ListPortMirroringResponder(resp *http.Response) (result WorkloadNetworkPortMirroringList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listPortMirroringNextResults retrieves the next set of results, if any. +func (client WorkloadNetworksClient) listPortMirroringNextResults(ctx context.Context, lastResults WorkloadNetworkPortMirroringList) (result WorkloadNetworkPortMirroringList, err error) { + req, err := lastResults.workloadNetworkPortMirroringListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listPortMirroringNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListPortMirroringSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listPortMirroringNextResults", resp, "Failure sending next results request") + } + result, err = client.ListPortMirroringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listPortMirroringNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListPortMirroringComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadNetworksClient) ListPortMirroringComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkPortMirroringListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListPortMirroring") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListPortMirroring(ctx, resourceGroupName, privateCloudName) + return +} + +// ListPublicIPs sends the list public i ps request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) ListPublicIPs(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkPublicIPsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListPublicIPs") + defer func() { + sc := -1 + if result.wnpipl.Response.Response != nil { + sc = result.wnpipl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "ListPublicIPs", err.Error()) + } + + result.fn = client.listPublicIPsNextResults + req, err := client.ListPublicIPsPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListPublicIPs", nil, "Failure preparing request") + return + } + + resp, err := client.ListPublicIPsSender(req) + if err != nil { + result.wnpipl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListPublicIPs", resp, "Failure sending request") + return + } + + result.wnpipl, err = client.ListPublicIPsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListPublicIPs", resp, "Failure responding to request") + return + } + if result.wnpipl.hasNextLink() && result.wnpipl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPublicIPsPreparer prepares the ListPublicIPs request. +func (client WorkloadNetworksClient) ListPublicIPsPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListPublicIPsSender sends the ListPublicIPs request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) ListPublicIPsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListPublicIPsResponder handles the response to the ListPublicIPs request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) ListPublicIPsResponder(resp *http.Response) (result WorkloadNetworkPublicIPsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listPublicIPsNextResults retrieves the next set of results, if any. +func (client WorkloadNetworksClient) listPublicIPsNextResults(ctx context.Context, lastResults WorkloadNetworkPublicIPsList) (result WorkloadNetworkPublicIPsList, err error) { + req, err := lastResults.workloadNetworkPublicIPsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listPublicIPsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListPublicIPsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listPublicIPsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListPublicIPsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listPublicIPsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListPublicIPsComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadNetworksClient) ListPublicIPsComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkPublicIPsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListPublicIPs") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListPublicIPs(ctx, resourceGroupName, privateCloudName) + return +} + +// ListSegments sends the list segments request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) ListSegments(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkSegmentsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListSegments") + defer func() { + sc := -1 + if result.wnsl.Response.Response != nil { + sc = result.wnsl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "ListSegments", err.Error()) + } + + result.fn = client.listSegmentsNextResults + req, err := client.ListSegmentsPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListSegments", nil, "Failure preparing request") + return + } + + resp, err := client.ListSegmentsSender(req) + if err != nil { + result.wnsl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListSegments", resp, "Failure sending request") + return + } + + result.wnsl, err = client.ListSegmentsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListSegments", resp, "Failure responding to request") + return + } + if result.wnsl.hasNextLink() && result.wnsl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListSegmentsPreparer prepares the ListSegments request. +func (client WorkloadNetworksClient) ListSegmentsPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSegmentsSender sends the ListSegments request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) ListSegmentsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSegmentsResponder handles the response to the ListSegments request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) ListSegmentsResponder(resp *http.Response) (result WorkloadNetworkSegmentsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listSegmentsNextResults retrieves the next set of results, if any. +func (client WorkloadNetworksClient) listSegmentsNextResults(ctx context.Context, lastResults WorkloadNetworkSegmentsList) (result WorkloadNetworkSegmentsList, err error) { + req, err := lastResults.workloadNetworkSegmentsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listSegmentsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSegmentsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listSegmentsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListSegmentsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listSegmentsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListSegmentsComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadNetworksClient) ListSegmentsComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkSegmentsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListSegments") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListSegments(ctx, resourceGroupName, privateCloudName) + return +} + +// ListVirtualMachines sends the list virtual machines request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) ListVirtualMachines(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkVirtualMachinesListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListVirtualMachines") + defer func() { + sc := -1 + if result.wnvml.Response.Response != nil { + sc = result.wnvml.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "ListVirtualMachines", err.Error()) + } + + result.fn = client.listVirtualMachinesNextResults + req, err := client.ListVirtualMachinesPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListVirtualMachines", nil, "Failure preparing request") + return + } + + resp, err := client.ListVirtualMachinesSender(req) + if err != nil { + result.wnvml.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListVirtualMachines", resp, "Failure sending request") + return + } + + result.wnvml, err = client.ListVirtualMachinesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListVirtualMachines", resp, "Failure responding to request") + return + } + if result.wnvml.hasNextLink() && result.wnvml.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListVirtualMachinesPreparer prepares the ListVirtualMachines request. +func (client WorkloadNetworksClient) ListVirtualMachinesPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListVirtualMachinesSender sends the ListVirtualMachines request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) ListVirtualMachinesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListVirtualMachinesResponder handles the response to the ListVirtualMachines request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) ListVirtualMachinesResponder(resp *http.Response) (result WorkloadNetworkVirtualMachinesList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listVirtualMachinesNextResults retrieves the next set of results, if any. +func (client WorkloadNetworksClient) listVirtualMachinesNextResults(ctx context.Context, lastResults WorkloadNetworkVirtualMachinesList) (result WorkloadNetworkVirtualMachinesList, err error) { + req, err := lastResults.workloadNetworkVirtualMachinesListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listVirtualMachinesNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListVirtualMachinesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listVirtualMachinesNextResults", resp, "Failure sending next results request") + } + result, err = client.ListVirtualMachinesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listVirtualMachinesNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListVirtualMachinesComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadNetworksClient) ListVirtualMachinesComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkVirtualMachinesListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListVirtualMachines") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListVirtualMachines(ctx, resourceGroupName, privateCloudName) + return +} + +// ListVMGroups sends the list vm groups request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client WorkloadNetworksClient) ListVMGroups(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkVMGroupsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListVMGroups") + defer func() { + sc := -1 + if result.wnvgl.Response.Response != nil { + sc = result.wnvgl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "ListVMGroups", err.Error()) + } + + result.fn = client.listVMGroupsNextResults + req, err := client.ListVMGroupsPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListVMGroups", nil, "Failure preparing request") + return + } + + resp, err := client.ListVMGroupsSender(req) + if err != nil { + result.wnvgl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListVMGroups", resp, "Failure sending request") + return + } + + result.wnvgl, err = client.ListVMGroupsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "ListVMGroups", resp, "Failure responding to request") + return + } + if result.wnvgl.hasNextLink() && result.wnvgl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListVMGroupsPreparer prepares the ListVMGroups request. +func (client WorkloadNetworksClient) ListVMGroupsPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListVMGroupsSender sends the ListVMGroups request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) ListVMGroupsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListVMGroupsResponder handles the response to the ListVMGroups request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) ListVMGroupsResponder(resp *http.Response) (result WorkloadNetworkVMGroupsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listVMGroupsNextResults retrieves the next set of results, if any. +func (client WorkloadNetworksClient) listVMGroupsNextResults(ctx context.Context, lastResults WorkloadNetworkVMGroupsList) (result WorkloadNetworkVMGroupsList, err error) { + req, err := lastResults.workloadNetworkVMGroupsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listVMGroupsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListVMGroupsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listVMGroupsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListVMGroupsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "listVMGroupsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListVMGroupsComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadNetworksClient) ListVMGroupsComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkVMGroupsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.ListVMGroups") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListVMGroups(ctx, resourceGroupName, privateCloudName) + return +} + +// UpdateDhcp sends the update dhcp request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// dhcpID - NSX DHCP identifier. Generally the same as the DHCP display name +// workloadNetworkDhcp - NSX DHCP +func (client WorkloadNetworksClient) UpdateDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp WorkloadNetworkDhcp) (result WorkloadNetworksUpdateDhcpFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.UpdateDhcp") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "UpdateDhcp", err.Error()) + } + + req, err := client.UpdateDhcpPreparer(ctx, resourceGroupName, privateCloudName, dhcpID, workloadNetworkDhcp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "UpdateDhcp", nil, "Failure preparing request") + return + } + + result, err = client.UpdateDhcpSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "UpdateDhcp", nil, "Failure sending request") + return + } + + return +} + +// UpdateDhcpPreparer prepares the UpdateDhcp request. +func (client WorkloadNetworksClient) UpdateDhcpPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp WorkloadNetworkDhcp) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dhcpId": autorest.Encode("path", dhcpID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}", pathParameters), + autorest.WithJSON(workloadNetworkDhcp), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateDhcpSender sends the UpdateDhcp request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) UpdateDhcpSender(req *http.Request) (future WorkloadNetworksUpdateDhcpFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateDhcpResponder handles the response to the UpdateDhcp request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) UpdateDhcpResponder(resp *http.Response) (result WorkloadNetworkDhcp, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateDNSService sends the update dns service request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// DNSServiceID - NSX DNS Service identifier. Generally the same as the DNS Service's display name +// workloadNetworkDNSService - NSX DNS Service +func (client WorkloadNetworksClient) UpdateDNSService(ctx context.Context, resourceGroupName string, privateCloudName string, DNSServiceID string, workloadNetworkDNSService WorkloadNetworkDNSService) (result WorkloadNetworksUpdateDNSServiceFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.UpdateDNSService") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "UpdateDNSService", err.Error()) + } + + req, err := client.UpdateDNSServicePreparer(ctx, resourceGroupName, privateCloudName, DNSServiceID, workloadNetworkDNSService) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "UpdateDNSService", nil, "Failure preparing request") + return + } + + result, err = client.UpdateDNSServiceSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "UpdateDNSService", nil, "Failure sending request") + return + } + + return +} + +// UpdateDNSServicePreparer prepares the UpdateDNSService request. +func (client WorkloadNetworksClient) UpdateDNSServicePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, DNSServiceID string, workloadNetworkDNSService WorkloadNetworkDNSService) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsServiceId": autorest.Encode("path", DNSServiceID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}", pathParameters), + autorest.WithJSON(workloadNetworkDNSService), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateDNSServiceSender sends the UpdateDNSService request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) UpdateDNSServiceSender(req *http.Request) (future WorkloadNetworksUpdateDNSServiceFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateDNSServiceResponder handles the response to the UpdateDNSService request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) UpdateDNSServiceResponder(resp *http.Response) (result WorkloadNetworkDNSService, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateDNSZone sends the update dns zone request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// DNSZoneID - NSX DNS Zone identifier. Generally the same as the DNS Zone's display name +// workloadNetworkDNSZone - NSX DNS Zone +func (client WorkloadNetworksClient) UpdateDNSZone(ctx context.Context, resourceGroupName string, privateCloudName string, DNSZoneID string, workloadNetworkDNSZone WorkloadNetworkDNSZone) (result WorkloadNetworksUpdateDNSZoneFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.UpdateDNSZone") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "UpdateDNSZone", err.Error()) + } + + req, err := client.UpdateDNSZonePreparer(ctx, resourceGroupName, privateCloudName, DNSZoneID, workloadNetworkDNSZone) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "UpdateDNSZone", nil, "Failure preparing request") + return + } + + result, err = client.UpdateDNSZoneSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "UpdateDNSZone", nil, "Failure sending request") + return + } + + return +} + +// UpdateDNSZonePreparer prepares the UpdateDNSZone request. +func (client WorkloadNetworksClient) UpdateDNSZonePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, DNSZoneID string, workloadNetworkDNSZone WorkloadNetworkDNSZone) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsZoneId": autorest.Encode("path", DNSZoneID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}", pathParameters), + autorest.WithJSON(workloadNetworkDNSZone), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateDNSZoneSender sends the UpdateDNSZone request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) UpdateDNSZoneSender(req *http.Request) (future WorkloadNetworksUpdateDNSZoneFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateDNSZoneResponder handles the response to the UpdateDNSZone request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) UpdateDNSZoneResponder(resp *http.Response) (result WorkloadNetworkDNSZone, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdatePortMirroring sends the update port mirroring request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// portMirroringID - NSX Port Mirroring identifier. Generally the same as the Port Mirroring display name +// workloadNetworkPortMirroring - NSX port mirroring +func (client WorkloadNetworksClient) UpdatePortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring WorkloadNetworkPortMirroring) (result WorkloadNetworksUpdatePortMirroringFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.UpdatePortMirroring") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "UpdatePortMirroring", err.Error()) + } + + req, err := client.UpdatePortMirroringPreparer(ctx, resourceGroupName, privateCloudName, portMirroringID, workloadNetworkPortMirroring) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "UpdatePortMirroring", nil, "Failure preparing request") + return + } + + result, err = client.UpdatePortMirroringSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "UpdatePortMirroring", nil, "Failure sending request") + return + } + + return +} + +// UpdatePortMirroringPreparer prepares the UpdatePortMirroring request. +func (client WorkloadNetworksClient) UpdatePortMirroringPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring WorkloadNetworkPortMirroring) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "portMirroringId": autorest.Encode("path", portMirroringID), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}", pathParameters), + autorest.WithJSON(workloadNetworkPortMirroring), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdatePortMirroringSender sends the UpdatePortMirroring request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) UpdatePortMirroringSender(req *http.Request) (future WorkloadNetworksUpdatePortMirroringFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdatePortMirroringResponder handles the response to the UpdatePortMirroring request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) UpdatePortMirroringResponder(resp *http.Response) (result WorkloadNetworkPortMirroring, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateSegments sends the update segments request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// segmentID - NSX Segment identifier. Generally the same as the Segment's display name +// workloadNetworkSegment - NSX Segment +func (client WorkloadNetworksClient) UpdateSegments(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, workloadNetworkSegment WorkloadNetworkSegment) (result WorkloadNetworksUpdateSegmentsFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.UpdateSegments") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "UpdateSegments", err.Error()) + } + + req, err := client.UpdateSegmentsPreparer(ctx, resourceGroupName, privateCloudName, segmentID, workloadNetworkSegment) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "UpdateSegments", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSegmentsSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "UpdateSegments", nil, "Failure sending request") + return + } + + return +} + +// UpdateSegmentsPreparer prepares the UpdateSegments request. +func (client WorkloadNetworksClient) UpdateSegmentsPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, segmentID string, workloadNetworkSegment WorkloadNetworkSegment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "segmentId": autorest.Encode("path", segmentID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}", pathParameters), + autorest.WithJSON(workloadNetworkSegment), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSegmentsSender sends the UpdateSegments request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) UpdateSegmentsSender(req *http.Request) (future WorkloadNetworksUpdateSegmentsFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateSegmentsResponder handles the response to the UpdateSegments request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) UpdateSegmentsResponder(resp *http.Response) (result WorkloadNetworkSegment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateVMGroup sends the update vm group request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// VMGroupID - NSX VM Group identifier. Generally the same as the VM Group's display name +// workloadNetworkVMGroup - NSX VM Group +func (client WorkloadNetworksClient) UpdateVMGroup(ctx context.Context, resourceGroupName string, privateCloudName string, VMGroupID string, workloadNetworkVMGroup WorkloadNetworkVMGroup) (result WorkloadNetworksUpdateVMGroupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadNetworksClient.UpdateVMGroup") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.WorkloadNetworksClient", "UpdateVMGroup", err.Error()) + } + + req, err := client.UpdateVMGroupPreparer(ctx, resourceGroupName, privateCloudName, VMGroupID, workloadNetworkVMGroup) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "UpdateVMGroup", nil, "Failure preparing request") + return + } + + result, err = client.UpdateVMGroupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.WorkloadNetworksClient", "UpdateVMGroup", nil, "Failure sending request") + return + } + + return +} + +// UpdateVMGroupPreparer prepares the UpdateVMGroup request. +func (client WorkloadNetworksClient) UpdateVMGroupPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, VMGroupID string, workloadNetworkVMGroup WorkloadNetworkVMGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmGroupId": autorest.Encode("path", VMGroupID), + } + + const APIVersion = "2021-06-01" + 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}", pathParameters), + autorest.WithJSON(workloadNetworkVMGroup), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateVMGroupSender sends the UpdateVMGroup request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadNetworksClient) UpdateVMGroupSender(req *http.Request) (future WorkloadNetworksUpdateVMGroupFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateVMGroupResponder handles the response to the UpdateVMGroup request. The method always +// closes the http.Response Body. +func (client WorkloadNetworksClient) UpdateVMGroupResponder(resp *http.Response) (result WorkloadNetworkVMGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}