diff --git a/services/preview/avs/mgmt/2020-07-17-preview/avs/authorizations.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/authorizations.go new file mode 100644 index 000000000000..710aaa38d7aa --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/authorizations.go @@ -0,0 +1,433 @@ +package avs + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/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.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.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", result.Response(), "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 = "2020-07-17-preview" + 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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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") + } + if result.eral.hasNextLink() && result.eral.IsEmpty() { + err = result.NextWithContext(ctx) + } + + 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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/preview/avs/mgmt/2020-07-17-preview/avs/avsapi/interfaces.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/avsapi/interfaces.go new file mode 100644 index 000000000000..c22b58411ce6 --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/avsapi/interfaces.go @@ -0,0 +1,136 @@ +package avsapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/avs/mgmt/2020-07-17-preview/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) + 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) + +// 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) + CreatePortMirroring(ctx context.Context, resourceGroupName string, privateCloudName string, portMirroringID string, workloadNetworkPortMirroring avs.WorkloadNetworkPortMirroring) (result avs.WorkloadNetworksCreatePortMirroringFuture, 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) + DeletePortMirroring(ctx context.Context, resourceGroupName string, portMirroringID string, privateCloudName string) (result avs.WorkloadNetworksDeletePortMirroringFuture, 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) + 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) + 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) + 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) + 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) + 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) diff --git a/services/preview/avs/mgmt/2020-07-17-preview/avs/client.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/client.go new file mode 100644 index 000000000000..049a8d0c8f19 --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/client.go @@ -0,0 +1,52 @@ +// Package avs implements the Azure ARM Avs service API version 2020-07-17-preview. +// +// Azure VMware Solution API +package avs + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service 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/preview/avs/mgmt/2020-07-17-preview/avs/clusters.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/clusters.go new file mode 100644 index 000000000000..e09e787ab8ca --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/clusters.go @@ -0,0 +1,525 @@ +package avs + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/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.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}}}, + {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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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") + } + if result.cl.hasNextLink() && result.cl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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/preview/avs/mgmt/2020-07-17-preview/avs/enums.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/enums.go new file mode 100644 index 000000000000..c1d8fcf1a9e1 --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/enums.go @@ -0,0 +1,392 @@ +package avs + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// ClusterProvisioningState enumerates the values for cluster provisioning state. +type ClusterProvisioningState string + +const ( + // Cancelled ... + Cancelled ClusterProvisioningState = "Cancelled" + // Deleting ... + Deleting ClusterProvisioningState = "Deleting" + // Failed ... + Failed ClusterProvisioningState = "Failed" + // Succeeded ... + Succeeded ClusterProvisioningState = "Succeeded" + // Updating ... + Updating ClusterProvisioningState = "Updating" +) + +// PossibleClusterProvisioningStateValues returns an array of possible values for the ClusterProvisioningState const type. +func PossibleClusterProvisioningStateValues() []ClusterProvisioningState { + return []ClusterProvisioningState{Cancelled, Deleting, Failed, Succeeded, Updating} +} + +// 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} +} + +// 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} +} + +// NsxtAdminRotateEnum enumerates the values for nsxt admin rotate enum. +type NsxtAdminRotateEnum string + +const ( + // OnetimeRotate ... + OnetimeRotate NsxtAdminRotateEnum = "OnetimeRotate" +) + +// PossibleNsxtAdminRotateEnumValues returns an array of possible values for the NsxtAdminRotateEnum const type. +func PossibleNsxtAdminRotateEnumValues() []NsxtAdminRotateEnum { + return []NsxtAdminRotateEnum{OnetimeRotate} +} + +// 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} +} + +// 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} +} + +// VcsaAdminRotateEnum enumerates the values for vcsa admin rotate enum. +type VcsaAdminRotateEnum string + +const ( + // VcsaAdminRotateEnumOnetimeRotate ... + VcsaAdminRotateEnumOnetimeRotate VcsaAdminRotateEnum = "OnetimeRotate" +) + +// PossibleVcsaAdminRotateEnumValues returns an array of possible values for the VcsaAdminRotateEnum const type. +func PossibleVcsaAdminRotateEnumValues() []VcsaAdminRotateEnum { + return []VcsaAdminRotateEnum{VcsaAdminRotateEnumOnetimeRotate} +} + +// 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} +} + +// 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} +} + +// 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/preview/avs/mgmt/2020-07-17-preview/avs/globalreachconnections.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/globalreachconnections.go new file mode 100644 index 000000000000..2e00db570fe8 --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/globalreachconnections.go @@ -0,0 +1,433 @@ +package avs + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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") + } + if result.grcl.hasNextLink() && result.grcl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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/preview/avs/mgmt/2020-07-17-preview/avs/hcxenterprisesites.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/hcxenterprisesites.go new file mode 100644 index 000000000000..132f732371df --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/hcxenterprisesites.go @@ -0,0 +1,434 @@ +package avs + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/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 +} + +// 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 = "2020-07-17-preview" + 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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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") + } + if result.hesl.hasNextLink() && result.hesl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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/preview/avs/mgmt/2020-07-17-preview/avs/locations.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/locations.go new file mode 100644 index 000000000000..9fa29d591882 --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/locations.go @@ -0,0 +1,201 @@ +package avs + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/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 +} + +// 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 = "2020-07-17-preview" + 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 +} + +// 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 = "2020-07-17-preview" + 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/preview/avs/mgmt/2020-07-17-preview/avs/models.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/models.go new file mode 100644 index 000000000000..58fea56d767f --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/models.go @@ -0,0 +1,4296 @@ +package avs + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "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/preview/avs/mgmt/2020-07-17-preview/avs" + +// 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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"` +} + +// 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 - READ-ONLY; The state of the cluster provisioning. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Deleting', 'Updating' + 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.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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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 - READ-ONLY; The state of the cluster provisioning. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Deleting', 'Updating' + 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.ClusterSize != nil { + objectMap["clusterSize"] = ccp.ClusterSize + } + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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 - READ-ONLY; The state of the cluster provisioning. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Deleting', 'Updating' + 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.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"` +} + +// 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"` +} + +// 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"` + // 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"` + // 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"` + // VcenterPassword - Indicate to rotate the vCenter admin password for the private cloud. Possible values include: 'VcsaAdminRotateEnumOnetimeRotate' + VcenterPassword VcsaAdminRotateEnum `json:"vcenterPassword,omitempty"` + // NsxtPassword - Indicate to rotate the NSX-T Manager password for the private cloud. Possible values include: 'OnetimeRotate' + NsxtPassword NsxtAdminRotateEnum `json:"nsxtPassword,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.ManagementCluster != nil { + objectMap["managementCluster"] = pcp.ManagementCluster + } + if pcp.Internet != "" { + objectMap["internet"] = pcp.Internet + } + if pcp.IdentitySources != nil { + objectMap["identitySources"] = pcp.IdentitySources + } + if pcp.VcenterPassword != "" { + objectMap["vcenterPassword"] = pcp.VcenterPassword + } + if pcp.NsxtPassword != "" { + objectMap["nsxtPassword"] = pcp.NsxtPassword + } + return json.Marshal(objectMap) +} + +// PrivateCloudsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateCloudsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateCloudsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PrivateCloudsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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"` + // VcenterPassword - Indicate to rotate the vCenter admin password for the private cloud. Possible values include: 'VcsaAdminRotateEnumOnetimeRotate' + VcenterPassword VcsaAdminRotateEnum `json:"vcenterPassword,omitempty"` + // NsxtPassword - Indicate to rotate the NSX-T Manager password for the private cloud. Possible values include: 'OnetimeRotate' + NsxtPassword NsxtAdminRotateEnum `json:"nsxtPassword,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"` +} + +// 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"` +} + +// 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:"-"` + // BasicWorkloadNetworkDhcpEntity - DHCP 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.BasicWorkloadNetworkDhcpEntity + 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 { + basicWorkloadNetworkDhcpEntity, err := unmarshalBasicWorkloadNetworkDhcpEntity(*v) + if err != nil { + return err + } + wnd.BasicWorkloadNetworkDhcpEntity = basicWorkloadNetworkDhcpEntity + } + 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 +} + +// 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) +} + +// WorkloadNetworksCreateDhcpFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksCreateDhcpFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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 +} + +// WorkloadNetworksCreatePortMirroringFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksCreatePortMirroringFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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 +} + +// WorkloadNetworksCreateSegmentsFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksCreateSegmentsFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksDeleteDhcpFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkloadNetworksDeletePortMirroringFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksDeletePortMirroringFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + err = azure.NewAsyncOpIncompleteError("avs.WorkloadNetworksDeletePortMirroringFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkloadNetworksDeleteSegmentFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksDeleteSegmentFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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 +} + +// WorkloadNetworksUpdatePortMirroringFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadNetworksUpdatePortMirroringFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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/preview/avs/mgmt/2020-07-17-preview/avs/operations.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/operations.go new file mode 100644 index 000000000000..34406795a166 --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/operations.go @@ -0,0 +1,149 @@ +package avs + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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") + } + if result.ol.hasNextLink() && result.ol.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-07-17-preview" + 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/preview/avs/mgmt/2020-07-17-preview/avs/privateclouds.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/privateclouds.go new file mode 100644 index 000000000000..52e824d93e1c --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/privateclouds.go @@ -0,0 +1,719 @@ +package avs + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/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.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}}}, + {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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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") + } + if result.pcl.hasNextLink() && result.pcl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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") + } + if result.pcl.hasNextLink() && result.pcl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + 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 = "2020-07-17-preview" + 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 +} + +// 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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/preview/avs/mgmt/2020-07-17-preview/avs/version.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/version.go new file mode 100644 index 000000000000..5547f458eb41 --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/version.go @@ -0,0 +1,30 @@ +package avs + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " avs/2020-07-17-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/avs/mgmt/2020-07-17-preview/avs/workloadnetworks.go b/services/preview/avs/mgmt/2020-07-17-preview/avs/workloadnetworks.go new file mode 100644 index 000000000000..84cb3d9e9e11 --- /dev/null +++ b/services/preview/avs/mgmt/2020-07-17-preview/avs/workloadnetworks.go @@ -0,0 +1,2386 @@ +package avs + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +} + +// 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +} + +// 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +} + +// 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +} + +// 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 +} + +// 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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 +} + +// 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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 - NSX 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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 +} + +// 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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") + } + if result.wndl.hasNextLink() && result.wndl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 +} + +// 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") + } + if result.wngl.hasNextLink() && result.wngl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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") + } + if result.wnpml.hasNextLink() && result.wnpml.IsEmpty() { + err = result.NextWithContext(ctx) + } + + 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 +} + +// 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") + } + if result.wnsl.hasNextLink() && result.wnsl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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") + } + if result.wnvml.hasNextLink() && result.wnvml.IsEmpty() { + err = result.NextWithContext(ctx) + } + + 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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") + } + if result.wnvgl.hasNextLink() && result.wnvgl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + 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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +} + +// 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.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.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", result.Response(), "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 = "2020-07-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +}