From 606f31541935ffbf590ef51851011f16bff36105 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 8 Aug 2019 04:03:51 +0000 Subject: [PATCH] Generated from e8805bf5ca1ff7c125b84a637eb483af9efd5ff5 add readme go --- .../managednetworkapi/models.go | 28 + .../mgmt/managednetwork/models.go | 185 ++ .../managednetwork/client.go | 53 + .../managednetwork/groups.go | 420 +++++ .../managednetworkapi/interfaces.go | 73 + .../managednetwork/managednetworks.go | 624 ++++++ .../managednetwork/models.go | 1668 +++++++++++++++++ .../managednetwork/operations.go | 149 ++ .../managednetwork/peeringpolicies.go | 420 +++++ .../managednetwork/scopeassignments.go | 389 ++++ .../managednetwork/version.go | 30 + 11 files changed, 4039 insertions(+) create mode 100644 profiles/preview/preview/managednetwork/mgmt/managednetwork/managednetworkapi/models.go create mode 100644 profiles/preview/preview/managednetwork/mgmt/managednetwork/models.go create mode 100644 services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/client.go create mode 100644 services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/groups.go create mode 100644 services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/managednetworkapi/interfaces.go create mode 100644 services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/managednetworks.go create mode 100644 services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/models.go create mode 100644 services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/operations.go create mode 100644 services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/peeringpolicies.go create mode 100644 services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/scopeassignments.go create mode 100644 services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/version.go diff --git a/profiles/preview/preview/managednetwork/mgmt/managednetwork/managednetworkapi/models.go b/profiles/preview/preview/managednetwork/mgmt/managednetwork/managednetworkapi/models.go new file mode 100644 index 000000000000..01732589b0cd --- /dev/null +++ b/profiles/preview/preview/managednetwork/mgmt/managednetwork/managednetworkapi/models.go @@ -0,0 +1,28 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// 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. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package managednetworkapi + +import original "github.com/Azure/azure-sdk-for-go/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/managednetworkapi" + +type GroupsClientAPI = original.GroupsClientAPI +type ManagedNetworksClientAPI = original.ManagedNetworksClientAPI +type OperationsClientAPI = original.OperationsClientAPI +type PeeringPoliciesClientAPI = original.PeeringPoliciesClientAPI +type ScopeAssignmentsClientAPI = original.ScopeAssignmentsClientAPI diff --git a/profiles/preview/preview/managednetwork/mgmt/managednetwork/models.go b/profiles/preview/preview/managednetwork/mgmt/managednetwork/models.go new file mode 100644 index 000000000000..579ee5b72acb --- /dev/null +++ b/profiles/preview/preview/managednetwork/mgmt/managednetwork/models.go @@ -0,0 +1,185 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// 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. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package managednetwork + +import ( + "context" + + original "github.com/Azure/azure-sdk-for-go/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork" +) + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type Kind = original.Kind + +const ( + Connectivity Kind = original.Connectivity +) + +type PeeringPolicyType = original.PeeringPolicyType + +const ( + PeeringPolicyTypeHubAndSpokeTopology PeeringPolicyType = original.PeeringPolicyTypeHubAndSpokeTopology + PeeringPolicyTypeManagedNetworkPeeringPolicyProperties PeeringPolicyType = original.PeeringPolicyTypeManagedNetworkPeeringPolicyProperties + PeeringPolicyTypeMeshTopology PeeringPolicyType = original.PeeringPolicyTypeMeshTopology +) + +type ProvisioningState = original.ProvisioningState + +const ( + Deleting ProvisioningState = original.Deleting + Failed ProvisioningState = original.Failed + Succeeded ProvisioningState = original.Succeeded + Updating ProvisioningState = original.Updating +) + +type BaseClient = original.BaseClient +type BasicPeeringPolicyProperties = original.BasicPeeringPolicyProperties +type ConnectivityCollection = original.ConnectivityCollection +type ErrorResponse = original.ErrorResponse +type Group = original.Group +type GroupListResult = original.GroupListResult +type GroupListResultIterator = original.GroupListResultIterator +type GroupListResultPage = original.GroupListResultPage +type GroupProperties = original.GroupProperties +type GroupsClient = original.GroupsClient +type GroupsCreateOrUpdateFuture = original.GroupsCreateOrUpdateFuture +type GroupsDeleteFuture = original.GroupsDeleteFuture +type HubAndSpokePeeringPolicyProperties = original.HubAndSpokePeeringPolicyProperties +type ListResult = original.ListResult +type ListResultIterator = original.ListResultIterator +type ListResultPage = original.ListResultPage +type ManagedNetwork = original.ManagedNetwork +type ManagedNetworksClient = original.ManagedNetworksClient +type ManagedNetworksDeleteFutureType = original.ManagedNetworksDeleteFutureType +type ManagedNetworksUpdateFutureType = original.ManagedNetworksUpdateFutureType +type MeshPeeringPolicyProperties = original.MeshPeeringPolicyProperties +type Operation = original.Operation +type OperationDisplay = original.OperationDisplay +type OperationListResult = original.OperationListResult +type OperationListResultIterator = original.OperationListResultIterator +type OperationListResultPage = original.OperationListResultPage +type OperationsClient = original.OperationsClient +type PeeringPoliciesClient = original.PeeringPoliciesClient +type PeeringPoliciesCreateOrUpdateFuture = original.PeeringPoliciesCreateOrUpdateFuture +type PeeringPoliciesDeleteFuture = original.PeeringPoliciesDeleteFuture +type PeeringPolicy = original.PeeringPolicy +type PeeringPolicyListResult = original.PeeringPolicyListResult +type PeeringPolicyListResultIterator = original.PeeringPolicyListResultIterator +type PeeringPolicyListResultPage = original.PeeringPolicyListResultPage +type PeeringPolicyProperties = original.PeeringPolicyProperties +type Properties = original.Properties +type ProxyResource = original.ProxyResource +type Resource = original.Resource +type ResourceID = original.ResourceID +type ResourceProperties = original.ResourceProperties +type Scope = original.Scope +type ScopeAssignment = original.ScopeAssignment +type ScopeAssignmentListResult = original.ScopeAssignmentListResult +type ScopeAssignmentListResultIterator = original.ScopeAssignmentListResultIterator +type ScopeAssignmentListResultPage = original.ScopeAssignmentListResultPage +type ScopeAssignmentProperties = original.ScopeAssignmentProperties +type ScopeAssignmentsClient = original.ScopeAssignmentsClient +type TrackedResource = original.TrackedResource +type Update = original.Update + +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewGroupListResultIterator(page GroupListResultPage) GroupListResultIterator { + return original.NewGroupListResultIterator(page) +} +func NewGroupListResultPage(getNextPage func(context.Context, GroupListResult) (GroupListResult, error)) GroupListResultPage { + return original.NewGroupListResultPage(getNextPage) +} +func NewGroupsClient(subscriptionID string) GroupsClient { + return original.NewGroupsClient(subscriptionID) +} +func NewGroupsClientWithBaseURI(baseURI string, subscriptionID string) GroupsClient { + return original.NewGroupsClientWithBaseURI(baseURI, subscriptionID) +} +func NewListResultIterator(page ListResultPage) ListResultIterator { + return original.NewListResultIterator(page) +} +func NewListResultPage(getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage { + return original.NewListResultPage(getNextPage) +} +func NewManagedNetworksClient(subscriptionID string) ManagedNetworksClient { + return original.NewManagedNetworksClient(subscriptionID) +} +func NewManagedNetworksClientWithBaseURI(baseURI string, subscriptionID string) ManagedNetworksClient { + return original.NewManagedNetworksClientWithBaseURI(baseURI, subscriptionID) +} +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return original.NewOperationListResultIterator(page) +} +func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return original.NewOperationListResultPage(getNextPage) +} +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewPeeringPoliciesClient(subscriptionID string) PeeringPoliciesClient { + return original.NewPeeringPoliciesClient(subscriptionID) +} +func NewPeeringPoliciesClientWithBaseURI(baseURI string, subscriptionID string) PeeringPoliciesClient { + return original.NewPeeringPoliciesClientWithBaseURI(baseURI, subscriptionID) +} +func NewPeeringPolicyListResultIterator(page PeeringPolicyListResultPage) PeeringPolicyListResultIterator { + return original.NewPeeringPolicyListResultIterator(page) +} +func NewPeeringPolicyListResultPage(getNextPage func(context.Context, PeeringPolicyListResult) (PeeringPolicyListResult, error)) PeeringPolicyListResultPage { + return original.NewPeeringPolicyListResultPage(getNextPage) +} +func NewScopeAssignmentListResultIterator(page ScopeAssignmentListResultPage) ScopeAssignmentListResultIterator { + return original.NewScopeAssignmentListResultIterator(page) +} +func NewScopeAssignmentListResultPage(getNextPage func(context.Context, ScopeAssignmentListResult) (ScopeAssignmentListResult, error)) ScopeAssignmentListResultPage { + return original.NewScopeAssignmentListResultPage(getNextPage) +} +func NewScopeAssignmentsClient(subscriptionID string) ScopeAssignmentsClient { + return original.NewScopeAssignmentsClient(subscriptionID) +} +func NewScopeAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) ScopeAssignmentsClient { + return original.NewScopeAssignmentsClientWithBaseURI(baseURI, subscriptionID) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func PossibleKindValues() []Kind { + return original.PossibleKindValues() +} +func PossiblePeeringPolicyTypeValues() []PeeringPolicyType { + return original.PossiblePeeringPolicyTypeValues() +} +func PossibleProvisioningStateValues() []ProvisioningState { + return original.PossibleProvisioningStateValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/client.go b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/client.go new file mode 100644 index 000000000000..a04580361ca7 --- /dev/null +++ b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/client.go @@ -0,0 +1,53 @@ +// Package managednetwork implements the Azure ARM Managednetwork service API version 2019-06-01-preview. +// +// The Microsoft Azure Managed Network management API provides a RESTful set of web services that interact with +// Microsoft Azure Networks service to programmatically view, control, change, and monitor your entire Azure network +// centrally and with ease. +package managednetwork + +// 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 Managednetwork + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Managednetwork. +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. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/groups.go b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/groups.go new file mode 100644 index 000000000000..3dc627a19697 --- /dev/null +++ b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/groups.go @@ -0,0 +1,420 @@ +package managednetwork + +// 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" +) + +// GroupsClient is the the Microsoft Azure Managed Network management API provides a RESTful set of web services that +// interact with Microsoft Azure Networks service to programmatically view, control, change, and monitor your entire +// Azure network centrally and with ease. +type GroupsClient struct { + BaseClient +} + +// NewGroupsClient creates an instance of the GroupsClient client. +func NewGroupsClient(subscriptionID string) GroupsClient { + return NewGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGroupsClientWithBaseURI creates an instance of the GroupsClient client. +func NewGroupsClientWithBaseURI(baseURI string, subscriptionID string) GroupsClient { + return GroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate the Put ManagedNetworkGroups operation creates or updates a Managed Network Group resource +// Parameters: +// managedNetworkGroup - parameters supplied to the create/update a Managed Network Group resource +// resourceGroupName - the name of the resource group. +// managedNetworkName - the name of the Managed Network. +// managedNetworkGroupName - the name of the Managed Network Group. +func (client GroupsClient) CreateOrUpdate(ctx context.Context, managedNetworkGroup Group, resourceGroupName string, managedNetworkName string, managedNetworkGroupName string) (result GroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, managedNetworkGroup, resourceGroupName, managedNetworkName, managedNetworkGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client GroupsClient) CreateOrUpdatePreparer(ctx context.Context, managedNetworkGroup Group, resourceGroupName string, managedNetworkName string, managedNetworkGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedNetworkGroupName": autorest.Encode("path", managedNetworkGroupName), + "managedNetworkName": autorest.Encode("path", managedNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}", pathParameters), + autorest.WithJSON(managedNetworkGroup), + 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 GroupsClient) CreateOrUpdateSender(req *http.Request) (future GroupsCreateOrUpdateFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 GroupsClient) CreateOrUpdateResponder(resp *http.Response) (result Group, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the Delete ManagedNetworkGroups operation deletes a Managed Network Group specified by the resource group, +// Managed Network name, and group name +// Parameters: +// resourceGroupName - the name of the resource group. +// managedNetworkName - the name of the Managed Network. +// managedNetworkGroupName - the name of the Managed Network Group. +func (client GroupsClient) Delete(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkGroupName string) (result GroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedNetworkName, managedNetworkGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client GroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedNetworkGroupName": autorest.Encode("path", managedNetworkGroupName), + "managedNetworkName": autorest.Encode("path", managedNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}", 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 GroupsClient) DeleteSender(req *http.Request) (future GroupsDeleteFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 GroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get the Get ManagedNetworkGroups operation gets a Managed Network Group specified by the resource group, Managed +// Network name, and group name +// Parameters: +// resourceGroupName - the name of the resource group. +// managedNetworkName - the name of the Managed Network. +// managedNetworkGroupName - the name of the Managed Network Group. +func (client GroupsClient) Get(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkGroupName string) (result Group, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedNetworkName, managedNetworkGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client GroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedNetworkGroupName": autorest.Encode("path", managedNetworkGroupName), + "managedNetworkName": autorest.Encode("path", managedNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups/{managedNetworkGroupName}", 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 GroupsClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GroupsClient) GetResponder(resp *http.Response) (result Group, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByManagedNetwork the ListByManagedNetwork ManagedNetworkGroup operation retrieves all the Managed Network Groups +// in a specified Managed Networks in a paginated format. +// Parameters: +// resourceGroupName - the name of the resource group. +// managedNetworkName - the name of the Managed Network. +// top - may be used to limit the number of results in a page for list queries. +// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response +// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that +// specifies a starting point to use for subsequent calls. +func (client GroupsClient) ListByManagedNetwork(ctx context.Context, resourceGroupName string, managedNetworkName string, top *int32, skiptoken string) (result GroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.ListByManagedNetwork") + defer func() { + sc := -1 + if result.glr.Response.Response != nil { + sc = result.glr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(20), Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("managednetwork.GroupsClient", "ListByManagedNetwork", err.Error()) + } + + result.fn = client.listByManagedNetworkNextResults + req, err := client.ListByManagedNetworkPreparer(ctx, resourceGroupName, managedNetworkName, top, skiptoken) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "ListByManagedNetwork", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagedNetworkSender(req) + if err != nil { + result.glr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "ListByManagedNetwork", resp, "Failure sending request") + return + } + + result.glr, err = client.ListByManagedNetworkResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "ListByManagedNetwork", resp, "Failure responding to request") + } + + return +} + +// ListByManagedNetworkPreparer prepares the ListByManagedNetwork request. +func (client GroupsClient) ListByManagedNetworkPreparer(ctx context.Context, resourceGroupName string, managedNetworkName string, top *int32, skiptoken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedNetworkName": autorest.Encode("path", managedNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByManagedNetworkSender sends the ListByManagedNetwork request. The method will close the +// http.Response Body if it receives an error. +func (client GroupsClient) ListByManagedNetworkSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByManagedNetworkResponder handles the response to the ListByManagedNetwork request. The method always +// closes the http.Response Body. +func (client GroupsClient) ListByManagedNetworkResponder(resp *http.Response) (result GroupListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByManagedNetworkNextResults retrieves the next set of results, if any. +func (client GroupsClient) listByManagedNetworkNextResults(ctx context.Context, lastResults GroupListResult) (result GroupListResult, err error) { + req, err := lastResults.groupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "listByManagedNetworkNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByManagedNetworkSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "listByManagedNetworkNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByManagedNetworkResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.GroupsClient", "listByManagedNetworkNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByManagedNetworkComplete enumerates all values, automatically crossing page boundaries as required. +func (client GroupsClient) ListByManagedNetworkComplete(ctx context.Context, resourceGroupName string, managedNetworkName string, top *int32, skiptoken string) (result GroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupsClient.ListByManagedNetwork") + 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.ListByManagedNetwork(ctx, resourceGroupName, managedNetworkName, top, skiptoken) + return +} diff --git a/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/managednetworkapi/interfaces.go b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/managednetworkapi/interfaces.go new file mode 100644 index 000000000000..a2380cd02d4c --- /dev/null +++ b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/managednetworkapi/interfaces.go @@ -0,0 +1,73 @@ +package managednetworkapi + +// 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/managednetwork/mgmt/2019-06-01-preview/managednetwork" + "github.com/Azure/go-autorest/autorest" +) + +// ManagedNetworksClientAPI contains the set of methods on the ManagedNetworksClient type. +type ManagedNetworksClientAPI interface { + CreateOrUpdate(ctx context.Context, managedNetwork managednetwork.ManagedNetwork, resourceGroupName string, managedNetworkName string) (result managednetwork.ManagedNetwork, err error) + Delete(ctx context.Context, resourceGroupName string, managedNetworkName string) (result managednetwork.ManagedNetworksDeleteFutureType, err error) + Get(ctx context.Context, resourceGroupName string, managedNetworkName string) (result managednetwork.ManagedNetwork, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, top *int32, skiptoken string) (result managednetwork.ListResultPage, err error) + ListBySubscription(ctx context.Context, top *int32, skiptoken string) (result managednetwork.ListResultPage, err error) + Update(ctx context.Context, parameters managednetwork.Update, resourceGroupName string, managedNetworkName string) (result managednetwork.ManagedNetworksUpdateFutureType, err error) +} + +var _ ManagedNetworksClientAPI = (*managednetwork.ManagedNetworksClient)(nil) + +// ScopeAssignmentsClientAPI contains the set of methods on the ScopeAssignmentsClient type. +type ScopeAssignmentsClientAPI interface { + CreateOrUpdate(ctx context.Context, parameters managednetwork.ScopeAssignment, scope string, scopeAssignmentName string) (result managednetwork.ScopeAssignment, err error) + Delete(ctx context.Context, scope string, scopeAssignmentName string) (result autorest.Response, err error) + Get(ctx context.Context, scope string, scopeAssignmentName string) (result managednetwork.ScopeAssignment, err error) + List(ctx context.Context, scope string) (result managednetwork.ScopeAssignmentListResultPage, err error) +} + +var _ ScopeAssignmentsClientAPI = (*managednetwork.ScopeAssignmentsClient)(nil) + +// GroupsClientAPI contains the set of methods on the GroupsClient type. +type GroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, managedNetworkGroup managednetwork.Group, resourceGroupName string, managedNetworkName string, managedNetworkGroupName string) (result managednetwork.GroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkGroupName string) (result managednetwork.GroupsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkGroupName string) (result managednetwork.Group, err error) + ListByManagedNetwork(ctx context.Context, resourceGroupName string, managedNetworkName string, top *int32, skiptoken string) (result managednetwork.GroupListResultPage, err error) +} + +var _ GroupsClientAPI = (*managednetwork.GroupsClient)(nil) + +// PeeringPoliciesClientAPI contains the set of methods on the PeeringPoliciesClient type. +type PeeringPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, managedNetworkPolicy managednetwork.PeeringPolicy, resourceGroupName string, managedNetworkName string, managedNetworkPeeringPolicyName string) (result managednetwork.PeeringPoliciesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkPeeringPolicyName string) (result managednetwork.PeeringPoliciesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkPeeringPolicyName string) (result managednetwork.PeeringPolicy, err error) + ListByManagedNetwork(ctx context.Context, resourceGroupName string, managedNetworkName string, top *int32, skiptoken string) (result managednetwork.PeeringPolicyListResultPage, err error) +} + +var _ PeeringPoliciesClientAPI = (*managednetwork.PeeringPoliciesClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result managednetwork.OperationListResultPage, err error) +} + +var _ OperationsClientAPI = (*managednetwork.OperationsClient)(nil) diff --git a/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/managednetworks.go b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/managednetworks.go new file mode 100644 index 000000000000..c8f386b685fb --- /dev/null +++ b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/managednetworks.go @@ -0,0 +1,624 @@ +package managednetwork + +// 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" +) + +// ManagedNetworksClient is the the Microsoft Azure Managed Network management API provides a RESTful set of web +// services that interact with Microsoft Azure Networks service to programmatically view, control, change, and monitor +// your entire Azure network centrally and with ease. +type ManagedNetworksClient struct { + BaseClient +} + +// NewManagedNetworksClient creates an instance of the ManagedNetworksClient client. +func NewManagedNetworksClient(subscriptionID string) ManagedNetworksClient { + return NewManagedNetworksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedNetworksClientWithBaseURI creates an instance of the ManagedNetworksClient client. +func NewManagedNetworksClientWithBaseURI(baseURI string, subscriptionID string) ManagedNetworksClient { + return ManagedNetworksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate the Put ManagedNetworks operation creates/updates a Managed Network Resource, specified by resource +// group and Managed Network name +// Parameters: +// managedNetwork - parameters supplied to the create/update a Managed Network Resource +// resourceGroupName - the name of the resource group. +// managedNetworkName - the name of the Managed Network. +func (client ManagedNetworksClient) CreateOrUpdate(ctx context.Context, managedNetwork ManagedNetwork, resourceGroupName string, managedNetworkName string) (result ManagedNetwork, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedNetworksClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, managedNetwork, resourceGroupName, managedNetworkName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedNetworksClient) CreateOrUpdatePreparer(ctx context.Context, managedNetwork ManagedNetwork, resourceGroupName string, managedNetworkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedNetworkName": autorest.Encode("path", managedNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}", pathParameters), + autorest.WithJSON(managedNetwork), + 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 ManagedNetworksClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedNetworksClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedNetwork, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the Delete ManagedNetworks operation deletes a Managed Network Resource, specified by the resource group and +// Managed Network name +// Parameters: +// resourceGroupName - the name of the resource group. +// managedNetworkName - the name of the Managed Network. +func (client ManagedNetworksClient) Delete(ctx context.Context, resourceGroupName string, managedNetworkName string) (result ManagedNetworksDeleteFutureType, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedNetworksClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedNetworkName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedNetworksClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedNetworkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedNetworkName": autorest.Encode("path", managedNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}", 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 ManagedNetworksClient) DeleteSender(req *http.Request) (future ManagedNetworksDeleteFutureType, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 ManagedNetworksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get the Get ManagedNetworks operation gets a Managed Network Resource, specified by the resource group and Managed +// Network name +// Parameters: +// resourceGroupName - the name of the resource group. +// managedNetworkName - the name of the Managed Network. +func (client ManagedNetworksClient) Get(ctx context.Context, resourceGroupName string, managedNetworkName string) (result ManagedNetwork, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedNetworksClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedNetworkName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedNetworksClient) GetPreparer(ctx context.Context, resourceGroupName string, managedNetworkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedNetworkName": autorest.Encode("path", managedNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}", 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 ManagedNetworksClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedNetworksClient) GetResponder(resp *http.Response) (result ManagedNetwork, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup the ListByResourceGroup ManagedNetwork operation retrieves all the Managed Network resources in +// a resource group in a paginated format. +// Parameters: +// resourceGroupName - the name of the resource group. +// top - may be used to limit the number of results in a page for list queries. +// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response +// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that +// specifies a starting point to use for subsequent calls. +func (client ManagedNetworksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, top *int32, skiptoken string) (result ListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedNetworksClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.lr.Response.Response != nil { + sc = result.lr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(20), Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("managednetwork.ManagedNetworksClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, top, skiptoken) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.lr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.lr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ManagedNetworksClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, top *int32, skiptoken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedNetworksClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ManagedNetworksClient) ListByResourceGroupResponder(resp *http.Response) (result ListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ManagedNetworksClient) listByResourceGroupNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) { + req, err := lastResults.listResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedNetworksClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, top *int32, skiptoken string) (result ListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedNetworksClient.ListByResourceGroup") + 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.ListByResourceGroup(ctx, resourceGroupName, top, skiptoken) + return +} + +// ListBySubscription the ListBySubscription ManagedNetwork operation retrieves all the Managed Network Resources in +// the current subscription in a paginated format. +// Parameters: +// top - may be used to limit the number of results in a page for list queries. +// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response +// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that +// specifies a starting point to use for subsequent calls. +func (client ManagedNetworksClient) ListBySubscription(ctx context.Context, top *int32, skiptoken string) (result ListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedNetworksClient.ListBySubscription") + defer func() { + sc := -1 + if result.lr.Response.Response != nil { + sc = result.lr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(20), Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("managednetwork.ManagedNetworksClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx, top, skiptoken) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.lr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.lr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ManagedNetworksClient) ListBySubscriptionPreparer(ctx context.Context, top *int32, skiptoken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ManagedNetwork/managedNetworks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedNetworksClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client ManagedNetworksClient) ListBySubscriptionResponder(resp *http.Response) (result ListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client ManagedNetworksClient) listBySubscriptionNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) { + req, err := lastResults.listResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedNetworksClient) ListBySubscriptionComplete(ctx context.Context, top *int32, skiptoken string) (result ListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedNetworksClient.ListBySubscription") + 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.ListBySubscription(ctx, top, skiptoken) + return +} + +// Update updates the specified Managed Network resource tags. +// Parameters: +// parameters - parameters supplied to update application gateway tags and/or scope. +// resourceGroupName - the name of the resource group. +// managedNetworkName - the name of the Managed Network. +func (client ManagedNetworksClient) Update(ctx context.Context, parameters Update, resourceGroupName string, managedNetworkName string) (result ManagedNetworksUpdateFutureType, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedNetworksClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, parameters, resourceGroupName, managedNetworkName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagedNetworksClient) UpdatePreparer(ctx context.Context, parameters Update, resourceGroupName string, managedNetworkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedNetworkName": autorest.Encode("path", managedNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}", pathParameters), + autorest.WithJSON(parameters), + 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 ManagedNetworksClient) UpdateSender(req *http.Request) (future ManagedNetworksUpdateFutureType, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 ManagedNetworksClient) UpdateResponder(resp *http.Response) (result ManagedNetwork, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/models.go b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/models.go new file mode 100644 index 000000000000..92c5c90ee3aa --- /dev/null +++ b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/models.go @@ -0,0 +1,1668 @@ +package managednetwork + +// 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/managednetwork/mgmt/2019-06-01-preview/managednetwork" + +// Kind enumerates the values for kind. +type Kind string + +const ( + // Connectivity ... + Connectivity Kind = "Connectivity" +) + +// PossibleKindValues returns an array of possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{Connectivity} +} + +// PeeringPolicyType enumerates the values for peering policy type. +type PeeringPolicyType string + +const ( + // PeeringPolicyTypeHubAndSpokeTopology ... + PeeringPolicyTypeHubAndSpokeTopology PeeringPolicyType = "HubAndSpokeTopology" + // PeeringPolicyTypeManagedNetworkPeeringPolicyProperties ... + PeeringPolicyTypeManagedNetworkPeeringPolicyProperties PeeringPolicyType = "ManagedNetworkPeeringPolicyProperties" + // PeeringPolicyTypeMeshTopology ... + PeeringPolicyTypeMeshTopology PeeringPolicyType = "MeshTopology" +) + +// PossiblePeeringPolicyTypeValues returns an array of possible values for the PeeringPolicyType const type. +func PossiblePeeringPolicyTypeValues() []PeeringPolicyType { + return []PeeringPolicyType{PeeringPolicyTypeHubAndSpokeTopology, PeeringPolicyTypeManagedNetworkPeeringPolicyProperties, PeeringPolicyTypeMeshTopology} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Failed ... + Failed ProvisioningState = "Failed" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" + // Updating ... + Updating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Deleting, Failed, Succeeded, Updating} +} + +// ConnectivityCollection the collection of Connectivity related groups and policies within the Managed +// Network +type ConnectivityCollection struct { + // Groups - READ-ONLY; The collection of connectivity related Managed Network Groups within the Managed Network + Groups *[]Group `json:"groups,omitempty"` + // Peerings - READ-ONLY; The collection of Managed Network Peering Policies within the Managed Network + Peerings *[]PeeringPolicy `json:"peerings,omitempty"` +} + +// ErrorResponse the error response that indicates why an operation has failed. +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"` +} + +// Group the Managed Network Group resource +type Group struct { + autorest.Response `json:"-"` + // GroupProperties - Gets or sets the properties of a network group + *GroupProperties `json:"properties,omitempty"` + // Kind - Responsibility role under which this Managed Network Group will be created. Possible values include: 'Connectivity' + Kind Kind `json:"kind,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Group. +func (g Group) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if g.GroupProperties != nil { + objectMap["properties"] = g.GroupProperties + } + if g.Kind != "" { + objectMap["kind"] = g.Kind + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Group struct. +func (g *Group) 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 groupProperties GroupProperties + err = json.Unmarshal(*v, &groupProperties) + if err != nil { + return err + } + g.GroupProperties = &groupProperties + } + case "kind": + if v != nil { + var kind Kind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + g.Kind = kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + g.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + g.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + g.Type = &typeVar + } + } + } + + return nil +} + +// GroupListResult result of the request to list Managed Network Groups. It contains a list of groups and a +// URL link to get the next set of results. +type GroupListResult struct { + autorest.Response `json:"-"` + // Value - Gets a page of ManagedNetworkGroup + Value *[]Group `json:"value,omitempty"` + // NextLink - Gets the URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// GroupListResultIterator provides access to a complete listing of Group values. +type GroupListResultIterator struct { + i int + page GroupListResultPage +} + +// 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 *GroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupListResultIterator.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 *GroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter GroupListResultIterator) 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 GroupListResultIterator) Response() GroupListResult { + 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 GroupListResultIterator) Value() Group { + if !iter.page.NotDone() { + return Group{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the GroupListResultIterator type. +func NewGroupListResultIterator(page GroupListResultPage) GroupListResultIterator { + return GroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (glr GroupListResult) IsEmpty() bool { + return glr.Value == nil || len(*glr.Value) == 0 +} + +// groupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (glr GroupListResult) groupListResultPreparer(ctx context.Context) (*http.Request, error) { + if glr.NextLink == nil || len(to.String(glr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(glr.NextLink))) +} + +// GroupListResultPage contains a page of Group values. +type GroupListResultPage struct { + fn func(context.Context, GroupListResult) (GroupListResult, error) + glr GroupListResult +} + +// 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 *GroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.glr) + if err != nil { + return err + } + page.glr = next + 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 *GroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page GroupListResultPage) NotDone() bool { + return !page.glr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page GroupListResultPage) Response() GroupListResult { + return page.glr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page GroupListResultPage) Values() []Group { + if page.glr.IsEmpty() { + return nil + } + return *page.glr.Value +} + +// Creates a new instance of the GroupListResultPage type. +func NewGroupListResultPage(getNextPage func(context.Context, GroupListResult) (GroupListResult, error)) GroupListResultPage { + return GroupListResultPage{fn: getNextPage} +} + +// GroupProperties properties of a Managed Network Group +type GroupProperties struct { + // ManagementGroups - The collection of management groups covered by the Managed Network + ManagementGroups *[]ResourceID `json:"managementGroups,omitempty"` + // Subscriptions - The collection of subscriptions covered by the Managed Network + Subscriptions *[]ResourceID `json:"subscriptions,omitempty"` + // VirtualNetworks - The collection of virtual nets covered by the Managed Network + VirtualNetworks *[]ResourceID `json:"virtualNetworks,omitempty"` + // Subnets - The collection of subnets covered by the Managed Network + Subnets *[]ResourceID `json:"subnets,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the ManagedNetwork resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. Possible values include: 'Updating', 'Deleting', 'Failed', 'Succeeded' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Etag - READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty"` +} + +// GroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type GroupsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *GroupsCreateOrUpdateFuture) Result(client GroupsClient) (g Group, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.GroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managednetwork.GroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if g.Response.Response, err = future.GetResult(sender); err == nil && g.Response.Response.StatusCode != http.StatusNoContent { + g, err = client.CreateOrUpdateResponder(g.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.GroupsCreateOrUpdateFuture", "Result", g.Response.Response, "Failure responding to request") + } + } + return +} + +// GroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type GroupsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *GroupsDeleteFuture) Result(client GroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.GroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managednetwork.GroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// HubAndSpokePeeringPolicyProperties properties of a Hub and Spoke Peering Policy +type HubAndSpokePeeringPolicyProperties struct { + // Hub - Gets or sets the hub virtual network ID + Hub *ResourceID `json:"hub,omitempty"` + // Spokes - Gets or sets the spokes group IDs + Spokes *[]ResourceID `json:"spokes,omitempty"` + // Mesh - Gets or sets the mesh group IDs + Mesh *[]ResourceID `json:"mesh,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the ManagedNetwork resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. Possible values include: 'Updating', 'Deleting', 'Failed', 'Succeeded' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Etag - READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty"` + // PeeringPolicyType - Possible values include: 'PeeringPolicyTypeManagedNetworkPeeringPolicyProperties', 'PeeringPolicyTypeHubAndSpokeTopology', 'PeeringPolicyTypeMeshTopology' + PeeringPolicyType PeeringPolicyType `json:"peeringPolicyType,omitempty"` +} + +// MarshalJSON is the custom marshaler for HubAndSpokePeeringPolicyProperties. +func (hasppp HubAndSpokePeeringPolicyProperties) MarshalJSON() ([]byte, error) { + hasppp.PeeringPolicyType = PeeringPolicyTypeHubAndSpokeTopology + objectMap := make(map[string]interface{}) + if hasppp.Hub != nil { + objectMap["hub"] = hasppp.Hub + } + if hasppp.Spokes != nil { + objectMap["spokes"] = hasppp.Spokes + } + if hasppp.Mesh != nil { + objectMap["mesh"] = hasppp.Mesh + } + if hasppp.PeeringPolicyType != "" { + objectMap["peeringPolicyType"] = hasppp.PeeringPolicyType + } + return json.Marshal(objectMap) +} + +// AsHubAndSpokePeeringPolicyProperties is the BasicPeeringPolicyProperties implementation for HubAndSpokePeeringPolicyProperties. +func (hasppp HubAndSpokePeeringPolicyProperties) AsHubAndSpokePeeringPolicyProperties() (*HubAndSpokePeeringPolicyProperties, bool) { + return &hasppp, true +} + +// AsMeshPeeringPolicyProperties is the BasicPeeringPolicyProperties implementation for HubAndSpokePeeringPolicyProperties. +func (hasppp HubAndSpokePeeringPolicyProperties) AsMeshPeeringPolicyProperties() (*MeshPeeringPolicyProperties, bool) { + return nil, false +} + +// AsPeeringPolicyProperties is the BasicPeeringPolicyProperties implementation for HubAndSpokePeeringPolicyProperties. +func (hasppp HubAndSpokePeeringPolicyProperties) AsPeeringPolicyProperties() (*PeeringPolicyProperties, bool) { + return nil, false +} + +// AsBasicPeeringPolicyProperties is the BasicPeeringPolicyProperties implementation for HubAndSpokePeeringPolicyProperties. +func (hasppp HubAndSpokePeeringPolicyProperties) AsBasicPeeringPolicyProperties() (BasicPeeringPolicyProperties, bool) { + return &hasppp, true +} + +// ListResult result of the request to list Managed Network. It contains a list of Managed Networks and a +// URL link to get the next set of results. +type ListResult struct { + autorest.Response `json:"-"` + // Value - Gets a page of ManagedNetworks + Value *[]ManagedNetwork `json:"value,omitempty"` + // NextLink - Gets the URL to get the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ListResultIterator provides access to a complete listing of ManagedNetwork values. +type ListResultIterator struct { + i int + page ListResultPage +} + +// 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 *ListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.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 *ListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ListResultIterator) 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 ListResultIterator) Response() ListResult { + 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 ListResultIterator) Value() ManagedNetwork { + if !iter.page.NotDone() { + return ManagedNetwork{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ListResultIterator type. +func NewListResultIterator(page ListResultPage) ListResultIterator { + return ListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (lr ListResult) IsEmpty() bool { + return lr.Value == nil || len(*lr.Value) == 0 +} + +// listResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) { + if lr.NextLink == nil || len(to.String(lr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lr.NextLink))) +} + +// ListResultPage contains a page of ManagedNetwork values. +type ListResultPage struct { + fn func(context.Context, ListResult) (ListResult, error) + lr ListResult +} + +// 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 *ListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.lr) + if err != nil { + return err + } + page.lr = next + 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 *ListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ListResultPage) NotDone() bool { + return !page.lr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ListResultPage) Response() ListResult { + return page.lr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ListResultPage) Values() []ManagedNetwork { + if page.lr.IsEmpty() { + return nil + } + return *page.lr.Value +} + +// Creates a new instance of the ListResultPage type. +func NewListResultPage(getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage { + return ListResultPage{fn: getNextPage} +} + +// ManagedNetwork the Managed Network resource +type ManagedNetwork struct { + autorest.Response `json:"-"` + // Properties - The MNC properties + *Properties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedNetwork. +func (mn ManagedNetwork) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mn.Properties != nil { + objectMap["properties"] = mn.Properties + } + if mn.Tags != nil { + objectMap["tags"] = mn.Tags + } + if mn.Location != nil { + objectMap["location"] = mn.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedNetwork struct. +func (mn *ManagedNetwork) 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 properties Properties + err = json.Unmarshal(*v, &properties) + if err != nil { + return err + } + mn.Properties = &properties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mn.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mn.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mn.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mn.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mn.Type = &typeVar + } + } + } + + return nil +} + +// ManagedNetworksDeleteFutureType an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedNetworksDeleteFutureType struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ManagedNetworksDeleteFutureType) Result(client ManagedNetworksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksDeleteFutureType", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managednetwork.ManagedNetworksDeleteFutureType") + return + } + ar.Response = future.Response() + return +} + +// ManagedNetworksUpdateFutureType an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedNetworksUpdateFutureType struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ManagedNetworksUpdateFutureType) Result(client ManagedNetworksClient) (mn ManagedNetwork, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksUpdateFutureType", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managednetwork.ManagedNetworksUpdateFutureType") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mn.Response.Response, err = future.GetResult(sender); err == nil && mn.Response.Response.StatusCode != http.StatusNoContent { + mn, err = client.UpdateResponder(mn.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ManagedNetworksUpdateFutureType", "Result", mn.Response.Response, "Failure responding to request") + } + } + return +} + +// MeshPeeringPolicyProperties properties of a Mesh Peering Policy +type MeshPeeringPolicyProperties struct { + // Hub - Gets or sets the hub virtual network ID + Hub *ResourceID `json:"hub,omitempty"` + // Spokes - Gets or sets the spokes group IDs + Spokes *[]ResourceID `json:"spokes,omitempty"` + // Mesh - Gets or sets the mesh group IDs + Mesh *[]ResourceID `json:"mesh,omitempty"` + // PeeringPolicyType - Possible values include: 'PeeringPolicyTypeManagedNetworkPeeringPolicyProperties', 'PeeringPolicyTypeHubAndSpokeTopology', 'PeeringPolicyTypeMeshTopology' + PeeringPolicyType PeeringPolicyType `json:"peeringPolicyType,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the ManagedNetwork resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. Possible values include: 'Updating', 'Deleting', 'Failed', 'Succeeded' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Etag - READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for MeshPeeringPolicyProperties. +func (mppp MeshPeeringPolicyProperties) MarshalJSON() ([]byte, error) { + mppp.PeeringPolicyType = PeeringPolicyTypeMeshTopology + objectMap := make(map[string]interface{}) + if mppp.Hub != nil { + objectMap["hub"] = mppp.Hub + } + if mppp.Spokes != nil { + objectMap["spokes"] = mppp.Spokes + } + if mppp.Mesh != nil { + objectMap["mesh"] = mppp.Mesh + } + if mppp.PeeringPolicyType != "" { + objectMap["peeringPolicyType"] = mppp.PeeringPolicyType + } + return json.Marshal(objectMap) +} + +// AsHubAndSpokePeeringPolicyProperties is the BasicPeeringPolicyProperties implementation for MeshPeeringPolicyProperties. +func (mppp MeshPeeringPolicyProperties) AsHubAndSpokePeeringPolicyProperties() (*HubAndSpokePeeringPolicyProperties, bool) { + return nil, false +} + +// AsMeshPeeringPolicyProperties is the BasicPeeringPolicyProperties implementation for MeshPeeringPolicyProperties. +func (mppp MeshPeeringPolicyProperties) AsMeshPeeringPolicyProperties() (*MeshPeeringPolicyProperties, bool) { + return &mppp, true +} + +// AsPeeringPolicyProperties is the BasicPeeringPolicyProperties implementation for MeshPeeringPolicyProperties. +func (mppp MeshPeeringPolicyProperties) AsPeeringPolicyProperties() (*PeeringPolicyProperties, bool) { + return nil, false +} + +// AsBasicPeeringPolicyProperties is the BasicPeeringPolicyProperties implementation for MeshPeeringPolicyProperties. +func (mppp MeshPeeringPolicyProperties) AsBasicPeeringPolicyProperties() (BasicPeeringPolicyProperties, bool) { + return &mppp, true +} + +// Operation REST API operation +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.ManagedNetwork + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: Profile, endpoint, etc. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult result of the request to list Managed Network operations. It contains a list of +// operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of Resource Provider operations supported by the Managed Network resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// 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 *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.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 *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) 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 OperationListResultIterator) Response() OperationListResult { + 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 OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// 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 *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + 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 *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{fn: getNextPage} +} + +// PeeringPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PeeringPoliciesCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PeeringPoliciesCreateOrUpdateFuture) Result(client PeeringPoliciesClient) (pp PeeringPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managednetwork.PeeringPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pp.Response.Response, err = future.GetResult(sender); err == nil && pp.Response.Response.StatusCode != http.StatusNoContent { + pp, err = client.CreateOrUpdateResponder(pp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesCreateOrUpdateFuture", "Result", pp.Response.Response, "Failure responding to request") + } + } + return +} + +// PeeringPoliciesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PeeringPoliciesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PeeringPoliciesDeleteFuture) Result(client PeeringPoliciesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("managednetwork.PeeringPoliciesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PeeringPolicy the Managed Network Peering Policy resource +type PeeringPolicy struct { + autorest.Response `json:"-"` + // Properties - Gets or sets the properties of a Managed Network Policy + Properties BasicPeeringPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for PeeringPolicy struct. +func (pp *PeeringPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + properties, err := unmarshalBasicPeeringPolicyProperties(*v) + if err != nil { + return err + } + pp.Properties = properties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pp.Type = &typeVar + } + } + } + + return nil +} + +// PeeringPolicyListResult result of the request to list Managed Network Peering Policies. It contains a +// list of policies and a URL link to get the next set of results. +type PeeringPolicyListResult struct { + autorest.Response `json:"-"` + // Value - Gets a page of Peering Policies + Value *[]PeeringPolicy `json:"value,omitempty"` + // NextLink - Gets the URL to get the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// PeeringPolicyListResultIterator provides access to a complete listing of PeeringPolicy values. +type PeeringPolicyListResultIterator struct { + i int + page PeeringPolicyListResultPage +} + +// 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 *PeeringPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringPolicyListResultIterator.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 *PeeringPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PeeringPolicyListResultIterator) 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 PeeringPolicyListResultIterator) Response() PeeringPolicyListResult { + 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 PeeringPolicyListResultIterator) Value() PeeringPolicy { + if !iter.page.NotDone() { + return PeeringPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PeeringPolicyListResultIterator type. +func NewPeeringPolicyListResultIterator(page PeeringPolicyListResultPage) PeeringPolicyListResultIterator { + return PeeringPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (pplr PeeringPolicyListResult) IsEmpty() bool { + return pplr.Value == nil || len(*pplr.Value) == 0 +} + +// peeringPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (pplr PeeringPolicyListResult) peeringPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if pplr.NextLink == nil || len(to.String(pplr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(pplr.NextLink))) +} + +// PeeringPolicyListResultPage contains a page of PeeringPolicy values. +type PeeringPolicyListResultPage struct { + fn func(context.Context, PeeringPolicyListResult) (PeeringPolicyListResult, error) + pplr PeeringPolicyListResult +} + +// 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 *PeeringPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.pplr) + if err != nil { + return err + } + page.pplr = next + 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 *PeeringPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PeeringPolicyListResultPage) NotDone() bool { + return !page.pplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PeeringPolicyListResultPage) Response() PeeringPolicyListResult { + return page.pplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PeeringPolicyListResultPage) Values() []PeeringPolicy { + if page.pplr.IsEmpty() { + return nil + } + return *page.pplr.Value +} + +// Creates a new instance of the PeeringPolicyListResultPage type. +func NewPeeringPolicyListResultPage(getNextPage func(context.Context, PeeringPolicyListResult) (PeeringPolicyListResult, error)) PeeringPolicyListResultPage { + return PeeringPolicyListResultPage{fn: getNextPage} +} + +// BasicPeeringPolicyProperties properties of a Managed Network Peering Policy +type BasicPeeringPolicyProperties interface { + AsHubAndSpokePeeringPolicyProperties() (*HubAndSpokePeeringPolicyProperties, bool) + AsMeshPeeringPolicyProperties() (*MeshPeeringPolicyProperties, bool) + AsPeeringPolicyProperties() (*PeeringPolicyProperties, bool) +} + +// PeeringPolicyProperties properties of a Managed Network Peering Policy +type PeeringPolicyProperties struct { + // Hub - Gets or sets the hub virtual network ID + Hub *ResourceID `json:"hub,omitempty"` + // Spokes - Gets or sets the spokes group IDs + Spokes *[]ResourceID `json:"spokes,omitempty"` + // Mesh - Gets or sets the mesh group IDs + Mesh *[]ResourceID `json:"mesh,omitempty"` + // PeeringPolicyType - Possible values include: 'PeeringPolicyTypeManagedNetworkPeeringPolicyProperties', 'PeeringPolicyTypeHubAndSpokeTopology', 'PeeringPolicyTypeMeshTopology' + PeeringPolicyType PeeringPolicyType `json:"peeringPolicyType,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the ManagedNetwork resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. Possible values include: 'Updating', 'Deleting', 'Failed', 'Succeeded' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Etag - READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty"` +} + +func unmarshalBasicPeeringPolicyProperties(body []byte) (BasicPeeringPolicyProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["peeringPolicyType"] { + case string(PeeringPolicyTypeHubAndSpokeTopology): + var hasppp HubAndSpokePeeringPolicyProperties + err := json.Unmarshal(body, &hasppp) + return hasppp, err + case string(PeeringPolicyTypeMeshTopology): + var mppp MeshPeeringPolicyProperties + err := json.Unmarshal(body, &mppp) + return mppp, err + default: + var ppp PeeringPolicyProperties + err := json.Unmarshal(body, &ppp) + return ppp, err + } +} +func unmarshalBasicPeeringPolicyPropertiesArray(body []byte) ([]BasicPeeringPolicyProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + pppArray := make([]BasicPeeringPolicyProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + ppp, err := unmarshalBasicPeeringPolicyProperties(*rawMessage) + if err != nil { + return nil, err + } + pppArray[index] = ppp + } + return pppArray, nil +} + +// MarshalJSON is the custom marshaler for PeeringPolicyProperties. +func (ppp PeeringPolicyProperties) MarshalJSON() ([]byte, error) { + ppp.PeeringPolicyType = PeeringPolicyTypeManagedNetworkPeeringPolicyProperties + objectMap := make(map[string]interface{}) + if ppp.Hub != nil { + objectMap["hub"] = ppp.Hub + } + if ppp.Spokes != nil { + objectMap["spokes"] = ppp.Spokes + } + if ppp.Mesh != nil { + objectMap["mesh"] = ppp.Mesh + } + if ppp.PeeringPolicyType != "" { + objectMap["peeringPolicyType"] = ppp.PeeringPolicyType + } + return json.Marshal(objectMap) +} + +// AsHubAndSpokePeeringPolicyProperties is the BasicPeeringPolicyProperties implementation for PeeringPolicyProperties. +func (ppp PeeringPolicyProperties) AsHubAndSpokePeeringPolicyProperties() (*HubAndSpokePeeringPolicyProperties, bool) { + return nil, false +} + +// AsMeshPeeringPolicyProperties is the BasicPeeringPolicyProperties implementation for PeeringPolicyProperties. +func (ppp PeeringPolicyProperties) AsMeshPeeringPolicyProperties() (*MeshPeeringPolicyProperties, bool) { + return nil, false +} + +// AsPeeringPolicyProperties is the BasicPeeringPolicyProperties implementation for PeeringPolicyProperties. +func (ppp PeeringPolicyProperties) AsPeeringPolicyProperties() (*PeeringPolicyProperties, bool) { + return &ppp, true +} + +// AsBasicPeeringPolicyProperties is the BasicPeeringPolicyProperties implementation for PeeringPolicyProperties. +func (ppp PeeringPolicyProperties) AsBasicPeeringPolicyProperties() (BasicPeeringPolicyProperties, bool) { + return &ppp, true +} + +// Properties properties of Managed Network +type Properties struct { + // Scope - READ-ONLY; The collection of management groups, subscriptions, virtual networks, and subnets by the Managed Network. This is a read-only property that is reflective of all ScopeAssignments for this Managed Network + Scope *Scope `json:"scope,omitempty"` + // Connectivity - READ-ONLY; The collection of groups and policies concerned with connectivity + Connectivity *ConnectivityCollection `json:"connectivity,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the ManagedNetwork resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. Possible values include: 'Updating', 'Deleting', 'Failed', 'Succeeded' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Etag - READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty"` +} + +// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than +// required location and tags +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// Resource the general resource model definition +type Resource struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// ResourceID generic pointer to a resource +type ResourceID struct { + // ID - Resource Id + ID *string `json:"id,omitempty"` +} + +// ResourceProperties base for resource properties. +type ResourceProperties struct { + // ProvisioningState - READ-ONLY; Provisioning state of the ManagedNetwork resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. Possible values include: 'Updating', 'Deleting', 'Failed', 'Succeeded' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Etag - READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty"` +} + +// Scope scope of a Managed Network +type Scope struct { + // ManagementGroups - The collection of management groups covered by the Managed Network + ManagementGroups *[]ResourceID `json:"managementGroups,omitempty"` + // Subscriptions - The collection of subscriptions covered by the Managed Network + Subscriptions *[]ResourceID `json:"subscriptions,omitempty"` + // VirtualNetworks - The collection of virtual nets covered by the Managed Network + VirtualNetworks *[]ResourceID `json:"virtualNetworks,omitempty"` + // Subnets - The collection of subnets covered by the Managed Network + Subnets *[]ResourceID `json:"subnets,omitempty"` +} + +// ScopeAssignment the Managed Network resource +type ScopeAssignment struct { + autorest.Response `json:"-"` + // ScopeAssignmentProperties - The Scope Assignment properties + *ScopeAssignmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScopeAssignment. +func (sa ScopeAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sa.ScopeAssignmentProperties != nil { + objectMap["properties"] = sa.ScopeAssignmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ScopeAssignment struct. +func (sa *ScopeAssignment) 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 scopeAssignmentProperties ScopeAssignmentProperties + err = json.Unmarshal(*v, &scopeAssignmentProperties) + if err != nil { + return err + } + sa.ScopeAssignmentProperties = &scopeAssignmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sa.Type = &typeVar + } + } + } + + return nil +} + +// ScopeAssignmentListResult result of the request to list ScopeAssignment. It contains a list of groups +// and a URL link to get the next set of results. +type ScopeAssignmentListResult struct { + autorest.Response `json:"-"` + // Value - Gets a page of ScopeAssignment + Value *[]ScopeAssignment `json:"value,omitempty"` + // NextLink - Gets the URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ScopeAssignmentListResultIterator provides access to a complete listing of ScopeAssignment values. +type ScopeAssignmentListResultIterator struct { + i int + page ScopeAssignmentListResultPage +} + +// 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 *ScopeAssignmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScopeAssignmentListResultIterator.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 *ScopeAssignmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ScopeAssignmentListResultIterator) 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 ScopeAssignmentListResultIterator) Response() ScopeAssignmentListResult { + 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 ScopeAssignmentListResultIterator) Value() ScopeAssignment { + if !iter.page.NotDone() { + return ScopeAssignment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ScopeAssignmentListResultIterator type. +func NewScopeAssignmentListResultIterator(page ScopeAssignmentListResultPage) ScopeAssignmentListResultIterator { + return ScopeAssignmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (salr ScopeAssignmentListResult) IsEmpty() bool { + return salr.Value == nil || len(*salr.Value) == 0 +} + +// scopeAssignmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (salr ScopeAssignmentListResult) scopeAssignmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if salr.NextLink == nil || len(to.String(salr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(salr.NextLink))) +} + +// ScopeAssignmentListResultPage contains a page of ScopeAssignment values. +type ScopeAssignmentListResultPage struct { + fn func(context.Context, ScopeAssignmentListResult) (ScopeAssignmentListResult, error) + salr ScopeAssignmentListResult +} + +// 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 *ScopeAssignmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScopeAssignmentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.salr) + if err != nil { + return err + } + page.salr = next + 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 *ScopeAssignmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ScopeAssignmentListResultPage) NotDone() bool { + return !page.salr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ScopeAssignmentListResultPage) Response() ScopeAssignmentListResult { + return page.salr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ScopeAssignmentListResultPage) Values() []ScopeAssignment { + if page.salr.IsEmpty() { + return nil + } + return *page.salr.Value +} + +// Creates a new instance of the ScopeAssignmentListResultPage type. +func NewScopeAssignmentListResultPage(getNextPage func(context.Context, ScopeAssignmentListResult) (ScopeAssignmentListResult, error)) ScopeAssignmentListResultPage { + return ScopeAssignmentListResultPage{fn: getNextPage} +} + +// ScopeAssignmentProperties properties of Managed Network +type ScopeAssignmentProperties struct { + // AssignedManagedNetwork - The managed network ID with scope will be assigned to. + AssignedManagedNetwork *string `json:"assignedManagedNetwork,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the ManagedNetwork resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. Possible values include: 'Updating', 'Deleting', 'Failed', 'Succeeded' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Etag - READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty"` +} + +// TrackedResource the resource model definition for a ARM tracked top level resource +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + 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.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// Update update Tags of Managed Network +type Update struct { + // Tags - Updates the tags property of the Managed Network + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Update. +func (u Update) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if u.Tags != nil { + objectMap["tags"] = u.Tags + } + return json.Marshal(objectMap) +} diff --git a/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/operations.go b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/operations.go new file mode 100644 index 000000000000..4d5a22fb4962 --- /dev/null +++ b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/operations.go @@ -0,0 +1,149 @@ +package managednetwork + +// 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 the Microsoft Azure Managed Network management API provides a RESTful set of web services +// that interact with Microsoft Azure Networks service to programmatically view, control, change, and monitor your +// entire Azure network centrally and with ease. +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. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available MNC operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managednetwork.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ManagedNetwork/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) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "managednetwork.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, "managednetwork.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.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 OperationListResultIterator, 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/managednetwork/mgmt/2019-06-01-preview/managednetwork/peeringpolicies.go b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/peeringpolicies.go new file mode 100644 index 000000000000..a4281b3da967 --- /dev/null +++ b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/peeringpolicies.go @@ -0,0 +1,420 @@ +package managednetwork + +// 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" +) + +// PeeringPoliciesClient is the the Microsoft Azure Managed Network management API provides a RESTful set of web +// services that interact with Microsoft Azure Networks service to programmatically view, control, change, and monitor +// your entire Azure network centrally and with ease. +type PeeringPoliciesClient struct { + BaseClient +} + +// NewPeeringPoliciesClient creates an instance of the PeeringPoliciesClient client. +func NewPeeringPoliciesClient(subscriptionID string) PeeringPoliciesClient { + return NewPeeringPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPeeringPoliciesClientWithBaseURI creates an instance of the PeeringPoliciesClient client. +func NewPeeringPoliciesClientWithBaseURI(baseURI string, subscriptionID string) PeeringPoliciesClient { + return PeeringPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate the Put ManagedNetworkPeeringPolicies operation creates/updates a new Managed Network Peering Policy +// Parameters: +// managedNetworkPolicy - parameters supplied to create/update a Managed Network Peering Policy +// resourceGroupName - the name of the resource group. +// managedNetworkName - the name of the Managed Network. +// managedNetworkPeeringPolicyName - the name of the Managed Network Peering Policy. +func (client PeeringPoliciesClient) CreateOrUpdate(ctx context.Context, managedNetworkPolicy PeeringPolicy, resourceGroupName string, managedNetworkName string, managedNetworkPeeringPolicyName string) (result PeeringPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, managedNetworkPolicy, resourceGroupName, managedNetworkName, managedNetworkPeeringPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PeeringPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, managedNetworkPolicy PeeringPolicy, resourceGroupName string, managedNetworkName string, managedNetworkPeeringPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedNetworkName": autorest.Encode("path", managedNetworkName), + "managedNetworkPeeringPolicyName": autorest.Encode("path", managedNetworkPeeringPolicyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}", pathParameters), + autorest.WithJSON(managedNetworkPolicy), + 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 PeeringPoliciesClient) CreateOrUpdateSender(req *http.Request) (future PeeringPoliciesCreateOrUpdateFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 PeeringPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result PeeringPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the Delete ManagedNetworkPeeringPolicies operation deletes a Managed Network Peering Policy, specified by the +// resource group, Managed Network name, and peering policy name +// Parameters: +// resourceGroupName - the name of the resource group. +// managedNetworkName - the name of the Managed Network. +// managedNetworkPeeringPolicyName - the name of the Managed Network Peering Policy. +func (client PeeringPoliciesClient) Delete(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkPeeringPolicyName string) (result PeeringPoliciesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringPoliciesClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedNetworkName, managedNetworkPeeringPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PeeringPoliciesClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkPeeringPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedNetworkName": autorest.Encode("path", managedNetworkName), + "managedNetworkPeeringPolicyName": autorest.Encode("path", managedNetworkPeeringPolicyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}", 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 PeeringPoliciesClient) DeleteSender(req *http.Request) (future PeeringPoliciesDeleteFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 PeeringPoliciesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get the Get ManagedNetworkPeeringPolicies operation gets a Managed Network Peering Policy resource, specified by the +// resource group, Managed Network name, and peering policy name +// Parameters: +// resourceGroupName - the name of the resource group. +// managedNetworkName - the name of the Managed Network. +// managedNetworkPeeringPolicyName - the name of the Managed Network Peering Policy. +func (client PeeringPoliciesClient) Get(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkPeeringPolicyName string) (result PeeringPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedNetworkName, managedNetworkPeeringPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PeeringPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkPeeringPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedNetworkName": autorest.Encode("path", managedNetworkName), + "managedNetworkPeeringPolicyName": autorest.Encode("path", managedNetworkPeeringPolicyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}", 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 PeeringPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PeeringPoliciesClient) GetResponder(resp *http.Response) (result PeeringPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByManagedNetwork the ListByManagedNetwork PeeringPolicies operation retrieves all the Managed Network Peering +// Policies in a specified Managed Network, in a paginated format. +// Parameters: +// resourceGroupName - the name of the resource group. +// managedNetworkName - the name of the Managed Network. +// top - may be used to limit the number of results in a page for list queries. +// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response +// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that +// specifies a starting point to use for subsequent calls. +func (client PeeringPoliciesClient) ListByManagedNetwork(ctx context.Context, resourceGroupName string, managedNetworkName string, top *int32, skiptoken string) (result PeeringPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringPoliciesClient.ListByManagedNetwork") + defer func() { + sc := -1 + if result.pplr.Response.Response != nil { + sc = result.pplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(20), Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("managednetwork.PeeringPoliciesClient", "ListByManagedNetwork", err.Error()) + } + + result.fn = client.listByManagedNetworkNextResults + req, err := client.ListByManagedNetworkPreparer(ctx, resourceGroupName, managedNetworkName, top, skiptoken) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "ListByManagedNetwork", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagedNetworkSender(req) + if err != nil { + result.pplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "ListByManagedNetwork", resp, "Failure sending request") + return + } + + result.pplr, err = client.ListByManagedNetworkResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "ListByManagedNetwork", resp, "Failure responding to request") + } + + return +} + +// ListByManagedNetworkPreparer prepares the ListByManagedNetwork request. +func (client PeeringPoliciesClient) ListByManagedNetworkPreparer(ctx context.Context, resourceGroupName string, managedNetworkName string, top *int32, skiptoken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedNetworkName": autorest.Encode("path", managedNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByManagedNetworkSender sends the ListByManagedNetwork request. The method will close the +// http.Response Body if it receives an error. +func (client PeeringPoliciesClient) ListByManagedNetworkSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByManagedNetworkResponder handles the response to the ListByManagedNetwork request. The method always +// closes the http.Response Body. +func (client PeeringPoliciesClient) ListByManagedNetworkResponder(resp *http.Response) (result PeeringPolicyListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByManagedNetworkNextResults retrieves the next set of results, if any. +func (client PeeringPoliciesClient) listByManagedNetworkNextResults(ctx context.Context, lastResults PeeringPolicyListResult) (result PeeringPolicyListResult, err error) { + req, err := lastResults.peeringPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "listByManagedNetworkNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByManagedNetworkSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "listByManagedNetworkNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByManagedNetworkResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.PeeringPoliciesClient", "listByManagedNetworkNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByManagedNetworkComplete enumerates all values, automatically crossing page boundaries as required. +func (client PeeringPoliciesClient) ListByManagedNetworkComplete(ctx context.Context, resourceGroupName string, managedNetworkName string, top *int32, skiptoken string) (result PeeringPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringPoliciesClient.ListByManagedNetwork") + 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.ListByManagedNetwork(ctx, resourceGroupName, managedNetworkName, top, skiptoken) + return +} diff --git a/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/scopeassignments.go b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/scopeassignments.go new file mode 100644 index 000000000000..0c4741c9de5b --- /dev/null +++ b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/scopeassignments.go @@ -0,0 +1,389 @@ +package managednetwork + +// 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" +) + +// ScopeAssignmentsClient is the the Microsoft Azure Managed Network management API provides a RESTful set of web +// services that interact with Microsoft Azure Networks service to programmatically view, control, change, and monitor +// your entire Azure network centrally and with ease. +type ScopeAssignmentsClient struct { + BaseClient +} + +// NewScopeAssignmentsClient creates an instance of the ScopeAssignmentsClient client. +func NewScopeAssignmentsClient(subscriptionID string) ScopeAssignmentsClient { + return NewScopeAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewScopeAssignmentsClientWithBaseURI creates an instance of the ScopeAssignmentsClient client. +func NewScopeAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) ScopeAssignmentsClient { + return ScopeAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a scope assignment. +// Parameters: +// parameters - parameters supplied to the specify which Managed Network this scope is being assigned +// scope - the base resource of the scope assignment to create. The scope can be any REST resource instance. +// For example, use '/subscriptions/{subscription-id}/' for a subscription, +// '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and +// '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' +// for a resource. +// scopeAssignmentName - the name of the scope assignment to create. +func (client ScopeAssignmentsClient) CreateOrUpdate(ctx context.Context, parameters ScopeAssignment, scope string, scopeAssignmentName string) (result ScopeAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScopeAssignmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, parameters, scope, scopeAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ScopeAssignmentsClient) CreateOrUpdatePreparer(ctx context.Context, parameters ScopeAssignment, scope string, scopeAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + "scopeAssignmentName": autorest.Encode("path", scopeAssignmentName), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments/{scopeAssignmentName}", pathParameters), + autorest.WithJSON(parameters), + 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 ScopeAssignmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ScopeAssignmentsClient) CreateOrUpdateResponder(resp *http.Response) (result ScopeAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a scope assignment. +// Parameters: +// scope - the scope of the scope assignment to delete. +// scopeAssignmentName - the name of the scope assignment to delete. +func (client ScopeAssignmentsClient) Delete(ctx context.Context, scope string, scopeAssignmentName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScopeAssignmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, scope, scopeAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ScopeAssignmentsClient) DeletePreparer(ctx context.Context, scope string, scopeAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + "scopeAssignmentName": autorest.Encode("path", scopeAssignmentName), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments/{scopeAssignmentName}", 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 ScopeAssignmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ScopeAssignmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the specified scope assignment. +// Parameters: +// scope - the base resource of the scope assignment. +// scopeAssignmentName - the name of the scope assignment to get. +func (client ScopeAssignmentsClient) Get(ctx context.Context, scope string, scopeAssignmentName string) (result ScopeAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScopeAssignmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, scope, scopeAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ScopeAssignmentsClient) GetPreparer(ctx context.Context, scope string, scopeAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + "scopeAssignmentName": autorest.Encode("path", scopeAssignmentName), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments/{scopeAssignmentName}", 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 ScopeAssignmentsClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ScopeAssignmentsClient) GetResponder(resp *http.Response) (result ScopeAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get the specified scope assignment. +// Parameters: +// scope - the base resource of the scope assignment. +func (client ScopeAssignmentsClient) List(ctx context.Context, scope string) (result ScopeAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScopeAssignmentsClient.List") + defer func() { + sc := -1 + if result.salr.Response.Response != nil { + sc = result.salr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.salr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "List", resp, "Failure sending request") + return + } + + result.salr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ScopeAssignmentsClient) ListPreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.ManagedNetwork/scopeAssignments", 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 ScopeAssignmentsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ScopeAssignmentsClient) ListResponder(resp *http.Response) (result ScopeAssignmentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 ScopeAssignmentsClient) listNextResults(ctx context.Context, lastResults ScopeAssignmentListResult) (result ScopeAssignmentListResult, err error) { + req, err := lastResults.scopeAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "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, "managednetwork.ScopeAssignmentsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managednetwork.ScopeAssignmentsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ScopeAssignmentsClient) ListComplete(ctx context.Context, scope string) (result ScopeAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScopeAssignmentsClient.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, scope) + return +} diff --git a/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/version.go b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/version.go new file mode 100644 index 000000000000..4924dee61437 --- /dev/null +++ b/services/preview/managednetwork/mgmt/2019-06-01-preview/managednetwork/version.go @@ -0,0 +1,30 @@ +package managednetwork + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " managednetwork/2019-06-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}