From bbda6a0c9b902ef1a50cab61989ce65fc9951ff4 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 26 Aug 2019 21:38:37 -0700 Subject: [PATCH] Generated from 65b2f8a37695f3d9cf53c50a05a61c4179857199 (#5605) updated readme with correct version. --- .../preview/peering/mgmt/peering/models.go | 134 +- .../peering/mgmt/peering/peeringapi/models.go | 8 +- .../mgmt/2019-08-01-preview/peering/client.go | 133 + .../peering/legacypeerings.go | 156 ++ .../2019-08-01-preview/peering/locations.go | 158 ++ .../mgmt/2019-08-01-preview/peering/models.go | 2399 +++++++++++++++++ .../2019-08-01-preview/peering/operations.go | 147 + .../2019-08-01-preview/peering/peerasns.go | 379 +++ .../peering/peeringapi/interfaces.go | 116 + .../2019-08-01-preview/peering/peerings.go | 586 ++++ .../2019-08-01-preview/peering/prefixes.go | 156 ++ .../peering/servicelocations.go | 151 ++ .../peering/serviceprefixes.go | 280 ++ .../peering/serviceproviders.go | 151 ++ .../2019-08-01-preview/peering/services.go | 585 ++++ .../2019-08-01-preview/peering/version.go | 30 + 16 files changed, 5567 insertions(+), 2 deletions(-) create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/client.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/legacypeerings.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/locations.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/models.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/operations.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/peerasns.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/peeringapi/interfaces.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/peerings.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/prefixes.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/servicelocations.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/serviceprefixes.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/serviceproviders.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/services.go create mode 100644 services/preview/peering/mgmt/2019-08-01-preview/peering/version.go diff --git a/profiles/preview/preview/peering/mgmt/peering/models.go b/profiles/preview/preview/peering/mgmt/peering/models.go index 944d06af4fc5..cabe32ebf48e 100644 --- a/profiles/preview/preview/peering/mgmt/peering/models.go +++ b/profiles/preview/preview/peering/mgmt/peering/models.go @@ -22,7 +22,7 @@ package peering import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/preview/peering/mgmt/2019-03-01-preview/peering" + original "github.com/Azure/azure-sdk-for-go/services/preview/peering/mgmt/2019-08-01-preview/peering" ) const ( @@ -42,6 +42,15 @@ const ( Validating ConnectionState = original.Validating ) +type DirectPeeringType = original.DirectPeeringType + +const ( + Cdn DirectPeeringType = original.Cdn + Edge DirectPeeringType = original.Edge + Internal DirectPeeringType = original.Internal + Transit DirectPeeringType = original.Transit +) + type Family = original.Family const ( @@ -56,15 +65,36 @@ const ( KindExchange Kind = original.KindExchange ) +type LearnedType = original.LearnedType + +const ( + LearnedTypeNone LearnedType = original.LearnedTypeNone + LearnedTypeViaPartner LearnedType = original.LearnedTypeViaPartner + LearnedTypeViaSession LearnedType = original.LearnedTypeViaSession +) + type Name = original.Name const ( BasicDirectFree Name = original.BasicDirectFree BasicExchangeFree Name = original.BasicExchangeFree PremiumDirectFree Name = original.PremiumDirectFree + PremiumDirectMetered Name = original.PremiumDirectMetered + PremiumDirectUnlimited Name = original.PremiumDirectUnlimited PremiumExchangeMetered Name = original.PremiumExchangeMetered ) +type PrefixValidationState = original.PrefixValidationState + +const ( + PrefixValidationStateFailed PrefixValidationState = original.PrefixValidationStateFailed + PrefixValidationStateInvalid PrefixValidationState = original.PrefixValidationStateInvalid + PrefixValidationStateNone PrefixValidationState = original.PrefixValidationStateNone + PrefixValidationStatePending PrefixValidationState = original.PrefixValidationStatePending + PrefixValidationStateUnknown PrefixValidationState = original.PrefixValidationStateUnknown + PrefixValidationStateVerified PrefixValidationState = original.PrefixValidationStateVerified +) + type ProvisioningState = original.ProvisioningState const ( @@ -74,6 +104,13 @@ const ( Updating ProvisioningState = original.Updating ) +type SessionAddressProvider = original.SessionAddressProvider + +const ( + Microsoft SessionAddressProvider = original.Microsoft + Peer SessionAddressProvider = original.Peer +) + type SessionStateV4 = original.SessionStateV4 const ( @@ -83,6 +120,7 @@ const ( SessionStateV4Idle SessionStateV4 = original.SessionStateV4Idle SessionStateV4None SessionStateV4 = original.SessionStateV4None SessionStateV4OpenConfirm SessionStateV4 = original.SessionStateV4OpenConfirm + SessionStateV4OpenReceived SessionStateV4 = original.SessionStateV4OpenReceived SessionStateV4OpenSent SessionStateV4 = original.SessionStateV4OpenSent SessionStateV4PendingAdd SessionStateV4 = original.SessionStateV4PendingAdd SessionStateV4PendingRemove SessionStateV4 = original.SessionStateV4PendingRemove @@ -98,6 +136,7 @@ const ( SessionStateV6Idle SessionStateV6 = original.SessionStateV6Idle SessionStateV6None SessionStateV6 = original.SessionStateV6None SessionStateV6OpenConfirm SessionStateV6 = original.SessionStateV6OpenConfirm + SessionStateV6OpenReceived SessionStateV6 = original.SessionStateV6OpenReceived SessionStateV6OpenSent SessionStateV6 = original.SessionStateV6OpenSent SessionStateV6PendingAdd SessionStateV6 = original.SessionStateV6PendingAdd SessionStateV6PendingRemove SessionStateV6 = original.SessionStateV6PendingRemove @@ -131,6 +170,7 @@ const ( type BandwidthOffer = original.BandwidthOffer type BaseClient = original.BaseClient type BgpSession = original.BgpSession +type CheckServiceProviderAvailabilityInput = original.CheckServiceProviderAvailabilityInput type ContactInfo = original.ContactInfo type DirectConnection = original.DirectConnection type DirectPeeringFacility = original.DirectPeeringFacility @@ -163,12 +203,38 @@ type PeerAsnListResultPage = original.PeerAsnListResultPage type PeerAsnProperties = original.PeerAsnProperties type PeerAsnsClient = original.PeerAsnsClient type PeeringsClient = original.PeeringsClient +type PrefixesClient = original.PrefixesClient type Properties = original.Properties type PropertiesDirect = original.PropertiesDirect type PropertiesExchange = original.PropertiesExchange type Resource = original.Resource type ResourceTags = original.ResourceTags +type Service = original.Service +type ServiceListResult = original.ServiceListResult +type ServiceListResultIterator = original.ServiceListResultIterator +type ServiceListResultPage = original.ServiceListResultPage +type ServiceLocation = original.ServiceLocation +type ServiceLocationListResult = original.ServiceLocationListResult +type ServiceLocationListResultIterator = original.ServiceLocationListResultIterator +type ServiceLocationListResultPage = original.ServiceLocationListResultPage +type ServiceLocationProperties = original.ServiceLocationProperties +type ServiceLocationsClient = original.ServiceLocationsClient +type ServicePrefix = original.ServicePrefix +type ServicePrefixListResult = original.ServicePrefixListResult +type ServicePrefixListResultIterator = original.ServicePrefixListResultIterator +type ServicePrefixListResultPage = original.ServicePrefixListResultPage +type ServicePrefixProperties = original.ServicePrefixProperties +type ServicePrefixesClient = original.ServicePrefixesClient +type ServiceProperties = original.ServiceProperties +type ServiceProvider = original.ServiceProvider +type ServiceProviderListResult = original.ServiceProviderListResult +type ServiceProviderListResultIterator = original.ServiceProviderListResultIterator +type ServiceProviderListResultPage = original.ServiceProviderListResultPage +type ServiceProviderProperties = original.ServiceProviderProperties +type ServiceProvidersClient = original.ServiceProvidersClient +type ServicesClient = original.ServicesClient type Sku = original.Sku +type String = original.String type SubResource = original.SubResource func New(subscriptionID string) BaseClient { @@ -228,24 +294,90 @@ func NewPeeringsClient(subscriptionID string) PeeringsClient { func NewPeeringsClientWithBaseURI(baseURI string, subscriptionID string) PeeringsClient { return original.NewPeeringsClientWithBaseURI(baseURI, subscriptionID) } +func NewPrefixesClient(subscriptionID string) PrefixesClient { + return original.NewPrefixesClient(subscriptionID) +} +func NewPrefixesClientWithBaseURI(baseURI string, subscriptionID string) PrefixesClient { + return original.NewPrefixesClientWithBaseURI(baseURI, subscriptionID) +} +func NewServiceListResultIterator(page ServiceListResultPage) ServiceListResultIterator { + return original.NewServiceListResultIterator(page) +} +func NewServiceListResultPage(getNextPage func(context.Context, ServiceListResult) (ServiceListResult, error)) ServiceListResultPage { + return original.NewServiceListResultPage(getNextPage) +} +func NewServiceLocationListResultIterator(page ServiceLocationListResultPage) ServiceLocationListResultIterator { + return original.NewServiceLocationListResultIterator(page) +} +func NewServiceLocationListResultPage(getNextPage func(context.Context, ServiceLocationListResult) (ServiceLocationListResult, error)) ServiceLocationListResultPage { + return original.NewServiceLocationListResultPage(getNextPage) +} +func NewServiceLocationsClient(subscriptionID string) ServiceLocationsClient { + return original.NewServiceLocationsClient(subscriptionID) +} +func NewServiceLocationsClientWithBaseURI(baseURI string, subscriptionID string) ServiceLocationsClient { + return original.NewServiceLocationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewServicePrefixListResultIterator(page ServicePrefixListResultPage) ServicePrefixListResultIterator { + return original.NewServicePrefixListResultIterator(page) +} +func NewServicePrefixListResultPage(getNextPage func(context.Context, ServicePrefixListResult) (ServicePrefixListResult, error)) ServicePrefixListResultPage { + return original.NewServicePrefixListResultPage(getNextPage) +} +func NewServicePrefixesClient(subscriptionID string) ServicePrefixesClient { + return original.NewServicePrefixesClient(subscriptionID) +} +func NewServicePrefixesClientWithBaseURI(baseURI string, subscriptionID string) ServicePrefixesClient { + return original.NewServicePrefixesClientWithBaseURI(baseURI, subscriptionID) +} +func NewServiceProviderListResultIterator(page ServiceProviderListResultPage) ServiceProviderListResultIterator { + return original.NewServiceProviderListResultIterator(page) +} +func NewServiceProviderListResultPage(getNextPage func(context.Context, ServiceProviderListResult) (ServiceProviderListResult, error)) ServiceProviderListResultPage { + return original.NewServiceProviderListResultPage(getNextPage) +} +func NewServiceProvidersClient(subscriptionID string) ServiceProvidersClient { + return original.NewServiceProvidersClient(subscriptionID) +} +func NewServiceProvidersClientWithBaseURI(baseURI string, subscriptionID string) ServiceProvidersClient { + return original.NewServiceProvidersClientWithBaseURI(baseURI, subscriptionID) +} +func NewServicesClient(subscriptionID string) ServicesClient { + return original.NewServicesClient(subscriptionID) +} +func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient { + return original.NewServicesClientWithBaseURI(baseURI, subscriptionID) +} func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } func PossibleConnectionStateValues() []ConnectionState { return original.PossibleConnectionStateValues() } +func PossibleDirectPeeringTypeValues() []DirectPeeringType { + return original.PossibleDirectPeeringTypeValues() +} func PossibleFamilyValues() []Family { return original.PossibleFamilyValues() } func PossibleKindValues() []Kind { return original.PossibleKindValues() } +func PossibleLearnedTypeValues() []LearnedType { + return original.PossibleLearnedTypeValues() +} func PossibleNameValues() []Name { return original.PossibleNameValues() } +func PossiblePrefixValidationStateValues() []PrefixValidationState { + return original.PossiblePrefixValidationStateValues() +} func PossibleProvisioningStateValues() []ProvisioningState { return original.PossibleProvisioningStateValues() } +func PossibleSessionAddressProviderValues() []SessionAddressProvider { + return original.PossibleSessionAddressProviderValues() +} func PossibleSessionStateV4Values() []SessionStateV4 { return original.PossibleSessionStateV4Values() } diff --git a/profiles/preview/preview/peering/mgmt/peering/peeringapi/models.go b/profiles/preview/preview/peering/mgmt/peering/peeringapi/models.go index 8a6e6b8888c5..d3fea5f8eafa 100644 --- a/profiles/preview/preview/peering/mgmt/peering/peeringapi/models.go +++ b/profiles/preview/preview/peering/mgmt/peering/peeringapi/models.go @@ -19,10 +19,16 @@ package peeringapi -import original "github.com/Azure/azure-sdk-for-go/services/preview/peering/mgmt/2019-03-01-preview/peering/peeringapi" +import original "github.com/Azure/azure-sdk-for-go/services/preview/peering/mgmt/2019-08-01-preview/peering/peeringapi" +type BaseClientAPI = original.BaseClientAPI type LegacyPeeringsClientAPI = original.LegacyPeeringsClientAPI type LocationsClientAPI = original.LocationsClientAPI type OperationsClientAPI = original.OperationsClientAPI type PeerAsnsClientAPI = original.PeerAsnsClientAPI type PeeringsClientAPI = original.PeeringsClientAPI +type PrefixesClientAPI = original.PrefixesClientAPI +type ServiceLocationsClientAPI = original.ServiceLocationsClientAPI +type ServicePrefixesClientAPI = original.ServicePrefixesClientAPI +type ServiceProvidersClientAPI = original.ServiceProvidersClientAPI +type ServicesClientAPI = original.ServicesClientAPI diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/client.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/client.go new file mode 100644 index 000000000000..b221a50435f4 --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/client.go @@ -0,0 +1,133 @@ +// Package peering implements the Azure ARM Peering service API version 2019-08-01-preview. +// +// Peering Client +package peering + +// 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" +) + +const ( + // DefaultBaseURI is the default URI used for the service Peering + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Peering. +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, + } +} + +// CheckServiceProviderAvailability checks if the peering service provider is present within 1000 miles of customer's +// location +// Parameters: +// checkServiceProviderAvailabilityInput - the CheckServiceProviderAvailabilityInput indicating customer +// location and service provider. +func (client BaseClient) CheckServiceProviderAvailability(ctx context.Context, checkServiceProviderAvailabilityInput CheckServiceProviderAvailabilityInput) (result String, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.CheckServiceProviderAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CheckServiceProviderAvailabilityPreparer(ctx, checkServiceProviderAvailabilityInput) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.BaseClient", "CheckServiceProviderAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckServiceProviderAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.BaseClient", "CheckServiceProviderAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckServiceProviderAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.BaseClient", "CheckServiceProviderAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckServiceProviderAvailabilityPreparer prepares the CheckServiceProviderAvailability request. +func (client BaseClient) CheckServiceProviderAvailabilityPreparer(ctx context.Context, checkServiceProviderAvailabilityInput CheckServiceProviderAvailabilityInput) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/CheckServiceProviderAvailability", pathParameters), + autorest.WithJSON(checkServiceProviderAvailabilityInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckServiceProviderAvailabilitySender sends the CheckServiceProviderAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) CheckServiceProviderAvailabilitySender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CheckServiceProviderAvailabilityResponder handles the response to the CheckServiceProviderAvailability request. The method always +// closes the http.Response Body. +func (client BaseClient) CheckServiceProviderAvailabilityResponder(resp *http.Response) (result String, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/legacypeerings.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/legacypeerings.go new file mode 100644 index 000000000000..bbb540643822 --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/legacypeerings.go @@ -0,0 +1,156 @@ +package peering + +// 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" +) + +// LegacyPeeringsClient is the peering Client +type LegacyPeeringsClient struct { + BaseClient +} + +// NewLegacyPeeringsClient creates an instance of the LegacyPeeringsClient client. +func NewLegacyPeeringsClient(subscriptionID string) LegacyPeeringsClient { + return NewLegacyPeeringsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLegacyPeeringsClientWithBaseURI creates an instance of the LegacyPeeringsClient client. +func NewLegacyPeeringsClientWithBaseURI(baseURI string, subscriptionID string) LegacyPeeringsClient { + return LegacyPeeringsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the legacy peerings under the given subscription matching the specified kind and location. +// Parameters: +// peeringLocation - the location of the peering. +// kind - the kind of the peering. +func (client LegacyPeeringsClient) List(ctx context.Context, peeringLocation string, kind string) (result ListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LegacyPeeringsClient.List") + defer func() { + sc := -1 + if result.lr.Response.Response != nil { + sc = result.lr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, peeringLocation, kind) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.LegacyPeeringsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.lr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.LegacyPeeringsClient", "List", resp, "Failure sending request") + return + } + + result.lr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.LegacyPeeringsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client LegacyPeeringsClient) ListPreparer(ctx context.Context, peeringLocation string, kind string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "kind": autorest.Encode("query", kind), + "peeringLocation": autorest.Encode("query", peeringLocation), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/legacyPeerings", 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 LegacyPeeringsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LegacyPeeringsClient) ListResponder(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 +} + +// listNextResults retrieves the next set of results, if any. +func (client LegacyPeeringsClient) listNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) { + req, err := lastResults.listResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.LegacyPeeringsClient", "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, "peering.LegacyPeeringsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.LegacyPeeringsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client LegacyPeeringsClient) ListComplete(ctx context.Context, peeringLocation string, kind string) (result ListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LegacyPeeringsClient.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, peeringLocation, kind) + return +} diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/locations.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/locations.go new file mode 100644 index 000000000000..c77b5576f293 --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/locations.go @@ -0,0 +1,158 @@ +package peering + +// 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" +) + +// LocationsClient is the peering Client +type LocationsClient struct { + BaseClient +} + +// NewLocationsClient creates an instance of the LocationsClient client. +func NewLocationsClient(subscriptionID string) LocationsClient { + return NewLocationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLocationsClientWithBaseURI creates an instance of the LocationsClient client. +func NewLocationsClientWithBaseURI(baseURI string, subscriptionID string) LocationsClient { + return LocationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available peering locations for the specified kind of peering. +// Parameters: +// kind - the kind of the peering. +// directPeeringType - the type of direct peering. +func (client LocationsClient) List(ctx context.Context, kind string, directPeeringType string) (result LocationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.List") + defer func() { + sc := -1 + if result.llr.Response.Response != nil { + sc = result.llr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, kind, directPeeringType) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.LocationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.llr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.LocationsClient", "List", resp, "Failure sending request") + return + } + + result.llr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.LocationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client LocationsClient) ListPreparer(ctx context.Context, kind string, directPeeringType string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "kind": autorest.Encode("query", kind), + } + if len(string(directPeeringType)) > 0 { + queryParameters["directPeeringType"] = autorest.Encode("query", directPeeringType) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringLocations", 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 LocationsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LocationsClient) ListResponder(resp *http.Response) (result LocationListResult, 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 LocationsClient) listNextResults(ctx context.Context, lastResults LocationListResult) (result LocationListResult, err error) { + req, err := lastResults.locationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.LocationsClient", "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, "peering.LocationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.LocationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client LocationsClient) ListComplete(ctx context.Context, kind string, directPeeringType string) (result LocationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.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, kind, directPeeringType) + return +} diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/models.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/models.go new file mode 100644 index 000000000000..676d8b5b540a --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/models.go @@ -0,0 +1,2399 @@ +package peering + +// 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/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/peering/mgmt/2019-08-01-preview/peering" + +// ConnectionState enumerates the values for connection state. +type ConnectionState string + +const ( + // Active ... + Active ConnectionState = "Active" + // Approved ... + Approved ConnectionState = "Approved" + // None ... + None ConnectionState = "None" + // PendingApproval ... + PendingApproval ConnectionState = "PendingApproval" + // ProvisioningCompleted ... + ProvisioningCompleted ConnectionState = "ProvisioningCompleted" + // ProvisioningFailed ... + ProvisioningFailed ConnectionState = "ProvisioningFailed" + // ProvisioningStarted ... + ProvisioningStarted ConnectionState = "ProvisioningStarted" + // Validating ... + Validating ConnectionState = "Validating" +) + +// PossibleConnectionStateValues returns an array of possible values for the ConnectionState const type. +func PossibleConnectionStateValues() []ConnectionState { + return []ConnectionState{Active, Approved, None, PendingApproval, ProvisioningCompleted, ProvisioningFailed, ProvisioningStarted, Validating} +} + +// DirectPeeringType enumerates the values for direct peering type. +type DirectPeeringType string + +const ( + // Cdn ... + Cdn DirectPeeringType = "Cdn" + // Edge ... + Edge DirectPeeringType = "Edge" + // Internal ... + Internal DirectPeeringType = "Internal" + // Transit ... + Transit DirectPeeringType = "Transit" +) + +// PossibleDirectPeeringTypeValues returns an array of possible values for the DirectPeeringType const type. +func PossibleDirectPeeringTypeValues() []DirectPeeringType { + return []DirectPeeringType{Cdn, Edge, Internal, Transit} +} + +// Family enumerates the values for family. +type Family string + +const ( + // Direct ... + Direct Family = "Direct" + // Exchange ... + Exchange Family = "Exchange" +) + +// PossibleFamilyValues returns an array of possible values for the Family const type. +func PossibleFamilyValues() []Family { + return []Family{Direct, Exchange} +} + +// Kind enumerates the values for kind. +type Kind string + +const ( + // KindDirect ... + KindDirect Kind = "Direct" + // KindExchange ... + KindExchange Kind = "Exchange" +) + +// PossibleKindValues returns an array of possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{KindDirect, KindExchange} +} + +// LearnedType enumerates the values for learned type. +type LearnedType string + +const ( + // LearnedTypeNone ... + LearnedTypeNone LearnedType = "None" + // LearnedTypeViaPartner ... + LearnedTypeViaPartner LearnedType = "ViaPartner" + // LearnedTypeViaSession ... + LearnedTypeViaSession LearnedType = "ViaSession" +) + +// PossibleLearnedTypeValues returns an array of possible values for the LearnedType const type. +func PossibleLearnedTypeValues() []LearnedType { + return []LearnedType{LearnedTypeNone, LearnedTypeViaPartner, LearnedTypeViaSession} +} + +// Name enumerates the values for name. +type Name string + +const ( + // BasicDirectFree ... + BasicDirectFree Name = "Basic_Direct_Free" + // BasicExchangeFree ... + BasicExchangeFree Name = "Basic_Exchange_Free" + // PremiumDirectFree ... + PremiumDirectFree Name = "Premium_Direct_Free" + // PremiumDirectMetered ... + PremiumDirectMetered Name = "Premium_Direct_Metered" + // PremiumDirectUnlimited ... + PremiumDirectUnlimited Name = "Premium_Direct_Unlimited" + // PremiumExchangeMetered ... + PremiumExchangeMetered Name = "Premium_Exchange_Metered" +) + +// PossibleNameValues returns an array of possible values for the Name const type. +func PossibleNameValues() []Name { + return []Name{BasicDirectFree, BasicExchangeFree, PremiumDirectFree, PremiumDirectMetered, PremiumDirectUnlimited, PremiumExchangeMetered} +} + +// PrefixValidationState enumerates the values for prefix validation state. +type PrefixValidationState string + +const ( + // PrefixValidationStateFailed ... + PrefixValidationStateFailed PrefixValidationState = "Failed" + // PrefixValidationStateInvalid ... + PrefixValidationStateInvalid PrefixValidationState = "Invalid" + // PrefixValidationStateNone ... + PrefixValidationStateNone PrefixValidationState = "None" + // PrefixValidationStatePending ... + PrefixValidationStatePending PrefixValidationState = "Pending" + // PrefixValidationStateUnknown ... + PrefixValidationStateUnknown PrefixValidationState = "Unknown" + // PrefixValidationStateVerified ... + PrefixValidationStateVerified PrefixValidationState = "Verified" +) + +// PossiblePrefixValidationStateValues returns an array of possible values for the PrefixValidationState const type. +func PossiblePrefixValidationStateValues() []PrefixValidationState { + return []PrefixValidationState{PrefixValidationStateFailed, PrefixValidationStateInvalid, PrefixValidationStateNone, PrefixValidationStatePending, PrefixValidationStateUnknown, PrefixValidationStateVerified} +} + +// 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} +} + +// SessionAddressProvider enumerates the values for session address provider. +type SessionAddressProvider string + +const ( + // Microsoft ... + Microsoft SessionAddressProvider = "Microsoft" + // Peer ... + Peer SessionAddressProvider = "Peer" +) + +// PossibleSessionAddressProviderValues returns an array of possible values for the SessionAddressProvider const type. +func PossibleSessionAddressProviderValues() []SessionAddressProvider { + return []SessionAddressProvider{Microsoft, Peer} +} + +// SessionStateV4 enumerates the values for session state v4. +type SessionStateV4 string + +const ( + // SessionStateV4Active ... + SessionStateV4Active SessionStateV4 = "Active" + // SessionStateV4Connect ... + SessionStateV4Connect SessionStateV4 = "Connect" + // SessionStateV4Established ... + SessionStateV4Established SessionStateV4 = "Established" + // SessionStateV4Idle ... + SessionStateV4Idle SessionStateV4 = "Idle" + // SessionStateV4None ... + SessionStateV4None SessionStateV4 = "None" + // SessionStateV4OpenConfirm ... + SessionStateV4OpenConfirm SessionStateV4 = "OpenConfirm" + // SessionStateV4OpenReceived ... + SessionStateV4OpenReceived SessionStateV4 = "OpenReceived" + // SessionStateV4OpenSent ... + SessionStateV4OpenSent SessionStateV4 = "OpenSent" + // SessionStateV4PendingAdd ... + SessionStateV4PendingAdd SessionStateV4 = "PendingAdd" + // SessionStateV4PendingRemove ... + SessionStateV4PendingRemove SessionStateV4 = "PendingRemove" + // SessionStateV4PendingUpdate ... + SessionStateV4PendingUpdate SessionStateV4 = "PendingUpdate" +) + +// PossibleSessionStateV4Values returns an array of possible values for the SessionStateV4 const type. +func PossibleSessionStateV4Values() []SessionStateV4 { + return []SessionStateV4{SessionStateV4Active, SessionStateV4Connect, SessionStateV4Established, SessionStateV4Idle, SessionStateV4None, SessionStateV4OpenConfirm, SessionStateV4OpenReceived, SessionStateV4OpenSent, SessionStateV4PendingAdd, SessionStateV4PendingRemove, SessionStateV4PendingUpdate} +} + +// SessionStateV6 enumerates the values for session state v6. +type SessionStateV6 string + +const ( + // SessionStateV6Active ... + SessionStateV6Active SessionStateV6 = "Active" + // SessionStateV6Connect ... + SessionStateV6Connect SessionStateV6 = "Connect" + // SessionStateV6Established ... + SessionStateV6Established SessionStateV6 = "Established" + // SessionStateV6Idle ... + SessionStateV6Idle SessionStateV6 = "Idle" + // SessionStateV6None ... + SessionStateV6None SessionStateV6 = "None" + // SessionStateV6OpenConfirm ... + SessionStateV6OpenConfirm SessionStateV6 = "OpenConfirm" + // SessionStateV6OpenReceived ... + SessionStateV6OpenReceived SessionStateV6 = "OpenReceived" + // SessionStateV6OpenSent ... + SessionStateV6OpenSent SessionStateV6 = "OpenSent" + // SessionStateV6PendingAdd ... + SessionStateV6PendingAdd SessionStateV6 = "PendingAdd" + // SessionStateV6PendingRemove ... + SessionStateV6PendingRemove SessionStateV6 = "PendingRemove" + // SessionStateV6PendingUpdate ... + SessionStateV6PendingUpdate SessionStateV6 = "PendingUpdate" +) + +// PossibleSessionStateV6Values returns an array of possible values for the SessionStateV6 const type. +func PossibleSessionStateV6Values() []SessionStateV6 { + return []SessionStateV6{SessionStateV6Active, SessionStateV6Connect, SessionStateV6Established, SessionStateV6Idle, SessionStateV6None, SessionStateV6OpenConfirm, SessionStateV6OpenReceived, SessionStateV6OpenSent, SessionStateV6PendingAdd, SessionStateV6PendingRemove, SessionStateV6PendingUpdate} +} + +// Size enumerates the values for size. +type Size string + +const ( + // Free ... + Free Size = "Free" + // Metered ... + Metered Size = "Metered" + // Unlimited ... + Unlimited Size = "Unlimited" +) + +// PossibleSizeValues returns an array of possible values for the Size const type. +func PossibleSizeValues() []Size { + return []Size{Free, Metered, Unlimited} +} + +// Tier enumerates the values for tier. +type Tier string + +const ( + // Basic ... + Basic Tier = "Basic" + // Premium ... + Premium Tier = "Premium" +) + +// PossibleTierValues returns an array of possible values for the Tier const type. +func PossibleTierValues() []Tier { + return []Tier{Basic, Premium} +} + +// ValidationState enumerates the values for validation state. +type ValidationState string + +const ( + // ValidationStateApproved ... + ValidationStateApproved ValidationState = "Approved" + // ValidationStateFailed ... + ValidationStateFailed ValidationState = "Failed" + // ValidationStateNone ... + ValidationStateNone ValidationState = "None" + // ValidationStatePending ... + ValidationStatePending ValidationState = "Pending" +) + +// PossibleValidationStateValues returns an array of possible values for the ValidationState const type. +func PossibleValidationStateValues() []ValidationState { + return []ValidationState{ValidationStateApproved, ValidationStateFailed, ValidationStateNone, ValidationStatePending} +} + +// BandwidthOffer the properties that define a peering bandwidth offer. +type BandwidthOffer struct { + // OfferName - The name of the bandwidth offer. + OfferName *string `json:"offerName,omitempty"` + // ValueInMbps - The value of the bandwidth offer in Mbps. + ValueInMbps *int32 `json:"valueInMbps,omitempty"` +} + +// BgpSession the properties that define a BGP session. +type BgpSession struct { + // SessionPrefixV4 - The IPv4 prefix that contains both ends' IPv4 addresses. + SessionPrefixV4 *string `json:"sessionPrefixV4,omitempty"` + // SessionPrefixV6 - The IPv6 prefix that contains both ends' IPv6 addresses. + SessionPrefixV6 *string `json:"sessionPrefixV6,omitempty"` + // MicrosoftSessionIPv4Address - READ-ONLY; The IPv4 session address on Microsoft's end. + MicrosoftSessionIPv4Address *string `json:"microsoftSessionIPv4Address,omitempty"` + // MicrosoftSessionIPv6Address - READ-ONLY; The IPv6 session address on Microsoft's end. + MicrosoftSessionIPv6Address *string `json:"microsoftSessionIPv6Address,omitempty"` + // PeerSessionIPv4Address - The IPv4 session address on peer's end. + PeerSessionIPv4Address *string `json:"peerSessionIPv4Address,omitempty"` + // PeerSessionIPv6Address - The IPv6 session address on peer's end. + PeerSessionIPv6Address *string `json:"peerSessionIPv6Address,omitempty"` + // SessionStateV4 - READ-ONLY; The state of the IPv4 session. Possible values include: 'SessionStateV4None', 'SessionStateV4Idle', 'SessionStateV4Connect', 'SessionStateV4Active', 'SessionStateV4OpenSent', 'SessionStateV4OpenConfirm', 'SessionStateV4OpenReceived', 'SessionStateV4Established', 'SessionStateV4PendingAdd', 'SessionStateV4PendingUpdate', 'SessionStateV4PendingRemove' + SessionStateV4 SessionStateV4 `json:"sessionStateV4,omitempty"` + // SessionStateV6 - READ-ONLY; The state of the IPv6 session. Possible values include: 'SessionStateV6None', 'SessionStateV6Idle', 'SessionStateV6Connect', 'SessionStateV6Active', 'SessionStateV6OpenSent', 'SessionStateV6OpenConfirm', 'SessionStateV6OpenReceived', 'SessionStateV6Established', 'SessionStateV6PendingAdd', 'SessionStateV6PendingUpdate', 'SessionStateV6PendingRemove' + SessionStateV6 SessionStateV6 `json:"sessionStateV6,omitempty"` + // MaxPrefixesAdvertisedV4 - The maximum number of prefixes advertised over the IPv4 session. + MaxPrefixesAdvertisedV4 *int32 `json:"maxPrefixesAdvertisedV4,omitempty"` + // MaxPrefixesAdvertisedV6 - The maximum number of prefixes advertised over the IPv6 session. + MaxPrefixesAdvertisedV6 *int32 `json:"maxPrefixesAdvertisedV6,omitempty"` + // Md5AuthenticationKey - The MD5 authentication key of the session. + Md5AuthenticationKey *string `json:"md5AuthenticationKey,omitempty"` +} + +// CheckServiceProviderAvailabilityInput class for CheckServiceProviderAvailabilityInput +type CheckServiceProviderAvailabilityInput struct { + // PeeringServiceLocation - Gets or sets the PeeringServiceLocation + PeeringServiceLocation *string `json:"peeringServiceLocation,omitempty"` + // PeeringServiceProvider - Gets or sets the PeeringServiceProvider + PeeringServiceProvider *string `json:"peeringServiceProvider,omitempty"` +} + +// ContactInfo the contact information of the peer. +type ContactInfo struct { + // Emails - The list of email addresses. + Emails *[]string `json:"emails,omitempty"` + // Phone - The list of contact numbers. + Phone *[]string `json:"phone,omitempty"` +} + +// DirectConnection the properties that define a direct connection. +type DirectConnection struct { + // BandwidthInMbps - The bandwidth of the connection. + BandwidthInMbps *int32 `json:"bandwidthInMbps,omitempty"` + // ProvisionedBandwidthInMbps - The bandwidth that is actually provisioned. + ProvisionedBandwidthInMbps *int32 `json:"provisionedBandwidthInMbps,omitempty"` + // SessionAddressProvider - The field indicating if Microsoft provides session ip addresses. Possible values include: 'Microsoft', 'Peer' + SessionAddressProvider SessionAddressProvider `json:"sessionAddressProvider,omitempty"` + // UseForPeeringService - The flag that indicates whether or not the connection is used for peering service. + UseForPeeringService *bool `json:"useForPeeringService,omitempty"` + // PeeringDBFacilityID - The PeeringDB.com ID of the facility at which the connection has to be set up. + PeeringDBFacilityID *int32 `json:"peeringDBFacilityId,omitempty"` + // ConnectionState - READ-ONLY; The state of the connection. Possible values include: 'None', 'PendingApproval', 'Approved', 'ProvisioningStarted', 'ProvisioningFailed', 'ProvisioningCompleted', 'Validating', 'Active' + ConnectionState ConnectionState `json:"connectionState,omitempty"` + // BgpSession - The BGP session associated with the connection. + BgpSession *BgpSession `json:"bgpSession,omitempty"` + // ConnectionIdentifier - The unique identifier (GUID) for the connection. + ConnectionIdentifier *string `json:"connectionIdentifier,omitempty"` +} + +// DirectPeeringFacility the properties that define a direct peering facility. +type DirectPeeringFacility struct { + // Address - The address of the direct peering facility. + Address *string `json:"address,omitempty"` + // DirectPeeringType - The type of the direct peering. Possible values include: 'Edge', 'Transit', 'Cdn', 'Internal' + DirectPeeringType DirectPeeringType `json:"directPeeringType,omitempty"` + // PeeringDBFacilityID - The PeeringDB.com ID of the facility. + PeeringDBFacilityID *int32 `json:"peeringDBFacilityId,omitempty"` + // PeeringDBFacilityLink - The PeeringDB.com URL of the facility. + PeeringDBFacilityLink *string `json:"peeringDBFacilityLink,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"` +} + +// ExchangeConnection the properties that define an exchange connection. +type ExchangeConnection struct { + // PeeringDBFacilityID - The PeeringDB.com ID of the facility at which the connection has to be set up. + PeeringDBFacilityID *int32 `json:"peeringDBFacilityId,omitempty"` + // ConnectionState - READ-ONLY; The state of the connection. Possible values include: 'None', 'PendingApproval', 'Approved', 'ProvisioningStarted', 'ProvisioningFailed', 'ProvisioningCompleted', 'Validating', 'Active' + ConnectionState ConnectionState `json:"connectionState,omitempty"` + // BgpSession - The BGP session associated with the connection. + BgpSession *BgpSession `json:"bgpSession,omitempty"` + // ConnectionIdentifier - The unique identifier (GUID) for the connection. + ConnectionIdentifier *string `json:"connectionIdentifier,omitempty"` +} + +// ExchangePeeringFacility the properties that define an exchange peering facility. +type ExchangePeeringFacility struct { + // ExchangeName - The name of the exchange peering facility. + ExchangeName *string `json:"exchangeName,omitempty"` + // BandwidthInMbps - The bandwidth of the connection between Microsoft and the exchange peering facility. + BandwidthInMbps *int32 `json:"bandwidthInMbps,omitempty"` + // MicrosoftIPv4Address - The IPv4 address of Microsoft at the exchange peering facility. + MicrosoftIPv4Address *string `json:"microsoftIPv4Address,omitempty"` + // MicrosoftIPv6Address - The IPv6 address of Microsoft at the exchange peering facility. + MicrosoftIPv6Address *string `json:"microsoftIPv6Address,omitempty"` + // FacilityIPv4Prefix - The IPv4 prefixes associated with the exchange peering facility. + FacilityIPv4Prefix *string `json:"facilityIPv4Prefix,omitempty"` + // FacilityIPv6Prefix - The IPv6 prefixes associated with the exchange peering facility. + FacilityIPv6Prefix *string `json:"facilityIPv6Prefix,omitempty"` + // PeeringDBFacilityID - The PeeringDB.com ID of the facility. + PeeringDBFacilityID *int32 `json:"peeringDBFacilityId,omitempty"` + // PeeringDBFacilityLink - The PeeringDB.com URL of the facility. + PeeringDBFacilityLink *string `json:"peeringDBFacilityLink,omitempty"` +} + +// ListResult the paginated list of peerings. +type ListResult struct { + autorest.Response `json:"-"` + // Value - The list of peerings. + Value *[]Model `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peerings. + NextLink *string `json:"nextLink,omitempty"` +} + +// ListResultIterator provides access to a complete listing of Model 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() Model { + if !iter.page.NotDone() { + return Model{} + } + 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 Model 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() []Model { + 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} +} + +// Location peering location is where connectivity could be established to the Microsoft Cloud Edge. +type Location struct { + // Kind - The kind of peering that the peering location supports. Possible values include: 'KindDirect', 'KindExchange' + Kind Kind `json:"kind,omitempty"` + // LocationProperties - The properties that define a peering location. + *LocationProperties `json:"properties,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; The ID of the resource. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Location. +func (l Location) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if l.Kind != "" { + objectMap["kind"] = l.Kind + } + if l.LocationProperties != nil { + objectMap["properties"] = l.LocationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Location struct. +func (l *Location) 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 "kind": + if v != nil { + var kind Kind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + l.Kind = kind + } + case "properties": + if v != nil { + var locationProperties LocationProperties + err = json.Unmarshal(*v, &locationProperties) + if err != nil { + return err + } + l.LocationProperties = &locationProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + l.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + l.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + l.Type = &typeVar + } + } + } + + return nil +} + +// LocationListResult the paginated list of peering locations. +type LocationListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering locations. + Value *[]Location `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering locations. + NextLink *string `json:"nextLink,omitempty"` +} + +// LocationListResultIterator provides access to a complete listing of Location values. +type LocationListResultIterator struct { + i int + page LocationListResultPage +} + +// 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 *LocationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationListResultIterator.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 *LocationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LocationListResultIterator) 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 LocationListResultIterator) Response() LocationListResult { + 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 LocationListResultIterator) Value() Location { + if !iter.page.NotDone() { + return Location{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the LocationListResultIterator type. +func NewLocationListResultIterator(page LocationListResultPage) LocationListResultIterator { + return LocationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (llr LocationListResult) IsEmpty() bool { + return llr.Value == nil || len(*llr.Value) == 0 +} + +// locationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (llr LocationListResult) locationListResultPreparer(ctx context.Context) (*http.Request, error) { + if llr.NextLink == nil || len(to.String(llr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(llr.NextLink))) +} + +// LocationListResultPage contains a page of Location values. +type LocationListResultPage struct { + fn func(context.Context, LocationListResult) (LocationListResult, error) + llr LocationListResult +} + +// 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 *LocationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationListResultPage.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.llr) + if err != nil { + return err + } + page.llr = 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 *LocationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LocationListResultPage) NotDone() bool { + return !page.llr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LocationListResultPage) Response() LocationListResult { + return page.llr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LocationListResultPage) Values() []Location { + if page.llr.IsEmpty() { + return nil + } + return *page.llr.Value +} + +// Creates a new instance of the LocationListResultPage type. +func NewLocationListResultPage(getNextPage func(context.Context, LocationListResult) (LocationListResult, error)) LocationListResultPage { + return LocationListResultPage{fn: getNextPage} +} + +// LocationProperties the properties that define a peering location. +type LocationProperties struct { + // Direct - The properties that define a direct peering location. + Direct *LocationPropertiesDirect `json:"direct,omitempty"` + // Exchange - The properties that define an exchange peering location. + Exchange *LocationPropertiesExchange `json:"exchange,omitempty"` + // PeeringLocation - The name of the peering location. + PeeringLocation *string `json:"peeringLocation,omitempty"` + // Country - The country in which the peering location exists. + Country *string `json:"country,omitempty"` + // AzureRegion - The Azure region associated with the peering location. + AzureRegion *string `json:"azureRegion,omitempty"` +} + +// LocationPropertiesDirect the properties that define a direct peering location. +type LocationPropertiesDirect struct { + // PeeringFacilities - The list of direct peering facilities at the peering location. + PeeringFacilities *[]DirectPeeringFacility `json:"peeringFacilities,omitempty"` + // BandwidthOffers - The list of bandwidth offers available at the peering location. + BandwidthOffers *[]BandwidthOffer `json:"bandwidthOffers,omitempty"` +} + +// LocationPropertiesExchange the properties that define an exchange peering location. +type LocationPropertiesExchange struct { + // PeeringFacilities - The list of exchange peering facilities at the peering location. + PeeringFacilities *[]ExchangePeeringFacility `json:"peeringFacilities,omitempty"` +} + +// Model peering is a logical representation of a set of connections to the Microsoft Cloud Edge at a +// location. +type Model struct { + autorest.Response `json:"-"` + // Sku - The SKU that defines the tier and kind of the peering. + Sku *Sku `json:"sku,omitempty"` + // Kind - The kind of the peering. Possible values include: 'KindDirect', 'KindExchange' + Kind Kind `json:"kind,omitempty"` + // Properties - The properties that define a peering. + *Properties `json:"properties,omitempty"` + // Location - The location of the resource. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; The ID of the resource. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Model. +func (mVar Model) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mVar.Sku != nil { + objectMap["sku"] = mVar.Sku + } + if mVar.Kind != "" { + objectMap["kind"] = mVar.Kind + } + if mVar.Properties != nil { + objectMap["properties"] = mVar.Properties + } + if mVar.Location != nil { + objectMap["location"] = mVar.Location + } + if mVar.Tags != nil { + objectMap["tags"] = mVar.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Model struct. +func (mVar *Model) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + mVar.Sku = &sku + } + case "kind": + if v != nil { + var kind Kind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + mVar.Kind = kind + } + case "properties": + if v != nil { + var properties Properties + err = json.Unmarshal(*v, &properties) + if err != nil { + return err + } + mVar.Properties = &properties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mVar.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mVar.Tags = tags + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mVar.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mVar.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mVar.Type = &typeVar + } + } + } + + return nil +} + +// Operation the peering API operation. +type Operation struct { + // Name - READ-ONLY; The name of the operation. + Name *string `json:"name,omitempty"` + // Display - READ-ONLY; The information related to the operation. + Display *OperationDisplayInfo `json:"display,omitempty"` + // IsDataAction - READ-ONLY; The flag that indicates whether the operation applies to data plane. + IsDataAction *bool `json:"isDataAction,omitempty"` +} + +// OperationDisplayInfo the information related to the operation. +type OperationDisplayInfo struct { + // Provider - READ-ONLY; The name of the resource provider. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; The type of the resource. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; The name of the operation. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; The description of the operation. + Description *string `json:"description,omitempty"` +} + +// OperationListResult the paginated list of peering API operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering API operations. + Value *[]Operation `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering API operations. + 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} +} + +// PeerAsn the essential information related to the peer's ASN. +type PeerAsn struct { + autorest.Response `json:"-"` + // PeerAsnProperties - The properties that define a peer's ASN. + *PeerAsnProperties `json:"properties,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; The ID of the resource. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PeerAsn. +func (pa PeerAsn) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pa.PeerAsnProperties != nil { + objectMap["properties"] = pa.PeerAsnProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PeerAsn struct. +func (pa *PeerAsn) 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 peerAsnProperties PeerAsnProperties + err = json.Unmarshal(*v, &peerAsnProperties) + if err != nil { + return err + } + pa.PeerAsnProperties = &peerAsnProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pa.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pa.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pa.Type = &typeVar + } + } + } + + return nil +} + +// PeerAsnListResult the paginated list of peer ASNs. +type PeerAsnListResult struct { + autorest.Response `json:"-"` + // Value - The list of peer ASNs. + Value *[]PeerAsn `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peer ASNs. + NextLink *string `json:"nextLink,omitempty"` +} + +// PeerAsnListResultIterator provides access to a complete listing of PeerAsn values. +type PeerAsnListResultIterator struct { + i int + page PeerAsnListResultPage +} + +// 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 *PeerAsnListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeerAsnListResultIterator.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 *PeerAsnListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PeerAsnListResultIterator) 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 PeerAsnListResultIterator) Response() PeerAsnListResult { + 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 PeerAsnListResultIterator) Value() PeerAsn { + if !iter.page.NotDone() { + return PeerAsn{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PeerAsnListResultIterator type. +func NewPeerAsnListResultIterator(page PeerAsnListResultPage) PeerAsnListResultIterator { + return PeerAsnListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (palr PeerAsnListResult) IsEmpty() bool { + return palr.Value == nil || len(*palr.Value) == 0 +} + +// peerAsnListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (palr PeerAsnListResult) peerAsnListResultPreparer(ctx context.Context) (*http.Request, error) { + if palr.NextLink == nil || len(to.String(palr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(palr.NextLink))) +} + +// PeerAsnListResultPage contains a page of PeerAsn values. +type PeerAsnListResultPage struct { + fn func(context.Context, PeerAsnListResult) (PeerAsnListResult, error) + palr PeerAsnListResult +} + +// 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 *PeerAsnListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeerAsnListResultPage.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.palr) + if err != nil { + return err + } + page.palr = 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 *PeerAsnListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PeerAsnListResultPage) NotDone() bool { + return !page.palr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PeerAsnListResultPage) Response() PeerAsnListResult { + return page.palr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PeerAsnListResultPage) Values() []PeerAsn { + if page.palr.IsEmpty() { + return nil + } + return *page.palr.Value +} + +// Creates a new instance of the PeerAsnListResultPage type. +func NewPeerAsnListResultPage(getNextPage func(context.Context, PeerAsnListResult) (PeerAsnListResult, error)) PeerAsnListResultPage { + return PeerAsnListResultPage{fn: getNextPage} +} + +// PeerAsnProperties the properties that define a peer's ASN. +type PeerAsnProperties struct { + // PeerAsn - The Autonomous System Number (ASN) of the peer. + PeerAsn *int32 `json:"peerAsn,omitempty"` + // PeerContactInfo - The contact information of the peer. + PeerContactInfo *ContactInfo `json:"peerContactInfo,omitempty"` + // PeerName - The name of the peer. + PeerName *string `json:"peerName,omitempty"` + // ValidationState - The validation state of the ASN associated with the peer. Possible values include: 'ValidationStateNone', 'ValidationStatePending', 'ValidationStateApproved', 'ValidationStateFailed' + ValidationState ValidationState `json:"validationState,omitempty"` +} + +// Properties the properties that define connectivity to the Microsoft Cloud Edge. +type Properties struct { + // Direct - The properties that define a direct peering. + Direct *PropertiesDirect `json:"direct,omitempty"` + // Exchange - The properties that define an exchange peering. + Exchange *PropertiesExchange `json:"exchange,omitempty"` + // PeeringLocation - The location of the peering. + PeeringLocation *string `json:"peeringLocation,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// PropertiesDirect the properties that define a direct peering. +type PropertiesDirect struct { + // Connections - The set of connections that constitute a direct peering. + Connections *[]DirectConnection `json:"connections,omitempty"` + // UseForPeeringService - The flag that indicates whether or not the peering is used for peering service. + UseForPeeringService *bool `json:"useForPeeringService,omitempty"` + // PeerAsn - The reference of the peer ASN. + PeerAsn *SubResource `json:"peerAsn,omitempty"` + // DirectPeeringType - The type of direct peering. Possible values include: 'Edge', 'Transit', 'Cdn', 'Internal' + DirectPeeringType DirectPeeringType `json:"directPeeringType,omitempty"` +} + +// PropertiesExchange the properties that define an exchange peering. +type PropertiesExchange struct { + // Connections - The set of connections that constitute an exchange peering. + Connections *[]ExchangeConnection `json:"connections,omitempty"` + // PeerAsn - The reference of the peer ASN. + PeerAsn *SubResource `json:"peerAsn,omitempty"` +} + +// Resource the ARM resource class. +type Resource struct { + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; The ID of the resource. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` +} + +// ResourceTags the resource tags. +type ResourceTags struct { + // Tags - Gets or sets the tags, a dictionary of descriptors arm object + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ResourceTags. +func (rt ResourceTags) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rt.Tags != nil { + objectMap["tags"] = rt.Tags + } + return json.Marshal(objectMap) +} + +// Service peering Service +type Service struct { + autorest.Response `json:"-"` + // ServiceProperties - The properties that define a peering service. + *ServiceProperties `json:"properties,omitempty"` + // Location - The location of the resource. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; The ID of the resource. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Service. +func (s Service) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.ServiceProperties != nil { + objectMap["properties"] = s.ServiceProperties + } + if s.Location != nil { + objectMap["location"] = s.Location + } + if s.Tags != nil { + objectMap["tags"] = s.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Service struct. +func (s *Service) 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 serviceProperties ServiceProperties + err = json.Unmarshal(*v, &serviceProperties) + if err != nil { + return err + } + s.ServiceProperties = &serviceProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + s.Tags = tags + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + } + } + + return nil +} + +// ServiceListResult the paginated list of peering services. +type ServiceListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering services. + Value *[]Service `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering services. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServiceListResultIterator provides access to a complete listing of Service values. +type ServiceListResultIterator struct { + i int + page ServiceListResultPage +} + +// 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 *ServiceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceListResultIterator.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 *ServiceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServiceListResultIterator) 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 ServiceListResultIterator) Response() ServiceListResult { + 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 ServiceListResultIterator) Value() Service { + if !iter.page.NotDone() { + return Service{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServiceListResultIterator type. +func NewServiceListResultIterator(page ServiceListResultPage) ServiceListResultIterator { + return ServiceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ServiceListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// serviceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ServiceListResult) serviceListResultPreparer(ctx context.Context) (*http.Request, error) { + if slr.NextLink == nil || len(to.String(slr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// ServiceListResultPage contains a page of Service values. +type ServiceListResultPage struct { + fn func(context.Context, ServiceListResult) (ServiceListResult, error) + slr ServiceListResult +} + +// 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 *ServiceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceListResultPage.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.slr) + if err != nil { + return err + } + page.slr = 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 *ServiceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServiceListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServiceListResultPage) Response() ServiceListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServiceListResultPage) Values() []Service { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// Creates a new instance of the ServiceListResultPage type. +func NewServiceListResultPage(getNextPage func(context.Context, ServiceListResult) (ServiceListResult, error)) ServiceListResultPage { + return ServiceListResultPage{fn: getNextPage} +} + +// ServiceLocation peeringService location +type ServiceLocation struct { + // ServiceLocationProperties - The properties that define a peering service location. + *ServiceLocationProperties `json:"properties,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; The ID of the resource. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceLocation. +func (sl ServiceLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sl.ServiceLocationProperties != nil { + objectMap["properties"] = sl.ServiceLocationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceLocation struct. +func (sl *ServiceLocation) 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 serviceLocationProperties ServiceLocationProperties + err = json.Unmarshal(*v, &serviceLocationProperties) + if err != nil { + return err + } + sl.ServiceLocationProperties = &serviceLocationProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sl.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sl.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sl.Type = &typeVar + } + } + } + + return nil +} + +// ServiceLocationListResult the paginated list of peering service locations. +type ServiceLocationListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering service locations. + Value *[]ServiceLocation `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering service locations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServiceLocationListResultIterator provides access to a complete listing of ServiceLocation values. +type ServiceLocationListResultIterator struct { + i int + page ServiceLocationListResultPage +} + +// 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 *ServiceLocationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceLocationListResultIterator.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 *ServiceLocationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServiceLocationListResultIterator) 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 ServiceLocationListResultIterator) Response() ServiceLocationListResult { + 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 ServiceLocationListResultIterator) Value() ServiceLocation { + if !iter.page.NotDone() { + return ServiceLocation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServiceLocationListResultIterator type. +func NewServiceLocationListResultIterator(page ServiceLocationListResultPage) ServiceLocationListResultIterator { + return ServiceLocationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sllr ServiceLocationListResult) IsEmpty() bool { + return sllr.Value == nil || len(*sllr.Value) == 0 +} + +// serviceLocationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sllr ServiceLocationListResult) serviceLocationListResultPreparer(ctx context.Context) (*http.Request, error) { + if sllr.NextLink == nil || len(to.String(sllr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sllr.NextLink))) +} + +// ServiceLocationListResultPage contains a page of ServiceLocation values. +type ServiceLocationListResultPage struct { + fn func(context.Context, ServiceLocationListResult) (ServiceLocationListResult, error) + sllr ServiceLocationListResult +} + +// 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 *ServiceLocationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceLocationListResultPage.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.sllr) + if err != nil { + return err + } + page.sllr = 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 *ServiceLocationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServiceLocationListResultPage) NotDone() bool { + return !page.sllr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServiceLocationListResultPage) Response() ServiceLocationListResult { + return page.sllr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServiceLocationListResultPage) Values() []ServiceLocation { + if page.sllr.IsEmpty() { + return nil + } + return *page.sllr.Value +} + +// Creates a new instance of the ServiceLocationListResultPage type. +func NewServiceLocationListResultPage(getNextPage func(context.Context, ServiceLocationListResult) (ServiceLocationListResult, error)) ServiceLocationListResultPage { + return ServiceLocationListResultPage{fn: getNextPage} +} + +// ServiceLocationProperties the properties that define connectivity to the Peering Service Location. +type ServiceLocationProperties struct { + // Country - Country of the customer + Country *string `json:"country,omitempty"` + // State - State of the customer + State *string `json:"state,omitempty"` + // AzureRegion - Azure region for the location + AzureRegion *string `json:"azureRegion,omitempty"` +} + +// ServicePrefix the peering service prefix class. +type ServicePrefix struct { + autorest.Response `json:"-"` + // ServicePrefixProperties - Gets or sets the peering prefix properties. + *ServicePrefixProperties `json:"properties,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; The ID of the resource. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicePrefix. +func (sp ServicePrefix) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.ServicePrefixProperties != nil { + objectMap["properties"] = sp.ServicePrefixProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServicePrefix struct. +func (sp *ServicePrefix) 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 servicePrefixProperties ServicePrefixProperties + err = json.Unmarshal(*v, &servicePrefixProperties) + if err != nil { + return err + } + sp.ServicePrefixProperties = &servicePrefixProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sp.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sp.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sp.Type = &typeVar + } + } + } + + return nil +} + +// ServicePrefixListResult the paginated list of [T]. +type ServicePrefixListResult struct { + autorest.Response `json:"-"` + // Value - The list of [T]. + Value *[]ServicePrefix `json:"value,omitempty"` + // NextLink - The link to fetch the next page of [T]. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServicePrefixListResultIterator provides access to a complete listing of ServicePrefix values. +type ServicePrefixListResultIterator struct { + i int + page ServicePrefixListResultPage +} + +// 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 *ServicePrefixListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicePrefixListResultIterator.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 *ServicePrefixListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServicePrefixListResultIterator) 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 ServicePrefixListResultIterator) Response() ServicePrefixListResult { + 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 ServicePrefixListResultIterator) Value() ServicePrefix { + if !iter.page.NotDone() { + return ServicePrefix{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServicePrefixListResultIterator type. +func NewServicePrefixListResultIterator(page ServicePrefixListResultPage) ServicePrefixListResultIterator { + return ServicePrefixListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (splr ServicePrefixListResult) IsEmpty() bool { + return splr.Value == nil || len(*splr.Value) == 0 +} + +// servicePrefixListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (splr ServicePrefixListResult) servicePrefixListResultPreparer(ctx context.Context) (*http.Request, error) { + if splr.NextLink == nil || len(to.String(splr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(splr.NextLink))) +} + +// ServicePrefixListResultPage contains a page of ServicePrefix values. +type ServicePrefixListResultPage struct { + fn func(context.Context, ServicePrefixListResult) (ServicePrefixListResult, error) + splr ServicePrefixListResult +} + +// 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 *ServicePrefixListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicePrefixListResultPage.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.splr) + if err != nil { + return err + } + page.splr = 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 *ServicePrefixListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServicePrefixListResultPage) NotDone() bool { + return !page.splr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServicePrefixListResultPage) Response() ServicePrefixListResult { + return page.splr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServicePrefixListResultPage) Values() []ServicePrefix { + if page.splr.IsEmpty() { + return nil + } + return *page.splr.Value +} + +// Creates a new instance of the ServicePrefixListResultPage type. +func NewServicePrefixListResultPage(getNextPage func(context.Context, ServicePrefixListResult) (ServicePrefixListResult, error)) ServicePrefixListResultPage { + return ServicePrefixListResultPage{fn: getNextPage} +} + +// ServicePrefixProperties the peering service prefix properties class. +type ServicePrefixProperties struct { + // Prefix - Valid route prefix + Prefix *string `json:"prefix,omitempty"` + // PrefixValidationState - The prefix validation state. Possible values include: 'PrefixValidationStateNone', 'PrefixValidationStateInvalid', 'PrefixValidationStateVerified', 'PrefixValidationStateFailed', 'PrefixValidationStatePending', 'PrefixValidationStateUnknown' + PrefixValidationState PrefixValidationState `json:"prefixValidationState,omitempty"` + // LearnedType - The prefix learned type. Possible values include: 'LearnedTypeNone', 'LearnedTypeViaPartner', 'LearnedTypeViaSession' + LearnedType LearnedType `json:"learnedType,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// ServiceProperties the properties that define connectivity to the Peering Service. +type ServiceProperties struct { + // PeeringServiceLocation - The PeeringServiceLocation of the Customer. + PeeringServiceLocation *string `json:"peeringServiceLocation,omitempty"` + // PeeringServiceProvider - The MAPS Provider Name. + PeeringServiceProvider *string `json:"peeringServiceProvider,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// ServiceProvider peeringService provider +type ServiceProvider struct { + // ServiceProviderProperties - The properties that define a peering service provider. + *ServiceProviderProperties `json:"properties,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; The ID of the resource. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceProvider. +func (sp ServiceProvider) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.ServiceProviderProperties != nil { + objectMap["properties"] = sp.ServiceProviderProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceProvider struct. +func (sp *ServiceProvider) 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 serviceProviderProperties ServiceProviderProperties + err = json.Unmarshal(*v, &serviceProviderProperties) + if err != nil { + return err + } + sp.ServiceProviderProperties = &serviceProviderProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sp.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sp.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sp.Type = &typeVar + } + } + } + + return nil +} + +// ServiceProviderListResult the paginated list of peering service providers. +type ServiceProviderListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering service providers. + Value *[]ServiceProvider `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering service providers. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServiceProviderListResultIterator provides access to a complete listing of ServiceProvider values. +type ServiceProviderListResultIterator struct { + i int + page ServiceProviderListResultPage +} + +// 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 *ServiceProviderListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceProviderListResultIterator.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 *ServiceProviderListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServiceProviderListResultIterator) 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 ServiceProviderListResultIterator) Response() ServiceProviderListResult { + 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 ServiceProviderListResultIterator) Value() ServiceProvider { + if !iter.page.NotDone() { + return ServiceProvider{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServiceProviderListResultIterator type. +func NewServiceProviderListResultIterator(page ServiceProviderListResultPage) ServiceProviderListResultIterator { + return ServiceProviderListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (splr ServiceProviderListResult) IsEmpty() bool { + return splr.Value == nil || len(*splr.Value) == 0 +} + +// serviceProviderListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (splr ServiceProviderListResult) serviceProviderListResultPreparer(ctx context.Context) (*http.Request, error) { + if splr.NextLink == nil || len(to.String(splr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(splr.NextLink))) +} + +// ServiceProviderListResultPage contains a page of ServiceProvider values. +type ServiceProviderListResultPage struct { + fn func(context.Context, ServiceProviderListResult) (ServiceProviderListResult, error) + splr ServiceProviderListResult +} + +// 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 *ServiceProviderListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceProviderListResultPage.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.splr) + if err != nil { + return err + } + page.splr = 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 *ServiceProviderListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServiceProviderListResultPage) NotDone() bool { + return !page.splr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServiceProviderListResultPage) Response() ServiceProviderListResult { + return page.splr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServiceProviderListResultPage) Values() []ServiceProvider { + if page.splr.IsEmpty() { + return nil + } + return *page.splr.Value +} + +// Creates a new instance of the ServiceProviderListResultPage type. +func NewServiceProviderListResultPage(getNextPage func(context.Context, ServiceProviderListResult) (ServiceProviderListResult, error)) ServiceProviderListResultPage { + return ServiceProviderListResultPage{fn: getNextPage} +} + +// ServiceProviderProperties the properties that define connectivity to the Peering Service Provider. +type ServiceProviderProperties struct { + // ServiceProviderName - The name of the service provider. + ServiceProviderName *string `json:"serviceProviderName,omitempty"` +} + +// Sku the SKU that defines the tier and kind of the peering. +type Sku struct { + // Name - The name of the peering SKU. Possible values include: 'BasicExchangeFree', 'BasicDirectFree', 'PremiumDirectFree', 'PremiumExchangeMetered', 'PremiumDirectMetered', 'PremiumDirectUnlimited' + Name Name `json:"name,omitempty"` + // Tier - The tier of the peering SKU. Possible values include: 'Basic', 'Premium' + Tier Tier `json:"tier,omitempty"` + // Family - The family of the peering SKU. Possible values include: 'Direct', 'Exchange' + Family Family `json:"family,omitempty"` + // Size - The size of the peering SKU. Possible values include: 'Free', 'Metered', 'Unlimited' + Size Size `json:"size,omitempty"` +} + +// String ... +type String struct { + autorest.Response `json:"-"` + // Value - Possible values include: 'Available', 'UnAvailable' + Value *string `json:"value,omitempty"` +} + +// SubResource the sub resource. +type SubResource struct { + // ID - The identifier of the referenced resource. + ID *string `json:"id,omitempty"` +} diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/operations.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/operations.go new file mode 100644 index 000000000000..63f06a85cf05 --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/operations.go @@ -0,0 +1,147 @@ +package peering + +// 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 peering Client +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 API operations for peering resources. +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, "peering.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, "peering.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.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-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Peering/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, "peering.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, "peering.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.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/peering/mgmt/2019-08-01-preview/peering/peerasns.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/peerasns.go new file mode 100644 index 000000000000..475bbf87f835 --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/peerasns.go @@ -0,0 +1,379 @@ +package peering + +// 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" +) + +// PeerAsnsClient is the peering Client +type PeerAsnsClient struct { + BaseClient +} + +// NewPeerAsnsClient creates an instance of the PeerAsnsClient client. +func NewPeerAsnsClient(subscriptionID string) PeerAsnsClient { + return NewPeerAsnsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPeerAsnsClientWithBaseURI creates an instance of the PeerAsnsClient client. +func NewPeerAsnsClientWithBaseURI(baseURI string, subscriptionID string) PeerAsnsClient { + return PeerAsnsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new peer ASN or updates an existing peer ASN with the specified name under the given +// subscription. +// Parameters: +// peerAsnName - the peer ASN name. +// peerAsn - the peer ASN. +func (client PeerAsnsClient) CreateOrUpdate(ctx context.Context, peerAsnName string, peerAsn PeerAsn) (result PeerAsn, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeerAsnsClient.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, peerAsnName, peerAsn) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PeerAsnsClient) CreateOrUpdatePreparer(ctx context.Context, peerAsnName string, peerAsn PeerAsn) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peerAsnName": autorest.Encode("path", peerAsnName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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}/providers/Microsoft.Peering/peerAsns/{peerAsnName}", pathParameters), + autorest.WithJSON(peerAsn), + 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 PeerAsnsClient) 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 PeerAsnsClient) CreateOrUpdateResponder(resp *http.Response) (result PeerAsn, 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 an existing peer ASN with the specified name under the given subscription. +// Parameters: +// peerAsnName - the peer ASN name. +func (client PeerAsnsClient) Delete(ctx context.Context, peerAsnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeerAsnsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, peerAsnName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PeerAsnsClient) DeletePreparer(ctx context.Context, peerAsnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peerAsnName": autorest.Encode("path", peerAsnName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}", 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 PeerAsnsClient) DeleteSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PeerAsnsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the peer ASN with the specified name under the given subscription. +// Parameters: +// peerAsnName - the peer ASN name. +func (client PeerAsnsClient) Get(ctx context.Context, peerAsnName string) (result PeerAsn, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeerAsnsClient.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, peerAsnName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PeerAsnsClient) GetPreparer(ctx context.Context, peerAsnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peerAsnName": autorest.Encode("path", peerAsnName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}", 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 PeerAsnsClient) 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 PeerAsnsClient) GetResponder(resp *http.Response) (result PeerAsn, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription lists all of the peer ASNs under the given subscription. +func (client PeerAsnsClient) ListBySubscription(ctx context.Context) (result PeerAsnListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeerAsnsClient.ListBySubscription") + defer func() { + sc := -1 + if result.palr.Response.Response != nil { + sc = result.palr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.palr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.palr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client PeerAsnsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns", 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 PeerAsnsClient) 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 PeerAsnsClient) ListBySubscriptionResponder(resp *http.Response) (result PeerAsnListResult, 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 PeerAsnsClient) listBySubscriptionNextResults(ctx context.Context, lastResults PeerAsnListResult) (result PeerAsnListResult, err error) { + req, err := lastResults.peerAsnListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "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, "peering.PeerAsnsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeerAsnsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client PeerAsnsClient) ListBySubscriptionComplete(ctx context.Context) (result PeerAsnListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeerAsnsClient.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) + return +} diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/peeringapi/interfaces.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/peeringapi/interfaces.go new file mode 100644 index 000000000000..f3c448884e9d --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/peeringapi/interfaces.go @@ -0,0 +1,116 @@ +package peeringapi + +// 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/peering/mgmt/2019-08-01-preview/peering" + "github.com/Azure/go-autorest/autorest" +) + +// BaseClientAPI contains the set of methods on the BaseClient type. +type BaseClientAPI interface { + CheckServiceProviderAvailability(ctx context.Context, checkServiceProviderAvailabilityInput peering.CheckServiceProviderAvailabilityInput) (result peering.String, err error) +} + +var _ BaseClientAPI = (*peering.BaseClient)(nil) + +// LegacyPeeringsClientAPI contains the set of methods on the LegacyPeeringsClient type. +type LegacyPeeringsClientAPI interface { + List(ctx context.Context, peeringLocation string, kind string) (result peering.ListResultPage, err error) +} + +var _ LegacyPeeringsClientAPI = (*peering.LegacyPeeringsClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result peering.OperationListResultPage, err error) +} + +var _ OperationsClientAPI = (*peering.OperationsClient)(nil) + +// PeerAsnsClientAPI contains the set of methods on the PeerAsnsClient type. +type PeerAsnsClientAPI interface { + CreateOrUpdate(ctx context.Context, peerAsnName string, peerAsn peering.PeerAsn) (result peering.PeerAsn, err error) + Delete(ctx context.Context, peerAsnName string) (result autorest.Response, err error) + Get(ctx context.Context, peerAsnName string) (result peering.PeerAsn, err error) + ListBySubscription(ctx context.Context) (result peering.PeerAsnListResultPage, err error) +} + +var _ PeerAsnsClientAPI = (*peering.PeerAsnsClient)(nil) + +// LocationsClientAPI contains the set of methods on the LocationsClient type. +type LocationsClientAPI interface { + List(ctx context.Context, kind string, directPeeringType string) (result peering.LocationListResultPage, err error) +} + +var _ LocationsClientAPI = (*peering.LocationsClient)(nil) + +// PeeringsClientAPI contains the set of methods on the PeeringsClient type. +type PeeringsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringName string, peering peering.Model) (result peering.Model, err error) + Delete(ctx context.Context, resourceGroupName string, peeringName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, peeringName string) (result peering.Model, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result peering.ListResultPage, err error) + ListBySubscription(ctx context.Context) (result peering.ListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, peeringName string, tags peering.ResourceTags) (result peering.Model, err error) +} + +var _ PeeringsClientAPI = (*peering.PeeringsClient)(nil) + +// ServiceLocationsClientAPI contains the set of methods on the ServiceLocationsClient type. +type ServiceLocationsClientAPI interface { + List(ctx context.Context) (result peering.ServiceLocationListResultPage, err error) +} + +var _ ServiceLocationsClientAPI = (*peering.ServiceLocationsClient)(nil) + +// ServicePrefixesClientAPI contains the set of methods on the ServicePrefixesClient type. +type ServicePrefixesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, peeringServicePrefix peering.ServicePrefix) (result peering.ServicePrefix, err error) + Delete(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string) (result peering.ServicePrefix, err error) +} + +var _ ServicePrefixesClientAPI = (*peering.ServicePrefixesClient)(nil) + +// PrefixesClientAPI contains the set of methods on the PrefixesClient type. +type PrefixesClientAPI interface { + ListByPeeringService(ctx context.Context, resourceGroupName string, peeringServiceName string) (result peering.ServicePrefixListResultPage, err error) +} + +var _ PrefixesClientAPI = (*peering.PrefixesClient)(nil) + +// ServiceProvidersClientAPI contains the set of methods on the ServiceProvidersClient type. +type ServiceProvidersClientAPI interface { + List(ctx context.Context) (result peering.ServiceProviderListResultPage, err error) +} + +var _ ServiceProvidersClientAPI = (*peering.ServiceProvidersClient)(nil) + +// ServicesClientAPI contains the set of methods on the ServicesClient type. +type ServicesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringServiceName string, peeringService peering.Service) (result peering.Service, err error) + Delete(ctx context.Context, resourceGroupName string, peeringServiceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, peeringServiceName string) (result peering.Service, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result peering.ServiceListResultPage, err error) + ListBySubscription(ctx context.Context) (result peering.ServiceListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, peeringServiceName string, tags peering.ResourceTags) (result peering.Service, err error) +} + +var _ ServicesClientAPI = (*peering.ServicesClient)(nil) diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/peerings.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/peerings.go new file mode 100644 index 000000000000..06e815d59656 --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/peerings.go @@ -0,0 +1,586 @@ +package peering + +// 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" +) + +// PeeringsClient is the peering Client +type PeeringsClient struct { + BaseClient +} + +// NewPeeringsClient creates an instance of the PeeringsClient client. +func NewPeeringsClient(subscriptionID string) PeeringsClient { + return NewPeeringsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPeeringsClientWithBaseURI creates an instance of the PeeringsClient client. +func NewPeeringsClientWithBaseURI(baseURI string, subscriptionID string) PeeringsClient { + return PeeringsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new peering or updates an existing peering with the specified name under the given +// subscription and resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// peering - the properties needed to create or update a peering. +func (client PeeringsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringName string, peering Model) (result Model, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: peering, + Constraints: []validation.Constraint{{Target: "peering.Sku", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "peering.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("peering.PeeringsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, peeringName, peering) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PeeringsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, peeringName string, peering Model) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peerings/{peeringName}", pathParameters), + autorest.WithJSON(peering), + 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 PeeringsClient) 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 PeeringsClient) CreateOrUpdateResponder(resp *http.Response) (result Model, 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 an existing peering with the specified name under the given subscription and resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +func (client PeeringsClient) Delete(ctx context.Context, resourceGroupName string, peeringName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, peeringName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PeeringsClient) DeletePreparer(ctx context.Context, resourceGroupName string, peeringName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peerings/{peeringName}", 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 PeeringsClient) DeleteSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PeeringsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an existing peering with the specified name under the given subscription and resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +func (client PeeringsClient) Get(ctx context.Context, resourceGroupName string, peeringName string) (result Model, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringsClient.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, peeringName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PeeringsClient) GetPreparer(ctx context.Context, resourceGroupName string, peeringName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peerings/{peeringName}", 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 PeeringsClient) 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 PeeringsClient) GetResponder(resp *http.Response) (result Model, 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 lists all of the peerings under the given subscription and resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client PeeringsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.lr.Response.Response != nil { + sc = result.lr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "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, "peering.PeeringsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.lr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client PeeringsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peerings", 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 PeeringsClient) 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 PeeringsClient) 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 PeeringsClient) listByResourceGroupNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) { + req, err := lastResults.listResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.PeeringsClient", "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, "peering.PeeringsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PeeringsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringsClient.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) + return +} + +// ListBySubscription lists all of the peerings under the given subscription. +func (client PeeringsClient) ListBySubscription(ctx context.Context) (result ListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringsClient.ListBySubscription") + defer func() { + sc := -1 + if result.lr.Response.Response != nil { + sc = result.lr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "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, "peering.PeeringsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.lr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client PeeringsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerings", 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 PeeringsClient) 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 PeeringsClient) 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 PeeringsClient) listBySubscriptionNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) { + req, err := lastResults.listResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.PeeringsClient", "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, "peering.PeeringsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client PeeringsClient) ListBySubscriptionComplete(ctx context.Context) (result ListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringsClient.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) + return +} + +// Update updates tags for a peering with the specified name under the given subscription and resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// tags - the resource tags. +func (client PeeringsClient) Update(ctx context.Context, resourceGroupName string, peeringName string, tags ResourceTags) (result Model, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PeeringsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, peeringName, tags) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PeeringsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PeeringsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, peeringName string, tags ResourceTags) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peerings/{peeringName}", pathParameters), + autorest.WithJSON(tags), + 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 PeeringsClient) UpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PeeringsClient) UpdateResponder(resp *http.Response) (result Model, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/prefixes.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/prefixes.go new file mode 100644 index 000000000000..449f7153a44b --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/prefixes.go @@ -0,0 +1,156 @@ +package peering + +// 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" +) + +// PrefixesClient is the peering Client +type PrefixesClient struct { + BaseClient +} + +// NewPrefixesClient creates an instance of the PrefixesClient client. +func NewPrefixesClient(subscriptionID string) PrefixesClient { + return NewPrefixesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrefixesClientWithBaseURI creates an instance of the PrefixesClient client. +func NewPrefixesClientWithBaseURI(baseURI string, subscriptionID string) PrefixesClient { + return PrefixesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByPeeringService lists the peerings prefix in the resource group. +// Parameters: +// resourceGroupName - the resource group name. +// peeringServiceName - the peering service name. +func (client PrefixesClient) ListByPeeringService(ctx context.Context, resourceGroupName string, peeringServiceName string) (result ServicePrefixListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrefixesClient.ListByPeeringService") + defer func() { + sc := -1 + if result.splr.Response.Response != nil { + sc = result.splr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByPeeringServiceNextResults + req, err := client.ListByPeeringServicePreparer(ctx, resourceGroupName, peeringServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "ListByPeeringService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPeeringServiceSender(req) + if err != nil { + result.splr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "ListByPeeringService", resp, "Failure sending request") + return + } + + result.splr, err = client.ListByPeeringServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "ListByPeeringService", resp, "Failure responding to request") + } + + return +} + +// ListByPeeringServicePreparer prepares the ListByPeeringService request. +func (client PrefixesClient) ListByPeeringServicePreparer(ctx context.Context, resourceGroupName string, peeringServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringServiceName": autorest.Encode("path", peeringServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peeringServices/{peeringServiceName}/prefixes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPeeringServiceSender sends the ListByPeeringService request. The method will close the +// http.Response Body if it receives an error. +func (client PrefixesClient) ListByPeeringServiceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByPeeringServiceResponder handles the response to the ListByPeeringService request. The method always +// closes the http.Response Body. +func (client PrefixesClient) ListByPeeringServiceResponder(resp *http.Response) (result ServicePrefixListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPeeringServiceNextResults retrieves the next set of results, if any. +func (client PrefixesClient) listByPeeringServiceNextResults(ctx context.Context, lastResults ServicePrefixListResult) (result ServicePrefixListResult, err error) { + req, err := lastResults.servicePrefixListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.PrefixesClient", "listByPeeringServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPeeringServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "peering.PrefixesClient", "listByPeeringServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPeeringServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "listByPeeringServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPeeringServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrefixesClient) ListByPeeringServiceComplete(ctx context.Context, resourceGroupName string, peeringServiceName string) (result ServicePrefixListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrefixesClient.ListByPeeringService") + 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.ListByPeeringService(ctx, resourceGroupName, peeringServiceName) + return +} diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/servicelocations.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/servicelocations.go new file mode 100644 index 000000000000..f20c06d98ee3 --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/servicelocations.go @@ -0,0 +1,151 @@ +package peering + +// 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" +) + +// ServiceLocationsClient is the peering Client +type ServiceLocationsClient struct { + BaseClient +} + +// NewServiceLocationsClient creates an instance of the ServiceLocationsClient client. +func NewServiceLocationsClient(subscriptionID string) ServiceLocationsClient { + return NewServiceLocationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceLocationsClientWithBaseURI creates an instance of the ServiceLocationsClient client. +func NewServiceLocationsClientWithBaseURI(baseURI string, subscriptionID string) ServiceLocationsClient { + return ServiceLocationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available peering service locations for the specified kind of peering. +func (client ServiceLocationsClient) List(ctx context.Context) (result ServiceLocationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceLocationsClient.List") + defer func() { + sc := -1 + if result.sllr.Response.Response != nil { + sc = result.sllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServiceLocationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ServiceLocationsClient", "List", resp, "Failure sending request") + return + } + + result.sllr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServiceLocationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ServiceLocationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceLocations", 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 ServiceLocationsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServiceLocationsClient) ListResponder(resp *http.Response) (result ServiceLocationListResult, 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 ServiceLocationsClient) listNextResults(ctx context.Context, lastResults ServiceLocationListResult) (result ServiceLocationListResult, err error) { + req, err := lastResults.serviceLocationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.ServiceLocationsClient", "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, "peering.ServiceLocationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServiceLocationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServiceLocationsClient) ListComplete(ctx context.Context) (result ServiceLocationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceLocationsClient.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/peering/mgmt/2019-08-01-preview/peering/serviceprefixes.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/serviceprefixes.go new file mode 100644 index 000000000000..edcabf337f8d --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/serviceprefixes.go @@ -0,0 +1,280 @@ +package peering + +// 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" +) + +// ServicePrefixesClient is the peering Client +type ServicePrefixesClient struct { + BaseClient +} + +// NewServicePrefixesClient creates an instance of the ServicePrefixesClient client. +func NewServicePrefixesClient(subscriptionID string) ServicePrefixesClient { + return NewServicePrefixesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServicePrefixesClientWithBaseURI creates an instance of the ServicePrefixesClient client. +func NewServicePrefixesClientWithBaseURI(baseURI string, subscriptionID string) ServicePrefixesClient { + return ServicePrefixesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the peering prefix. +// Parameters: +// resourceGroupName - the resource group name. +// peeringServiceName - the peering service name. +// prefixName - the prefix name +// peeringServicePrefix - the IP prefix for an peering +func (client ServicePrefixesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, peeringServicePrefix ServicePrefix) (result ServicePrefix, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicePrefixesClient.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, resourceGroupName, peeringServiceName, prefixName, peeringServicePrefix) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicePrefixesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ServicePrefixesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicePrefixesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServicePrefixesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, peeringServicePrefix ServicePrefix) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringServiceName": autorest.Encode("path", peeringServiceName), + "prefixName": autorest.Encode("path", prefixName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}", pathParameters), + autorest.WithJSON(peeringServicePrefix), + 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 ServicePrefixesClient) 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 ServicePrefixesClient) CreateOrUpdateResponder(resp *http.Response) (result ServicePrefix, 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 removes the peering prefix. +// Parameters: +// resourceGroupName - the resource group name. +// peeringServiceName - the peering service name. +// prefixName - the prefix name +func (client ServicePrefixesClient) Delete(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicePrefixesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, peeringServiceName, prefixName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicePrefixesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "peering.ServicePrefixesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicePrefixesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServicePrefixesClient) DeletePreparer(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringServiceName": autorest.Encode("path", peeringServiceName), + "prefixName": autorest.Encode("path", prefixName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}", 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 ServicePrefixesClient) DeleteSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServicePrefixesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the peering service prefix. +// Parameters: +// resourceGroupName - the resource group name. +// peeringServiceName - the peering service name. +// prefixName - the prefix name. +func (client ServicePrefixesClient) Get(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string) (result ServicePrefix, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicePrefixesClient.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, peeringServiceName, prefixName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicePrefixesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ServicePrefixesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicePrefixesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServicePrefixesClient) GetPreparer(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringServiceName": autorest.Encode("path", peeringServiceName), + "prefixName": autorest.Encode("path", prefixName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}", 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 ServicePrefixesClient) 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 ServicePrefixesClient) GetResponder(resp *http.Response) (result ServicePrefix, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/serviceproviders.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/serviceproviders.go new file mode 100644 index 000000000000..0ab15633390b --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/serviceproviders.go @@ -0,0 +1,151 @@ +package peering + +// 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" +) + +// ServiceProvidersClient is the peering Client +type ServiceProvidersClient struct { + BaseClient +} + +// NewServiceProvidersClient creates an instance of the ServiceProvidersClient client. +func NewServiceProvidersClient(subscriptionID string) ServiceProvidersClient { + return NewServiceProvidersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceProvidersClientWithBaseURI creates an instance of the ServiceProvidersClient client. +func NewServiceProvidersClientWithBaseURI(baseURI string, subscriptionID string) ServiceProvidersClient { + return ServiceProvidersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available peering service locations for the specified kind of peering. +func (client ServiceProvidersClient) List(ctx context.Context) (result ServiceProviderListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceProvidersClient.List") + defer func() { + sc := -1 + if result.splr.Response.Response != nil { + sc = result.splr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServiceProvidersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.splr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ServiceProvidersClient", "List", resp, "Failure sending request") + return + } + + result.splr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServiceProvidersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ServiceProvidersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceProviders", 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 ServiceProvidersClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServiceProvidersClient) ListResponder(resp *http.Response) (result ServiceProviderListResult, 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 ServiceProvidersClient) listNextResults(ctx context.Context, lastResults ServiceProviderListResult) (result ServiceProviderListResult, err error) { + req, err := lastResults.serviceProviderListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.ServiceProvidersClient", "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, "peering.ServiceProvidersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServiceProvidersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServiceProvidersClient) ListComplete(ctx context.Context) (result ServiceProviderListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceProvidersClient.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/peering/mgmt/2019-08-01-preview/peering/services.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/services.go new file mode 100644 index 000000000000..65c4f1337d87 --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/services.go @@ -0,0 +1,585 @@ +package peering + +// 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" +) + +// ServicesClient is the peering Client +type ServicesClient struct { + BaseClient +} + +// NewServicesClient creates an instance of the ServicesClient client. +func NewServicesClient(subscriptionID string) ServicesClient { + return NewServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServicesClientWithBaseURI creates an instance of the ServicesClient client. +func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient { + return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new peering service or updates an existing peering with the specified name under the given +// subscription and resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// peeringService - the properties needed to create or update a peering service. +func (client ServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringServiceName string, peeringService Service) (result Service, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: peeringService, + Constraints: []validation.Constraint{{Target: "peeringService.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("peering.ServicesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, peeringServiceName, peeringService) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, peeringServiceName string, peeringService Service) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringServiceName": autorest.Encode("path", peeringServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peeringServices/{peeringServiceName}", pathParameters), + autorest.WithJSON(peeringService), + 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 ServicesClient) 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 ServicesClient) CreateOrUpdateResponder(resp *http.Response) (result Service, 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 an existing peering service with the specified name under the given subscription and resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +func (client ServicesClient) Delete(ctx context.Context, resourceGroupName string, peeringServiceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, peeringServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, peeringServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringServiceName": autorest.Encode("path", peeringServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peeringServices/{peeringServiceName}", 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 ServicesClient) DeleteSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an existing peering service with the specified name under the given subscription and resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering. +func (client ServicesClient) Get(ctx context.Context, resourceGroupName string, peeringServiceName string) (result Service, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.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, peeringServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, peeringServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringServiceName": autorest.Encode("path", peeringServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peeringServices/{peeringServiceName}", 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 ServicesClient) 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 ServicesClient) GetResponder(resp *http.Response) (result Service, 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 lists all of the peering services under the given subscription and resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client ServicesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServiceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ServicesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peeringServices", 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 ServicesClient) 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 ServicesClient) ListByResourceGroupResponder(resp *http.Response) (result ServiceListResult, 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 ServicesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServiceListResult) (result ServiceListResult, err error) { + req, err := lastResults.serviceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.ServicesClient", "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, "peering.ServicesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServicesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ServiceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.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) + return +} + +// ListBySubscription lists all of the peerings under the given subscription. +func (client ServicesClient) ListBySubscription(ctx context.Context) (result ServiceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListBySubscription") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.slr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ServicesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServices", 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 ServicesClient) 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 ServicesClient) ListBySubscriptionResponder(resp *http.Response) (result ServiceListResult, 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 ServicesClient) listBySubscriptionNextResults(ctx context.Context, lastResults ServiceListResult) (result ServiceListResult, err error) { + req, err := lastResults.serviceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.ServicesClient", "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, "peering.ServicesClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServicesClient) ListBySubscriptionComplete(ctx context.Context) (result ServiceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.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) + return +} + +// Update updates tags for a peering service with the specified name under the given subscription and resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// tags - the resource tags. +func (client ServicesClient) Update(ctx context.Context, resourceGroupName string, peeringServiceName string, tags ResourceTags) (result Service, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, peeringServiceName, tags) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServicesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, peeringServiceName string, tags ResourceTags) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringServiceName": autorest.Encode("path", peeringServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.Peering/peeringServices/{peeringServiceName}", pathParameters), + autorest.WithJSON(tags), + 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 ServicesClient) UpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServicesClient) UpdateResponder(resp *http.Response) (result Service, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/version.go b/services/preview/peering/mgmt/2019-08-01-preview/peering/version.go new file mode 100644 index 000000000000..23c3bf5cc149 --- /dev/null +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/version.go @@ -0,0 +1,30 @@ +package peering + +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 + " peering/2019-08-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}