From 086b10e6a43e74ec09b9e069adba4493ef14cd74 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 30 Jun 2021 00:35:24 +0000 Subject: [PATCH] CodeGen from PR 14703 in Azure/azure-rest-api-specs Peering api 2021-06-01 (#14703) * Existing version in new directory * 2021-06-01 swagger correctness changes * Resolved conflict * [feat] Add looking glass documentation to 2021-06-01 * [fix] Change LookingGlasses to LookingGlass * Add connection monitor models and examples * Remove LookingGlass response status codes and fix parameter capitalization * Fix ReadOnly properties in request * Remove last readOnly property Co-authored-by: Renuka Raju Co-authored-by: Jimmy Xu Co-authored-by: Slava Uryumtsev --- .../mgmt/2020-04-01/peering/CHANGELOG.md | 13 +- .../mgmt/2020-04-01/peering/_meta.json | 2 +- .../mgmt/2020-10-01/peering/CHANGELOG.md | 14 +- .../mgmt/2020-10-01/peering/_meta.json | 2 +- .../mgmt/2021-01-01/peering/CHANGELOG.md | 2 + .../mgmt/2021-01-01/peering/_meta.json | 11 + .../2021-01-01/peering/cdnpeeringprefixes.go | 148 + .../peering/mgmt/2021-01-01/peering/client.go | 122 + .../peering/mgmt/2021-01-01/peering/enums.go | 305 ++ .../mgmt/2021-01-01/peering/legacypeerings.go | 153 + .../mgmt/2021-01-01/peering/locations.go | 151 + .../peering/mgmt/2021-01-01/peering/models.go | 3560 +++++++++++++++ .../mgmt/2021-01-01/peering/operations.go | 140 + .../mgmt/2021-01-01/peering/peerasns.go | 369 ++ .../peering/peeringapi/interfaces.go | 156 + .../mgmt/2021-01-01/peering/peerings.go | 578 +++ .../mgmt/2021-01-01/peering/prefixes.go | 396 ++ .../mgmt/2021-01-01/peering/receivedroutes.go | 170 + .../mgmt/2021-01-01/peering/registeredasns.go | 388 ++ .../2021-01-01/peering/registeredprefixes.go | 389 ++ .../2021-01-01/peering/servicecountries.go | 145 + .../2021-01-01/peering/servicelocations.go | 150 + .../2021-01-01/peering/serviceproviders.go | 145 + .../mgmt/2021-01-01/peering/services.go | 577 +++ .../mgmt/2021-01-01/peering/version.go | 19 + .../mgmt/2021-06-01/peering/CHANGELOG.md | 2 + .../mgmt/2021-06-01/peering/_meta.json | 11 + .../2021-06-01/peering/cdnpeeringprefixes.go | 148 + .../peering/mgmt/2021-06-01/peering/client.go | 122 + .../peering/connectionmonitortests.go | 390 ++ .../peering/mgmt/2021-06-01/peering/enums.go | 322 ++ .../mgmt/2021-06-01/peering/legacypeerings.go | 153 + .../mgmt/2021-06-01/peering/locations.go | 151 + .../mgmt/2021-06-01/peering/lookingglass.go | 111 + .../peering/mgmt/2021-06-01/peering/models.go | 3980 +++++++++++++++++ .../mgmt/2021-06-01/peering/operations.go | 140 + .../mgmt/2021-06-01/peering/peerasns.go | 369 ++ .../peering/peeringapi/interfaces.go | 175 + .../mgmt/2021-06-01/peering/peerings.go | 578 +++ .../mgmt/2021-06-01/peering/prefixes.go | 396 ++ .../mgmt/2021-06-01/peering/receivedroutes.go | 170 + .../mgmt/2021-06-01/peering/registeredasns.go | 388 ++ .../2021-06-01/peering/registeredprefixes.go | 389 ++ .../2021-06-01/peering/servicecountries.go | 145 + .../2021-06-01/peering/servicelocations.go | 150 + .../2021-06-01/peering/serviceproviders.go | 145 + .../mgmt/2021-06-01/peering/services.go | 647 +++ .../mgmt/2021-06-01/peering/version.go | 19 + .../2019-08-01-preview/peering/CHANGELOG.md | 10 +- .../2019-08-01-preview/peering/_meta.json | 2 +- .../2019-09-01-preview/peering/CHANGELOG.md | 11 +- .../2019-09-01-preview/peering/_meta.json | 2 +- .../2020-01-01-preview/peering/CHANGELOG.md | 12 +- .../2020-01-01-preview/peering/_meta.json | 2 +- 54 files changed, 17185 insertions(+), 60 deletions(-) create mode 100644 services/peering/mgmt/2021-01-01/peering/CHANGELOG.md create mode 100644 services/peering/mgmt/2021-01-01/peering/_meta.json create mode 100644 services/peering/mgmt/2021-01-01/peering/cdnpeeringprefixes.go create mode 100644 services/peering/mgmt/2021-01-01/peering/client.go create mode 100644 services/peering/mgmt/2021-01-01/peering/enums.go create mode 100644 services/peering/mgmt/2021-01-01/peering/legacypeerings.go create mode 100644 services/peering/mgmt/2021-01-01/peering/locations.go create mode 100644 services/peering/mgmt/2021-01-01/peering/models.go create mode 100644 services/peering/mgmt/2021-01-01/peering/operations.go create mode 100644 services/peering/mgmt/2021-01-01/peering/peerasns.go create mode 100644 services/peering/mgmt/2021-01-01/peering/peeringapi/interfaces.go create mode 100644 services/peering/mgmt/2021-01-01/peering/peerings.go create mode 100644 services/peering/mgmt/2021-01-01/peering/prefixes.go create mode 100644 services/peering/mgmt/2021-01-01/peering/receivedroutes.go create mode 100644 services/peering/mgmt/2021-01-01/peering/registeredasns.go create mode 100644 services/peering/mgmt/2021-01-01/peering/registeredprefixes.go create mode 100644 services/peering/mgmt/2021-01-01/peering/servicecountries.go create mode 100644 services/peering/mgmt/2021-01-01/peering/servicelocations.go create mode 100644 services/peering/mgmt/2021-01-01/peering/serviceproviders.go create mode 100644 services/peering/mgmt/2021-01-01/peering/services.go create mode 100644 services/peering/mgmt/2021-01-01/peering/version.go create mode 100644 services/peering/mgmt/2021-06-01/peering/CHANGELOG.md create mode 100644 services/peering/mgmt/2021-06-01/peering/_meta.json create mode 100644 services/peering/mgmt/2021-06-01/peering/cdnpeeringprefixes.go create mode 100644 services/peering/mgmt/2021-06-01/peering/client.go create mode 100644 services/peering/mgmt/2021-06-01/peering/connectionmonitortests.go create mode 100644 services/peering/mgmt/2021-06-01/peering/enums.go create mode 100644 services/peering/mgmt/2021-06-01/peering/legacypeerings.go create mode 100644 services/peering/mgmt/2021-06-01/peering/locations.go create mode 100644 services/peering/mgmt/2021-06-01/peering/lookingglass.go create mode 100644 services/peering/mgmt/2021-06-01/peering/models.go create mode 100644 services/peering/mgmt/2021-06-01/peering/operations.go create mode 100644 services/peering/mgmt/2021-06-01/peering/peerasns.go create mode 100644 services/peering/mgmt/2021-06-01/peering/peeringapi/interfaces.go create mode 100644 services/peering/mgmt/2021-06-01/peering/peerings.go create mode 100644 services/peering/mgmt/2021-06-01/peering/prefixes.go create mode 100644 services/peering/mgmt/2021-06-01/peering/receivedroutes.go create mode 100644 services/peering/mgmt/2021-06-01/peering/registeredasns.go create mode 100644 services/peering/mgmt/2021-06-01/peering/registeredprefixes.go create mode 100644 services/peering/mgmt/2021-06-01/peering/servicecountries.go create mode 100644 services/peering/mgmt/2021-06-01/peering/servicelocations.go create mode 100644 services/peering/mgmt/2021-06-01/peering/serviceproviders.go create mode 100644 services/peering/mgmt/2021-06-01/peering/services.go create mode 100644 services/peering/mgmt/2021-06-01/peering/version.go diff --git a/services/peering/mgmt/2020-04-01/peering/CHANGELOG.md b/services/peering/mgmt/2020-04-01/peering/CHANGELOG.md index a7673d285336..a1ecf841edb0 100644 --- a/services/peering/mgmt/2020-04-01/peering/CHANGELOG.md +++ b/services/peering/mgmt/2020-04-01/peering/CHANGELOG.md @@ -1,13 +1,2 @@ -# Change History +# Unreleased -## Additive Changes - -### New Funcs - -1. ErrorDetail.MarshalJSON() ([]byte, error) -1. Operation.MarshalJSON() ([]byte, error) -1. OperationDisplayInfo.MarshalJSON() ([]byte, error) -1. ReceivedRoute.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) -1. ServiceCountry.MarshalJSON() ([]byte, error) -1. ServicePrefixEvent.MarshalJSON() ([]byte, error) diff --git a/services/peering/mgmt/2020-04-01/peering/_meta.json b/services/peering/mgmt/2020-04-01/peering/_meta.json index a3a033aa30b1..bce8cf2fde2a 100644 --- a/services/peering/mgmt/2020-04-01/peering/_meta.json +++ b/services/peering/mgmt/2020-04-01/peering/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "c51580c6f102bace66c5bed4b979437c21b81882", "readme": "/_/azure-rest-api-specs/specification/peering/resource-manager/readme.md", "tag": "package-2020-04-01", "use": "@microsoft.azure/autorest.go@2.1.183", diff --git a/services/peering/mgmt/2020-10-01/peering/CHANGELOG.md b/services/peering/mgmt/2020-10-01/peering/CHANGELOG.md index 9b0f5c553f1c..a1ecf841edb0 100644 --- a/services/peering/mgmt/2020-10-01/peering/CHANGELOG.md +++ b/services/peering/mgmt/2020-10-01/peering/CHANGELOG.md @@ -1,14 +1,2 @@ -# Change History +# Unreleased -## Additive Changes - -### New Funcs - -1. CdnPeeringPrefixProperties.MarshalJSON() ([]byte, error) -1. ErrorDetail.MarshalJSON() ([]byte, error) -1. Operation.MarshalJSON() ([]byte, error) -1. OperationDisplayInfo.MarshalJSON() ([]byte, error) -1. ReceivedRoute.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) -1. ServiceCountry.MarshalJSON() ([]byte, error) -1. ServicePrefixEvent.MarshalJSON() ([]byte, error) diff --git a/services/peering/mgmt/2020-10-01/peering/_meta.json b/services/peering/mgmt/2020-10-01/peering/_meta.json index 4250d79bb228..dde6d0db12fa 100644 --- a/services/peering/mgmt/2020-10-01/peering/_meta.json +++ b/services/peering/mgmt/2020-10-01/peering/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "c51580c6f102bace66c5bed4b979437c21b81882", "readme": "/_/azure-rest-api-specs/specification/peering/resource-manager/readme.md", "tag": "package-2020-10-01", "use": "@microsoft.azure/autorest.go@2.1.183", diff --git a/services/peering/mgmt/2021-01-01/peering/CHANGELOG.md b/services/peering/mgmt/2021-01-01/peering/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/peering/mgmt/2021-01-01/peering/_meta.json b/services/peering/mgmt/2021-01-01/peering/_meta.json new file mode 100644 index 000000000000..f176e2906468 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "c51580c6f102bace66c5bed4b979437c21b81882", + "readme": "/_/azure-rest-api-specs/specification/peering/resource-manager/readme.md", + "tag": "package-2021-01-01", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2021-01-01 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/peering/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/peering/mgmt/2021-01-01/peering/cdnpeeringprefixes.go b/services/peering/mgmt/2021-01-01/peering/cdnpeeringprefixes.go new file mode 100644 index 000000000000..9a76afe45b3b --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/cdnpeeringprefixes.go @@ -0,0 +1,148 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CdnPeeringPrefixesClient is the peering Client +type CdnPeeringPrefixesClient struct { + BaseClient +} + +// NewCdnPeeringPrefixesClient creates an instance of the CdnPeeringPrefixesClient client. +func NewCdnPeeringPrefixesClient(subscriptionID string) CdnPeeringPrefixesClient { + return NewCdnPeeringPrefixesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCdnPeeringPrefixesClientWithBaseURI creates an instance of the CdnPeeringPrefixesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewCdnPeeringPrefixesClientWithBaseURI(baseURI string, subscriptionID string) CdnPeeringPrefixesClient { + return CdnPeeringPrefixesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the advertised prefixes for the specified peering location +// Parameters: +// peeringLocation - the peering location. +func (client CdnPeeringPrefixesClient) List(ctx context.Context, peeringLocation string) (result CdnPeeringPrefixListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CdnPeeringPrefixesClient.List") + defer func() { + sc := -1 + if result.cpplr.Response.Response != nil { + sc = result.cpplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, peeringLocation) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.CdnPeeringPrefixesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cpplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.CdnPeeringPrefixesClient", "List", resp, "Failure sending request") + return + } + + result.cpplr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.CdnPeeringPrefixesClient", "List", resp, "Failure responding to request") + return + } + if result.cpplr.hasNextLink() && result.cpplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client CdnPeeringPrefixesClient) ListPreparer(ctx context.Context, peeringLocation string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "peeringLocation": autorest.Encode("query", peeringLocation), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/cdnPeeringPrefixes", 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 CdnPeeringPrefixesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client CdnPeeringPrefixesClient) ListResponder(resp *http.Response) (result CdnPeeringPrefixListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client CdnPeeringPrefixesClient) listNextResults(ctx context.Context, lastResults CdnPeeringPrefixListResult) (result CdnPeeringPrefixListResult, err error) { + req, err := lastResults.cdnPeeringPrefixListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.CdnPeeringPrefixesClient", "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.CdnPeeringPrefixesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.CdnPeeringPrefixesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client CdnPeeringPrefixesClient) ListComplete(ctx context.Context, peeringLocation string) (result CdnPeeringPrefixListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CdnPeeringPrefixesClient.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) + return +} diff --git a/services/peering/mgmt/2021-01-01/peering/client.go b/services/peering/mgmt/2021-01-01/peering/client.go new file mode 100644 index 000000000000..d2655a1cffa6 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/client.go @@ -0,0 +1,122 @@ +// Package peering implements the Azure ARM Peering service API version 2021-01-01. +// +// Peering Client +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +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 using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} + +// 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 + } + + 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/peering/mgmt/2021-01-01/peering/enums.go b/services/peering/mgmt/2021-01-01/peering/enums.go new file mode 100644 index 000000000000..643f44d03d2d --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/enums.go @@ -0,0 +1,305 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// 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" + // Ix ... + Ix DirectPeeringType = "Ix" + // IxRs ... + IxRs DirectPeeringType = "IxRs" + // Transit ... + Transit DirectPeeringType = "Transit" + // Voice ... + Voice DirectPeeringType = "Voice" +) + +// PossibleDirectPeeringTypeValues returns an array of possible values for the DirectPeeringType const type. +func PossibleDirectPeeringTypeValues() []DirectPeeringType { + return []DirectPeeringType{Cdn, Edge, Internal, Ix, IxRs, Transit, Voice} +} + +// 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" + // LearnedTypeViaServiceProvider ... + LearnedTypeViaServiceProvider LearnedType = "ViaServiceProvider" + // LearnedTypeViaSession ... + LearnedTypeViaSession LearnedType = "ViaSession" +) + +// PossibleLearnedTypeValues returns an array of possible values for the LearnedType const type. +func PossibleLearnedTypeValues() []LearnedType { + return []LearnedType{LearnedTypeNone, LearnedTypeViaServiceProvider, LearnedTypeViaSession} +} + +// 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" + // PrefixValidationStateWarning ... + PrefixValidationStateWarning PrefixValidationState = "Warning" +) + +// PossiblePrefixValidationStateValues returns an array of possible values for the PrefixValidationState const type. +func PossiblePrefixValidationStateValues() []PrefixValidationState { + return []PrefixValidationState{PrefixValidationStateFailed, PrefixValidationStateInvalid, PrefixValidationStateNone, PrefixValidationStatePending, PrefixValidationStateUnknown, PrefixValidationStateVerified, PrefixValidationStateWarning} +} + +// 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} +} + +// Role enumerates the values for role. +type Role string + +const ( + // RoleEscalation ... + RoleEscalation Role = "Escalation" + // RoleNoc ... + RoleNoc Role = "Noc" + // RoleOther ... + RoleOther Role = "Other" + // RolePolicy ... + RolePolicy Role = "Policy" + // RoleService ... + RoleService Role = "Service" + // RoleTechnical ... + RoleTechnical Role = "Technical" +) + +// PossibleRoleValues returns an array of possible values for the Role const type. +func PossibleRoleValues() []Role { + return []Role{RoleEscalation, RoleNoc, RoleOther, RolePolicy, RoleService, RoleTechnical} +} + +// 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} +} diff --git a/services/peering/mgmt/2021-01-01/peering/legacypeerings.go b/services/peering/mgmt/2021-01-01/peering/legacypeerings.go new file mode 100644 index 000000000000..dad1b9cbaedc --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/legacypeerings.go @@ -0,0 +1,153 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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. +// asn - the ASN number associated with a legacy peering. +func (client LegacyPeeringsClient) List(ctx context.Context, peeringLocation string, kind string, asn *int32) (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, asn) + 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 + } + if result.lr.hasNextLink() && result.lr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client LegacyPeeringsClient) ListPreparer(ctx context.Context, peeringLocation string, kind string, asn *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "kind": autorest.Encode("query", kind), + "peeringLocation": autorest.Encode("query", peeringLocation), + } + if asn != nil { + queryParameters["asn"] = autorest.Encode("query", *asn) + } + + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LegacyPeeringsClient) ListResponder(resp *http.Response) (result ListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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, asn *int32) (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, asn) + return +} diff --git a/services/peering/mgmt/2021-01-01/peering/locations.go b/services/peering/mgmt/2021-01-01/peering/locations.go new file mode 100644 index 000000000000..69e87f0f9177 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/locations.go @@ -0,0 +1,151 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewLocationsClientWithBaseURI(baseURI string, subscriptionID string) LocationsClient { + return LocationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// 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 + } + if result.llr.hasNextLink() && result.llr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-01-01" + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LocationsClient) ListResponder(resp *http.Response) (result LocationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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/peering/mgmt/2021-01-01/peering/models.go b/services/peering/mgmt/2021-01-01/peering/models.go new file mode 100644 index 000000000000..db8df5093554 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/models.go @@ -0,0 +1,3560 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/peering/mgmt/2021-01-01/peering" + +// 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 - The IPv4 session address on Microsoft's end. + MicrosoftSessionIPv4Address *string `json:"microsoftSessionIPv4Address,omitempty"` + // MicrosoftSessionIPv6Address - 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"` +} + +// MarshalJSON is the custom marshaler for BgpSession. +func (bs BgpSession) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bs.SessionPrefixV4 != nil { + objectMap["sessionPrefixV4"] = bs.SessionPrefixV4 + } + if bs.SessionPrefixV6 != nil { + objectMap["sessionPrefixV6"] = bs.SessionPrefixV6 + } + if bs.MicrosoftSessionIPv4Address != nil { + objectMap["microsoftSessionIPv4Address"] = bs.MicrosoftSessionIPv4Address + } + if bs.MicrosoftSessionIPv6Address != nil { + objectMap["microsoftSessionIPv6Address"] = bs.MicrosoftSessionIPv6Address + } + if bs.PeerSessionIPv4Address != nil { + objectMap["peerSessionIPv4Address"] = bs.PeerSessionIPv4Address + } + if bs.PeerSessionIPv6Address != nil { + objectMap["peerSessionIPv6Address"] = bs.PeerSessionIPv6Address + } + if bs.MaxPrefixesAdvertisedV4 != nil { + objectMap["maxPrefixesAdvertisedV4"] = bs.MaxPrefixesAdvertisedV4 + } + if bs.MaxPrefixesAdvertisedV6 != nil { + objectMap["maxPrefixesAdvertisedV6"] = bs.MaxPrefixesAdvertisedV6 + } + if bs.Md5AuthenticationKey != nil { + objectMap["md5AuthenticationKey"] = bs.Md5AuthenticationKey + } + return json.Marshal(objectMap) +} + +// CdnPeeringPrefix the CDN peering prefix +type CdnPeeringPrefix struct { + // CdnPeeringPrefixProperties - The properties that define a cdn peering prefix. + *CdnPeeringPrefixProperties `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 CdnPeeringPrefix. +func (cpp CdnPeeringPrefix) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cpp.CdnPeeringPrefixProperties != nil { + objectMap["properties"] = cpp.CdnPeeringPrefixProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CdnPeeringPrefix struct. +func (cpp *CdnPeeringPrefix) 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 cdnPeeringPrefixProperties CdnPeeringPrefixProperties + err = json.Unmarshal(*v, &cdnPeeringPrefixProperties) + if err != nil { + return err + } + cpp.CdnPeeringPrefixProperties = &cdnPeeringPrefixProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cpp.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cpp.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cpp.Type = &typeVar + } + } + } + + return nil +} + +// CdnPeeringPrefixListResult the paginated list of CDN peering prefixes. +type CdnPeeringPrefixListResult struct { + autorest.Response `json:"-"` + // Value - The list of CDN peering prefixes. + Value *[]CdnPeeringPrefix `json:"value,omitempty"` + // NextLink - The link to fetch the next page of CDN peering prefixes. + NextLink *string `json:"nextLink,omitempty"` +} + +// CdnPeeringPrefixListResultIterator provides access to a complete listing of CdnPeeringPrefix values. +type CdnPeeringPrefixListResultIterator struct { + i int + page CdnPeeringPrefixListResultPage +} + +// 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 *CdnPeeringPrefixListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CdnPeeringPrefixListResultIterator.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 *CdnPeeringPrefixListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CdnPeeringPrefixListResultIterator) 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 CdnPeeringPrefixListResultIterator) Response() CdnPeeringPrefixListResult { + 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 CdnPeeringPrefixListResultIterator) Value() CdnPeeringPrefix { + if !iter.page.NotDone() { + return CdnPeeringPrefix{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CdnPeeringPrefixListResultIterator type. +func NewCdnPeeringPrefixListResultIterator(page CdnPeeringPrefixListResultPage) CdnPeeringPrefixListResultIterator { + return CdnPeeringPrefixListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cpplr CdnPeeringPrefixListResult) IsEmpty() bool { + return cpplr.Value == nil || len(*cpplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cpplr CdnPeeringPrefixListResult) hasNextLink() bool { + return cpplr.NextLink != nil && len(*cpplr.NextLink) != 0 +} + +// cdnPeeringPrefixListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cpplr CdnPeeringPrefixListResult) cdnPeeringPrefixListResultPreparer(ctx context.Context) (*http.Request, error) { + if !cpplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cpplr.NextLink))) +} + +// CdnPeeringPrefixListResultPage contains a page of CdnPeeringPrefix values. +type CdnPeeringPrefixListResultPage struct { + fn func(context.Context, CdnPeeringPrefixListResult) (CdnPeeringPrefixListResult, error) + cpplr CdnPeeringPrefixListResult +} + +// 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 *CdnPeeringPrefixListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CdnPeeringPrefixListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.cpplr) + if err != nil { + return err + } + page.cpplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *CdnPeeringPrefixListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CdnPeeringPrefixListResultPage) NotDone() bool { + return !page.cpplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CdnPeeringPrefixListResultPage) Response() CdnPeeringPrefixListResult { + return page.cpplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CdnPeeringPrefixListResultPage) Values() []CdnPeeringPrefix { + if page.cpplr.IsEmpty() { + return nil + } + return *page.cpplr.Value +} + +// Creates a new instance of the CdnPeeringPrefixListResultPage type. +func NewCdnPeeringPrefixListResultPage(cur CdnPeeringPrefixListResult, getNextPage func(context.Context, CdnPeeringPrefixListResult) (CdnPeeringPrefixListResult, error)) CdnPeeringPrefixListResultPage { + return CdnPeeringPrefixListResultPage{ + fn: getNextPage, + cpplr: cur, + } +} + +// CdnPeeringPrefixProperties the properties that define a CDN peering prefix +type CdnPeeringPrefixProperties struct { + // Prefix - READ-ONLY; The prefix. + Prefix *string `json:"prefix,omitempty"` + // AzureRegion - READ-ONLY; The Azure region. + AzureRegion *string `json:"azureRegion,omitempty"` + // AzureService - READ-ONLY; The Azure service. + AzureService *string `json:"azureService,omitempty"` + // IsPrimaryRegion - READ-ONLY; The flag that indicates whether or not this is the primary region. + IsPrimaryRegion *bool `json:"isPrimaryRegion,omitempty"` + // BgpCommunity - READ-ONLY; The BGP Community + BgpCommunity *string `json:"bgpCommunity,omitempty"` +} + +// MarshalJSON is the custom marshaler for CdnPeeringPrefixProperties. +func (cppp CdnPeeringPrefixProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CheckServiceProviderAvailabilityInput class for CheckServiceProviderAvailabilityInput +type CheckServiceProviderAvailabilityInput struct { + // PeeringServiceLocation - Gets or sets the peering service location. + PeeringServiceLocation *string `json:"peeringServiceLocation,omitempty"` + // PeeringServiceProvider - Gets or sets the peering service provider. + PeeringServiceProvider *string `json:"peeringServiceProvider,omitempty"` +} + +// ContactDetail the contact detail class. +type ContactDetail struct { + // Role - The role of the contact. Possible values include: 'RoleNoc', 'RolePolicy', 'RoleTechnical', 'RoleService', 'RoleEscalation', 'RoleOther' + Role Role `json:"role,omitempty"` + // Email - The e-mail address of the contact. + Email *string `json:"email,omitempty"` + // Phone - The phone number of the contact. + 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 - READ-ONLY; 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"` + // MicrosoftTrackingID - READ-ONLY; The ID used within Microsoft's peering provisioning system to track the connection + MicrosoftTrackingID *string `json:"microsoftTrackingId,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"` + // ErrorMessage - READ-ONLY; The error message related to the connection state, if any. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// MarshalJSON is the custom marshaler for DirectConnection. +func (dc DirectConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dc.BandwidthInMbps != nil { + objectMap["bandwidthInMbps"] = dc.BandwidthInMbps + } + if dc.SessionAddressProvider != "" { + objectMap["sessionAddressProvider"] = dc.SessionAddressProvider + } + if dc.UseForPeeringService != nil { + objectMap["useForPeeringService"] = dc.UseForPeeringService + } + if dc.PeeringDBFacilityID != nil { + objectMap["peeringDBFacilityId"] = dc.PeeringDBFacilityID + } + if dc.BgpSession != nil { + objectMap["bgpSession"] = dc.BgpSession + } + if dc.ConnectionIdentifier != nil { + objectMap["connectionIdentifier"] = dc.ConnectionIdentifier + } + return json.Marshal(objectMap) +} + +// 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', 'Ix', 'IxRs', 'Voice' + 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"` +} + +// ErrorDetail the error detail that describes why an operation has failed. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse the error response that indicates why an operation has failed. +type ErrorResponse struct { + // Error - The error detail that describes why an operation has failed. + Error *ErrorDetail `json:"error,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"` + // ErrorMessage - READ-ONLY; The error message related to the connection state, if any. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExchangeConnection. +func (ec ExchangeConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ec.PeeringDBFacilityID != nil { + objectMap["peeringDBFacilityId"] = ec.PeeringDBFacilityID + } + if ec.BgpSession != nil { + objectMap["bgpSession"] = ec.BgpSession + } + if ec.ConnectionIdentifier != nil { + objectMap["connectionIdentifier"] = ec.ConnectionIdentifier + } + return json.Marshal(objectMap) +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (lr ListResult) hasNextLink() bool { + return lr.NextLink != nil && len(*lr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.lr) + if err != nil { + return err + } + page.lr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage { + return ListResultPage{ + fn: getNextPage, + lr: cur, + } +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (llr LocationListResult) hasNextLink() bool { + return llr.NextLink != nil && len(*llr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.llr) + if err != nil { + return err + } + page.llr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur LocationListResult, getNextPage func(context.Context, LocationListResult) (LocationListResult, error)) LocationListResultPage { + return LocationListResultPage{ + fn: getNextPage, + llr: cur, + } +} + +// 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"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// 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"` +} + +// MarshalJSON is the custom marshaler for OperationDisplayInfo. +func (odi OperationDisplayInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (palr PeerAsnListResult) hasNextLink() bool { + return palr.NextLink != nil && len(*palr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.palr) + if err != nil { + return err + } + page.palr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur PeerAsnListResult, getNextPage func(context.Context, PeerAsnListResult) (PeerAsnListResult, error)) PeerAsnListResultPage { + return PeerAsnListResultPage{ + fn: getNextPage, + palr: cur, + } +} + +// 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"` + // PeerContactDetail - The contact details of the peer. + PeerContactDetail *[]ContactDetail `json:"peerContactDetail,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"` + // ErrorMessage - READ-ONLY; The error message for the validation state + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// MarshalJSON is the custom marshaler for PeerAsnProperties. +func (pap PeerAsnProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pap.PeerAsn != nil { + objectMap["peerAsn"] = pap.PeerAsn + } + if pap.PeerContactDetail != nil { + objectMap["peerContactDetail"] = pap.PeerContactDetail + } + if pap.PeerName != nil { + objectMap["peerName"] = pap.PeerName + } + if pap.ValidationState != "" { + objectMap["validationState"] = pap.ValidationState + } + return json.Marshal(objectMap) +} + +// 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"` +} + +// MarshalJSON is the custom marshaler for Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.Direct != nil { + objectMap["direct"] = p.Direct + } + if p.Exchange != nil { + objectMap["exchange"] = p.Exchange + } + if p.PeeringLocation != nil { + objectMap["peeringLocation"] = p.PeeringLocation + } + return json.Marshal(objectMap) +} + +// 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 - READ-ONLY; 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', 'Ix', 'IxRs', 'Voice' + DirectPeeringType DirectPeeringType `json:"directPeeringType,omitempty"` +} + +// MarshalJSON is the custom marshaler for PropertiesDirect. +func (pd PropertiesDirect) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pd.Connections != nil { + objectMap["connections"] = pd.Connections + } + if pd.PeerAsn != nil { + objectMap["peerAsn"] = pd.PeerAsn + } + if pd.DirectPeeringType != "" { + objectMap["directPeeringType"] = pd.DirectPeeringType + } + return json.Marshal(objectMap) +} + +// 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"` +} + +// ReceivedRoute the properties that define a received route. +type ReceivedRoute struct { + // Prefix - READ-ONLY; The prefix. + Prefix *string `json:"prefix,omitempty"` + // NextHop - READ-ONLY; The next hop for the prefix. + NextHop *string `json:"nextHop,omitempty"` + // AsPath - READ-ONLY; The AS path for the prefix. + AsPath *string `json:"asPath,omitempty"` + // OriginAsValidationState - READ-ONLY; The origin AS change information for the prefix. + OriginAsValidationState *string `json:"originAsValidationState,omitempty"` + // RpkiValidationState - READ-ONLY; The RPKI validation state for the prefix and origin AS that's listed in the AS path. + RpkiValidationState *string `json:"rpkiValidationState,omitempty"` + // TrustAnchor - READ-ONLY; The authority which holds the Route Origin Authorization record for the prefix, if any. + TrustAnchor *string `json:"trustAnchor,omitempty"` + // ReceivedTimestamp - READ-ONLY; The received timestamp associated with the prefix. + ReceivedTimestamp *string `json:"receivedTimestamp,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReceivedRoute. +func (rr ReceivedRoute) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ReceivedRouteListResult the paginated list of received routes for the peering. +type ReceivedRouteListResult struct { + autorest.Response `json:"-"` + // Value - The list of received routes for the peering. + Value *[]ReceivedRoute `json:"value,omitempty"` + // NextLink - The link to fetch the next page of received routes for the peering. + NextLink *string `json:"nextLink,omitempty"` +} + +// ReceivedRouteListResultIterator provides access to a complete listing of ReceivedRoute values. +type ReceivedRouteListResultIterator struct { + i int + page ReceivedRouteListResultPage +} + +// 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 *ReceivedRouteListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReceivedRouteListResultIterator.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 *ReceivedRouteListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ReceivedRouteListResultIterator) 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 ReceivedRouteListResultIterator) Response() ReceivedRouteListResult { + 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 ReceivedRouteListResultIterator) Value() ReceivedRoute { + if !iter.page.NotDone() { + return ReceivedRoute{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ReceivedRouteListResultIterator type. +func NewReceivedRouteListResultIterator(page ReceivedRouteListResultPage) ReceivedRouteListResultIterator { + return ReceivedRouteListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rrlr ReceivedRouteListResult) IsEmpty() bool { + return rrlr.Value == nil || len(*rrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rrlr ReceivedRouteListResult) hasNextLink() bool { + return rrlr.NextLink != nil && len(*rrlr.NextLink) != 0 +} + +// receivedRouteListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rrlr ReceivedRouteListResult) receivedRouteListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rrlr.NextLink))) +} + +// ReceivedRouteListResultPage contains a page of ReceivedRoute values. +type ReceivedRouteListResultPage struct { + fn func(context.Context, ReceivedRouteListResult) (ReceivedRouteListResult, error) + rrlr ReceivedRouteListResult +} + +// 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 *ReceivedRouteListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReceivedRouteListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rrlr) + if err != nil { + return err + } + page.rrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ReceivedRouteListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ReceivedRouteListResultPage) NotDone() bool { + return !page.rrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ReceivedRouteListResultPage) Response() ReceivedRouteListResult { + return page.rrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ReceivedRouteListResultPage) Values() []ReceivedRoute { + if page.rrlr.IsEmpty() { + return nil + } + return *page.rrlr.Value +} + +// Creates a new instance of the ReceivedRouteListResultPage type. +func NewReceivedRouteListResultPage(cur ReceivedRouteListResult, getNextPage func(context.Context, ReceivedRouteListResult) (ReceivedRouteListResult, error)) ReceivedRouteListResultPage { + return ReceivedRouteListResultPage{ + fn: getNextPage, + rrlr: cur, + } +} + +// RegisteredAsn the customer's ASN that is registered by the peering service provider. +type RegisteredAsn struct { + autorest.Response `json:"-"` + // RegisteredAsnProperties - The properties that define a registered ASN. + *RegisteredAsnProperties `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 RegisteredAsn. +func (ra RegisteredAsn) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ra.RegisteredAsnProperties != nil { + objectMap["properties"] = ra.RegisteredAsnProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegisteredAsn struct. +func (ra *RegisteredAsn) 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 registeredAsnProperties RegisteredAsnProperties + err = json.Unmarshal(*v, ®isteredAsnProperties) + if err != nil { + return err + } + ra.RegisteredAsnProperties = ®isteredAsnProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ra.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ra.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ra.Type = &typeVar + } + } + } + + return nil +} + +// RegisteredAsnListResult the paginated list of peering registered ASNs. +type RegisteredAsnListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering registered ASNs. + Value *[]RegisteredAsn `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering registered ASNs. + NextLink *string `json:"nextLink,omitempty"` +} + +// RegisteredAsnListResultIterator provides access to a complete listing of RegisteredAsn values. +type RegisteredAsnListResultIterator struct { + i int + page RegisteredAsnListResultPage +} + +// 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 *RegisteredAsnListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnListResultIterator.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 *RegisteredAsnListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegisteredAsnListResultIterator) 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 RegisteredAsnListResultIterator) Response() RegisteredAsnListResult { + 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 RegisteredAsnListResultIterator) Value() RegisteredAsn { + if !iter.page.NotDone() { + return RegisteredAsn{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegisteredAsnListResultIterator type. +func NewRegisteredAsnListResultIterator(page RegisteredAsnListResultPage) RegisteredAsnListResultIterator { + return RegisteredAsnListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ralr RegisteredAsnListResult) IsEmpty() bool { + return ralr.Value == nil || len(*ralr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ralr RegisteredAsnListResult) hasNextLink() bool { + return ralr.NextLink != nil && len(*ralr.NextLink) != 0 +} + +// registeredAsnListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ralr RegisteredAsnListResult) registeredAsnListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ralr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ralr.NextLink))) +} + +// RegisteredAsnListResultPage contains a page of RegisteredAsn values. +type RegisteredAsnListResultPage struct { + fn func(context.Context, RegisteredAsnListResult) (RegisteredAsnListResult, error) + ralr RegisteredAsnListResult +} + +// 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 *RegisteredAsnListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ralr) + if err != nil { + return err + } + page.ralr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegisteredAsnListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegisteredAsnListResultPage) NotDone() bool { + return !page.ralr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegisteredAsnListResultPage) Response() RegisteredAsnListResult { + return page.ralr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegisteredAsnListResultPage) Values() []RegisteredAsn { + if page.ralr.IsEmpty() { + return nil + } + return *page.ralr.Value +} + +// Creates a new instance of the RegisteredAsnListResultPage type. +func NewRegisteredAsnListResultPage(cur RegisteredAsnListResult, getNextPage func(context.Context, RegisteredAsnListResult) (RegisteredAsnListResult, error)) RegisteredAsnListResultPage { + return RegisteredAsnListResultPage{ + fn: getNextPage, + ralr: cur, + } +} + +// RegisteredAsnProperties the properties that define a registered ASN. +type RegisteredAsnProperties struct { + // Asn - The customer's ASN from which traffic originates. + Asn *int32 `json:"asn,omitempty"` + // PeeringServicePrefixKey - READ-ONLY; The peering service prefix key that is to be shared with the customer. + PeeringServicePrefixKey *string `json:"peeringServicePrefixKey,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegisteredAsnProperties. +func (rap RegisteredAsnProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rap.Asn != nil { + objectMap["asn"] = rap.Asn + } + return json.Marshal(objectMap) +} + +// RegisteredPrefix the customer's prefix that is registered by the peering service provider. +type RegisteredPrefix struct { + autorest.Response `json:"-"` + // RegisteredPrefixProperties - The properties that define a registered prefix. + *RegisteredPrefixProperties `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 RegisteredPrefix. +func (rp RegisteredPrefix) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rp.RegisteredPrefixProperties != nil { + objectMap["properties"] = rp.RegisteredPrefixProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegisteredPrefix struct. +func (rp *RegisteredPrefix) 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 registeredPrefixProperties RegisteredPrefixProperties + err = json.Unmarshal(*v, ®isteredPrefixProperties) + if err != nil { + return err + } + rp.RegisteredPrefixProperties = ®isteredPrefixProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rp.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rp.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rp.Type = &typeVar + } + } + } + + return nil +} + +// RegisteredPrefixListResult the paginated list of peering registered prefixes. +type RegisteredPrefixListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering registered prefixes. + Value *[]RegisteredPrefix `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering registered prefixes. + NextLink *string `json:"nextLink,omitempty"` +} + +// RegisteredPrefixListResultIterator provides access to a complete listing of RegisteredPrefix values. +type RegisteredPrefixListResultIterator struct { + i int + page RegisteredPrefixListResultPage +} + +// 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 *RegisteredPrefixListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixListResultIterator.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 *RegisteredPrefixListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegisteredPrefixListResultIterator) 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 RegisteredPrefixListResultIterator) Response() RegisteredPrefixListResult { + 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 RegisteredPrefixListResultIterator) Value() RegisteredPrefix { + if !iter.page.NotDone() { + return RegisteredPrefix{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegisteredPrefixListResultIterator type. +func NewRegisteredPrefixListResultIterator(page RegisteredPrefixListResultPage) RegisteredPrefixListResultIterator { + return RegisteredPrefixListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rplr RegisteredPrefixListResult) IsEmpty() bool { + return rplr.Value == nil || len(*rplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rplr RegisteredPrefixListResult) hasNextLink() bool { + return rplr.NextLink != nil && len(*rplr.NextLink) != 0 +} + +// registeredPrefixListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rplr RegisteredPrefixListResult) registeredPrefixListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rplr.NextLink))) +} + +// RegisteredPrefixListResultPage contains a page of RegisteredPrefix values. +type RegisteredPrefixListResultPage struct { + fn func(context.Context, RegisteredPrefixListResult) (RegisteredPrefixListResult, error) + rplr RegisteredPrefixListResult +} + +// 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 *RegisteredPrefixListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rplr) + if err != nil { + return err + } + page.rplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegisteredPrefixListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegisteredPrefixListResultPage) NotDone() bool { + return !page.rplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegisteredPrefixListResultPage) Response() RegisteredPrefixListResult { + return page.rplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegisteredPrefixListResultPage) Values() []RegisteredPrefix { + if page.rplr.IsEmpty() { + return nil + } + return *page.rplr.Value +} + +// Creates a new instance of the RegisteredPrefixListResultPage type. +func NewRegisteredPrefixListResultPage(cur RegisteredPrefixListResult, getNextPage func(context.Context, RegisteredPrefixListResult) (RegisteredPrefixListResult, error)) RegisteredPrefixListResultPage { + return RegisteredPrefixListResultPage{ + fn: getNextPage, + rplr: cur, + } +} + +// RegisteredPrefixProperties the properties that define a registered prefix. +type RegisteredPrefixProperties struct { + // Prefix - The customer's prefix from which traffic originates. + Prefix *string `json:"prefix,omitempty"` + // PrefixValidationState - READ-ONLY; The prefix validation state. Possible values include: 'PrefixValidationStateNone', 'PrefixValidationStateInvalid', 'PrefixValidationStateVerified', 'PrefixValidationStateFailed', 'PrefixValidationStatePending', 'PrefixValidationStateWarning', 'PrefixValidationStateUnknown' + PrefixValidationState PrefixValidationState `json:"prefixValidationState,omitempty"` + // PeeringServicePrefixKey - READ-ONLY; The peering service prefix key that is to be shared with the customer. + PeeringServicePrefixKey *string `json:"peeringServicePrefixKey,omitempty"` + // ErrorMessage - READ-ONLY; The error message associated with the validation state, if any. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegisteredPrefixProperties. +func (rpp RegisteredPrefixProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rpp.Prefix != nil { + objectMap["prefix"] = rpp.Prefix + } + return json.Marshal(objectMap) +} + +// 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"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// 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:"-"` + // Sku - The SKU that defines the type of the peering service. + Sku *ServiceSku `json:"sku,omitempty"` + // 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.Sku != nil { + objectMap["sku"] = s.Sku + } + 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 "sku": + if v != nil { + var sku ServiceSku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + s.Sku = &sku + } + 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 +} + +// ServiceCountry the peering service country. +type ServiceCountry 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"` +} + +// MarshalJSON is the custom marshaler for ServiceCountry. +func (sc ServiceCountry) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServiceCountryListResult the paginated list of peering service countries. +type ServiceCountryListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering service countries. + Value *[]ServiceCountry `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering service countries. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServiceCountryListResultIterator provides access to a complete listing of ServiceCountry values. +type ServiceCountryListResultIterator struct { + i int + page ServiceCountryListResultPage +} + +// 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 *ServiceCountryListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceCountryListResultIterator.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 *ServiceCountryListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServiceCountryListResultIterator) 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 ServiceCountryListResultIterator) Response() ServiceCountryListResult { + 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 ServiceCountryListResultIterator) Value() ServiceCountry { + if !iter.page.NotDone() { + return ServiceCountry{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServiceCountryListResultIterator type. +func NewServiceCountryListResultIterator(page ServiceCountryListResultPage) ServiceCountryListResultIterator { + return ServiceCountryListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sclr ServiceCountryListResult) IsEmpty() bool { + return sclr.Value == nil || len(*sclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sclr ServiceCountryListResult) hasNextLink() bool { + return sclr.NextLink != nil && len(*sclr.NextLink) != 0 +} + +// serviceCountryListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sclr ServiceCountryListResult) serviceCountryListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sclr.NextLink))) +} + +// ServiceCountryListResultPage contains a page of ServiceCountry values. +type ServiceCountryListResultPage struct { + fn func(context.Context, ServiceCountryListResult) (ServiceCountryListResult, error) + sclr ServiceCountryListResult +} + +// 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 *ServiceCountryListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceCountryListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sclr) + if err != nil { + return err + } + page.sclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServiceCountryListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServiceCountryListResultPage) NotDone() bool { + return !page.sclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServiceCountryListResultPage) Response() ServiceCountryListResult { + return page.sclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServiceCountryListResultPage) Values() []ServiceCountry { + if page.sclr.IsEmpty() { + return nil + } + return *page.sclr.Value +} + +// Creates a new instance of the ServiceCountryListResultPage type. +func NewServiceCountryListResultPage(cur ServiceCountryListResult, getNextPage func(context.Context, ServiceCountryListResult) (ServiceCountryListResult, error)) ServiceCountryListResultPage { + return ServiceCountryListResultPage{ + fn: getNextPage, + sclr: cur, + } +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (slr ServiceListResult) hasNextLink() bool { + return slr.NextLink != nil && len(*slr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.slr) + if err != nil { + return err + } + page.slr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur ServiceListResult, getNextPage func(context.Context, ServiceListResult) (ServiceListResult, error)) ServiceListResultPage { + return ServiceListResultPage{ + fn: getNextPage, + slr: cur, + } +} + +// ServiceLocation the peering service 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sllr ServiceLocationListResult) hasNextLink() bool { + return sllr.NextLink != nil && len(*sllr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.sllr) + if err != nil { + return err + } + page.sllr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur ServiceLocationListResult, getNextPage func(context.Context, ServiceLocationListResult) (ServiceLocationListResult, error)) ServiceLocationListResultPage { + return ServiceLocationListResultPage{ + fn: getNextPage, + sllr: cur, + } +} + +// 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 +} + +// ServicePrefixEvent the details of the event associated with a prefix. +type ServicePrefixEvent struct { + // EventTimestamp - READ-ONLY; The timestamp of the event associated with a prefix. + EventTimestamp *date.Time `json:"eventTimestamp,omitempty"` + // EventType - READ-ONLY; The type of the event associated with a prefix. + EventType *string `json:"eventType,omitempty"` + // EventSummary - READ-ONLY; The summary of the event associated with a prefix. + EventSummary *string `json:"eventSummary,omitempty"` + // EventLevel - READ-ONLY; The level of the event associated with a prefix. + EventLevel *string `json:"eventLevel,omitempty"` + // EventDescription - READ-ONLY; The description of the event associated with a prefix. + EventDescription *string `json:"eventDescription,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicePrefixEvent. +func (spe ServicePrefixEvent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServicePrefixListResult the paginated list of peering service prefixes. +type ServicePrefixListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering service prefixes. + Value *[]ServicePrefix `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering service prefixes. + 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (splr ServicePrefixListResult) hasNextLink() bool { + return splr.NextLink != nil && len(*splr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.splr) + if err != nil { + return err + } + page.splr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur ServicePrefixListResult, getNextPage func(context.Context, ServicePrefixListResult) (ServicePrefixListResult, error)) ServicePrefixListResultPage { + return ServicePrefixListResultPage{ + fn: getNextPage, + splr: cur, + } +} + +// ServicePrefixProperties the peering service prefix properties class. +type ServicePrefixProperties struct { + // Prefix - The prefix from which your traffic originates. + Prefix *string `json:"prefix,omitempty"` + // PrefixValidationState - READ-ONLY; The prefix validation state. Possible values include: 'PrefixValidationStateNone', 'PrefixValidationStateInvalid', 'PrefixValidationStateVerified', 'PrefixValidationStateFailed', 'PrefixValidationStatePending', 'PrefixValidationStateWarning', 'PrefixValidationStateUnknown' + PrefixValidationState PrefixValidationState `json:"prefixValidationState,omitempty"` + // LearnedType - READ-ONLY; The prefix learned type. Possible values include: 'LearnedTypeNone', 'LearnedTypeViaServiceProvider', 'LearnedTypeViaSession' + LearnedType LearnedType `json:"learnedType,omitempty"` + // ErrorMessage - READ-ONLY; The error message for validation state + ErrorMessage *string `json:"errorMessage,omitempty"` + // Events - READ-ONLY; The list of events for peering service prefix + Events *[]ServicePrefixEvent `json:"events,omitempty"` + // PeeringServicePrefixKey - The peering service prefix key + PeeringServicePrefixKey *string `json:"peeringServicePrefixKey,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicePrefixProperties. +func (spp ServicePrefixProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if spp.Prefix != nil { + objectMap["prefix"] = spp.Prefix + } + if spp.PeeringServicePrefixKey != nil { + objectMap["peeringServicePrefixKey"] = spp.PeeringServicePrefixKey + } + return json.Marshal(objectMap) +} + +// ServiceProperties the properties that define connectivity to the Peering Service. +type ServiceProperties struct { + // PeeringServiceLocation - The location (state/province) of the customer. + PeeringServiceLocation *string `json:"peeringServiceLocation,omitempty"` + // PeeringServiceProvider - The name of the service provider. + 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"` + // ProviderPrimaryPeeringLocation - The primary peering (Microsoft/service provider) location to be used for customer traffic. + ProviderPrimaryPeeringLocation *string `json:"providerPrimaryPeeringLocation,omitempty"` + // ProviderBackupPeeringLocation - The backup peering (Microsoft/service provider) location to be used for customer traffic. + ProviderBackupPeeringLocation *string `json:"providerBackupPeeringLocation,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceProperties. +func (sp ServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.PeeringServiceLocation != nil { + objectMap["peeringServiceLocation"] = sp.PeeringServiceLocation + } + if sp.PeeringServiceProvider != nil { + objectMap["peeringServiceProvider"] = sp.PeeringServiceProvider + } + if sp.ProviderPrimaryPeeringLocation != nil { + objectMap["providerPrimaryPeeringLocation"] = sp.ProviderPrimaryPeeringLocation + } + if sp.ProviderBackupPeeringLocation != nil { + objectMap["providerBackupPeeringLocation"] = sp.ProviderBackupPeeringLocation + } + return json.Marshal(objectMap) +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (splr ServiceProviderListResult) hasNextLink() bool { + return splr.NextLink != nil && len(*splr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.splr) + if err != nil { + return err + } + page.splr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur ServiceProviderListResult, getNextPage func(context.Context, ServiceProviderListResult) (ServiceProviderListResult, error)) ServiceProviderListResultPage { + return ServiceProviderListResultPage{ + fn: getNextPage, + splr: cur, + } +} + +// 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"` + // PeeringLocations - The list of locations at which the service provider peers with Microsoft. + PeeringLocations *[]string `json:"peeringLocations,omitempty"` +} + +// ServiceSku the SKU that defines the type of the peering service. +type ServiceSku struct { + // Name - The name of the peering service SKU. + Name *string `json:"name,omitempty"` +} + +// Sku the SKU that defines the tier and kind of the peering. +type Sku struct { + // Name - The name of the peering SKU. + Name *string `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/peering/mgmt/2021-01-01/peering/operations.go b/services/peering/mgmt/2021-01-01/peering/operations.go new file mode 100644 index 000000000000..63767d24520e --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/operations.go @@ -0,0 +1,140 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available 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 + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-01-01" + 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) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults 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/peering/mgmt/2021-01-01/peering/peerasns.go b/services/peering/mgmt/2021-01-01/peering/peerasns.go new file mode 100644 index 000000000000..fc4b24295c3d --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/peerasns.go @@ -0,0 +1,369 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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 + } + + 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PeerAsnsClient) CreateOrUpdateResponder(resp *http.Response) (result PeerAsn, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete 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 + } + + 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 = "2021-01-01" + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PeerAsnsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get 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 + } + + 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 = "2021-01-01" + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PeerAsnsClient) GetResponder(resp *http.Response) (result PeerAsn, err error) { + err = autorest.Respond( + resp, + 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 + } + if result.palr.hasNextLink() && result.palr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-01-01" + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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/peering/mgmt/2021-01-01/peering/peeringapi/interfaces.go b/services/peering/mgmt/2021-01-01/peering/peeringapi/interfaces.go new file mode 100644 index 000000000000..dc3c17f54100 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/peeringapi/interfaces.go @@ -0,0 +1,156 @@ +package peeringapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/peering/mgmt/2021-01-01/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) + +// CdnPeeringPrefixesClientAPI contains the set of methods on the CdnPeeringPrefixesClient type. +type CdnPeeringPrefixesClientAPI interface { + List(ctx context.Context, peeringLocation string) (result peering.CdnPeeringPrefixListResultPage, err error) + ListComplete(ctx context.Context, peeringLocation string) (result peering.CdnPeeringPrefixListResultIterator, err error) +} + +var _ CdnPeeringPrefixesClientAPI = (*peering.CdnPeeringPrefixesClient)(nil) + +// LegacyPeeringsClientAPI contains the set of methods on the LegacyPeeringsClient type. +type LegacyPeeringsClientAPI interface { + List(ctx context.Context, peeringLocation string, kind string, asn *int32) (result peering.ListResultPage, err error) + ListComplete(ctx context.Context, peeringLocation string, kind string, asn *int32) (result peering.ListResultIterator, 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) + ListComplete(ctx context.Context) (result peering.OperationListResultIterator, 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) + ListBySubscriptionComplete(ctx context.Context) (result peering.PeerAsnListResultIterator, 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) + ListComplete(ctx context.Context, kind string, directPeeringType string) (result peering.LocationListResultIterator, err error) +} + +var _ LocationsClientAPI = (*peering.LocationsClient)(nil) + +// RegisteredAsnsClientAPI contains the set of methods on the RegisteredAsnsClient type. +type RegisteredAsnsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string, registeredAsn peering.RegisteredAsn) (result peering.RegisteredAsn, err error) + Delete(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string) (result peering.RegisteredAsn, err error) + ListByPeering(ctx context.Context, resourceGroupName string, peeringName string) (result peering.RegisteredAsnListResultPage, err error) + ListByPeeringComplete(ctx context.Context, resourceGroupName string, peeringName string) (result peering.RegisteredAsnListResultIterator, err error) +} + +var _ RegisteredAsnsClientAPI = (*peering.RegisteredAsnsClient)(nil) + +// RegisteredPrefixesClientAPI contains the set of methods on the RegisteredPrefixesClient type. +type RegisteredPrefixesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string, registeredPrefix peering.RegisteredPrefix) (result peering.RegisteredPrefix, err error) + Delete(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string) (result peering.RegisteredPrefix, err error) + ListByPeering(ctx context.Context, resourceGroupName string, peeringName string) (result peering.RegisteredPrefixListResultPage, err error) + ListByPeeringComplete(ctx context.Context, resourceGroupName string, peeringName string) (result peering.RegisteredPrefixListResultIterator, err error) +} + +var _ RegisteredPrefixesClientAPI = (*peering.RegisteredPrefixesClient)(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) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result peering.ListResultIterator, err error) + ListBySubscription(ctx context.Context) (result peering.ListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result peering.ListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, peeringName string, tags peering.ResourceTags) (result peering.Model, err error) +} + +var _ PeeringsClientAPI = (*peering.PeeringsClient)(nil) + +// ReceivedRoutesClientAPI contains the set of methods on the ReceivedRoutesClient type. +type ReceivedRoutesClientAPI interface { + ListByPeering(ctx context.Context, resourceGroupName string, peeringName string, prefix string, asPath string, originAsValidationState string, rpkiValidationState string, skipToken string) (result peering.ReceivedRouteListResultPage, err error) + ListByPeeringComplete(ctx context.Context, resourceGroupName string, peeringName string, prefix string, asPath string, originAsValidationState string, rpkiValidationState string, skipToken string) (result peering.ReceivedRouteListResultIterator, err error) +} + +var _ ReceivedRoutesClientAPI = (*peering.ReceivedRoutesClient)(nil) + +// ServiceCountriesClientAPI contains the set of methods on the ServiceCountriesClient type. +type ServiceCountriesClientAPI interface { + List(ctx context.Context) (result peering.ServiceCountryListResultPage, err error) + ListComplete(ctx context.Context) (result peering.ServiceCountryListResultIterator, err error) +} + +var _ ServiceCountriesClientAPI = (*peering.ServiceCountriesClient)(nil) + +// ServiceLocationsClientAPI contains the set of methods on the ServiceLocationsClient type. +type ServiceLocationsClientAPI interface { + List(ctx context.Context, country string) (result peering.ServiceLocationListResultPage, err error) + ListComplete(ctx context.Context, country string) (result peering.ServiceLocationListResultIterator, err error) +} + +var _ ServiceLocationsClientAPI = (*peering.ServiceLocationsClient)(nil) + +// PrefixesClientAPI contains the set of methods on the PrefixesClient type. +type PrefixesClientAPI 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, expand string) (result peering.ServicePrefix, err error) + ListByPeeringService(ctx context.Context, resourceGroupName string, peeringServiceName string, expand string) (result peering.ServicePrefixListResultPage, err error) + ListByPeeringServiceComplete(ctx context.Context, resourceGroupName string, peeringServiceName string, expand string) (result peering.ServicePrefixListResultIterator, 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) + ListComplete(ctx context.Context) (result peering.ServiceProviderListResultIterator, 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) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result peering.ServiceListResultIterator, err error) + ListBySubscription(ctx context.Context) (result peering.ServiceListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result peering.ServiceListResultIterator, 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/peering/mgmt/2021-01-01/peering/peerings.go b/services/peering/mgmt/2021-01-01/peering/peerings.go new file mode 100644 index 000000000000..de4e4ebc64f3 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/peerings.go @@ -0,0 +1,578 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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 + } + + 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PeeringsClient) CreateOrUpdateResponder(resp *http.Response) (result Model, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete 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 + } + + 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PeeringsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get 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 + } + + 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PeeringsClient) GetResponder(resp *http.Response) (result Model, err error) { + err = autorest.Respond( + resp, + 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 + } + if result.lr.hasNextLink() && result.lr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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 + } + if result.lr.hasNextLink() && result.lr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-01-01" + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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 + } + + 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/peering/mgmt/2021-01-01/peering/prefixes.go b/services/peering/mgmt/2021-01-01/peering/prefixes.go new file mode 100644 index 000000000000..55630bb83e93 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/prefixes.go @@ -0,0 +1,396 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrefixesClientWithBaseURI(baseURI string, subscriptionID string) PrefixesClient { + return PrefixesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new prefix with the specified name under the given subscription, resource group and peering +// service. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// prefixName - the name of the prefix. +// peeringServicePrefix - the properties needed to create a prefix. +func (client PrefixesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, peeringServicePrefix ServicePrefix) (result ServicePrefix, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrefixesClient.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.PrefixesClient", "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.PrefixesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrefixesClient) 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 PrefixesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrefixesClient) CreateOrUpdateResponder(resp *http.Response) (result ServicePrefix, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing prefix with the specified name under the given subscription, resource group and peering +// service. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// prefixName - the name of the prefix. +func (client PrefixesClient) Delete(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrefixesClient.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.PrefixesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrefixesClient) 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 PrefixesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrefixesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an existing prefix with the specified name under the given subscription, resource group and peering +// service. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// prefixName - the name of the prefix. +// expand - the properties to be expanded. +func (client PrefixesClient) Get(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, expand string) (result ServicePrefix, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrefixesClient.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, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "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.PrefixesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrefixesClient) GetPreparer(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, expand 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + 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 PrefixesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrefixesClient) GetResponder(resp *http.Response) (result ServicePrefix, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPeeringService lists all prefixes under the given subscription, resource group and peering service. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// expand - the properties to be expanded. +func (client PrefixesClient) ListByPeeringService(ctx context.Context, resourceGroupName string, peeringServiceName string, expand 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, expand) + 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 + } + if result.splr.hasNextLink() && result.splr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPeeringServicePreparer prepares the ListByPeeringService request. +func (client PrefixesClient) ListByPeeringServicePreparer(ctx context.Context, resourceGroupName string, peeringServiceName string, expand 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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, expand 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, expand) + return +} diff --git a/services/peering/mgmt/2021-01-01/peering/receivedroutes.go b/services/peering/mgmt/2021-01-01/peering/receivedroutes.go new file mode 100644 index 000000000000..3905b3c6aef1 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/receivedroutes.go @@ -0,0 +1,170 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ReceivedRoutesClient is the peering Client +type ReceivedRoutesClient struct { + BaseClient +} + +// NewReceivedRoutesClient creates an instance of the ReceivedRoutesClient client. +func NewReceivedRoutesClient(subscriptionID string) ReceivedRoutesClient { + return NewReceivedRoutesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewReceivedRoutesClientWithBaseURI creates an instance of the ReceivedRoutesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewReceivedRoutesClientWithBaseURI(baseURI string, subscriptionID string) ReceivedRoutesClient { + return ReceivedRoutesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByPeering lists the prefixes received over the specified peering under the given subscription and resource +// group. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// prefix - the optional prefix that can be used to filter the routes. +// asPath - the optional AS path that can be used to filter the routes. +// originAsValidationState - the optional origin AS validation state that can be used to filter the routes. +// rpkiValidationState - the optional RPKI validation state that can be used to filter the routes. +// skipToken - the optional page continuation token that is used in the event of paginated result. +func (client ReceivedRoutesClient) ListByPeering(ctx context.Context, resourceGroupName string, peeringName string, prefix string, asPath string, originAsValidationState string, rpkiValidationState string, skipToken string) (result ReceivedRouteListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReceivedRoutesClient.ListByPeering") + defer func() { + sc := -1 + if result.rrlr.Response.Response != nil { + sc = result.rrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByPeeringNextResults + req, err := client.ListByPeeringPreparer(ctx, resourceGroupName, peeringName, prefix, asPath, originAsValidationState, rpkiValidationState, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ReceivedRoutesClient", "ListByPeering", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPeeringSender(req) + if err != nil { + result.rrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ReceivedRoutesClient", "ListByPeering", resp, "Failure sending request") + return + } + + result.rrlr, err = client.ListByPeeringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ReceivedRoutesClient", "ListByPeering", resp, "Failure responding to request") + return + } + if result.rrlr.hasNextLink() && result.rrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPeeringPreparer prepares the ListByPeering request. +func (client ReceivedRoutesClient) ListByPeeringPreparer(ctx context.Context, resourceGroupName string, peeringName string, prefix string, asPath string, originAsValidationState string, rpkiValidationState string, skipToken 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(prefix) > 0 { + queryParameters["prefix"] = autorest.Encode("query", prefix) + } + if len(asPath) > 0 { + queryParameters["asPath"] = autorest.Encode("query", asPath) + } + if len(originAsValidationState) > 0 { + queryParameters["originAsValidationState"] = autorest.Encode("query", originAsValidationState) + } + if len(rpkiValidationState) > 0 { + queryParameters["rpkiValidationState"] = autorest.Encode("query", rpkiValidationState) + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/receivedRoutes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPeeringSender sends the ListByPeering request. The method will close the +// http.Response Body if it receives an error. +func (client ReceivedRoutesClient) ListByPeeringSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPeeringResponder handles the response to the ListByPeering request. The method always +// closes the http.Response Body. +func (client ReceivedRoutesClient) ListByPeeringResponder(resp *http.Response) (result ReceivedRouteListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPeeringNextResults retrieves the next set of results, if any. +func (client ReceivedRoutesClient) listByPeeringNextResults(ctx context.Context, lastResults ReceivedRouteListResult) (result ReceivedRouteListResult, err error) { + req, err := lastResults.receivedRouteListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.ReceivedRoutesClient", "listByPeeringNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPeeringSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "peering.ReceivedRoutesClient", "listByPeeringNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPeeringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ReceivedRoutesClient", "listByPeeringNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPeeringComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReceivedRoutesClient) ListByPeeringComplete(ctx context.Context, resourceGroupName string, peeringName string, prefix string, asPath string, originAsValidationState string, rpkiValidationState string, skipToken string) (result ReceivedRouteListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReceivedRoutesClient.ListByPeering") + 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.ListByPeering(ctx, resourceGroupName, peeringName, prefix, asPath, originAsValidationState, rpkiValidationState, skipToken) + return +} diff --git a/services/peering/mgmt/2021-01-01/peering/registeredasns.go b/services/peering/mgmt/2021-01-01/peering/registeredasns.go new file mode 100644 index 000000000000..7133eded9a19 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/registeredasns.go @@ -0,0 +1,388 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegisteredAsnsClient is the peering Client +type RegisteredAsnsClient struct { + BaseClient +} + +// NewRegisteredAsnsClient creates an instance of the RegisteredAsnsClient client. +func NewRegisteredAsnsClient(subscriptionID string) RegisteredAsnsClient { + return NewRegisteredAsnsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRegisteredAsnsClientWithBaseURI creates an instance of the RegisteredAsnsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewRegisteredAsnsClientWithBaseURI(baseURI string, subscriptionID string) RegisteredAsnsClient { + return RegisteredAsnsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new registered ASN with the specified name under the given subscription, resource group and +// peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// registeredAsnName - the name of the ASN. +// registeredAsn - the properties needed to create a registered ASN. +func (client RegisteredAsnsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string, registeredAsn RegisteredAsn) (result RegisteredAsn, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnsClient.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, peeringName, registeredAsnName, registeredAsn) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "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.RegisteredAsnsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RegisteredAsnsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string, registeredAsn RegisteredAsn) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "registeredAsnName": autorest.Encode("path", registeredAsnName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}", pathParameters), + autorest.WithJSON(registeredAsn), + 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 RegisteredAsnsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RegisteredAsnsClient) CreateOrUpdateResponder(resp *http.Response) (result RegisteredAsn, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing registered ASN with the specified name under the given subscription, resource group and +// peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// registeredAsnName - the name of the registered ASN. +func (client RegisteredAsnsClient) Delete(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnsClient.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, registeredAsnName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RegisteredAsnsClient) DeletePreparer(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "registeredAsnName": autorest.Encode("path", registeredAsnName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}", 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 RegisteredAsnsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RegisteredAsnsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an existing registered ASN with the specified name under the given subscription, resource group and +// peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// registeredAsnName - the name of the registered ASN. +func (client RegisteredAsnsClient) Get(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string) (result RegisteredAsn, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnsClient.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, registeredAsnName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "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.RegisteredAsnsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegisteredAsnsClient) GetPreparer(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "registeredAsnName": autorest.Encode("path", registeredAsnName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}", 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 RegisteredAsnsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegisteredAsnsClient) GetResponder(resp *http.Response) (result RegisteredAsn, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPeering lists all registered ASNs under the given subscription, resource group and peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +func (client RegisteredAsnsClient) ListByPeering(ctx context.Context, resourceGroupName string, peeringName string) (result RegisteredAsnListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnsClient.ListByPeering") + defer func() { + sc := -1 + if result.ralr.Response.Response != nil { + sc = result.ralr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByPeeringNextResults + req, err := client.ListByPeeringPreparer(ctx, resourceGroupName, peeringName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "ListByPeering", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPeeringSender(req) + if err != nil { + result.ralr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "ListByPeering", resp, "Failure sending request") + return + } + + result.ralr, err = client.ListByPeeringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "ListByPeering", resp, "Failure responding to request") + return + } + if result.ralr.hasNextLink() && result.ralr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPeeringPreparer prepares the ListByPeering request. +func (client RegisteredAsnsClient) ListByPeeringPreparer(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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPeeringSender sends the ListByPeering request. The method will close the +// http.Response Body if it receives an error. +func (client RegisteredAsnsClient) ListByPeeringSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPeeringResponder handles the response to the ListByPeering request. The method always +// closes the http.Response Body. +func (client RegisteredAsnsClient) ListByPeeringResponder(resp *http.Response) (result RegisteredAsnListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPeeringNextResults retrieves the next set of results, if any. +func (client RegisteredAsnsClient) listByPeeringNextResults(ctx context.Context, lastResults RegisteredAsnListResult) (result RegisteredAsnListResult, err error) { + req, err := lastResults.registeredAsnListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "listByPeeringNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPeeringSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "listByPeeringNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPeeringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "listByPeeringNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPeeringComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegisteredAsnsClient) ListByPeeringComplete(ctx context.Context, resourceGroupName string, peeringName string) (result RegisteredAsnListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnsClient.ListByPeering") + 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.ListByPeering(ctx, resourceGroupName, peeringName) + return +} diff --git a/services/peering/mgmt/2021-01-01/peering/registeredprefixes.go b/services/peering/mgmt/2021-01-01/peering/registeredprefixes.go new file mode 100644 index 000000000000..ed09a4a58166 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/registeredprefixes.go @@ -0,0 +1,389 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegisteredPrefixesClient is the peering Client +type RegisteredPrefixesClient struct { + BaseClient +} + +// NewRegisteredPrefixesClient creates an instance of the RegisteredPrefixesClient client. +func NewRegisteredPrefixesClient(subscriptionID string) RegisteredPrefixesClient { + return NewRegisteredPrefixesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRegisteredPrefixesClientWithBaseURI creates an instance of the RegisteredPrefixesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewRegisteredPrefixesClientWithBaseURI(baseURI string, subscriptionID string) RegisteredPrefixesClient { + return RegisteredPrefixesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new registered prefix with the specified name under the given subscription, resource group +// and peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// registeredPrefixName - the name of the registered prefix. +// registeredPrefix - the properties needed to create a registered prefix. +func (client RegisteredPrefixesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string, registeredPrefix RegisteredPrefix) (result RegisteredPrefix, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixesClient.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, peeringName, registeredPrefixName, registeredPrefix) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "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.RegisteredPrefixesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RegisteredPrefixesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string, registeredPrefix RegisteredPrefix) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "registeredPrefixName": autorest.Encode("path", registeredPrefixName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}", pathParameters), + autorest.WithJSON(registeredPrefix), + 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 RegisteredPrefixesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RegisteredPrefixesClient) CreateOrUpdateResponder(resp *http.Response) (result RegisteredPrefix, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing registered prefix with the specified name under the given subscription, resource group +// and peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// registeredPrefixName - the name of the registered prefix. +func (client RegisteredPrefixesClient) Delete(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixesClient.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, registeredPrefixName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RegisteredPrefixesClient) DeletePreparer(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "registeredPrefixName": autorest.Encode("path", registeredPrefixName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}", 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 RegisteredPrefixesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RegisteredPrefixesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an existing registered prefix with the specified name under the given subscription, resource group and +// peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// registeredPrefixName - the name of the registered prefix. +func (client RegisteredPrefixesClient) Get(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string) (result RegisteredPrefix, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixesClient.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, registeredPrefixName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "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.RegisteredPrefixesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegisteredPrefixesClient) GetPreparer(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "registeredPrefixName": autorest.Encode("path", registeredPrefixName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}", 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 RegisteredPrefixesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegisteredPrefixesClient) GetResponder(resp *http.Response) (result RegisteredPrefix, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPeering lists all registered prefixes under the given subscription, resource group and peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +func (client RegisteredPrefixesClient) ListByPeering(ctx context.Context, resourceGroupName string, peeringName string) (result RegisteredPrefixListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixesClient.ListByPeering") + defer func() { + sc := -1 + if result.rplr.Response.Response != nil { + sc = result.rplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByPeeringNextResults + req, err := client.ListByPeeringPreparer(ctx, resourceGroupName, peeringName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "ListByPeering", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPeeringSender(req) + if err != nil { + result.rplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "ListByPeering", resp, "Failure sending request") + return + } + + result.rplr, err = client.ListByPeeringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "ListByPeering", resp, "Failure responding to request") + return + } + if result.rplr.hasNextLink() && result.rplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPeeringPreparer prepares the ListByPeering request. +func (client RegisteredPrefixesClient) ListByPeeringPreparer(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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPeeringSender sends the ListByPeering request. The method will close the +// http.Response Body if it receives an error. +func (client RegisteredPrefixesClient) ListByPeeringSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPeeringResponder handles the response to the ListByPeering request. The method always +// closes the http.Response Body. +func (client RegisteredPrefixesClient) ListByPeeringResponder(resp *http.Response) (result RegisteredPrefixListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPeeringNextResults retrieves the next set of results, if any. +func (client RegisteredPrefixesClient) listByPeeringNextResults(ctx context.Context, lastResults RegisteredPrefixListResult) (result RegisteredPrefixListResult, err error) { + req, err := lastResults.registeredPrefixListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "listByPeeringNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPeeringSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "listByPeeringNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPeeringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "listByPeeringNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPeeringComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegisteredPrefixesClient) ListByPeeringComplete(ctx context.Context, resourceGroupName string, peeringName string) (result RegisteredPrefixListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixesClient.ListByPeering") + 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.ListByPeering(ctx, resourceGroupName, peeringName) + return +} diff --git a/services/peering/mgmt/2021-01-01/peering/servicecountries.go b/services/peering/mgmt/2021-01-01/peering/servicecountries.go new file mode 100644 index 000000000000..914792eb6778 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/servicecountries.go @@ -0,0 +1,145 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServiceCountriesClient is the peering Client +type ServiceCountriesClient struct { + BaseClient +} + +// NewServiceCountriesClient creates an instance of the ServiceCountriesClient client. +func NewServiceCountriesClient(subscriptionID string) ServiceCountriesClient { + return NewServiceCountriesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceCountriesClientWithBaseURI creates an instance of the ServiceCountriesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServiceCountriesClientWithBaseURI(baseURI string, subscriptionID string) ServiceCountriesClient { + return ServiceCountriesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available countries for peering service. +func (client ServiceCountriesClient) List(ctx context.Context) (result ServiceCountryListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceCountriesClient.List") + defer func() { + sc := -1 + if result.sclr.Response.Response != nil { + sc = result.sclr.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.ServiceCountriesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ServiceCountriesClient", "List", resp, "Failure sending request") + return + } + + result.sclr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServiceCountriesClient", "List", resp, "Failure responding to request") + return + } + if result.sclr.hasNextLink() && result.sclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServiceCountriesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceCountries", 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 ServiceCountriesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServiceCountriesClient) ListResponder(resp *http.Response) (result ServiceCountryListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ServiceCountriesClient) listNextResults(ctx context.Context, lastResults ServiceCountryListResult) (result ServiceCountryListResult, err error) { + req, err := lastResults.serviceCountryListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.ServiceCountriesClient", "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.ServiceCountriesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServiceCountriesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServiceCountriesClient) ListComplete(ctx context.Context) (result ServiceCountryListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceCountriesClient.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/peering/mgmt/2021-01-01/peering/servicelocations.go b/services/peering/mgmt/2021-01-01/peering/servicelocations.go new file mode 100644 index 000000000000..aef32951f389 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/servicelocations.go @@ -0,0 +1,150 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServiceLocationsClientWithBaseURI(baseURI string, subscriptionID string) ServiceLocationsClient { + return ServiceLocationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available locations for peering service. +// Parameters: +// country - the country of interest, in which the locations are to be present. +func (client ServiceLocationsClient) List(ctx context.Context, country string) (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, country) + 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 + } + if result.sllr.hasNextLink() && result.sllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServiceLocationsClient) ListPreparer(ctx context.Context, country string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(country) > 0 { + queryParameters["country"] = autorest.Encode("query", country) + } + + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServiceLocationsClient) ListResponder(resp *http.Response) (result ServiceLocationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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, country string) (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, country) + return +} diff --git a/services/peering/mgmt/2021-01-01/peering/serviceproviders.go b/services/peering/mgmt/2021-01-01/peering/serviceproviders.go new file mode 100644 index 000000000000..2a1e496bd232 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/serviceproviders.go @@ -0,0 +1,145 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +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 + } + if result.splr.hasNextLink() && result.splr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-01-01" + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServiceProvidersClient) ListResponder(resp *http.Response) (result ServiceProviderListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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/peering/mgmt/2021-01-01/peering/services.go b/services/peering/mgmt/2021-01-01/peering/services.go new file mode 100644 index 000000000000..a2b8a08af90a --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/services.go @@ -0,0 +1,577 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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 + } + + 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServicesClient) CreateOrUpdateResponder(resp *http.Response) (result Service, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete 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 + } + + 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get 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 + } + + 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServicesClient) GetResponder(resp *http.Response) (result Service, err error) { + err = autorest.Respond( + resp, + 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 + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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 + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-01-01" + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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 + } + + 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 = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/peering/mgmt/2021-01-01/peering/version.go b/services/peering/mgmt/2021-01-01/peering/version.go new file mode 100644 index 000000000000..dac301e3a277 --- /dev/null +++ b/services/peering/mgmt/2021-01-01/peering/version.go @@ -0,0 +1,19 @@ +package peering + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " peering/2021-01-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/peering/mgmt/2021-06-01/peering/CHANGELOG.md b/services/peering/mgmt/2021-06-01/peering/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/peering/mgmt/2021-06-01/peering/_meta.json b/services/peering/mgmt/2021-06-01/peering/_meta.json new file mode 100644 index 000000000000..356a0dc0c356 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "c51580c6f102bace66c5bed4b979437c21b81882", + "readme": "/_/azure-rest-api-specs/specification/peering/resource-manager/readme.md", + "tag": "package-2021-06-01", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2021-06-01 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/peering/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/peering/mgmt/2021-06-01/peering/cdnpeeringprefixes.go b/services/peering/mgmt/2021-06-01/peering/cdnpeeringprefixes.go new file mode 100644 index 000000000000..f78f4fb6afd9 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/cdnpeeringprefixes.go @@ -0,0 +1,148 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CdnPeeringPrefixesClient is the peering Client +type CdnPeeringPrefixesClient struct { + BaseClient +} + +// NewCdnPeeringPrefixesClient creates an instance of the CdnPeeringPrefixesClient client. +func NewCdnPeeringPrefixesClient(subscriptionID string) CdnPeeringPrefixesClient { + return NewCdnPeeringPrefixesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCdnPeeringPrefixesClientWithBaseURI creates an instance of the CdnPeeringPrefixesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewCdnPeeringPrefixesClientWithBaseURI(baseURI string, subscriptionID string) CdnPeeringPrefixesClient { + return CdnPeeringPrefixesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the advertised prefixes for the specified peering location +// Parameters: +// peeringLocation - the peering location. +func (client CdnPeeringPrefixesClient) List(ctx context.Context, peeringLocation string) (result CdnPeeringPrefixListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CdnPeeringPrefixesClient.List") + defer func() { + sc := -1 + if result.cpplr.Response.Response != nil { + sc = result.cpplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, peeringLocation) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.CdnPeeringPrefixesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cpplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.CdnPeeringPrefixesClient", "List", resp, "Failure sending request") + return + } + + result.cpplr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.CdnPeeringPrefixesClient", "List", resp, "Failure responding to request") + return + } + if result.cpplr.hasNextLink() && result.cpplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client CdnPeeringPrefixesClient) ListPreparer(ctx context.Context, peeringLocation string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "peeringLocation": autorest.Encode("query", peeringLocation), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/cdnPeeringPrefixes", 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 CdnPeeringPrefixesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client CdnPeeringPrefixesClient) ListResponder(resp *http.Response) (result CdnPeeringPrefixListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client CdnPeeringPrefixesClient) listNextResults(ctx context.Context, lastResults CdnPeeringPrefixListResult) (result CdnPeeringPrefixListResult, err error) { + req, err := lastResults.cdnPeeringPrefixListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.CdnPeeringPrefixesClient", "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.CdnPeeringPrefixesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.CdnPeeringPrefixesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client CdnPeeringPrefixesClient) ListComplete(ctx context.Context, peeringLocation string) (result CdnPeeringPrefixListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CdnPeeringPrefixesClient.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) + return +} diff --git a/services/peering/mgmt/2021-06-01/peering/client.go b/services/peering/mgmt/2021-06-01/peering/client.go new file mode 100644 index 000000000000..fc818cfb5faa --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/client.go @@ -0,0 +1,122 @@ +// Package peering implements the Azure ARM Peering service API version 2021-06-01. +// +// Peering Client +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +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 using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} + +// 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 + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/peering/mgmt/2021-06-01/peering/connectionmonitortests.go b/services/peering/mgmt/2021-06-01/peering/connectionmonitortests.go new file mode 100644 index 000000000000..2b41a3c64a9d --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/connectionmonitortests.go @@ -0,0 +1,390 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ConnectionMonitorTestsClient is the peering Client +type ConnectionMonitorTestsClient struct { + BaseClient +} + +// NewConnectionMonitorTestsClient creates an instance of the ConnectionMonitorTestsClient client. +func NewConnectionMonitorTestsClient(subscriptionID string) ConnectionMonitorTestsClient { + return NewConnectionMonitorTestsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConnectionMonitorTestsClientWithBaseURI creates an instance of the ConnectionMonitorTestsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewConnectionMonitorTestsClientWithBaseURI(baseURI string, subscriptionID string) ConnectionMonitorTestsClient { + return ConnectionMonitorTestsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a connection monitor test with the specified name under the given subscription, +// resource group and peering service. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// connectionMonitorTestName - the name of the connection monitor test +// connectionMonitorTest - the properties needed to create a connection monitor test +func (client ConnectionMonitorTestsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringServiceName string, connectionMonitorTestName string, connectionMonitorTest ConnectionMonitorTest) (result ConnectionMonitorTest, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorTestsClient.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, connectionMonitorTestName, connectionMonitorTest) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ConnectionMonitorTestsClient", "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.ConnectionMonitorTestsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ConnectionMonitorTestsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConnectionMonitorTestsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, peeringServiceName string, connectionMonitorTestName string, connectionMonitorTest ConnectionMonitorTest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectionMonitorTestName": autorest.Encode("path", connectionMonitorTestName), + "peeringServiceName": autorest.Encode("path", peeringServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests/{connectionMonitorTestName}", pathParameters), + autorest.WithJSON(connectionMonitorTest), + 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 ConnectionMonitorTestsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConnectionMonitorTestsClient) CreateOrUpdateResponder(resp *http.Response) (result ConnectionMonitorTest, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing connection monitor test with the specified name under the given subscription, resource +// group and peering service. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// connectionMonitorTestName - the name of the connection monitor test +func (client ConnectionMonitorTestsClient) Delete(ctx context.Context, resourceGroupName string, peeringServiceName string, connectionMonitorTestName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorTestsClient.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, connectionMonitorTestName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ConnectionMonitorTestsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "peering.ConnectionMonitorTestsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ConnectionMonitorTestsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConnectionMonitorTestsClient) DeletePreparer(ctx context.Context, resourceGroupName string, peeringServiceName string, connectionMonitorTestName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectionMonitorTestName": autorest.Encode("path", connectionMonitorTestName), + "peeringServiceName": autorest.Encode("path", peeringServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests/{connectionMonitorTestName}", 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 ConnectionMonitorTestsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConnectionMonitorTestsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an existing connection monitor test with the specified name under the given subscription, resource group +// and peering service. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// connectionMonitorTestName - the name of the connection monitor test +func (client ConnectionMonitorTestsClient) Get(ctx context.Context, resourceGroupName string, peeringServiceName string, connectionMonitorTestName string) (result ConnectionMonitorTest, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorTestsClient.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, connectionMonitorTestName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ConnectionMonitorTestsClient", "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.ConnectionMonitorTestsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ConnectionMonitorTestsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConnectionMonitorTestsClient) GetPreparer(ctx context.Context, resourceGroupName string, peeringServiceName string, connectionMonitorTestName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectionMonitorTestName": autorest.Encode("path", connectionMonitorTestName), + "peeringServiceName": autorest.Encode("path", peeringServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests/{connectionMonitorTestName}", 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 ConnectionMonitorTestsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConnectionMonitorTestsClient) GetResponder(resp *http.Response) (result ConnectionMonitorTest, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPeeringService lists all connection monitor tests under the given subscription, resource group and peering +// service. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +func (client ConnectionMonitorTestsClient) ListByPeeringService(ctx context.Context, resourceGroupName string, peeringServiceName string) (result ConnectionMonitorTestListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorTestsClient.ListByPeeringService") + defer func() { + sc := -1 + if result.cmtlr.Response.Response != nil { + sc = result.cmtlr.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.ConnectionMonitorTestsClient", "ListByPeeringService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPeeringServiceSender(req) + if err != nil { + result.cmtlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ConnectionMonitorTestsClient", "ListByPeeringService", resp, "Failure sending request") + return + } + + result.cmtlr, err = client.ListByPeeringServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ConnectionMonitorTestsClient", "ListByPeeringService", resp, "Failure responding to request") + return + } + if result.cmtlr.hasNextLink() && result.cmtlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPeeringServicePreparer prepares the ListByPeeringService request. +func (client ConnectionMonitorTestsClient) 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/connectionMonitorTests", 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 ConnectionMonitorTestsClient) ListByPeeringServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPeeringServiceResponder handles the response to the ListByPeeringService request. The method always +// closes the http.Response Body. +func (client ConnectionMonitorTestsClient) ListByPeeringServiceResponder(resp *http.Response) (result ConnectionMonitorTestListResult, err error) { + err = autorest.Respond( + resp, + 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 ConnectionMonitorTestsClient) listByPeeringServiceNextResults(ctx context.Context, lastResults ConnectionMonitorTestListResult) (result ConnectionMonitorTestListResult, err error) { + req, err := lastResults.connectionMonitorTestListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.ConnectionMonitorTestsClient", "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.ConnectionMonitorTestsClient", "listByPeeringServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPeeringServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ConnectionMonitorTestsClient", "listByPeeringServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPeeringServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConnectionMonitorTestsClient) ListByPeeringServiceComplete(ctx context.Context, resourceGroupName string, peeringServiceName string) (result ConnectionMonitorTestListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorTestsClient.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/peering/mgmt/2021-06-01/peering/enums.go b/services/peering/mgmt/2021-06-01/peering/enums.go new file mode 100644 index 000000000000..d76d3eb1dea3 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/enums.go @@ -0,0 +1,322 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// Command enumerates the values for command. +type Command string + +const ( + // BgpRoute ... + BgpRoute Command = "BgpRoute" + // Ping ... + Ping Command = "Ping" + // Traceroute ... + Traceroute Command = "Traceroute" +) + +// PossibleCommandValues returns an array of possible values for the Command const type. +func PossibleCommandValues() []Command { + return []Command{BgpRoute, Ping, Traceroute} +} + +// 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" + // Ix ... + Ix DirectPeeringType = "Ix" + // IxRs ... + IxRs DirectPeeringType = "IxRs" + // Transit ... + Transit DirectPeeringType = "Transit" + // Voice ... + Voice DirectPeeringType = "Voice" +) + +// PossibleDirectPeeringTypeValues returns an array of possible values for the DirectPeeringType const type. +func PossibleDirectPeeringTypeValues() []DirectPeeringType { + return []DirectPeeringType{Cdn, Edge, Internal, Ix, IxRs, Transit, Voice} +} + +// 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" + // LearnedTypeViaServiceProvider ... + LearnedTypeViaServiceProvider LearnedType = "ViaServiceProvider" + // LearnedTypeViaSession ... + LearnedTypeViaSession LearnedType = "ViaSession" +) + +// PossibleLearnedTypeValues returns an array of possible values for the LearnedType const type. +func PossibleLearnedTypeValues() []LearnedType { + return []LearnedType{LearnedTypeNone, LearnedTypeViaServiceProvider, LearnedTypeViaSession} +} + +// 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" + // PrefixValidationStateWarning ... + PrefixValidationStateWarning PrefixValidationState = "Warning" +) + +// PossiblePrefixValidationStateValues returns an array of possible values for the PrefixValidationState const type. +func PossiblePrefixValidationStateValues() []PrefixValidationState { + return []PrefixValidationState{PrefixValidationStateFailed, PrefixValidationStateInvalid, PrefixValidationStateNone, PrefixValidationStatePending, PrefixValidationStateUnknown, PrefixValidationStateVerified, PrefixValidationStateWarning} +} + +// 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} +} + +// Role enumerates the values for role. +type Role string + +const ( + // RoleEscalation ... + RoleEscalation Role = "Escalation" + // RoleNoc ... + RoleNoc Role = "Noc" + // RoleOther ... + RoleOther Role = "Other" + // RolePolicy ... + RolePolicy Role = "Policy" + // RoleService ... + RoleService Role = "Service" + // RoleTechnical ... + RoleTechnical Role = "Technical" +) + +// PossibleRoleValues returns an array of possible values for the Role const type. +func PossibleRoleValues() []Role { + return []Role{RoleEscalation, RoleNoc, RoleOther, RolePolicy, RoleService, RoleTechnical} +} + +// 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} +} diff --git a/services/peering/mgmt/2021-06-01/peering/legacypeerings.go b/services/peering/mgmt/2021-06-01/peering/legacypeerings.go new file mode 100644 index 000000000000..6b3cd3bcc359 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/legacypeerings.go @@ -0,0 +1,153 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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. +// asn - the ASN number associated with a legacy peering. +func (client LegacyPeeringsClient) List(ctx context.Context, peeringLocation string, kind string, asn *int32) (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, asn) + 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 + } + if result.lr.hasNextLink() && result.lr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client LegacyPeeringsClient) ListPreparer(ctx context.Context, peeringLocation string, kind string, asn *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "kind": autorest.Encode("query", kind), + "peeringLocation": autorest.Encode("query", peeringLocation), + } + if asn != nil { + queryParameters["asn"] = autorest.Encode("query", *asn) + } + + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LegacyPeeringsClient) ListResponder(resp *http.Response) (result ListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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, asn *int32) (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, asn) + return +} diff --git a/services/peering/mgmt/2021-06-01/peering/locations.go b/services/peering/mgmt/2021-06-01/peering/locations.go new file mode 100644 index 000000000000..06c22deeb8a2 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/locations.go @@ -0,0 +1,151 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewLocationsClientWithBaseURI(baseURI string, subscriptionID string) LocationsClient { + return LocationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// 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 + } + if result.llr.hasNextLink() && result.llr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-06-01" + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LocationsClient) ListResponder(resp *http.Response) (result LocationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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/peering/mgmt/2021-06-01/peering/lookingglass.go b/services/peering/mgmt/2021-06-01/peering/lookingglass.go new file mode 100644 index 000000000000..49d489b51de1 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/lookingglass.go @@ -0,0 +1,111 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// LookingGlassClient is the peering Client +type LookingGlassClient struct { + BaseClient +} + +// NewLookingGlassClient creates an instance of the LookingGlassClient client. +func NewLookingGlassClient(subscriptionID string) LookingGlassClient { + return NewLookingGlassClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLookingGlassClientWithBaseURI creates an instance of the LookingGlassClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewLookingGlassClientWithBaseURI(baseURI string, subscriptionID string) LookingGlassClient { + return LookingGlassClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Invoke run looking glass functionality +// Parameters: +// command - the command to be executed: ping, traceroute, bgpRoute. +// sourceType - the type of the source: Edge site or Azure Region. +// sourceLocation - the location of the source. +// destinationIP - the IP address of the destination. +func (client LookingGlassClient) Invoke(ctx context.Context, command string, sourceType string, sourceLocation string, destinationIP string) (result LookingGlassOutput, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LookingGlassClient.Invoke") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.InvokePreparer(ctx, command, sourceType, sourceLocation, destinationIP) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.LookingGlassClient", "Invoke", nil, "Failure preparing request") + return + } + + resp, err := client.InvokeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.LookingGlassClient", "Invoke", resp, "Failure sending request") + return + } + + result, err = client.InvokeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.LookingGlassClient", "Invoke", resp, "Failure responding to request") + return + } + + return +} + +// InvokePreparer prepares the Invoke request. +func (client LookingGlassClient) InvokePreparer(ctx context.Context, command string, sourceType string, sourceLocation string, destinationIP string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "command": autorest.Encode("query", command), + "destinationIP": autorest.Encode("query", destinationIP), + "sourceLocation": autorest.Encode("query", sourceLocation), + "sourceType": autorest.Encode("query", sourceType), + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/lookingGlass", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// InvokeSender sends the Invoke request. The method will close the +// http.Response Body if it receives an error. +func (client LookingGlassClient) InvokeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// InvokeResponder handles the response to the Invoke request. The method always +// closes the http.Response Body. +func (client LookingGlassClient) InvokeResponder(resp *http.Response) (result LookingGlassOutput, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/peering/mgmt/2021-06-01/peering/models.go b/services/peering/mgmt/2021-06-01/peering/models.go new file mode 100644 index 000000000000..f718cef6d82b --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/models.go @@ -0,0 +1,3980 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/peering/mgmt/2021-06-01/peering" + +// 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 - The IPv4 session address on Microsoft's end. + MicrosoftSessionIPv4Address *string `json:"microsoftSessionIPv4Address,omitempty"` + // MicrosoftSessionIPv6Address - 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"` +} + +// MarshalJSON is the custom marshaler for BgpSession. +func (bs BgpSession) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bs.SessionPrefixV4 != nil { + objectMap["sessionPrefixV4"] = bs.SessionPrefixV4 + } + if bs.SessionPrefixV6 != nil { + objectMap["sessionPrefixV6"] = bs.SessionPrefixV6 + } + if bs.MicrosoftSessionIPv4Address != nil { + objectMap["microsoftSessionIPv4Address"] = bs.MicrosoftSessionIPv4Address + } + if bs.MicrosoftSessionIPv6Address != nil { + objectMap["microsoftSessionIPv6Address"] = bs.MicrosoftSessionIPv6Address + } + if bs.PeerSessionIPv4Address != nil { + objectMap["peerSessionIPv4Address"] = bs.PeerSessionIPv4Address + } + if bs.PeerSessionIPv6Address != nil { + objectMap["peerSessionIPv6Address"] = bs.PeerSessionIPv6Address + } + if bs.MaxPrefixesAdvertisedV4 != nil { + objectMap["maxPrefixesAdvertisedV4"] = bs.MaxPrefixesAdvertisedV4 + } + if bs.MaxPrefixesAdvertisedV6 != nil { + objectMap["maxPrefixesAdvertisedV6"] = bs.MaxPrefixesAdvertisedV6 + } + if bs.Md5AuthenticationKey != nil { + objectMap["md5AuthenticationKey"] = bs.Md5AuthenticationKey + } + return json.Marshal(objectMap) +} + +// CdnPeeringPrefix the CDN peering prefix +type CdnPeeringPrefix struct { + // CdnPeeringPrefixProperties - The properties that define a cdn peering prefix. + *CdnPeeringPrefixProperties `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 CdnPeeringPrefix. +func (cpp CdnPeeringPrefix) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cpp.CdnPeeringPrefixProperties != nil { + objectMap["properties"] = cpp.CdnPeeringPrefixProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CdnPeeringPrefix struct. +func (cpp *CdnPeeringPrefix) 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 cdnPeeringPrefixProperties CdnPeeringPrefixProperties + err = json.Unmarshal(*v, &cdnPeeringPrefixProperties) + if err != nil { + return err + } + cpp.CdnPeeringPrefixProperties = &cdnPeeringPrefixProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cpp.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cpp.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cpp.Type = &typeVar + } + } + } + + return nil +} + +// CdnPeeringPrefixListResult the paginated list of CDN peering prefixes. +type CdnPeeringPrefixListResult struct { + autorest.Response `json:"-"` + // Value - The list of CDN peering prefixes. + Value *[]CdnPeeringPrefix `json:"value,omitempty"` + // NextLink - The link to fetch the next page of CDN peering prefixes. + NextLink *string `json:"nextLink,omitempty"` +} + +// CdnPeeringPrefixListResultIterator provides access to a complete listing of CdnPeeringPrefix values. +type CdnPeeringPrefixListResultIterator struct { + i int + page CdnPeeringPrefixListResultPage +} + +// 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 *CdnPeeringPrefixListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CdnPeeringPrefixListResultIterator.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 *CdnPeeringPrefixListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CdnPeeringPrefixListResultIterator) 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 CdnPeeringPrefixListResultIterator) Response() CdnPeeringPrefixListResult { + 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 CdnPeeringPrefixListResultIterator) Value() CdnPeeringPrefix { + if !iter.page.NotDone() { + return CdnPeeringPrefix{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CdnPeeringPrefixListResultIterator type. +func NewCdnPeeringPrefixListResultIterator(page CdnPeeringPrefixListResultPage) CdnPeeringPrefixListResultIterator { + return CdnPeeringPrefixListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cpplr CdnPeeringPrefixListResult) IsEmpty() bool { + return cpplr.Value == nil || len(*cpplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cpplr CdnPeeringPrefixListResult) hasNextLink() bool { + return cpplr.NextLink != nil && len(*cpplr.NextLink) != 0 +} + +// cdnPeeringPrefixListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cpplr CdnPeeringPrefixListResult) cdnPeeringPrefixListResultPreparer(ctx context.Context) (*http.Request, error) { + if !cpplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cpplr.NextLink))) +} + +// CdnPeeringPrefixListResultPage contains a page of CdnPeeringPrefix values. +type CdnPeeringPrefixListResultPage struct { + fn func(context.Context, CdnPeeringPrefixListResult) (CdnPeeringPrefixListResult, error) + cpplr CdnPeeringPrefixListResult +} + +// 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 *CdnPeeringPrefixListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CdnPeeringPrefixListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.cpplr) + if err != nil { + return err + } + page.cpplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *CdnPeeringPrefixListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CdnPeeringPrefixListResultPage) NotDone() bool { + return !page.cpplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CdnPeeringPrefixListResultPage) Response() CdnPeeringPrefixListResult { + return page.cpplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CdnPeeringPrefixListResultPage) Values() []CdnPeeringPrefix { + if page.cpplr.IsEmpty() { + return nil + } + return *page.cpplr.Value +} + +// Creates a new instance of the CdnPeeringPrefixListResultPage type. +func NewCdnPeeringPrefixListResultPage(cur CdnPeeringPrefixListResult, getNextPage func(context.Context, CdnPeeringPrefixListResult) (CdnPeeringPrefixListResult, error)) CdnPeeringPrefixListResultPage { + return CdnPeeringPrefixListResultPage{ + fn: getNextPage, + cpplr: cur, + } +} + +// CdnPeeringPrefixProperties the properties that define a CDN peering prefix +type CdnPeeringPrefixProperties struct { + // Prefix - READ-ONLY; The prefix. + Prefix *string `json:"prefix,omitempty"` + // AzureRegion - READ-ONLY; The Azure region. + AzureRegion *string `json:"azureRegion,omitempty"` + // AzureService - READ-ONLY; The Azure service. + AzureService *string `json:"azureService,omitempty"` + // IsPrimaryRegion - READ-ONLY; The flag that indicates whether or not this is the primary region. + IsPrimaryRegion *bool `json:"isPrimaryRegion,omitempty"` + // BgpCommunity - READ-ONLY; The BGP Community + BgpCommunity *string `json:"bgpCommunity,omitempty"` +} + +// MarshalJSON is the custom marshaler for CdnPeeringPrefixProperties. +func (cppp CdnPeeringPrefixProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CheckServiceProviderAvailabilityInput class for CheckServiceProviderAvailabilityInput +type CheckServiceProviderAvailabilityInput struct { + // PeeringServiceLocation - Gets or sets the peering service location. + PeeringServiceLocation *string `json:"peeringServiceLocation,omitempty"` + // PeeringServiceProvider - Gets or sets the peering service provider. + PeeringServiceProvider *string `json:"peeringServiceProvider,omitempty"` +} + +// ConnectionMonitorTest the Connection Monitor Test class. +type ConnectionMonitorTest struct { + autorest.Response `json:"-"` + // ConnectionMonitorTestProperties - The properties that define a Connection Monitor Test. + *ConnectionMonitorTestProperties `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 ConnectionMonitorTest. +func (cmt ConnectionMonitorTest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cmt.ConnectionMonitorTestProperties != nil { + objectMap["properties"] = cmt.ConnectionMonitorTestProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectionMonitorTest struct. +func (cmt *ConnectionMonitorTest) 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 connectionMonitorTestProperties ConnectionMonitorTestProperties + err = json.Unmarshal(*v, &connectionMonitorTestProperties) + if err != nil { + return err + } + cmt.ConnectionMonitorTestProperties = &connectionMonitorTestProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cmt.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cmt.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cmt.Type = &typeVar + } + } + } + + return nil +} + +// ConnectionMonitorTestListResult the paginated list of [T]. +type ConnectionMonitorTestListResult struct { + autorest.Response `json:"-"` + // Value - The list of [T]. + Value *[]ConnectionMonitorTest `json:"value,omitempty"` + // NextLink - The link to fetch the next page of [T]. + NextLink *string `json:"nextLink,omitempty"` +} + +// ConnectionMonitorTestListResultIterator provides access to a complete listing of ConnectionMonitorTest +// values. +type ConnectionMonitorTestListResultIterator struct { + i int + page ConnectionMonitorTestListResultPage +} + +// 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 *ConnectionMonitorTestListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorTestListResultIterator.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 *ConnectionMonitorTestListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ConnectionMonitorTestListResultIterator) 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 ConnectionMonitorTestListResultIterator) Response() ConnectionMonitorTestListResult { + 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 ConnectionMonitorTestListResultIterator) Value() ConnectionMonitorTest { + if !iter.page.NotDone() { + return ConnectionMonitorTest{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ConnectionMonitorTestListResultIterator type. +func NewConnectionMonitorTestListResultIterator(page ConnectionMonitorTestListResultPage) ConnectionMonitorTestListResultIterator { + return ConnectionMonitorTestListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cmtlr ConnectionMonitorTestListResult) IsEmpty() bool { + return cmtlr.Value == nil || len(*cmtlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cmtlr ConnectionMonitorTestListResult) hasNextLink() bool { + return cmtlr.NextLink != nil && len(*cmtlr.NextLink) != 0 +} + +// connectionMonitorTestListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cmtlr ConnectionMonitorTestListResult) connectionMonitorTestListResultPreparer(ctx context.Context) (*http.Request, error) { + if !cmtlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cmtlr.NextLink))) +} + +// ConnectionMonitorTestListResultPage contains a page of ConnectionMonitorTest values. +type ConnectionMonitorTestListResultPage struct { + fn func(context.Context, ConnectionMonitorTestListResult) (ConnectionMonitorTestListResult, error) + cmtlr ConnectionMonitorTestListResult +} + +// 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 *ConnectionMonitorTestListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorTestListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.cmtlr) + if err != nil { + return err + } + page.cmtlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ConnectionMonitorTestListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ConnectionMonitorTestListResultPage) NotDone() bool { + return !page.cmtlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ConnectionMonitorTestListResultPage) Response() ConnectionMonitorTestListResult { + return page.cmtlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ConnectionMonitorTestListResultPage) Values() []ConnectionMonitorTest { + if page.cmtlr.IsEmpty() { + return nil + } + return *page.cmtlr.Value +} + +// Creates a new instance of the ConnectionMonitorTestListResultPage type. +func NewConnectionMonitorTestListResultPage(cur ConnectionMonitorTestListResult, getNextPage func(context.Context, ConnectionMonitorTestListResult) (ConnectionMonitorTestListResult, error)) ConnectionMonitorTestListResultPage { + return ConnectionMonitorTestListResultPage{ + fn: getNextPage, + cmtlr: cur, + } +} + +// ConnectionMonitorTestProperties the properties that define a Connection Monitor Test. +type ConnectionMonitorTestProperties struct { + // SourceAgent - The Connection Monitor test source agent + SourceAgent *string `json:"sourceAgent,omitempty"` + // Destination - The Connection Monitor test destination + Destination *string `json:"destination,omitempty"` + // DestinationPort - The Connection Monitor test destination port + DestinationPort *int32 `json:"destinationPort,omitempty"` + // TestFrequencyInSec - The Connection Monitor test frequency in seconds + TestFrequencyInSec *int32 `json:"testFrequencyInSec,omitempty"` + // IsTestSuccessful - READ-ONLY; The flag that indicates if the Connection Monitor test is successful or not. + IsTestSuccessful *bool `json:"isTestSuccessful,omitempty"` + // Path - READ-ONLY; The path representing the Connection Monitor test. + Path *[]string `json:"path,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionMonitorTestProperties. +func (cmtp ConnectionMonitorTestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cmtp.SourceAgent != nil { + objectMap["sourceAgent"] = cmtp.SourceAgent + } + if cmtp.Destination != nil { + objectMap["destination"] = cmtp.Destination + } + if cmtp.DestinationPort != nil { + objectMap["destinationPort"] = cmtp.DestinationPort + } + if cmtp.TestFrequencyInSec != nil { + objectMap["testFrequencyInSec"] = cmtp.TestFrequencyInSec + } + return json.Marshal(objectMap) +} + +// ContactDetail the contact detail class. +type ContactDetail struct { + // Role - The role of the contact. Possible values include: 'RoleNoc', 'RolePolicy', 'RoleTechnical', 'RoleService', 'RoleEscalation', 'RoleOther' + Role Role `json:"role,omitempty"` + // Email - The e-mail address of the contact. + Email *string `json:"email,omitempty"` + // Phone - The phone number of the contact. + 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 - READ-ONLY; 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"` + // MicrosoftTrackingID - READ-ONLY; The ID used within Microsoft's peering provisioning system to track the connection + MicrosoftTrackingID *string `json:"microsoftTrackingId,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"` + // ErrorMessage - READ-ONLY; The error message related to the connection state, if any. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// MarshalJSON is the custom marshaler for DirectConnection. +func (dc DirectConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dc.BandwidthInMbps != nil { + objectMap["bandwidthInMbps"] = dc.BandwidthInMbps + } + if dc.SessionAddressProvider != "" { + objectMap["sessionAddressProvider"] = dc.SessionAddressProvider + } + if dc.UseForPeeringService != nil { + objectMap["useForPeeringService"] = dc.UseForPeeringService + } + if dc.PeeringDBFacilityID != nil { + objectMap["peeringDBFacilityId"] = dc.PeeringDBFacilityID + } + if dc.BgpSession != nil { + objectMap["bgpSession"] = dc.BgpSession + } + if dc.ConnectionIdentifier != nil { + objectMap["connectionIdentifier"] = dc.ConnectionIdentifier + } + return json.Marshal(objectMap) +} + +// 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', 'Ix', 'IxRs', 'Voice' + 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"` +} + +// ErrorDetail the error detail that describes why an operation has failed. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse the error response that indicates why an operation has failed. +type ErrorResponse struct { + // Error - The error detail that describes why an operation has failed. + Error *ErrorDetail `json:"error,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"` + // ErrorMessage - READ-ONLY; The error message related to the connection state, if any. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExchangeConnection. +func (ec ExchangeConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ec.PeeringDBFacilityID != nil { + objectMap["peeringDBFacilityId"] = ec.PeeringDBFacilityID + } + if ec.BgpSession != nil { + objectMap["bgpSession"] = ec.BgpSession + } + if ec.ConnectionIdentifier != nil { + objectMap["connectionIdentifier"] = ec.ConnectionIdentifier + } + return json.Marshal(objectMap) +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (lr ListResult) hasNextLink() bool { + return lr.NextLink != nil && len(*lr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.lr) + if err != nil { + return err + } + page.lr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage { + return ListResultPage{ + fn: getNextPage, + lr: cur, + } +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (llr LocationListResult) hasNextLink() bool { + return llr.NextLink != nil && len(*llr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.llr) + if err != nil { + return err + } + page.llr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur LocationListResult, getNextPage func(context.Context, LocationListResult) (LocationListResult, error)) LocationListResultPage { + return LocationListResultPage{ + fn: getNextPage, + llr: cur, + } +} + +// 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"` +} + +// LogAnalyticsWorkspaceProperties the properties that define a Log Analytics Workspace. +type LogAnalyticsWorkspaceProperties struct { + // WorkspaceID - READ-ONLY; The Workspace ID. + WorkspaceID *string `json:"workspaceID,omitempty"` + // Key - READ-ONLY; The Workspace Key. + Key *string `json:"key,omitempty"` + // ConnectedAgents - READ-ONLY; The list of connected agents. + ConnectedAgents *[]string `json:"connectedAgents,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogAnalyticsWorkspaceProperties. +func (lawp LogAnalyticsWorkspaceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LookingGlassOutput looking glass output model +type LookingGlassOutput struct { + autorest.Response `json:"-"` + // Command - Invoked command. Possible values include: 'Traceroute', 'Ping', 'BgpRoute' + Command Command `json:"command,omitempty"` + // Output - Output of the command + Output *string `json:"output,omitempty"` +} + +// MetricDimension dimensions of the metric. +type MetricDimension struct { + // Name - READ-ONLY; Name of the dimension. + Name *string `json:"name,omitempty"` + // DisplayName - READ-ONLY; Localized friendly display name of the dimension. + DisplayName *string `json:"displayName,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricDimension. +func (md MetricDimension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricSpecification specifications of the Metrics for Azure Monitoring. +type MetricSpecification struct { + // Name - READ-ONLY; Name of the metric. + Name *string `json:"name,omitempty"` + // DisplayName - READ-ONLY; Localized friendly display name of the metric. + DisplayName *string `json:"displayName,omitempty"` + // DisplayDescription - READ-ONLY; Localized friendly description of the metric. + DisplayDescription *string `json:"displayDescription,omitempty"` + // Unit - READ-ONLY; Unit that makes sense for the metric. + Unit *string `json:"unit,omitempty"` + // AggregationType - READ-ONLY; Aggregation type will be set to one of the values: Average, Minimum, Maximum, Total, Count. + AggregationType *string `json:"aggregationType,omitempty"` + // SupportedTimeGrainTypes - READ-ONLY; Supported time grain types for the metric. + SupportedTimeGrainTypes *[]string `json:"supportedTimeGrainTypes,omitempty"` + // Dimensions - READ-ONLY; Dimensions of the metric. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricSpecification. +func (ms MetricSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// 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"` + // OperationProperties - READ-ONLY; The properties of the operation. + *OperationProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Operation struct. +func (o *Operation) 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 "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + o.Name = &name + } + case "display": + if v != nil { + var display OperationDisplayInfo + err = json.Unmarshal(*v, &display) + if err != nil { + return err + } + o.Display = &display + } + case "isDataAction": + if v != nil { + var isDataAction bool + err = json.Unmarshal(*v, &isDataAction) + if err != nil { + return err + } + o.IsDataAction = &isDataAction + } + case "properties": + if v != nil { + var operationProperties OperationProperties + err = json.Unmarshal(*v, &operationProperties) + if err != nil { + return err + } + o.OperationProperties = &operationProperties + } + } + } + + return nil +} + +// 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"` +} + +// MarshalJSON is the custom marshaler for OperationDisplayInfo. +func (odi OperationDisplayInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// OperationProperties the properties of the operation. +type OperationProperties struct { + // ServiceSpecification - READ-ONLY; Service specification payload. + ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationProperties. +func (op OperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (palr PeerAsnListResult) hasNextLink() bool { + return palr.NextLink != nil && len(*palr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.palr) + if err != nil { + return err + } + page.palr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur PeerAsnListResult, getNextPage func(context.Context, PeerAsnListResult) (PeerAsnListResult, error)) PeerAsnListResultPage { + return PeerAsnListResultPage{ + fn: getNextPage, + palr: cur, + } +} + +// 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"` + // PeerContactDetail - The contact details of the peer. + PeerContactDetail *[]ContactDetail `json:"peerContactDetail,omitempty"` + // PeerName - The name of the peer. + PeerName *string `json:"peerName,omitempty"` + // ValidationState - READ-ONLY; The validation state of the ASN associated with the peer. Possible values include: 'ValidationStateNone', 'ValidationStatePending', 'ValidationStateApproved', 'ValidationStateFailed' + ValidationState ValidationState `json:"validationState,omitempty"` + // ErrorMessage - READ-ONLY; The error message for the validation state + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// MarshalJSON is the custom marshaler for PeerAsnProperties. +func (pap PeerAsnProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pap.PeerAsn != nil { + objectMap["peerAsn"] = pap.PeerAsn + } + if pap.PeerContactDetail != nil { + objectMap["peerContactDetail"] = pap.PeerContactDetail + } + if pap.PeerName != nil { + objectMap["peerName"] = pap.PeerName + } + return json.Marshal(objectMap) +} + +// 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"` +} + +// MarshalJSON is the custom marshaler for Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.Direct != nil { + objectMap["direct"] = p.Direct + } + if p.Exchange != nil { + objectMap["exchange"] = p.Exchange + } + if p.PeeringLocation != nil { + objectMap["peeringLocation"] = p.PeeringLocation + } + return json.Marshal(objectMap) +} + +// 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 - READ-ONLY; 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', 'Ix', 'IxRs', 'Voice' + DirectPeeringType DirectPeeringType `json:"directPeeringType,omitempty"` +} + +// MarshalJSON is the custom marshaler for PropertiesDirect. +func (pd PropertiesDirect) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pd.Connections != nil { + objectMap["connections"] = pd.Connections + } + if pd.PeerAsn != nil { + objectMap["peerAsn"] = pd.PeerAsn + } + if pd.DirectPeeringType != "" { + objectMap["directPeeringType"] = pd.DirectPeeringType + } + return json.Marshal(objectMap) +} + +// 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"` +} + +// ReceivedRoute the properties that define a received route. +type ReceivedRoute struct { + // Prefix - READ-ONLY; The prefix. + Prefix *string `json:"prefix,omitempty"` + // NextHop - READ-ONLY; The next hop for the prefix. + NextHop *string `json:"nextHop,omitempty"` + // AsPath - READ-ONLY; The AS path for the prefix. + AsPath *string `json:"asPath,omitempty"` + // OriginAsValidationState - READ-ONLY; The origin AS change information for the prefix. + OriginAsValidationState *string `json:"originAsValidationState,omitempty"` + // RpkiValidationState - READ-ONLY; The RPKI validation state for the prefix and origin AS that's listed in the AS path. + RpkiValidationState *string `json:"rpkiValidationState,omitempty"` + // TrustAnchor - READ-ONLY; The authority which holds the Route Origin Authorization record for the prefix, if any. + TrustAnchor *string `json:"trustAnchor,omitempty"` + // ReceivedTimestamp - READ-ONLY; The received timestamp associated with the prefix. + ReceivedTimestamp *string `json:"receivedTimestamp,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReceivedRoute. +func (rr ReceivedRoute) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ReceivedRouteListResult the paginated list of received routes for the peering. +type ReceivedRouteListResult struct { + autorest.Response `json:"-"` + // Value - The list of received routes for the peering. + Value *[]ReceivedRoute `json:"value,omitempty"` + // NextLink - The link to fetch the next page of received routes for the peering. + NextLink *string `json:"nextLink,omitempty"` +} + +// ReceivedRouteListResultIterator provides access to a complete listing of ReceivedRoute values. +type ReceivedRouteListResultIterator struct { + i int + page ReceivedRouteListResultPage +} + +// 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 *ReceivedRouteListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReceivedRouteListResultIterator.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 *ReceivedRouteListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ReceivedRouteListResultIterator) 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 ReceivedRouteListResultIterator) Response() ReceivedRouteListResult { + 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 ReceivedRouteListResultIterator) Value() ReceivedRoute { + if !iter.page.NotDone() { + return ReceivedRoute{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ReceivedRouteListResultIterator type. +func NewReceivedRouteListResultIterator(page ReceivedRouteListResultPage) ReceivedRouteListResultIterator { + return ReceivedRouteListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rrlr ReceivedRouteListResult) IsEmpty() bool { + return rrlr.Value == nil || len(*rrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rrlr ReceivedRouteListResult) hasNextLink() bool { + return rrlr.NextLink != nil && len(*rrlr.NextLink) != 0 +} + +// receivedRouteListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rrlr ReceivedRouteListResult) receivedRouteListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rrlr.NextLink))) +} + +// ReceivedRouteListResultPage contains a page of ReceivedRoute values. +type ReceivedRouteListResultPage struct { + fn func(context.Context, ReceivedRouteListResult) (ReceivedRouteListResult, error) + rrlr ReceivedRouteListResult +} + +// 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 *ReceivedRouteListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReceivedRouteListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rrlr) + if err != nil { + return err + } + page.rrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ReceivedRouteListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ReceivedRouteListResultPage) NotDone() bool { + return !page.rrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ReceivedRouteListResultPage) Response() ReceivedRouteListResult { + return page.rrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ReceivedRouteListResultPage) Values() []ReceivedRoute { + if page.rrlr.IsEmpty() { + return nil + } + return *page.rrlr.Value +} + +// Creates a new instance of the ReceivedRouteListResultPage type. +func NewReceivedRouteListResultPage(cur ReceivedRouteListResult, getNextPage func(context.Context, ReceivedRouteListResult) (ReceivedRouteListResult, error)) ReceivedRouteListResultPage { + return ReceivedRouteListResultPage{ + fn: getNextPage, + rrlr: cur, + } +} + +// RegisteredAsn the customer's ASN that is registered by the peering service provider. +type RegisteredAsn struct { + autorest.Response `json:"-"` + // RegisteredAsnProperties - The properties that define a registered ASN. + *RegisteredAsnProperties `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 RegisteredAsn. +func (ra RegisteredAsn) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ra.RegisteredAsnProperties != nil { + objectMap["properties"] = ra.RegisteredAsnProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegisteredAsn struct. +func (ra *RegisteredAsn) 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 registeredAsnProperties RegisteredAsnProperties + err = json.Unmarshal(*v, ®isteredAsnProperties) + if err != nil { + return err + } + ra.RegisteredAsnProperties = ®isteredAsnProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ra.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ra.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ra.Type = &typeVar + } + } + } + + return nil +} + +// RegisteredAsnListResult the paginated list of peering registered ASNs. +type RegisteredAsnListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering registered ASNs. + Value *[]RegisteredAsn `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering registered ASNs. + NextLink *string `json:"nextLink,omitempty"` +} + +// RegisteredAsnListResultIterator provides access to a complete listing of RegisteredAsn values. +type RegisteredAsnListResultIterator struct { + i int + page RegisteredAsnListResultPage +} + +// 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 *RegisteredAsnListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnListResultIterator.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 *RegisteredAsnListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegisteredAsnListResultIterator) 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 RegisteredAsnListResultIterator) Response() RegisteredAsnListResult { + 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 RegisteredAsnListResultIterator) Value() RegisteredAsn { + if !iter.page.NotDone() { + return RegisteredAsn{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegisteredAsnListResultIterator type. +func NewRegisteredAsnListResultIterator(page RegisteredAsnListResultPage) RegisteredAsnListResultIterator { + return RegisteredAsnListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ralr RegisteredAsnListResult) IsEmpty() bool { + return ralr.Value == nil || len(*ralr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ralr RegisteredAsnListResult) hasNextLink() bool { + return ralr.NextLink != nil && len(*ralr.NextLink) != 0 +} + +// registeredAsnListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ralr RegisteredAsnListResult) registeredAsnListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ralr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ralr.NextLink))) +} + +// RegisteredAsnListResultPage contains a page of RegisteredAsn values. +type RegisteredAsnListResultPage struct { + fn func(context.Context, RegisteredAsnListResult) (RegisteredAsnListResult, error) + ralr RegisteredAsnListResult +} + +// 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 *RegisteredAsnListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ralr) + if err != nil { + return err + } + page.ralr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegisteredAsnListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegisteredAsnListResultPage) NotDone() bool { + return !page.ralr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegisteredAsnListResultPage) Response() RegisteredAsnListResult { + return page.ralr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegisteredAsnListResultPage) Values() []RegisteredAsn { + if page.ralr.IsEmpty() { + return nil + } + return *page.ralr.Value +} + +// Creates a new instance of the RegisteredAsnListResultPage type. +func NewRegisteredAsnListResultPage(cur RegisteredAsnListResult, getNextPage func(context.Context, RegisteredAsnListResult) (RegisteredAsnListResult, error)) RegisteredAsnListResultPage { + return RegisteredAsnListResultPage{ + fn: getNextPage, + ralr: cur, + } +} + +// RegisteredAsnProperties the properties that define a registered ASN. +type RegisteredAsnProperties struct { + // Asn - The customer's ASN from which traffic originates. + Asn *int32 `json:"asn,omitempty"` + // PeeringServicePrefixKey - READ-ONLY; The peering service prefix key that is to be shared with the customer. + PeeringServicePrefixKey *string `json:"peeringServicePrefixKey,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegisteredAsnProperties. +func (rap RegisteredAsnProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rap.Asn != nil { + objectMap["asn"] = rap.Asn + } + return json.Marshal(objectMap) +} + +// RegisteredPrefix the customer's prefix that is registered by the peering service provider. +type RegisteredPrefix struct { + autorest.Response `json:"-"` + // RegisteredPrefixProperties - The properties that define a registered prefix. + *RegisteredPrefixProperties `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 RegisteredPrefix. +func (rp RegisteredPrefix) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rp.RegisteredPrefixProperties != nil { + objectMap["properties"] = rp.RegisteredPrefixProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegisteredPrefix struct. +func (rp *RegisteredPrefix) 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 registeredPrefixProperties RegisteredPrefixProperties + err = json.Unmarshal(*v, ®isteredPrefixProperties) + if err != nil { + return err + } + rp.RegisteredPrefixProperties = ®isteredPrefixProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rp.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rp.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rp.Type = &typeVar + } + } + } + + return nil +} + +// RegisteredPrefixListResult the paginated list of peering registered prefixes. +type RegisteredPrefixListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering registered prefixes. + Value *[]RegisteredPrefix `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering registered prefixes. + NextLink *string `json:"nextLink,omitempty"` +} + +// RegisteredPrefixListResultIterator provides access to a complete listing of RegisteredPrefix values. +type RegisteredPrefixListResultIterator struct { + i int + page RegisteredPrefixListResultPage +} + +// 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 *RegisteredPrefixListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixListResultIterator.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 *RegisteredPrefixListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegisteredPrefixListResultIterator) 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 RegisteredPrefixListResultIterator) Response() RegisteredPrefixListResult { + 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 RegisteredPrefixListResultIterator) Value() RegisteredPrefix { + if !iter.page.NotDone() { + return RegisteredPrefix{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegisteredPrefixListResultIterator type. +func NewRegisteredPrefixListResultIterator(page RegisteredPrefixListResultPage) RegisteredPrefixListResultIterator { + return RegisteredPrefixListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rplr RegisteredPrefixListResult) IsEmpty() bool { + return rplr.Value == nil || len(*rplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rplr RegisteredPrefixListResult) hasNextLink() bool { + return rplr.NextLink != nil && len(*rplr.NextLink) != 0 +} + +// registeredPrefixListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rplr RegisteredPrefixListResult) registeredPrefixListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rplr.NextLink))) +} + +// RegisteredPrefixListResultPage contains a page of RegisteredPrefix values. +type RegisteredPrefixListResultPage struct { + fn func(context.Context, RegisteredPrefixListResult) (RegisteredPrefixListResult, error) + rplr RegisteredPrefixListResult +} + +// 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 *RegisteredPrefixListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rplr) + if err != nil { + return err + } + page.rplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegisteredPrefixListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegisteredPrefixListResultPage) NotDone() bool { + return !page.rplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegisteredPrefixListResultPage) Response() RegisteredPrefixListResult { + return page.rplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegisteredPrefixListResultPage) Values() []RegisteredPrefix { + if page.rplr.IsEmpty() { + return nil + } + return *page.rplr.Value +} + +// Creates a new instance of the RegisteredPrefixListResultPage type. +func NewRegisteredPrefixListResultPage(cur RegisteredPrefixListResult, getNextPage func(context.Context, RegisteredPrefixListResult) (RegisteredPrefixListResult, error)) RegisteredPrefixListResultPage { + return RegisteredPrefixListResultPage{ + fn: getNextPage, + rplr: cur, + } +} + +// RegisteredPrefixProperties the properties that define a registered prefix. +type RegisteredPrefixProperties struct { + // Prefix - The customer's prefix from which traffic originates. + Prefix *string `json:"prefix,omitempty"` + // PrefixValidationState - READ-ONLY; The prefix validation state. Possible values include: 'PrefixValidationStateNone', 'PrefixValidationStateInvalid', 'PrefixValidationStateVerified', 'PrefixValidationStateFailed', 'PrefixValidationStatePending', 'PrefixValidationStateWarning', 'PrefixValidationStateUnknown' + PrefixValidationState PrefixValidationState `json:"prefixValidationState,omitempty"` + // PeeringServicePrefixKey - READ-ONLY; The peering service prefix key that is to be shared with the customer. + PeeringServicePrefixKey *string `json:"peeringServicePrefixKey,omitempty"` + // ErrorMessage - READ-ONLY; The error message associated with the validation state, if any. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegisteredPrefixProperties. +func (rpp RegisteredPrefixProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rpp.Prefix != nil { + objectMap["prefix"] = rpp.Prefix + } + return json.Marshal(objectMap) +} + +// 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"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// 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:"-"` + // Sku - The SKU that defines the type of the peering service. + Sku *ServiceSku `json:"sku,omitempty"` + // 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.Sku != nil { + objectMap["sku"] = s.Sku + } + 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 "sku": + if v != nil { + var sku ServiceSku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + s.Sku = &sku + } + 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 +} + +// ServiceCountry the peering service country. +type ServiceCountry 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"` +} + +// MarshalJSON is the custom marshaler for ServiceCountry. +func (sc ServiceCountry) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServiceCountryListResult the paginated list of peering service countries. +type ServiceCountryListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering service countries. + Value *[]ServiceCountry `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering service countries. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServiceCountryListResultIterator provides access to a complete listing of ServiceCountry values. +type ServiceCountryListResultIterator struct { + i int + page ServiceCountryListResultPage +} + +// 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 *ServiceCountryListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceCountryListResultIterator.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 *ServiceCountryListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServiceCountryListResultIterator) 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 ServiceCountryListResultIterator) Response() ServiceCountryListResult { + 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 ServiceCountryListResultIterator) Value() ServiceCountry { + if !iter.page.NotDone() { + return ServiceCountry{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServiceCountryListResultIterator type. +func NewServiceCountryListResultIterator(page ServiceCountryListResultPage) ServiceCountryListResultIterator { + return ServiceCountryListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sclr ServiceCountryListResult) IsEmpty() bool { + return sclr.Value == nil || len(*sclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sclr ServiceCountryListResult) hasNextLink() bool { + return sclr.NextLink != nil && len(*sclr.NextLink) != 0 +} + +// serviceCountryListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sclr ServiceCountryListResult) serviceCountryListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sclr.NextLink))) +} + +// ServiceCountryListResultPage contains a page of ServiceCountry values. +type ServiceCountryListResultPage struct { + fn func(context.Context, ServiceCountryListResult) (ServiceCountryListResult, error) + sclr ServiceCountryListResult +} + +// 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 *ServiceCountryListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceCountryListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sclr) + if err != nil { + return err + } + page.sclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServiceCountryListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServiceCountryListResultPage) NotDone() bool { + return !page.sclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServiceCountryListResultPage) Response() ServiceCountryListResult { + return page.sclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServiceCountryListResultPage) Values() []ServiceCountry { + if page.sclr.IsEmpty() { + return nil + } + return *page.sclr.Value +} + +// Creates a new instance of the ServiceCountryListResultPage type. +func NewServiceCountryListResultPage(cur ServiceCountryListResult, getNextPage func(context.Context, ServiceCountryListResult) (ServiceCountryListResult, error)) ServiceCountryListResultPage { + return ServiceCountryListResultPage{ + fn: getNextPage, + sclr: cur, + } +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (slr ServiceListResult) hasNextLink() bool { + return slr.NextLink != nil && len(*slr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.slr) + if err != nil { + return err + } + page.slr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur ServiceListResult, getNextPage func(context.Context, ServiceListResult) (ServiceListResult, error)) ServiceListResultPage { + return ServiceListResultPage{ + fn: getNextPage, + slr: cur, + } +} + +// ServiceLocation the peering service 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sllr ServiceLocationListResult) hasNextLink() bool { + return sllr.NextLink != nil && len(*sllr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.sllr) + if err != nil { + return err + } + page.sllr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur ServiceLocationListResult, getNextPage func(context.Context, ServiceLocationListResult) (ServiceLocationListResult, error)) ServiceLocationListResultPage { + return ServiceLocationListResultPage{ + fn: getNextPage, + sllr: cur, + } +} + +// 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 +} + +// ServicePrefixEvent the details of the event associated with a prefix. +type ServicePrefixEvent struct { + // EventTimestamp - READ-ONLY; The timestamp of the event associated with a prefix. + EventTimestamp *date.Time `json:"eventTimestamp,omitempty"` + // EventType - READ-ONLY; The type of the event associated with a prefix. + EventType *string `json:"eventType,omitempty"` + // EventSummary - READ-ONLY; The summary of the event associated with a prefix. + EventSummary *string `json:"eventSummary,omitempty"` + // EventLevel - READ-ONLY; The level of the event associated with a prefix. + EventLevel *string `json:"eventLevel,omitempty"` + // EventDescription - READ-ONLY; The description of the event associated with a prefix. + EventDescription *string `json:"eventDescription,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicePrefixEvent. +func (spe ServicePrefixEvent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServicePrefixListResult the paginated list of peering service prefixes. +type ServicePrefixListResult struct { + autorest.Response `json:"-"` + // Value - The list of peering service prefixes. + Value *[]ServicePrefix `json:"value,omitempty"` + // NextLink - The link to fetch the next page of peering service prefixes. + 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (splr ServicePrefixListResult) hasNextLink() bool { + return splr.NextLink != nil && len(*splr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.splr) + if err != nil { + return err + } + page.splr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur ServicePrefixListResult, getNextPage func(context.Context, ServicePrefixListResult) (ServicePrefixListResult, error)) ServicePrefixListResultPage { + return ServicePrefixListResultPage{ + fn: getNextPage, + splr: cur, + } +} + +// ServicePrefixProperties the peering service prefix properties class. +type ServicePrefixProperties struct { + // Prefix - The prefix from which your traffic originates. + Prefix *string `json:"prefix,omitempty"` + // PrefixValidationState - READ-ONLY; The prefix validation state. Possible values include: 'PrefixValidationStateNone', 'PrefixValidationStateInvalid', 'PrefixValidationStateVerified', 'PrefixValidationStateFailed', 'PrefixValidationStatePending', 'PrefixValidationStateWarning', 'PrefixValidationStateUnknown' + PrefixValidationState PrefixValidationState `json:"prefixValidationState,omitempty"` + // LearnedType - READ-ONLY; The prefix learned type. Possible values include: 'LearnedTypeNone', 'LearnedTypeViaServiceProvider', 'LearnedTypeViaSession' + LearnedType LearnedType `json:"learnedType,omitempty"` + // ErrorMessage - READ-ONLY; The error message for validation state + ErrorMessage *string `json:"errorMessage,omitempty"` + // Events - READ-ONLY; The list of events for peering service prefix + Events *[]ServicePrefixEvent `json:"events,omitempty"` + // PeeringServicePrefixKey - The peering service prefix key + PeeringServicePrefixKey *string `json:"peeringServicePrefixKey,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicePrefixProperties. +func (spp ServicePrefixProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if spp.Prefix != nil { + objectMap["prefix"] = spp.Prefix + } + if spp.PeeringServicePrefixKey != nil { + objectMap["peeringServicePrefixKey"] = spp.PeeringServicePrefixKey + } + return json.Marshal(objectMap) +} + +// ServiceProperties the properties that define connectivity to the Peering Service. +type ServiceProperties struct { + // PeeringServiceLocation - The location (state/province) of the customer. + PeeringServiceLocation *string `json:"peeringServiceLocation,omitempty"` + // PeeringServiceProvider - The name of the service provider. + 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"` + // ProviderPrimaryPeeringLocation - The primary peering (Microsoft/service provider) location to be used for customer traffic. + ProviderPrimaryPeeringLocation *string `json:"providerPrimaryPeeringLocation,omitempty"` + // ProviderBackupPeeringLocation - The backup peering (Microsoft/service provider) location to be used for customer traffic. + ProviderBackupPeeringLocation *string `json:"providerBackupPeeringLocation,omitempty"` + // LogAnalyticsWorkspaceProperties - The Log Analytics Workspace Properties + LogAnalyticsWorkspaceProperties *LogAnalyticsWorkspaceProperties `json:"logAnalyticsWorkspaceProperties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceProperties. +func (sp ServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.PeeringServiceLocation != nil { + objectMap["peeringServiceLocation"] = sp.PeeringServiceLocation + } + if sp.PeeringServiceProvider != nil { + objectMap["peeringServiceProvider"] = sp.PeeringServiceProvider + } + if sp.ProviderPrimaryPeeringLocation != nil { + objectMap["providerPrimaryPeeringLocation"] = sp.ProviderPrimaryPeeringLocation + } + if sp.ProviderBackupPeeringLocation != nil { + objectMap["providerBackupPeeringLocation"] = sp.ProviderBackupPeeringLocation + } + if sp.LogAnalyticsWorkspaceProperties != nil { + objectMap["logAnalyticsWorkspaceProperties"] = sp.LogAnalyticsWorkspaceProperties + } + return json.Marshal(objectMap) +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (splr ServiceProviderListResult) hasNextLink() bool { + return splr.NextLink != nil && len(*splr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.splr) + if err != nil { + return err + } + page.splr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur ServiceProviderListResult, getNextPage func(context.Context, ServiceProviderListResult) (ServiceProviderListResult, error)) ServiceProviderListResultPage { + return ServiceProviderListResultPage{ + fn: getNextPage, + splr: cur, + } +} + +// 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"` + // PeeringLocations - The list of locations at which the service provider peers with Microsoft. + PeeringLocations *[]string `json:"peeringLocations,omitempty"` +} + +// ServiceSku the SKU that defines the type of the peering service. +type ServiceSku struct { + // Name - The name of the peering service SKU. + Name *string `json:"name,omitempty"` +} + +// ServiceSpecification service specification payload. +type ServiceSpecification struct { + // MetricSpecifications - READ-ONLY; Specifications of the Metrics for Azure Monitoring. + MetricSpecifications *[]MetricSpecification `json:"metricSpecifications,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceSpecification. +func (ss ServiceSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Sku the SKU that defines the tier and kind of the peering. +type Sku struct { + // Name - The name of the peering SKU. + Name *string `json:"name,omitempty"` + // Tier - READ-ONLY; The tier of the peering SKU. Possible values include: 'Basic', 'Premium' + Tier Tier `json:"tier,omitempty"` + // Family - READ-ONLY; The family of the peering SKU. Possible values include: 'Direct', 'Exchange' + Family Family `json:"family,omitempty"` + // Size - READ-ONLY; The size of the peering SKU. Possible values include: 'Free', 'Metered', 'Unlimited' + Size Size `json:"size,omitempty"` +} + +// MarshalJSON is the custom marshaler for Sku. +func (s Sku) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.Name != nil { + objectMap["name"] = s.Name + } + return json.Marshal(objectMap) +} + +// 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/peering/mgmt/2021-06-01/peering/operations.go b/services/peering/mgmt/2021-06-01/peering/operations.go new file mode 100644 index 000000000000..721d5a145b66 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/operations.go @@ -0,0 +1,140 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available 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 + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.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) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults 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/peering/mgmt/2021-06-01/peering/peerasns.go b/services/peering/mgmt/2021-06-01/peering/peerasns.go new file mode 100644 index 000000000000..0dc82741b7f2 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/peerasns.go @@ -0,0 +1,369 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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 + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PeerAsnsClient) CreateOrUpdateResponder(resp *http.Response) (result PeerAsn, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete 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 + } + + 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 = "2021-06-01" + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PeerAsnsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get 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 + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PeerAsnsClient) GetResponder(resp *http.Response) (result PeerAsn, err error) { + err = autorest.Respond( + resp, + 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 + } + if result.palr.hasNextLink() && result.palr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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/peering/mgmt/2021-06-01/peering/peeringapi/interfaces.go b/services/peering/mgmt/2021-06-01/peering/peeringapi/interfaces.go new file mode 100644 index 000000000000..75d54ae642de --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/peeringapi/interfaces.go @@ -0,0 +1,175 @@ +package peeringapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/peering/mgmt/2021-06-01/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) + +// CdnPeeringPrefixesClientAPI contains the set of methods on the CdnPeeringPrefixesClient type. +type CdnPeeringPrefixesClientAPI interface { + List(ctx context.Context, peeringLocation string) (result peering.CdnPeeringPrefixListResultPage, err error) + ListComplete(ctx context.Context, peeringLocation string) (result peering.CdnPeeringPrefixListResultIterator, err error) +} + +var _ CdnPeeringPrefixesClientAPI = (*peering.CdnPeeringPrefixesClient)(nil) + +// LegacyPeeringsClientAPI contains the set of methods on the LegacyPeeringsClient type. +type LegacyPeeringsClientAPI interface { + List(ctx context.Context, peeringLocation string, kind string, asn *int32) (result peering.ListResultPage, err error) + ListComplete(ctx context.Context, peeringLocation string, kind string, asn *int32) (result peering.ListResultIterator, err error) +} + +var _ LegacyPeeringsClientAPI = (*peering.LegacyPeeringsClient)(nil) + +// LookingGlassClientAPI contains the set of methods on the LookingGlassClient type. +type LookingGlassClientAPI interface { + Invoke(ctx context.Context, command string, sourceType string, sourceLocation string, destinationIP string) (result peering.LookingGlassOutput, err error) +} + +var _ LookingGlassClientAPI = (*peering.LookingGlassClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result peering.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result peering.OperationListResultIterator, 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) + ListBySubscriptionComplete(ctx context.Context) (result peering.PeerAsnListResultIterator, 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) + ListComplete(ctx context.Context, kind string, directPeeringType string) (result peering.LocationListResultIterator, err error) +} + +var _ LocationsClientAPI = (*peering.LocationsClient)(nil) + +// RegisteredAsnsClientAPI contains the set of methods on the RegisteredAsnsClient type. +type RegisteredAsnsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string, registeredAsn peering.RegisteredAsn) (result peering.RegisteredAsn, err error) + Delete(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string) (result peering.RegisteredAsn, err error) + ListByPeering(ctx context.Context, resourceGroupName string, peeringName string) (result peering.RegisteredAsnListResultPage, err error) + ListByPeeringComplete(ctx context.Context, resourceGroupName string, peeringName string) (result peering.RegisteredAsnListResultIterator, err error) +} + +var _ RegisteredAsnsClientAPI = (*peering.RegisteredAsnsClient)(nil) + +// RegisteredPrefixesClientAPI contains the set of methods on the RegisteredPrefixesClient type. +type RegisteredPrefixesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string, registeredPrefix peering.RegisteredPrefix) (result peering.RegisteredPrefix, err error) + Delete(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string) (result peering.RegisteredPrefix, err error) + ListByPeering(ctx context.Context, resourceGroupName string, peeringName string) (result peering.RegisteredPrefixListResultPage, err error) + ListByPeeringComplete(ctx context.Context, resourceGroupName string, peeringName string) (result peering.RegisteredPrefixListResultIterator, err error) +} + +var _ RegisteredPrefixesClientAPI = (*peering.RegisteredPrefixesClient)(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) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result peering.ListResultIterator, err error) + ListBySubscription(ctx context.Context) (result peering.ListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result peering.ListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, peeringName string, tags peering.ResourceTags) (result peering.Model, err error) +} + +var _ PeeringsClientAPI = (*peering.PeeringsClient)(nil) + +// ReceivedRoutesClientAPI contains the set of methods on the ReceivedRoutesClient type. +type ReceivedRoutesClientAPI interface { + ListByPeering(ctx context.Context, resourceGroupName string, peeringName string, prefix string, asPath string, originAsValidationState string, rpkiValidationState string, skipToken string) (result peering.ReceivedRouteListResultPage, err error) + ListByPeeringComplete(ctx context.Context, resourceGroupName string, peeringName string, prefix string, asPath string, originAsValidationState string, rpkiValidationState string, skipToken string) (result peering.ReceivedRouteListResultIterator, err error) +} + +var _ ReceivedRoutesClientAPI = (*peering.ReceivedRoutesClient)(nil) + +// ConnectionMonitorTestsClientAPI contains the set of methods on the ConnectionMonitorTestsClient type. +type ConnectionMonitorTestsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringServiceName string, connectionMonitorTestName string, connectionMonitorTest peering.ConnectionMonitorTest) (result peering.ConnectionMonitorTest, err error) + Delete(ctx context.Context, resourceGroupName string, peeringServiceName string, connectionMonitorTestName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, peeringServiceName string, connectionMonitorTestName string) (result peering.ConnectionMonitorTest, err error) + ListByPeeringService(ctx context.Context, resourceGroupName string, peeringServiceName string) (result peering.ConnectionMonitorTestListResultPage, err error) + ListByPeeringServiceComplete(ctx context.Context, resourceGroupName string, peeringServiceName string) (result peering.ConnectionMonitorTestListResultIterator, err error) +} + +var _ ConnectionMonitorTestsClientAPI = (*peering.ConnectionMonitorTestsClient)(nil) + +// ServiceCountriesClientAPI contains the set of methods on the ServiceCountriesClient type. +type ServiceCountriesClientAPI interface { + List(ctx context.Context) (result peering.ServiceCountryListResultPage, err error) + ListComplete(ctx context.Context) (result peering.ServiceCountryListResultIterator, err error) +} + +var _ ServiceCountriesClientAPI = (*peering.ServiceCountriesClient)(nil) + +// ServiceLocationsClientAPI contains the set of methods on the ServiceLocationsClient type. +type ServiceLocationsClientAPI interface { + List(ctx context.Context, country string) (result peering.ServiceLocationListResultPage, err error) + ListComplete(ctx context.Context, country string) (result peering.ServiceLocationListResultIterator, err error) +} + +var _ ServiceLocationsClientAPI = (*peering.ServiceLocationsClient)(nil) + +// PrefixesClientAPI contains the set of methods on the PrefixesClient type. +type PrefixesClientAPI 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, expand string) (result peering.ServicePrefix, err error) + ListByPeeringService(ctx context.Context, resourceGroupName string, peeringServiceName string, expand string) (result peering.ServicePrefixListResultPage, err error) + ListByPeeringServiceComplete(ctx context.Context, resourceGroupName string, peeringServiceName string, expand string) (result peering.ServicePrefixListResultIterator, 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) + ListComplete(ctx context.Context) (result peering.ServiceProviderListResultIterator, 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) + InitializeConnectionMonitor(ctx context.Context) (result autorest.Response, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result peering.ServiceListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result peering.ServiceListResultIterator, err error) + ListBySubscription(ctx context.Context) (result peering.ServiceListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result peering.ServiceListResultIterator, 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/peering/mgmt/2021-06-01/peering/peerings.go b/services/peering/mgmt/2021-06-01/peering/peerings.go new file mode 100644 index 000000000000..44e9962ab221 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/peerings.go @@ -0,0 +1,578 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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 + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PeeringsClient) CreateOrUpdateResponder(resp *http.Response) (result Model, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete 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 + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PeeringsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get 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 + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PeeringsClient) GetResponder(resp *http.Response) (result Model, err error) { + err = autorest.Respond( + resp, + 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 + } + if result.lr.hasNextLink() && result.lr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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 + } + if result.lr.hasNextLink() && result.lr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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 + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/peering/mgmt/2021-06-01/peering/prefixes.go b/services/peering/mgmt/2021-06-01/peering/prefixes.go new file mode 100644 index 000000000000..392d0b70eadb --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/prefixes.go @@ -0,0 +1,396 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPrefixesClientWithBaseURI(baseURI string, subscriptionID string) PrefixesClient { + return PrefixesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new prefix with the specified name under the given subscription, resource group and peering +// service. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// prefixName - the name of the prefix. +// peeringServicePrefix - the properties needed to create a prefix. +func (client PrefixesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, peeringServicePrefix ServicePrefix) (result ServicePrefix, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrefixesClient.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.PrefixesClient", "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.PrefixesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrefixesClient) 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 PrefixesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrefixesClient) CreateOrUpdateResponder(resp *http.Response) (result ServicePrefix, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing prefix with the specified name under the given subscription, resource group and peering +// service. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// prefixName - the name of the prefix. +func (client PrefixesClient) Delete(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrefixesClient.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.PrefixesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrefixesClient) 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 PrefixesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrefixesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an existing prefix with the specified name under the given subscription, resource group and peering +// service. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// prefixName - the name of the prefix. +// expand - the properties to be expanded. +func (client PrefixesClient) Get(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, expand string) (result ServicePrefix, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrefixesClient.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, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "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.PrefixesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.PrefixesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrefixesClient) GetPreparer(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, expand 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + 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 PrefixesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrefixesClient) GetResponder(resp *http.Response) (result ServicePrefix, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPeeringService lists all prefixes under the given subscription, resource group and peering service. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringServiceName - the name of the peering service. +// expand - the properties to be expanded. +func (client PrefixesClient) ListByPeeringService(ctx context.Context, resourceGroupName string, peeringServiceName string, expand 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, expand) + 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 + } + if result.splr.hasNextLink() && result.splr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPeeringServicePreparer prepares the ListByPeeringService request. +func (client PrefixesClient) ListByPeeringServicePreparer(ctx context.Context, resourceGroupName string, peeringServiceName string, expand 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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, expand 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, expand) + return +} diff --git a/services/peering/mgmt/2021-06-01/peering/receivedroutes.go b/services/peering/mgmt/2021-06-01/peering/receivedroutes.go new file mode 100644 index 000000000000..4f199eaff530 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/receivedroutes.go @@ -0,0 +1,170 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ReceivedRoutesClient is the peering Client +type ReceivedRoutesClient struct { + BaseClient +} + +// NewReceivedRoutesClient creates an instance of the ReceivedRoutesClient client. +func NewReceivedRoutesClient(subscriptionID string) ReceivedRoutesClient { + return NewReceivedRoutesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewReceivedRoutesClientWithBaseURI creates an instance of the ReceivedRoutesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewReceivedRoutesClientWithBaseURI(baseURI string, subscriptionID string) ReceivedRoutesClient { + return ReceivedRoutesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByPeering lists the prefixes received over the specified peering under the given subscription and resource +// group. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// prefix - the optional prefix that can be used to filter the routes. +// asPath - the optional AS path that can be used to filter the routes. +// originAsValidationState - the optional origin AS validation state that can be used to filter the routes. +// rpkiValidationState - the optional RPKI validation state that can be used to filter the routes. +// skipToken - the optional page continuation token that is used in the event of paginated result. +func (client ReceivedRoutesClient) ListByPeering(ctx context.Context, resourceGroupName string, peeringName string, prefix string, asPath string, originAsValidationState string, rpkiValidationState string, skipToken string) (result ReceivedRouteListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReceivedRoutesClient.ListByPeering") + defer func() { + sc := -1 + if result.rrlr.Response.Response != nil { + sc = result.rrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByPeeringNextResults + req, err := client.ListByPeeringPreparer(ctx, resourceGroupName, peeringName, prefix, asPath, originAsValidationState, rpkiValidationState, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ReceivedRoutesClient", "ListByPeering", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPeeringSender(req) + if err != nil { + result.rrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ReceivedRoutesClient", "ListByPeering", resp, "Failure sending request") + return + } + + result.rrlr, err = client.ListByPeeringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ReceivedRoutesClient", "ListByPeering", resp, "Failure responding to request") + return + } + if result.rrlr.hasNextLink() && result.rrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPeeringPreparer prepares the ListByPeering request. +func (client ReceivedRoutesClient) ListByPeeringPreparer(ctx context.Context, resourceGroupName string, peeringName string, prefix string, asPath string, originAsValidationState string, rpkiValidationState string, skipToken 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(prefix) > 0 { + queryParameters["prefix"] = autorest.Encode("query", prefix) + } + if len(asPath) > 0 { + queryParameters["asPath"] = autorest.Encode("query", asPath) + } + if len(originAsValidationState) > 0 { + queryParameters["originAsValidationState"] = autorest.Encode("query", originAsValidationState) + } + if len(rpkiValidationState) > 0 { + queryParameters["rpkiValidationState"] = autorest.Encode("query", rpkiValidationState) + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/receivedRoutes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPeeringSender sends the ListByPeering request. The method will close the +// http.Response Body if it receives an error. +func (client ReceivedRoutesClient) ListByPeeringSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPeeringResponder handles the response to the ListByPeering request. The method always +// closes the http.Response Body. +func (client ReceivedRoutesClient) ListByPeeringResponder(resp *http.Response) (result ReceivedRouteListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPeeringNextResults retrieves the next set of results, if any. +func (client ReceivedRoutesClient) listByPeeringNextResults(ctx context.Context, lastResults ReceivedRouteListResult) (result ReceivedRouteListResult, err error) { + req, err := lastResults.receivedRouteListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.ReceivedRoutesClient", "listByPeeringNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPeeringSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "peering.ReceivedRoutesClient", "listByPeeringNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPeeringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ReceivedRoutesClient", "listByPeeringNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPeeringComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReceivedRoutesClient) ListByPeeringComplete(ctx context.Context, resourceGroupName string, peeringName string, prefix string, asPath string, originAsValidationState string, rpkiValidationState string, skipToken string) (result ReceivedRouteListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReceivedRoutesClient.ListByPeering") + 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.ListByPeering(ctx, resourceGroupName, peeringName, prefix, asPath, originAsValidationState, rpkiValidationState, skipToken) + return +} diff --git a/services/peering/mgmt/2021-06-01/peering/registeredasns.go b/services/peering/mgmt/2021-06-01/peering/registeredasns.go new file mode 100644 index 000000000000..ea86cb970f0b --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/registeredasns.go @@ -0,0 +1,388 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegisteredAsnsClient is the peering Client +type RegisteredAsnsClient struct { + BaseClient +} + +// NewRegisteredAsnsClient creates an instance of the RegisteredAsnsClient client. +func NewRegisteredAsnsClient(subscriptionID string) RegisteredAsnsClient { + return NewRegisteredAsnsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRegisteredAsnsClientWithBaseURI creates an instance of the RegisteredAsnsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewRegisteredAsnsClientWithBaseURI(baseURI string, subscriptionID string) RegisteredAsnsClient { + return RegisteredAsnsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new registered ASN with the specified name under the given subscription, resource group and +// peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// registeredAsnName - the name of the ASN. +// registeredAsn - the properties needed to create a registered ASN. +func (client RegisteredAsnsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string, registeredAsn RegisteredAsn) (result RegisteredAsn, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnsClient.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, peeringName, registeredAsnName, registeredAsn) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "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.RegisteredAsnsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RegisteredAsnsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string, registeredAsn RegisteredAsn) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "registeredAsnName": autorest.Encode("path", registeredAsnName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}", pathParameters), + autorest.WithJSON(registeredAsn), + 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 RegisteredAsnsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RegisteredAsnsClient) CreateOrUpdateResponder(resp *http.Response) (result RegisteredAsn, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing registered ASN with the specified name under the given subscription, resource group and +// peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// registeredAsnName - the name of the registered ASN. +func (client RegisteredAsnsClient) Delete(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnsClient.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, registeredAsnName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RegisteredAsnsClient) DeletePreparer(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "registeredAsnName": autorest.Encode("path", registeredAsnName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}", 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 RegisteredAsnsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RegisteredAsnsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an existing registered ASN with the specified name under the given subscription, resource group and +// peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// registeredAsnName - the name of the registered ASN. +func (client RegisteredAsnsClient) Get(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string) (result RegisteredAsn, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnsClient.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, registeredAsnName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "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.RegisteredAsnsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegisteredAsnsClient) GetPreparer(ctx context.Context, resourceGroupName string, peeringName string, registeredAsnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "registeredAsnName": autorest.Encode("path", registeredAsnName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns/{registeredAsnName}", 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 RegisteredAsnsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegisteredAsnsClient) GetResponder(resp *http.Response) (result RegisteredAsn, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPeering lists all registered ASNs under the given subscription, resource group and peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +func (client RegisteredAsnsClient) ListByPeering(ctx context.Context, resourceGroupName string, peeringName string) (result RegisteredAsnListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnsClient.ListByPeering") + defer func() { + sc := -1 + if result.ralr.Response.Response != nil { + sc = result.ralr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByPeeringNextResults + req, err := client.ListByPeeringPreparer(ctx, resourceGroupName, peeringName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "ListByPeering", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPeeringSender(req) + if err != nil { + result.ralr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "ListByPeering", resp, "Failure sending request") + return + } + + result.ralr, err = client.ListByPeeringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "ListByPeering", resp, "Failure responding to request") + return + } + if result.ralr.hasNextLink() && result.ralr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPeeringPreparer prepares the ListByPeering request. +func (client RegisteredAsnsClient) ListByPeeringPreparer(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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredAsns", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPeeringSender sends the ListByPeering request. The method will close the +// http.Response Body if it receives an error. +func (client RegisteredAsnsClient) ListByPeeringSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPeeringResponder handles the response to the ListByPeering request. The method always +// closes the http.Response Body. +func (client RegisteredAsnsClient) ListByPeeringResponder(resp *http.Response) (result RegisteredAsnListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPeeringNextResults retrieves the next set of results, if any. +func (client RegisteredAsnsClient) listByPeeringNextResults(ctx context.Context, lastResults RegisteredAsnListResult) (result RegisteredAsnListResult, err error) { + req, err := lastResults.registeredAsnListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "listByPeeringNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPeeringSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "listByPeeringNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPeeringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredAsnsClient", "listByPeeringNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPeeringComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegisteredAsnsClient) ListByPeeringComplete(ctx context.Context, resourceGroupName string, peeringName string) (result RegisteredAsnListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredAsnsClient.ListByPeering") + 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.ListByPeering(ctx, resourceGroupName, peeringName) + return +} diff --git a/services/peering/mgmt/2021-06-01/peering/registeredprefixes.go b/services/peering/mgmt/2021-06-01/peering/registeredprefixes.go new file mode 100644 index 000000000000..3fd5e6b5a073 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/registeredprefixes.go @@ -0,0 +1,389 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegisteredPrefixesClient is the peering Client +type RegisteredPrefixesClient struct { + BaseClient +} + +// NewRegisteredPrefixesClient creates an instance of the RegisteredPrefixesClient client. +func NewRegisteredPrefixesClient(subscriptionID string) RegisteredPrefixesClient { + return NewRegisteredPrefixesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRegisteredPrefixesClientWithBaseURI creates an instance of the RegisteredPrefixesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewRegisteredPrefixesClientWithBaseURI(baseURI string, subscriptionID string) RegisteredPrefixesClient { + return RegisteredPrefixesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new registered prefix with the specified name under the given subscription, resource group +// and peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// registeredPrefixName - the name of the registered prefix. +// registeredPrefix - the properties needed to create a registered prefix. +func (client RegisteredPrefixesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string, registeredPrefix RegisteredPrefix) (result RegisteredPrefix, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixesClient.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, peeringName, registeredPrefixName, registeredPrefix) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "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.RegisteredPrefixesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RegisteredPrefixesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string, registeredPrefix RegisteredPrefix) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "registeredPrefixName": autorest.Encode("path", registeredPrefixName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}", pathParameters), + autorest.WithJSON(registeredPrefix), + 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 RegisteredPrefixesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RegisteredPrefixesClient) CreateOrUpdateResponder(resp *http.Response) (result RegisteredPrefix, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing registered prefix with the specified name under the given subscription, resource group +// and peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// registeredPrefixName - the name of the registered prefix. +func (client RegisteredPrefixesClient) Delete(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixesClient.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, registeredPrefixName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RegisteredPrefixesClient) DeletePreparer(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "registeredPrefixName": autorest.Encode("path", registeredPrefixName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}", 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 RegisteredPrefixesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RegisteredPrefixesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an existing registered prefix with the specified name under the given subscription, resource group and +// peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +// registeredPrefixName - the name of the registered prefix. +func (client RegisteredPrefixesClient) Get(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string) (result RegisteredPrefix, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixesClient.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, registeredPrefixName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "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.RegisteredPrefixesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegisteredPrefixesClient) GetPreparer(ctx context.Context, resourceGroupName string, peeringName string, registeredPrefixName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "peeringName": autorest.Encode("path", peeringName), + "registeredPrefixName": autorest.Encode("path", registeredPrefixName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes/{registeredPrefixName}", 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 RegisteredPrefixesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegisteredPrefixesClient) GetResponder(resp *http.Response) (result RegisteredPrefix, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPeering lists all registered prefixes under the given subscription, resource group and peering. +// Parameters: +// resourceGroupName - the name of the resource group. +// peeringName - the name of the peering. +func (client RegisteredPrefixesClient) ListByPeering(ctx context.Context, resourceGroupName string, peeringName string) (result RegisteredPrefixListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixesClient.ListByPeering") + defer func() { + sc := -1 + if result.rplr.Response.Response != nil { + sc = result.rplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByPeeringNextResults + req, err := client.ListByPeeringPreparer(ctx, resourceGroupName, peeringName) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "ListByPeering", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPeeringSender(req) + if err != nil { + result.rplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "ListByPeering", resp, "Failure sending request") + return + } + + result.rplr, err = client.ListByPeeringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "ListByPeering", resp, "Failure responding to request") + return + } + if result.rplr.hasNextLink() && result.rplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPeeringPreparer prepares the ListByPeering request. +func (client RegisteredPrefixesClient) ListByPeeringPreparer(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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}/registeredPrefixes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPeeringSender sends the ListByPeering request. The method will close the +// http.Response Body if it receives an error. +func (client RegisteredPrefixesClient) ListByPeeringSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPeeringResponder handles the response to the ListByPeering request. The method always +// closes the http.Response Body. +func (client RegisteredPrefixesClient) ListByPeeringResponder(resp *http.Response) (result RegisteredPrefixListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPeeringNextResults retrieves the next set of results, if any. +func (client RegisteredPrefixesClient) listByPeeringNextResults(ctx context.Context, lastResults RegisteredPrefixListResult) (result RegisteredPrefixListResult, err error) { + req, err := lastResults.registeredPrefixListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "listByPeeringNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPeeringSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "listByPeeringNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPeeringResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.RegisteredPrefixesClient", "listByPeeringNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPeeringComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegisteredPrefixesClient) ListByPeeringComplete(ctx context.Context, resourceGroupName string, peeringName string) (result RegisteredPrefixListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredPrefixesClient.ListByPeering") + 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.ListByPeering(ctx, resourceGroupName, peeringName) + return +} diff --git a/services/peering/mgmt/2021-06-01/peering/servicecountries.go b/services/peering/mgmt/2021-06-01/peering/servicecountries.go new file mode 100644 index 000000000000..ebe408fe67b6 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/servicecountries.go @@ -0,0 +1,145 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServiceCountriesClient is the peering Client +type ServiceCountriesClient struct { + BaseClient +} + +// NewServiceCountriesClient creates an instance of the ServiceCountriesClient client. +func NewServiceCountriesClient(subscriptionID string) ServiceCountriesClient { + return NewServiceCountriesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceCountriesClientWithBaseURI creates an instance of the ServiceCountriesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServiceCountriesClientWithBaseURI(baseURI string, subscriptionID string) ServiceCountriesClient { + return ServiceCountriesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available countries for peering service. +func (client ServiceCountriesClient) List(ctx context.Context) (result ServiceCountryListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceCountriesClient.List") + defer func() { + sc := -1 + if result.sclr.Response.Response != nil { + sc = result.sclr.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.ServiceCountriesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "peering.ServiceCountriesClient", "List", resp, "Failure sending request") + return + } + + result.sclr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServiceCountriesClient", "List", resp, "Failure responding to request") + return + } + if result.sclr.hasNextLink() && result.sclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServiceCountriesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceCountries", 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 ServiceCountriesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServiceCountriesClient) ListResponder(resp *http.Response) (result ServiceCountryListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ServiceCountriesClient) listNextResults(ctx context.Context, lastResults ServiceCountryListResult) (result ServiceCountryListResult, err error) { + req, err := lastResults.serviceCountryListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "peering.ServiceCountriesClient", "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.ServiceCountriesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServiceCountriesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServiceCountriesClient) ListComplete(ctx context.Context) (result ServiceCountryListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceCountriesClient.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/peering/mgmt/2021-06-01/peering/servicelocations.go b/services/peering/mgmt/2021-06-01/peering/servicelocations.go new file mode 100644 index 000000000000..c0e9d47dedfa --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/servicelocations.go @@ -0,0 +1,150 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServiceLocationsClientWithBaseURI(baseURI string, subscriptionID string) ServiceLocationsClient { + return ServiceLocationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available locations for peering service. +// Parameters: +// country - the country of interest, in which the locations are to be present. +func (client ServiceLocationsClient) List(ctx context.Context, country string) (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, country) + 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 + } + if result.sllr.hasNextLink() && result.sllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServiceLocationsClient) ListPreparer(ctx context.Context, country string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(country) > 0 { + queryParameters["country"] = autorest.Encode("query", country) + } + + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServiceLocationsClient) ListResponder(resp *http.Response) (result ServiceLocationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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, country string) (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, country) + return +} diff --git a/services/peering/mgmt/2021-06-01/peering/serviceproviders.go b/services/peering/mgmt/2021-06-01/peering/serviceproviders.go new file mode 100644 index 000000000000..3f4ee8eb5c44 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/serviceproviders.go @@ -0,0 +1,145 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +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 + } + if result.splr.hasNextLink() && result.splr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServiceProvidersClient) ListResponder(resp *http.Response) (result ServiceProviderListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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/peering/mgmt/2021-06-01/peering/services.go b/services/peering/mgmt/2021-06-01/peering/services.go new file mode 100644 index 000000000000..c5ad53047bea --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/services.go @@ -0,0 +1,647 @@ +package peering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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 + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServicesClient) CreateOrUpdateResponder(resp *http.Response) (result Service, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete 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 + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get 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 + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServicesClient) GetResponder(resp *http.Response) (result Service, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// InitializeConnectionMonitor initialize Peering Service for Connection Monitor functionality +func (client ServicesClient) InitializeConnectionMonitor(ctx context.Context) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.InitializeConnectionMonitor") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.InitializeConnectionMonitorPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "InitializeConnectionMonitor", nil, "Failure preparing request") + return + } + + resp, err := client.InitializeConnectionMonitorSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "InitializeConnectionMonitor", resp, "Failure sending request") + return + } + + result, err = client.InitializeConnectionMonitorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "peering.ServicesClient", "InitializeConnectionMonitor", resp, "Failure responding to request") + return + } + + return +} + +// InitializeConnectionMonitorPreparer prepares the InitializeConnectionMonitor request. +func (client ServicesClient) InitializeConnectionMonitorPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Peering/initializeConnectionMonitor", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// InitializeConnectionMonitorSender sends the InitializeConnectionMonitor request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) InitializeConnectionMonitorSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// InitializeConnectionMonitorResponder handles the response to the InitializeConnectionMonitor request. The method always +// closes the http.Response Body. +func (client ServicesClient) InitializeConnectionMonitorResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.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 + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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 + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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 + } + + 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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/peering/mgmt/2021-06-01/peering/version.go b/services/peering/mgmt/2021-06-01/peering/version.go new file mode 100644 index 000000000000..dad8393ccdc4 --- /dev/null +++ b/services/peering/mgmt/2021-06-01/peering/version.go @@ -0,0 +1,19 @@ +package peering + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " peering/2021-06-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/CHANGELOG.md b/services/preview/peering/mgmt/2019-08-01-preview/peering/CHANGELOG.md index dd2e4a49828f..a1ecf841edb0 100644 --- a/services/preview/peering/mgmt/2019-08-01-preview/peering/CHANGELOG.md +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/CHANGELOG.md @@ -1,10 +1,2 @@ -# Change History +# Unreleased -## Additive Changes - -### New Funcs - -1. ErrorResponse.MarshalJSON() ([]byte, error) -1. Operation.MarshalJSON() ([]byte, error) -1. OperationDisplayInfo.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) diff --git a/services/preview/peering/mgmt/2019-08-01-preview/peering/_meta.json b/services/preview/peering/mgmt/2019-08-01-preview/peering/_meta.json index bd2585cd55d5..a505d1168997 100644 --- a/services/preview/peering/mgmt/2019-08-01-preview/peering/_meta.json +++ b/services/preview/peering/mgmt/2019-08-01-preview/peering/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "c51580c6f102bace66c5bed4b979437c21b81882", "readme": "/_/azure-rest-api-specs/specification/peering/resource-manager/readme.md", "tag": "package-2019-08-01-preview", "use": "@microsoft.azure/autorest.go@2.1.183", diff --git a/services/preview/peering/mgmt/2019-09-01-preview/peering/CHANGELOG.md b/services/preview/peering/mgmt/2019-09-01-preview/peering/CHANGELOG.md index e15e4e247ae9..a1ecf841edb0 100644 --- a/services/preview/peering/mgmt/2019-09-01-preview/peering/CHANGELOG.md +++ b/services/preview/peering/mgmt/2019-09-01-preview/peering/CHANGELOG.md @@ -1,11 +1,2 @@ -# Change History +# Unreleased -## Additive Changes - -### New Funcs - -1. ErrorResponse.MarshalJSON() ([]byte, error) -1. Operation.MarshalJSON() ([]byte, error) -1. OperationDisplayInfo.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) -1. ServicePrefixEvent.MarshalJSON() ([]byte, error) diff --git a/services/preview/peering/mgmt/2019-09-01-preview/peering/_meta.json b/services/preview/peering/mgmt/2019-09-01-preview/peering/_meta.json index a7ee0817b010..c4ee33dbaf8b 100644 --- a/services/preview/peering/mgmt/2019-09-01-preview/peering/_meta.json +++ b/services/preview/peering/mgmt/2019-09-01-preview/peering/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "c51580c6f102bace66c5bed4b979437c21b81882", "readme": "/_/azure-rest-api-specs/specification/peering/resource-manager/readme.md", "tag": "package-2019-09-01-preview", "use": "@microsoft.azure/autorest.go@2.1.183", diff --git a/services/preview/peering/mgmt/2020-01-01-preview/peering/CHANGELOG.md b/services/preview/peering/mgmt/2020-01-01-preview/peering/CHANGELOG.md index 9fd3f6255ee1..a1ecf841edb0 100644 --- a/services/preview/peering/mgmt/2020-01-01-preview/peering/CHANGELOG.md +++ b/services/preview/peering/mgmt/2020-01-01-preview/peering/CHANGELOG.md @@ -1,12 +1,2 @@ -# Change History +# Unreleased -## Additive Changes - -### New Funcs - -1. ErrorResponse.MarshalJSON() ([]byte, error) -1. Operation.MarshalJSON() ([]byte, error) -1. OperationDisplayInfo.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) -1. ServiceCountry.MarshalJSON() ([]byte, error) -1. ServicePrefixEvent.MarshalJSON() ([]byte, error) diff --git a/services/preview/peering/mgmt/2020-01-01-preview/peering/_meta.json b/services/preview/peering/mgmt/2020-01-01-preview/peering/_meta.json index b0200cdbff5e..ee7bcbbbfb2f 100644 --- a/services/preview/peering/mgmt/2020-01-01-preview/peering/_meta.json +++ b/services/preview/peering/mgmt/2020-01-01-preview/peering/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "c51580c6f102bace66c5bed4b979437c21b81882", "readme": "/_/azure-rest-api-specs/specification/peering/resource-manager/readme.md", "tag": "package-2020-01-01-preview", "use": "@microsoft.azure/autorest.go@2.1.183",