diff --git a/sdk/resourcemanager/peering/armpeering/CHANGELOG.md b/sdk/resourcemanager/peering/armpeering/CHANGELOG.md new file mode 100644 index 000000000000..17b9dceace74 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-10) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/peering/armpeering/LICENSE.txt b/sdk/resourcemanager/peering/armpeering/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/peering/armpeering/README.md b/sdk/resourcemanager/peering/armpeering/README.md new file mode 100644 index 000000000000..1612ed0e60d9 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/README.md @@ -0,0 +1,75 @@ +# Azure Peering Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/peering/armpeering)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/peering/armpeering) + +The `armpeering` module provides operations for working with Azure Peering. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/peering/armpeering) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Peering module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/peering/armpeering +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Peering. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Clients + +Azure Peering modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. + +```go +client := armpeering.NewLegacyPeeringsClient(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options = arm.ClientOptions{ + Host: arm.AzureChina, +} +client := armpeering.NewLegacyPeeringsClient(, cred, &options) +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Peering` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/peering/armpeering/autorest.md b/sdk/resourcemanager/peering/armpeering/autorest.md new file mode 100644 index 000000000000..3d0d4eb627b4 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/peering/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/peering/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/peering/armpeering/build.go b/sdk/resourcemanager/peering/armpeering/build.go new file mode 100644 index 000000000000..2e68b494e335 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/peering/armpeering + +package armpeering diff --git a/sdk/resourcemanager/peering/armpeering/ci.yml b/sdk/resourcemanager/peering/armpeering/ci.yml new file mode 100644 index 000000000000..fc527651bec3 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/peering/armpeering/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/peering/armpeering/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/peering/armpeering' diff --git a/sdk/resourcemanager/peering/armpeering/go.mod b/sdk/resourcemanager/peering/armpeering/go.mod new file mode 100644 index 000000000000..cc1ce0009908 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/peering/armpeering + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v60.1.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/peering/armpeering/go.sum b/sdk/resourcemanager/peering/armpeering/go.sum new file mode 100644 index 000000000000..960c6c966a3f --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v60.1.0+incompatible h1:j6y8ddurcaiyLfwBwPmJFaunp6BDzyQTuAgMrm1r++o= +github.com/Azure/azure-sdk-for-go v60.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/peering/armpeering/go_mod_tidy_hack.go b/sdk/resourcemanager/peering/armpeering/go_mod_tidy_hack.go new file mode 100644 index 000000000000..5867fecf9959 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armpeering + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_constants.go b/sdk/resourcemanager/peering/armpeering/zz_generated_constants.go new file mode 100644 index 000000000000..8babe4249cce --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_constants.go @@ -0,0 +1,472 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +const ( + module = "armpeering" + version = "v0.1.0" +) + +// ConnectionState - The state of the connection. +type ConnectionState string + +const ( + ConnectionStateActive ConnectionState = "Active" + ConnectionStateApproved ConnectionState = "Approved" + ConnectionStateNone ConnectionState = "None" + ConnectionStatePendingApproval ConnectionState = "PendingApproval" + ConnectionStateProvisioningCompleted ConnectionState = "ProvisioningCompleted" + ConnectionStateProvisioningFailed ConnectionState = "ProvisioningFailed" + ConnectionStateProvisioningStarted ConnectionState = "ProvisioningStarted" + ConnectionStateValidating ConnectionState = "Validating" +) + +// PossibleConnectionStateValues returns the possible values for the ConnectionState const type. +func PossibleConnectionStateValues() []ConnectionState { + return []ConnectionState{ + ConnectionStateActive, + ConnectionStateApproved, + ConnectionStateNone, + ConnectionStatePendingApproval, + ConnectionStateProvisioningCompleted, + ConnectionStateProvisioningFailed, + ConnectionStateProvisioningStarted, + ConnectionStateValidating, + } +} + +// ToPtr returns a *ConnectionState pointing to the current value. +func (c ConnectionState) ToPtr() *ConnectionState { + return &c +} + +// DirectPeeringType - The type of direct peering. +type DirectPeeringType string + +const ( + DirectPeeringTypeCdn DirectPeeringType = "Cdn" + DirectPeeringTypeEdge DirectPeeringType = "Edge" + DirectPeeringTypeInternal DirectPeeringType = "Internal" + DirectPeeringTypeTransit DirectPeeringType = "Transit" +) + +// PossibleDirectPeeringTypeValues returns the possible values for the DirectPeeringType const type. +func PossibleDirectPeeringTypeValues() []DirectPeeringType { + return []DirectPeeringType{ + DirectPeeringTypeCdn, + DirectPeeringTypeEdge, + DirectPeeringTypeInternal, + DirectPeeringTypeTransit, + } +} + +// ToPtr returns a *DirectPeeringType pointing to the current value. +func (c DirectPeeringType) ToPtr() *DirectPeeringType { + return &c +} + +type Enum0 string + +const ( + Enum0Available Enum0 = "Available" + Enum0UnAvailable Enum0 = "UnAvailable" +) + +// PossibleEnum0Values returns the possible values for the Enum0 const type. +func PossibleEnum0Values() []Enum0 { + return []Enum0{ + Enum0Available, + Enum0UnAvailable, + } +} + +// ToPtr returns a *Enum0 pointing to the current value. +func (c Enum0) ToPtr() *Enum0 { + return &c +} + +type Enum1 string + +const ( + Enum1Direct Enum1 = "Direct" + Enum1Exchange Enum1 = "Exchange" +) + +// PossibleEnum1Values returns the possible values for the Enum1 const type. +func PossibleEnum1Values() []Enum1 { + return []Enum1{ + Enum1Direct, + Enum1Exchange, + } +} + +// ToPtr returns a *Enum1 pointing to the current value. +func (c Enum1) ToPtr() *Enum1 { + return &c +} + +type Enum14 string + +const ( + Enum14Direct Enum14 = "Direct" + Enum14Exchange Enum14 = "Exchange" +) + +// PossibleEnum14Values returns the possible values for the Enum14 const type. +func PossibleEnum14Values() []Enum14 { + return []Enum14{ + Enum14Direct, + Enum14Exchange, + } +} + +// ToPtr returns a *Enum14 pointing to the current value. +func (c Enum14) ToPtr() *Enum14 { + return &c +} + +type Enum15 string + +const ( + Enum15Cdn Enum15 = "Cdn" + Enum15Edge Enum15 = "Edge" + Enum15Internal Enum15 = "Internal" + Enum15Transit Enum15 = "Transit" +) + +// PossibleEnum15Values returns the possible values for the Enum15 const type. +func PossibleEnum15Values() []Enum15 { + return []Enum15{ + Enum15Cdn, + Enum15Edge, + Enum15Internal, + Enum15Transit, + } +} + +// ToPtr returns a *Enum15 pointing to the current value. +func (c Enum15) ToPtr() *Enum15 { + return &c +} + +// Family - The family of the peering SKU. +type Family string + +const ( + FamilyDirect Family = "Direct" + FamilyExchange Family = "Exchange" +) + +// PossibleFamilyValues returns the possible values for the Family const type. +func PossibleFamilyValues() []Family { + return []Family{ + FamilyDirect, + FamilyExchange, + } +} + +// ToPtr returns a *Family pointing to the current value. +func (c Family) ToPtr() *Family { + return &c +} + +// Kind - The kind of the peering. +type Kind string + +const ( + KindDirect Kind = "Direct" + KindExchange Kind = "Exchange" +) + +// PossibleKindValues returns the possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{ + KindDirect, + KindExchange, + } +} + +// ToPtr returns a *Kind pointing to the current value. +func (c Kind) ToPtr() *Kind { + return &c +} + +// LearnedType - The prefix learned type +type LearnedType string + +const ( + LearnedTypeNone LearnedType = "None" + LearnedTypeViaPartner LearnedType = "ViaPartner" + LearnedTypeViaSession LearnedType = "ViaSession" +) + +// PossibleLearnedTypeValues returns the possible values for the LearnedType const type. +func PossibleLearnedTypeValues() []LearnedType { + return []LearnedType{ + LearnedTypeNone, + LearnedTypeViaPartner, + LearnedTypeViaSession, + } +} + +// ToPtr returns a *LearnedType pointing to the current value. +func (c LearnedType) ToPtr() *LearnedType { + return &c +} + +// Name - The name of the peering SKU. +type Name string + +const ( + NameBasicDirectFree Name = "Basic_Direct_Free" + NameBasicExchangeFree Name = "Basic_Exchange_Free" + NamePremiumDirectFree Name = "Premium_Direct_Free" + NamePremiumDirectMetered Name = "Premium_Direct_Metered" + NamePremiumDirectUnlimited Name = "Premium_Direct_Unlimited" + NamePremiumExchangeMetered Name = "Premium_Exchange_Metered" +) + +// PossibleNameValues returns the possible values for the Name const type. +func PossibleNameValues() []Name { + return []Name{ + NameBasicDirectFree, + NameBasicExchangeFree, + NamePremiumDirectFree, + NamePremiumDirectMetered, + NamePremiumDirectUnlimited, + NamePremiumExchangeMetered, + } +} + +// ToPtr returns a *Name pointing to the current value. +func (c Name) ToPtr() *Name { + return &c +} + +// PrefixValidationState - The prefix validation state +type PrefixValidationState string + +const ( + PrefixValidationStateFailed PrefixValidationState = "Failed" + PrefixValidationStateInvalid PrefixValidationState = "Invalid" + PrefixValidationStateNone PrefixValidationState = "None" + PrefixValidationStatePending PrefixValidationState = "Pending" + PrefixValidationStateUnknown PrefixValidationState = "Unknown" + PrefixValidationStateVerified PrefixValidationState = "Verified" +) + +// PossiblePrefixValidationStateValues returns the possible values for the PrefixValidationState const type. +func PossiblePrefixValidationStateValues() []PrefixValidationState { + return []PrefixValidationState{ + PrefixValidationStateFailed, + PrefixValidationStateInvalid, + PrefixValidationStateNone, + PrefixValidationStatePending, + PrefixValidationStateUnknown, + PrefixValidationStateVerified, + } +} + +// ToPtr returns a *PrefixValidationState pointing to the current value. +func (c PrefixValidationState) ToPtr() *PrefixValidationState { + return &c +} + +// ProvisioningState - The provisioning state of the resource. +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// SessionAddressProvider - The field indicating if Microsoft provides session ip addresses. +type SessionAddressProvider string + +const ( + SessionAddressProviderMicrosoft SessionAddressProvider = "Microsoft" + SessionAddressProviderPeer SessionAddressProvider = "Peer" +) + +// PossibleSessionAddressProviderValues returns the possible values for the SessionAddressProvider const type. +func PossibleSessionAddressProviderValues() []SessionAddressProvider { + return []SessionAddressProvider{ + SessionAddressProviderMicrosoft, + SessionAddressProviderPeer, + } +} + +// ToPtr returns a *SessionAddressProvider pointing to the current value. +func (c SessionAddressProvider) ToPtr() *SessionAddressProvider { + return &c +} + +// SessionStateV4 - The state of the IPv4 session. +type SessionStateV4 string + +const ( + SessionStateV4Active SessionStateV4 = "Active" + SessionStateV4Connect SessionStateV4 = "Connect" + SessionStateV4Established SessionStateV4 = "Established" + SessionStateV4Idle SessionStateV4 = "Idle" + SessionStateV4None SessionStateV4 = "None" + SessionStateV4OpenConfirm SessionStateV4 = "OpenConfirm" + SessionStateV4OpenReceived SessionStateV4 = "OpenReceived" + SessionStateV4OpenSent SessionStateV4 = "OpenSent" + SessionStateV4PendingAdd SessionStateV4 = "PendingAdd" + SessionStateV4PendingRemove SessionStateV4 = "PendingRemove" + SessionStateV4PendingUpdate SessionStateV4 = "PendingUpdate" +) + +// PossibleSessionStateV4Values returns the possible values for the SessionStateV4 const type. +func PossibleSessionStateV4Values() []SessionStateV4 { + return []SessionStateV4{ + SessionStateV4Active, + SessionStateV4Connect, + SessionStateV4Established, + SessionStateV4Idle, + SessionStateV4None, + SessionStateV4OpenConfirm, + SessionStateV4OpenReceived, + SessionStateV4OpenSent, + SessionStateV4PendingAdd, + SessionStateV4PendingRemove, + SessionStateV4PendingUpdate, + } +} + +// ToPtr returns a *SessionStateV4 pointing to the current value. +func (c SessionStateV4) ToPtr() *SessionStateV4 { + return &c +} + +// SessionStateV6 - The state of the IPv6 session. +type SessionStateV6 string + +const ( + SessionStateV6Active SessionStateV6 = "Active" + SessionStateV6Connect SessionStateV6 = "Connect" + SessionStateV6Established SessionStateV6 = "Established" + SessionStateV6Idle SessionStateV6 = "Idle" + SessionStateV6None SessionStateV6 = "None" + SessionStateV6OpenConfirm SessionStateV6 = "OpenConfirm" + SessionStateV6OpenReceived SessionStateV6 = "OpenReceived" + SessionStateV6OpenSent SessionStateV6 = "OpenSent" + SessionStateV6PendingAdd SessionStateV6 = "PendingAdd" + SessionStateV6PendingRemove SessionStateV6 = "PendingRemove" + SessionStateV6PendingUpdate SessionStateV6 = "PendingUpdate" +) + +// PossibleSessionStateV6Values returns the possible values for the SessionStateV6 const type. +func PossibleSessionStateV6Values() []SessionStateV6 { + return []SessionStateV6{ + SessionStateV6Active, + SessionStateV6Connect, + SessionStateV6Established, + SessionStateV6Idle, + SessionStateV6None, + SessionStateV6OpenConfirm, + SessionStateV6OpenReceived, + SessionStateV6OpenSent, + SessionStateV6PendingAdd, + SessionStateV6PendingRemove, + SessionStateV6PendingUpdate, + } +} + +// ToPtr returns a *SessionStateV6 pointing to the current value. +func (c SessionStateV6) ToPtr() *SessionStateV6 { + return &c +} + +// Size - The size of the peering SKU. +type Size string + +const ( + SizeFree Size = "Free" + SizeMetered Size = "Metered" + SizeUnlimited Size = "Unlimited" +) + +// PossibleSizeValues returns the possible values for the Size const type. +func PossibleSizeValues() []Size { + return []Size{ + SizeFree, + SizeMetered, + SizeUnlimited, + } +} + +// ToPtr returns a *Size pointing to the current value. +func (c Size) ToPtr() *Size { + return &c +} + +// Tier - The tier of the peering SKU. +type Tier string + +const ( + TierBasic Tier = "Basic" + TierPremium Tier = "Premium" +) + +// PossibleTierValues returns the possible values for the Tier const type. +func PossibleTierValues() []Tier { + return []Tier{ + TierBasic, + TierPremium, + } +} + +// ToPtr returns a *Tier pointing to the current value. +func (c Tier) ToPtr() *Tier { + return &c +} + +// ValidationState - The validation state of the ASN associated with the peer. +type ValidationState string + +const ( + ValidationStateApproved ValidationState = "Approved" + ValidationStateFailed ValidationState = "Failed" + ValidationStateNone ValidationState = "None" + ValidationStatePending ValidationState = "Pending" +) + +// PossibleValidationStateValues returns the possible values for the ValidationState const type. +func PossibleValidationStateValues() []ValidationState { + return []ValidationState{ + ValidationStateApproved, + ValidationStateFailed, + ValidationStateNone, + ValidationStatePending, + } +} + +// ToPtr returns a *ValidationState pointing to the current value. +func (c ValidationState) ToPtr() *ValidationState { + return &c +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_legacypeerings_client.go b/sdk/resourcemanager/peering/armpeering/zz_generated_legacypeerings_client.go new file mode 100644 index 000000000000..ff7faadf8892 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_legacypeerings_client.go @@ -0,0 +1,99 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// LegacyPeeringsClient contains the methods for the LegacyPeerings group. +// Don't use this type directly, use NewLegacyPeeringsClient() instead. +type LegacyPeeringsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewLegacyPeeringsClient creates a new instance of LegacyPeeringsClient with the specified values. +func NewLegacyPeeringsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *LegacyPeeringsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &LegacyPeeringsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists all of the legacy peerings under the given subscription matching the specified kind and location. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LegacyPeeringsClient) List(peeringLocation string, kind Enum1, options *LegacyPeeringsListOptions) *LegacyPeeringsListPager { + return &LegacyPeeringsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, peeringLocation, kind, options) + }, + advancer: func(ctx context.Context, resp LegacyPeeringsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PeeringListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *LegacyPeeringsClient) listCreateRequest(ctx context.Context, peeringLocation string, kind Enum1, options *LegacyPeeringsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Peering/legacyPeerings" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("peeringLocation", peeringLocation) + reqQP.Set("kind", string(kind)) + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *LegacyPeeringsClient) listHandleResponse(resp *http.Response) (LegacyPeeringsListResponse, error) { + result := LegacyPeeringsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringListResult); err != nil { + return LegacyPeeringsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *LegacyPeeringsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_models.go b/sdk/resourcemanager/peering/armpeering/zz_generated_models.go new file mode 100644 index 000000000000..58eeb195f766 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_models.go @@ -0,0 +1,849 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// BgpSession - The properties that define a BGP session. +type BgpSession struct { + // The MD5 authentication key of the session. + MD5AuthenticationKey *string `json:"md5AuthenticationKey,omitempty"` + + // The maximum number of prefixes advertised over the IPv4 session. + MaxPrefixesAdvertisedV4 *int32 `json:"maxPrefixesAdvertisedV4,omitempty"` + + // The maximum number of prefixes advertised over the IPv6 session. + MaxPrefixesAdvertisedV6 *int32 `json:"maxPrefixesAdvertisedV6,omitempty"` + + // The IPv4 session address on peer's end. + PeerSessionIPv4Address *string `json:"peerSessionIPv4Address,omitempty"` + + // The IPv6 session address on peer's end. + PeerSessionIPv6Address *string `json:"peerSessionIPv6Address,omitempty"` + + // The IPv4 prefix that contains both ends' IPv4 addresses. + SessionPrefixV4 *string `json:"sessionPrefixV4,omitempty"` + + // The IPv6 prefix that contains both ends' IPv6 addresses. + SessionPrefixV6 *string `json:"sessionPrefixV6,omitempty"` + + // READ-ONLY; The IPv4 session address on Microsoft's end. + MicrosoftSessionIPv4Address *string `json:"microsoftSessionIPv4Address,omitempty" azure:"ro"` + + // READ-ONLY; The IPv6 session address on Microsoft's end. + MicrosoftSessionIPv6Address *string `json:"microsoftSessionIPv6Address,omitempty" azure:"ro"` + + // READ-ONLY; The state of the IPv4 session. + SessionStateV4 *SessionStateV4 `json:"sessionStateV4,omitempty" azure:"ro"` + + // READ-ONLY; The state of the IPv6 session. + SessionStateV6 *SessionStateV6 `json:"sessionStateV6,omitempty" azure:"ro"` +} + +// CheckServiceProviderAvailabilityInput - Class for CheckServiceProviderAvailabilityInput +type CheckServiceProviderAvailabilityInput struct { + // Gets or sets the PeeringServiceLocation + PeeringServiceLocation *string `json:"peeringServiceLocation,omitempty"` + + // Gets or sets the PeeringServiceProvider + PeeringServiceProvider *string `json:"peeringServiceProvider,omitempty"` +} + +// ContactInfo - The contact information of the peer. +type ContactInfo struct { + // The list of email addresses. + Emails []*string `json:"emails,omitempty"` + + // The list of contact numbers. + Phone []*string `json:"phone,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContactInfo. +func (c ContactInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "emails", c.Emails) + populate(objectMap, "phone", c.Phone) + return json.Marshal(objectMap) +} + +// DirectConnection - The properties that define a direct connection. +type DirectConnection struct { + // The bandwidth of the connection. + BandwidthInMbps *int32 `json:"bandwidthInMbps,omitempty"` + + // The BGP session associated with the connection. + BgpSession *BgpSession `json:"bgpSession,omitempty"` + + // The unique identifier (GUID) for the connection. + ConnectionIdentifier *string `json:"connectionIdentifier,omitempty"` + + // The PeeringDB.com ID of the facility at which the connection has to be set up. + PeeringDBFacilityID *int32 `json:"peeringDBFacilityId,omitempty"` + + // The bandwidth that is actually provisioned. + ProvisionedBandwidthInMbps *int32 `json:"provisionedBandwidthInMbps,omitempty"` + + // The field indicating if Microsoft provides session ip addresses. + SessionAddressProvider *SessionAddressProvider `json:"sessionAddressProvider,omitempty"` + + // The flag that indicates whether or not the connection is used for peering service. + UseForPeeringService *bool `json:"useForPeeringService,omitempty"` + + // READ-ONLY; The state of the connection. + ConnectionState *ConnectionState `json:"connectionState,omitempty" azure:"ro"` +} + +// DirectPeeringFacility - The properties that define a direct peering facility. +type DirectPeeringFacility struct { + // The address of the direct peering facility. + Address *string `json:"address,omitempty"` + + // The type of the direct peering. + DirectPeeringType *DirectPeeringType `json:"directPeeringType,omitempty"` + + // The PeeringDB.com ID of the facility. + PeeringDBFacilityID *int32 `json:"peeringDBFacilityId,omitempty"` + + // The PeeringDB.com URL of the facility. + PeeringDBFacilityLink *string `json:"peeringDBFacilityLink,omitempty"` +} + +// ErrorResponse - The error response that indicates why an operation has failed. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// ExchangeConnection - The properties that define an exchange connection. +type ExchangeConnection struct { + // The BGP session associated with the connection. + BgpSession *BgpSession `json:"bgpSession,omitempty"` + + // The unique identifier (GUID) for the connection. + ConnectionIdentifier *string `json:"connectionIdentifier,omitempty"` + + // The PeeringDB.com ID of the facility at which the connection has to be set up. + PeeringDBFacilityID *int32 `json:"peeringDBFacilityId,omitempty"` + + // READ-ONLY; The state of the connection. + ConnectionState *ConnectionState `json:"connectionState,omitempty" azure:"ro"` +} + +// ExchangePeeringFacility - The properties that define an exchange peering facility. +type ExchangePeeringFacility struct { + // The bandwidth of the connection between Microsoft and the exchange peering facility. + BandwidthInMbps *int32 `json:"bandwidthInMbps,omitempty"` + + // The name of the exchange peering facility. + ExchangeName *string `json:"exchangeName,omitempty"` + + // The IPv4 prefixes associated with the exchange peering facility. + FacilityIPv4Prefix *string `json:"facilityIPv4Prefix,omitempty"` + + // The IPv6 prefixes associated with the exchange peering facility. + FacilityIPv6Prefix *string `json:"facilityIPv6Prefix,omitempty"` + + // The IPv4 address of Microsoft at the exchange peering facility. + MicrosoftIPv4Address *string `json:"microsoftIPv4Address,omitempty"` + + // The IPv6 address of Microsoft at the exchange peering facility. + MicrosoftIPv6Address *string `json:"microsoftIPv6Address,omitempty"` + + // The PeeringDB.com ID of the facility. + PeeringDBFacilityID *int32 `json:"peeringDBFacilityId,omitempty"` + + // The PeeringDB.com URL of the facility. + PeeringDBFacilityLink *string `json:"peeringDBFacilityLink,omitempty"` +} + +// LegacyPeeringsListOptions contains the optional parameters for the LegacyPeerings.List method. +type LegacyPeeringsListOptions struct { + // placeholder for future optional parameters +} + +// Operation - The peering API operation. +type Operation struct { + // READ-ONLY; The information related to the operation. + Display *OperationDisplayInfo `json:"display,omitempty" azure:"ro"` + + // READ-ONLY; The flag that indicates whether the operation applies to data plane. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation. + Name *string `json:"name,omitempty" azure:"ro"` +} + +// OperationDisplayInfo - The information related to the operation. +type OperationDisplayInfo struct { + // READ-ONLY; The description of the operation. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation. + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource provider. + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - The paginated list of peering API operations. +type OperationListResult struct { + // The link to fetch the next page of peering API operations. + NextLink *string `json:"nextLink,omitempty"` + + // The list of peering API operations. + Value []*Operation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// PeerAsn - The essential information related to the peer's ASN. +type PeerAsn struct { + Resource + // The properties that define a peer's ASN. + Properties *PeerAsnProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeerAsn. +func (p PeerAsn) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PeerAsnListResult - The paginated list of peer ASNs. +type PeerAsnListResult struct { + // The link to fetch the next page of peer ASNs. + NextLink *string `json:"nextLink,omitempty"` + + // The list of peer ASNs. + Value []*PeerAsn `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeerAsnListResult. +func (p PeerAsnListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PeerAsnProperties - The properties that define a peer's ASN. +type PeerAsnProperties struct { + // The Autonomous System Number (ASN) of the peer. + PeerAsn *int32 `json:"peerAsn,omitempty"` + + // The contact information of the peer. + PeerContactInfo *ContactInfo `json:"peerContactInfo,omitempty"` + + // The name of the peer. + PeerName *string `json:"peerName,omitempty"` + + // The validation state of the ASN associated with the peer. + ValidationState *ValidationState `json:"validationState,omitempty"` +} + +// PeerAsnsCreateOrUpdateOptions contains the optional parameters for the PeerAsns.CreateOrUpdate method. +type PeerAsnsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PeerAsnsDeleteOptions contains the optional parameters for the PeerAsns.Delete method. +type PeerAsnsDeleteOptions struct { + // placeholder for future optional parameters +} + +// PeerAsnsGetOptions contains the optional parameters for the PeerAsns.Get method. +type PeerAsnsGetOptions struct { + // placeholder for future optional parameters +} + +// PeerAsnsListBySubscriptionOptions contains the optional parameters for the PeerAsns.ListBySubscription method. +type PeerAsnsListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// Peering is a logical representation of a set of connections to the Microsoft Cloud Edge at a location. +type Peering struct { + Resource + // REQUIRED; The kind of the peering. + Kind *Kind `json:"kind,omitempty"` + + // REQUIRED; The location of the resource. + Location *string `json:"location,omitempty"` + + // REQUIRED; The SKU that defines the tier and kind of the peering. + SKU *PeeringSKU `json:"sku,omitempty"` + + // The properties that define a peering. + Properties *PeeringProperties `json:"properties,omitempty"` + + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Peering. +func (p Peering) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.Resource.marshalInternal(objectMap) + populate(objectMap, "kind", p.Kind) + populate(objectMap, "location", p.Location) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "sku", p.SKU) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// PeeringBandwidthOffer - The properties that define a peering bandwidth offer. +type PeeringBandwidthOffer struct { + // The name of the bandwidth offer. + OfferName *string `json:"offerName,omitempty"` + + // The value of the bandwidth offer in Mbps. + ValueInMbps *int32 `json:"valueInMbps,omitempty"` +} + +// PeeringListResult - The paginated list of peerings. +type PeeringListResult struct { + // The link to fetch the next page of peerings. + NextLink *string `json:"nextLink,omitempty"` + + // The list of peerings. + Value []*Peering `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringListResult. +func (p PeeringListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PeeringLocation - Peering location is where connectivity could be established to the Microsoft Cloud Edge. +type PeeringLocation struct { + Resource + // The kind of peering that the peering location supports. + Kind *Kind `json:"kind,omitempty"` + + // The properties that define a peering location. + Properties *PeeringLocationProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringLocation. +func (p PeeringLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.Resource.marshalInternal(objectMap) + populate(objectMap, "kind", p.Kind) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PeeringLocationListResult - The paginated list of peering locations. +type PeeringLocationListResult struct { + // The link to fetch the next page of peering locations. + NextLink *string `json:"nextLink,omitempty"` + + // The list of peering locations. + Value []*PeeringLocation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringLocationListResult. +func (p PeeringLocationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PeeringLocationProperties - The properties that define a peering location. +type PeeringLocationProperties struct { + // The Azure region associated with the peering location. + AzureRegion *string `json:"azureRegion,omitempty"` + + // The country in which the peering location exists. + Country *string `json:"country,omitempty"` + + // The properties that define a direct peering location. + Direct *PeeringLocationPropertiesDirect `json:"direct,omitempty"` + + // The properties that define an exchange peering location. + Exchange *PeeringLocationPropertiesExchange `json:"exchange,omitempty"` + + // The name of the peering location. + PeeringLocation *string `json:"peeringLocation,omitempty"` +} + +// PeeringLocationPropertiesDirect - The properties that define a direct peering location. +type PeeringLocationPropertiesDirect struct { + // The list of bandwidth offers available at the peering location. + BandwidthOffers []*PeeringBandwidthOffer `json:"bandwidthOffers,omitempty"` + + // The list of direct peering facilities at the peering location. + PeeringFacilities []*DirectPeeringFacility `json:"peeringFacilities,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringLocationPropertiesDirect. +func (p PeeringLocationPropertiesDirect) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "bandwidthOffers", p.BandwidthOffers) + populate(objectMap, "peeringFacilities", p.PeeringFacilities) + return json.Marshal(objectMap) +} + +// PeeringLocationPropertiesExchange - The properties that define an exchange peering location. +type PeeringLocationPropertiesExchange struct { + // The list of exchange peering facilities at the peering location. + PeeringFacilities []*ExchangePeeringFacility `json:"peeringFacilities,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringLocationPropertiesExchange. +func (p PeeringLocationPropertiesExchange) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "peeringFacilities", p.PeeringFacilities) + return json.Marshal(objectMap) +} + +// PeeringLocationsListOptions contains the optional parameters for the PeeringLocations.List method. +type PeeringLocationsListOptions struct { + // The type of direct peering. + DirectPeeringType *Enum15 +} + +// PeeringManagementClientCheckServiceProviderAvailabilityOptions contains the optional parameters for the PeeringManagementClient.CheckServiceProviderAvailability +// method. +type PeeringManagementClientCheckServiceProviderAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// PeeringProperties - The properties that define connectivity to the Microsoft Cloud Edge. +type PeeringProperties struct { + // The properties that define a direct peering. + Direct *PeeringPropertiesDirect `json:"direct,omitempty"` + + // The properties that define an exchange peering. + Exchange *PeeringPropertiesExchange `json:"exchange,omitempty"` + + // The location of the peering. + PeeringLocation *string `json:"peeringLocation,omitempty"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// PeeringPropertiesDirect - The properties that define a direct peering. +type PeeringPropertiesDirect struct { + // The set of connections that constitute a direct peering. + Connections []*DirectConnection `json:"connections,omitempty"` + + // The type of direct peering. + DirectPeeringType *DirectPeeringType `json:"directPeeringType,omitempty"` + + // The reference of the peer ASN. + PeerAsn *SubResource `json:"peerAsn,omitempty"` + + // The flag that indicates whether or not the peering is used for peering service. + UseForPeeringService *bool `json:"useForPeeringService,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringPropertiesDirect. +func (p PeeringPropertiesDirect) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "connections", p.Connections) + populate(objectMap, "directPeeringType", p.DirectPeeringType) + populate(objectMap, "peerAsn", p.PeerAsn) + populate(objectMap, "useForPeeringService", p.UseForPeeringService) + return json.Marshal(objectMap) +} + +// PeeringPropertiesExchange - The properties that define an exchange peering. +type PeeringPropertiesExchange struct { + // The set of connections that constitute an exchange peering. + Connections []*ExchangeConnection `json:"connections,omitempty"` + + // The reference of the peer ASN. + PeerAsn *SubResource `json:"peerAsn,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringPropertiesExchange. +func (p PeeringPropertiesExchange) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "connections", p.Connections) + populate(objectMap, "peerAsn", p.PeerAsn) + return json.Marshal(objectMap) +} + +// PeeringSKU - The SKU that defines the tier and kind of the peering. +type PeeringSKU struct { + // The family of the peering SKU. + Family *Family `json:"family,omitempty"` + + // The name of the peering SKU. + Name *Name `json:"name,omitempty"` + + // The size of the peering SKU. + Size *Size `json:"size,omitempty"` + + // The tier of the peering SKU. + Tier *Tier `json:"tier,omitempty"` +} + +// PeeringService - Peering Service +type PeeringService struct { + Resource + // REQUIRED; The location of the resource. + Location *string `json:"location,omitempty"` + + // The properties that define a peering service. + Properties *PeeringServiceProperties `json:"properties,omitempty"` + + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringService. +func (p PeeringService) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.Resource.marshalInternal(objectMap) + populate(objectMap, "location", p.Location) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// PeeringServiceListResult - The paginated list of peering services. +type PeeringServiceListResult struct { + // The link to fetch the next page of peering services. + NextLink *string `json:"nextLink,omitempty"` + + // The list of peering services. + Value []*PeeringService `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringServiceListResult. +func (p PeeringServiceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PeeringServiceLocation - PeeringService location +type PeeringServiceLocation struct { + Resource + // The properties that define a peering service location. + Properties *PeeringServiceLocationProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringServiceLocation. +func (p PeeringServiceLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PeeringServiceLocationListResult - The paginated list of peering service locations. +type PeeringServiceLocationListResult struct { + // The link to fetch the next page of peering service locations. + NextLink *string `json:"nextLink,omitempty"` + + // The list of peering service locations. + Value []*PeeringServiceLocation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringServiceLocationListResult. +func (p PeeringServiceLocationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PeeringServiceLocationProperties - The properties that define connectivity to the Peering Service Location. +type PeeringServiceLocationProperties struct { + // Azure region for the location + AzureRegion *string `json:"azureRegion,omitempty"` + + // Country of the customer + Country *string `json:"country,omitempty"` + + // State of the customer + State *string `json:"state,omitempty"` +} + +// PeeringServiceLocationsListOptions contains the optional parameters for the PeeringServiceLocations.List method. +type PeeringServiceLocationsListOptions struct { + // placeholder for future optional parameters +} + +// PeeringServicePrefix - The peering service prefix class. +type PeeringServicePrefix struct { + Resource + // Gets or sets the peering prefix properties. + Properties *PeeringServicePrefixProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringServicePrefix. +func (p PeeringServicePrefix) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PeeringServicePrefixListResult - The paginated list of [T]. +type PeeringServicePrefixListResult struct { + // The link to fetch the next page of [T]. + NextLink *string `json:"nextLink,omitempty"` + + // The list of [T]. + Value []*PeeringServicePrefix `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringServicePrefixListResult. +func (p PeeringServicePrefixListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PeeringServicePrefixProperties - The peering service prefix properties class. +type PeeringServicePrefixProperties struct { + // The prefix learned type + LearnedType *LearnedType `json:"learnedType,omitempty"` + + // Valid route prefix + Prefix *string `json:"prefix,omitempty"` + + // The prefix validation state + PrefixValidationState *PrefixValidationState `json:"prefixValidationState,omitempty"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// PeeringServicePrefixesCreateOrUpdateOptions contains the optional parameters for the PeeringServicePrefixes.CreateOrUpdate method. +type PeeringServicePrefixesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PeeringServicePrefixesDeleteOptions contains the optional parameters for the PeeringServicePrefixes.Delete method. +type PeeringServicePrefixesDeleteOptions struct { + // placeholder for future optional parameters +} + +// PeeringServicePrefixesGetOptions contains the optional parameters for the PeeringServicePrefixes.Get method. +type PeeringServicePrefixesGetOptions struct { + // placeholder for future optional parameters +} + +// PeeringServiceProperties - The properties that define connectivity to the Peering Service. +type PeeringServiceProperties struct { + // The PeeringServiceLocation of the Customer. + PeeringServiceLocation *string `json:"peeringServiceLocation,omitempty"` + + // The MAPS Provider Name. + PeeringServiceProvider *string `json:"peeringServiceProvider,omitempty"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// PeeringServiceProvider - PeeringService provider +type PeeringServiceProvider struct { + Resource + // The properties that define a peering service provider. + Properties *PeeringServiceProviderProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringServiceProvider. +func (p PeeringServiceProvider) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PeeringServiceProviderListResult - The paginated list of peering service providers. +type PeeringServiceProviderListResult struct { + // The link to fetch the next page of peering service providers. + NextLink *string `json:"nextLink,omitempty"` + + // The list of peering service providers. + Value []*PeeringServiceProvider `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PeeringServiceProviderListResult. +func (p PeeringServiceProviderListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PeeringServiceProviderProperties - The properties that define connectivity to the Peering Service Provider. +type PeeringServiceProviderProperties struct { + // The name of the service provider. + ServiceProviderName *string `json:"serviceProviderName,omitempty"` +} + +// PeeringServiceProvidersListOptions contains the optional parameters for the PeeringServiceProviders.List method. +type PeeringServiceProvidersListOptions struct { + // placeholder for future optional parameters +} + +// PeeringServicesCreateOrUpdateOptions contains the optional parameters for the PeeringServices.CreateOrUpdate method. +type PeeringServicesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PeeringServicesDeleteOptions contains the optional parameters for the PeeringServices.Delete method. +type PeeringServicesDeleteOptions struct { + // placeholder for future optional parameters +} + +// PeeringServicesGetOptions contains the optional parameters for the PeeringServices.Get method. +type PeeringServicesGetOptions struct { + // placeholder for future optional parameters +} + +// PeeringServicesListByResourceGroupOptions contains the optional parameters for the PeeringServices.ListByResourceGroup method. +type PeeringServicesListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// PeeringServicesListBySubscriptionOptions contains the optional parameters for the PeeringServices.ListBySubscription method. +type PeeringServicesListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// PeeringServicesUpdateOptions contains the optional parameters for the PeeringServices.Update method. +type PeeringServicesUpdateOptions struct { + // placeholder for future optional parameters +} + +// PeeringsCreateOrUpdateOptions contains the optional parameters for the Peerings.CreateOrUpdate method. +type PeeringsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PeeringsDeleteOptions contains the optional parameters for the Peerings.Delete method. +type PeeringsDeleteOptions struct { + // placeholder for future optional parameters +} + +// PeeringsGetOptions contains the optional parameters for the Peerings.Get method. +type PeeringsGetOptions struct { + // placeholder for future optional parameters +} + +// PeeringsListByResourceGroupOptions contains the optional parameters for the Peerings.ListByResourceGroup method. +type PeeringsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// PeeringsListBySubscriptionOptions contains the optional parameters for the Peerings.ListBySubscription method. +type PeeringsListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// PeeringsUpdateOptions contains the optional parameters for the Peerings.Update method. +type PeeringsUpdateOptions struct { + // placeholder for future optional parameters +} + +// PrefixesListByPeeringServiceOptions contains the optional parameters for the Prefixes.ListByPeeringService method. +type PrefixesListByPeeringServiceOptions struct { + // placeholder for future optional parameters +} + +// Resource - The ARM resource class. +type Resource struct { + // READ-ONLY; The ID of the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) +} + +// ResourceTags - The resource tags. +type ResourceTags struct { + // Gets or sets the tags, a dictionary of descriptors arm object + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceTags. +func (r ResourceTags) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +// SubResource - The sub resource. +type SubResource struct { + // The identifier of the referenced resource. + ID *string `json:"id,omitempty"` +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_operations_client.go b/sdk/resourcemanager/peering/armpeering/zz_generated_operations_client.go new file mode 100644 index 000000000000..1871b75094e9 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_operations_client.go @@ -0,0 +1,89 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists all of the available API operations for peering resources. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(options *OperationsListOptions) *OperationsListPager { + return &OperationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Peering/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_pagers.go b/sdk/resourcemanager/peering/armpeering/zz_generated_pagers.go new file mode 100644 index 000000000000..44a007e134c1 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_pagers.go @@ -0,0 +1,611 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "reflect" +) + +// LegacyPeeringsListPager provides operations for iterating over paged responses. +type LegacyPeeringsListPager struct { + client *LegacyPeeringsClient + current LegacyPeeringsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, LegacyPeeringsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *LegacyPeeringsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *LegacyPeeringsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PeeringListResult.NextLink == nil || len(*p.current.PeeringListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current LegacyPeeringsListResponse page. +func (p *LegacyPeeringsListPager) PageResponse() LegacyPeeringsListResponse { + return p.current +} + +// OperationsListPager provides operations for iterating over paged responses. +type OperationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *OperationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationsListResponse page. +func (p *OperationsListPager) PageResponse() OperationsListResponse { + return p.current +} + +// PeerAsnsListBySubscriptionPager provides operations for iterating over paged responses. +type PeerAsnsListBySubscriptionPager struct { + client *PeerAsnsClient + current PeerAsnsListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PeerAsnsListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PeerAsnsListBySubscriptionPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PeerAsnsListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PeerAsnListResult.NextLink == nil || len(*p.current.PeerAsnListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PeerAsnsListBySubscriptionResponse page. +func (p *PeerAsnsListBySubscriptionPager) PageResponse() PeerAsnsListBySubscriptionResponse { + return p.current +} + +// PeeringLocationsListPager provides operations for iterating over paged responses. +type PeeringLocationsListPager struct { + client *PeeringLocationsClient + current PeeringLocationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PeeringLocationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PeeringLocationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PeeringLocationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PeeringLocationListResult.NextLink == nil || len(*p.current.PeeringLocationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PeeringLocationsListResponse page. +func (p *PeeringLocationsListPager) PageResponse() PeeringLocationsListResponse { + return p.current +} + +// PeeringServiceLocationsListPager provides operations for iterating over paged responses. +type PeeringServiceLocationsListPager struct { + client *PeeringServiceLocationsClient + current PeeringServiceLocationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PeeringServiceLocationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PeeringServiceLocationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PeeringServiceLocationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PeeringServiceLocationListResult.NextLink == nil || len(*p.current.PeeringServiceLocationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PeeringServiceLocationsListResponse page. +func (p *PeeringServiceLocationsListPager) PageResponse() PeeringServiceLocationsListResponse { + return p.current +} + +// PeeringServiceProvidersListPager provides operations for iterating over paged responses. +type PeeringServiceProvidersListPager struct { + client *PeeringServiceProvidersClient + current PeeringServiceProvidersListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PeeringServiceProvidersListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PeeringServiceProvidersListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PeeringServiceProvidersListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PeeringServiceProviderListResult.NextLink == nil || len(*p.current.PeeringServiceProviderListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PeeringServiceProvidersListResponse page. +func (p *PeeringServiceProvidersListPager) PageResponse() PeeringServiceProvidersListResponse { + return p.current +} + +// PeeringServicesListByResourceGroupPager provides operations for iterating over paged responses. +type PeeringServicesListByResourceGroupPager struct { + client *PeeringServicesClient + current PeeringServicesListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PeeringServicesListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PeeringServicesListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PeeringServicesListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PeeringServiceListResult.NextLink == nil || len(*p.current.PeeringServiceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PeeringServicesListByResourceGroupResponse page. +func (p *PeeringServicesListByResourceGroupPager) PageResponse() PeeringServicesListByResourceGroupResponse { + return p.current +} + +// PeeringServicesListBySubscriptionPager provides operations for iterating over paged responses. +type PeeringServicesListBySubscriptionPager struct { + client *PeeringServicesClient + current PeeringServicesListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PeeringServicesListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PeeringServicesListBySubscriptionPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PeeringServicesListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PeeringServiceListResult.NextLink == nil || len(*p.current.PeeringServiceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PeeringServicesListBySubscriptionResponse page. +func (p *PeeringServicesListBySubscriptionPager) PageResponse() PeeringServicesListBySubscriptionResponse { + return p.current +} + +// PeeringsListByResourceGroupPager provides operations for iterating over paged responses. +type PeeringsListByResourceGroupPager struct { + client *PeeringsClient + current PeeringsListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PeeringsListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PeeringsListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PeeringsListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PeeringListResult.NextLink == nil || len(*p.current.PeeringListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PeeringsListByResourceGroupResponse page. +func (p *PeeringsListByResourceGroupPager) PageResponse() PeeringsListByResourceGroupResponse { + return p.current +} + +// PeeringsListBySubscriptionPager provides operations for iterating over paged responses. +type PeeringsListBySubscriptionPager struct { + client *PeeringsClient + current PeeringsListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PeeringsListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PeeringsListBySubscriptionPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PeeringsListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PeeringListResult.NextLink == nil || len(*p.current.PeeringListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PeeringsListBySubscriptionResponse page. +func (p *PeeringsListBySubscriptionPager) PageResponse() PeeringsListBySubscriptionResponse { + return p.current +} + +// PrefixesListByPeeringServicePager provides operations for iterating over paged responses. +type PrefixesListByPeeringServicePager struct { + client *PrefixesClient + current PrefixesListByPeeringServiceResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PrefixesListByPeeringServiceResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PrefixesListByPeeringServicePager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *PrefixesListByPeeringServicePager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PeeringServicePrefixListResult.NextLink == nil || len(*p.current.PeeringServicePrefixListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByPeeringServiceHandleError(resp) + return false + } + result, err := p.client.listByPeeringServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current PrefixesListByPeeringServiceResponse page. +func (p *PrefixesListByPeeringServicePager) PageResponse() PrefixesListByPeeringServiceResponse { + return p.current +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_peerasns_client.go b/sdk/resourcemanager/peering/armpeering/zz_generated_peerasns_client.go new file mode 100644 index 000000000000..873adadf4a3b --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_peerasns_client.go @@ -0,0 +1,271 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PeerAsnsClient contains the methods for the PeerAsns group. +// Don't use this type directly, use NewPeerAsnsClient() instead. +type PeerAsnsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPeerAsnsClient creates a new instance of PeerAsnsClient with the specified values. +func NewPeerAsnsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PeerAsnsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PeerAsnsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Creates a new peer ASN or updates an existing peer ASN with the specified name under the given subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeerAsnsClient) CreateOrUpdate(ctx context.Context, peerAsnName string, peerAsn PeerAsn, options *PeerAsnsCreateOrUpdateOptions) (PeerAsnsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, peerAsnName, peerAsn, options) + if err != nil { + return PeerAsnsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeerAsnsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return PeerAsnsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PeerAsnsClient) createOrUpdateCreateRequest(ctx context.Context, peerAsnName string, peerAsn PeerAsn, options *PeerAsnsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}" + if peerAsnName == "" { + return nil, errors.New("parameter peerAsnName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peerAsnName}", url.PathEscape(peerAsnName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, peerAsn) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PeerAsnsClient) createOrUpdateHandleResponse(resp *http.Response) (PeerAsnsCreateOrUpdateResponse, error) { + result := PeerAsnsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeerAsn); err != nil { + return PeerAsnsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PeerAsnsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Deletes an existing peer ASN with the specified name under the given subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeerAsnsClient) Delete(ctx context.Context, peerAsnName string, options *PeerAsnsDeleteOptions) (PeerAsnsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, peerAsnName, options) + if err != nil { + return PeerAsnsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeerAsnsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return PeerAsnsDeleteResponse{}, client.deleteHandleError(resp) + } + return PeerAsnsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PeerAsnsClient) deleteCreateRequest(ctx context.Context, peerAsnName string, options *PeerAsnsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}" + if peerAsnName == "" { + return nil, errors.New("parameter peerAsnName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peerAsnName}", url.PathEscape(peerAsnName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PeerAsnsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets the peer ASN with the specified name under the given subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeerAsnsClient) Get(ctx context.Context, peerAsnName string, options *PeerAsnsGetOptions) (PeerAsnsGetResponse, error) { + req, err := client.getCreateRequest(ctx, peerAsnName, options) + if err != nil { + return PeerAsnsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeerAsnsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PeerAsnsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PeerAsnsClient) getCreateRequest(ctx context.Context, peerAsnName string, options *PeerAsnsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}" + if peerAsnName == "" { + return nil, errors.New("parameter peerAsnName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peerAsnName}", url.PathEscape(peerAsnName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PeerAsnsClient) getHandleResponse(resp *http.Response) (PeerAsnsGetResponse, error) { + result := PeerAsnsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeerAsn); err != nil { + return PeerAsnsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PeerAsnsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - Lists all of the peer ASNs under the given subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeerAsnsClient) ListBySubscription(options *PeerAsnsListBySubscriptionOptions) *PeerAsnsListBySubscriptionPager { + return &PeerAsnsListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp PeerAsnsListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PeerAsnListResult.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *PeerAsnsClient) listBySubscriptionCreateRequest(ctx context.Context, options *PeerAsnsListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *PeerAsnsClient) listBySubscriptionHandleResponse(resp *http.Response) (PeerAsnsListBySubscriptionResponse, error) { + result := PeerAsnsListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeerAsnListResult); err != nil { + return PeerAsnsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *PeerAsnsClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_peeringlocations_client.go b/sdk/resourcemanager/peering/armpeering/zz_generated_peeringlocations_client.go new file mode 100644 index 000000000000..c631f39a1dc1 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_peeringlocations_client.go @@ -0,0 +1,101 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PeeringLocationsClient contains the methods for the PeeringLocations group. +// Don't use this type directly, use NewPeeringLocationsClient() instead. +type PeeringLocationsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPeeringLocationsClient creates a new instance of PeeringLocationsClient with the specified values. +func NewPeeringLocationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PeeringLocationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PeeringLocationsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists all of the available peering locations for the specified kind of peering. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringLocationsClient) List(kind Enum14, options *PeeringLocationsListOptions) *PeeringLocationsListPager { + return &PeeringLocationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, kind, options) + }, + advancer: func(ctx context.Context, resp PeeringLocationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PeeringLocationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *PeeringLocationsClient) listCreateRequest(ctx context.Context, kind Enum14, options *PeeringLocationsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringLocations" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("kind", string(kind)) + if options != nil && options.DirectPeeringType != nil { + reqQP.Set("directPeeringType", string(*options.DirectPeeringType)) + } + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PeeringLocationsClient) listHandleResponse(resp *http.Response) (PeeringLocationsListResponse, error) { + result := PeeringLocationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringLocationListResult); err != nil { + return PeeringLocationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PeeringLocationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_peeringmanagementclient_client.go b/sdk/resourcemanager/peering/armpeering/zz_generated_peeringmanagementclient_client.go new file mode 100644 index 000000000000..8ddb0a20934c --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_peeringmanagementclient_client.go @@ -0,0 +1,100 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PeeringManagementClient contains the methods for the PeeringManagementClient group. +// Don't use this type directly, use NewPeeringManagementClient() instead. +type PeeringManagementClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPeeringManagementClient creates a new instance of PeeringManagementClient with the specified values. +func NewPeeringManagementClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PeeringManagementClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PeeringManagementClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckServiceProviderAvailability - Checks if the peering service provider is present within 1000 miles of customer's location +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringManagementClient) CheckServiceProviderAvailability(ctx context.Context, checkServiceProviderAvailabilityInput CheckServiceProviderAvailabilityInput, options *PeeringManagementClientCheckServiceProviderAvailabilityOptions) (PeeringManagementClientCheckServiceProviderAvailabilityResponse, error) { + req, err := client.checkServiceProviderAvailabilityCreateRequest(ctx, checkServiceProviderAvailabilityInput, options) + if err != nil { + return PeeringManagementClientCheckServiceProviderAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeeringManagementClientCheckServiceProviderAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PeeringManagementClientCheckServiceProviderAvailabilityResponse{}, client.checkServiceProviderAvailabilityHandleError(resp) + } + return client.checkServiceProviderAvailabilityHandleResponse(resp) +} + +// checkServiceProviderAvailabilityCreateRequest creates the CheckServiceProviderAvailability request. +func (client *PeeringManagementClient) checkServiceProviderAvailabilityCreateRequest(ctx context.Context, checkServiceProviderAvailabilityInput CheckServiceProviderAvailabilityInput, options *PeeringManagementClientCheckServiceProviderAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Peering/CheckServiceProviderAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, checkServiceProviderAvailabilityInput) +} + +// checkServiceProviderAvailabilityHandleResponse handles the CheckServiceProviderAvailability response. +func (client *PeeringManagementClient) checkServiceProviderAvailabilityHandleResponse(resp *http.Response) (PeeringManagementClientCheckServiceProviderAvailabilityResponse, error) { + result := PeeringManagementClientCheckServiceProviderAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Value); err != nil { + return PeeringManagementClientCheckServiceProviderAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkServiceProviderAvailabilityHandleError handles the CheckServiceProviderAvailability error response. +func (client *PeeringManagementClient) checkServiceProviderAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_peerings_client.go b/sdk/resourcemanager/peering/armpeering/zz_generated_peerings_client.go new file mode 100644 index 000000000000..98e542e185c6 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_peerings_client.go @@ -0,0 +1,406 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PeeringsClient contains the methods for the Peerings group. +// Don't use this type directly, use NewPeeringsClient() instead. +type PeeringsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPeeringsClient creates a new instance of PeeringsClient with the specified values. +func NewPeeringsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PeeringsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PeeringsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Creates a new peering or updates an existing peering with the specified name under the given subscription and resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringName string, peering Peering, options *PeeringsCreateOrUpdateOptions) (PeeringsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, peeringName, peering, options) + if err != nil { + return PeeringsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeeringsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return PeeringsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PeeringsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, peeringName string, peering Peering, options *PeeringsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if peeringName == "" { + return nil, errors.New("parameter peeringName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringName}", url.PathEscape(peeringName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, peering) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PeeringsClient) createOrUpdateHandleResponse(resp *http.Response) (PeeringsCreateOrUpdateResponse, error) { + result := PeeringsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Peering); err != nil { + return PeeringsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PeeringsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Deletes an existing peering with the specified name under the given subscription and resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringsClient) Delete(ctx context.Context, resourceGroupName string, peeringName string, options *PeeringsDeleteOptions) (PeeringsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, peeringName, options) + if err != nil { + return PeeringsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeeringsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return PeeringsDeleteResponse{}, client.deleteHandleError(resp) + } + return PeeringsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PeeringsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, peeringName string, options *PeeringsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if peeringName == "" { + return nil, errors.New("parameter peeringName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringName}", url.PathEscape(peeringName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PeeringsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets an existing peering with the specified name under the given subscription and resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringsClient) Get(ctx context.Context, resourceGroupName string, peeringName string, options *PeeringsGetOptions) (PeeringsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, peeringName, options) + if err != nil { + return PeeringsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeeringsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PeeringsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PeeringsClient) getCreateRequest(ctx context.Context, resourceGroupName string, peeringName string, options *PeeringsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if peeringName == "" { + return nil, errors.New("parameter peeringName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringName}", url.PathEscape(peeringName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PeeringsClient) getHandleResponse(resp *http.Response) (PeeringsGetResponse, error) { + result := PeeringsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Peering); err != nil { + return PeeringsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PeeringsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - Lists all of the peerings under the given subscription and resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringsClient) ListByResourceGroup(resourceGroupName string, options *PeeringsListByResourceGroupOptions) *PeeringsListByResourceGroupPager { + return &PeeringsListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp PeeringsListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PeeringListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *PeeringsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *PeeringsListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *PeeringsClient) listByResourceGroupHandleResponse(resp *http.Response) (PeeringsListByResourceGroupResponse, error) { + result := PeeringsListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringListResult); err != nil { + return PeeringsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *PeeringsClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - Lists all of the peerings under the given subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringsClient) ListBySubscription(options *PeeringsListBySubscriptionOptions) *PeeringsListBySubscriptionPager { + return &PeeringsListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp PeeringsListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PeeringListResult.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *PeeringsClient) listBySubscriptionCreateRequest(ctx context.Context, options *PeeringsListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerings" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *PeeringsClient) listBySubscriptionHandleResponse(resp *http.Response) (PeeringsListBySubscriptionResponse, error) { + result := PeeringsListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringListResult); err != nil { + return PeeringsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *PeeringsClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Updates tags for a peering with the specified name under the given subscription and resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringsClient) Update(ctx context.Context, resourceGroupName string, peeringName string, tags ResourceTags, options *PeeringsUpdateOptions) (PeeringsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, peeringName, tags, options) + if err != nil { + return PeeringsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeeringsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PeeringsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *PeeringsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, peeringName string, tags ResourceTags, options *PeeringsUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if peeringName == "" { + return nil, errors.New("parameter peeringName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringName}", url.PathEscape(peeringName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, tags) +} + +// updateHandleResponse handles the Update response. +func (client *PeeringsClient) updateHandleResponse(resp *http.Response) (PeeringsUpdateResponse, error) { + result := PeeringsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Peering); err != nil { + return PeeringsUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *PeeringsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_peeringservicelocations_client.go b/sdk/resourcemanager/peering/armpeering/zz_generated_peeringservicelocations_client.go new file mode 100644 index 000000000000..86bc8f2ca98e --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_peeringservicelocations_client.go @@ -0,0 +1,97 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PeeringServiceLocationsClient contains the methods for the PeeringServiceLocations group. +// Don't use this type directly, use NewPeeringServiceLocationsClient() instead. +type PeeringServiceLocationsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPeeringServiceLocationsClient creates a new instance of PeeringServiceLocationsClient with the specified values. +func NewPeeringServiceLocationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PeeringServiceLocationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PeeringServiceLocationsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists all of the available peering service locations for the specified kind of peering. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringServiceLocationsClient) List(options *PeeringServiceLocationsListOptions) *PeeringServiceLocationsListPager { + return &PeeringServiceLocationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp PeeringServiceLocationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PeeringServiceLocationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *PeeringServiceLocationsClient) listCreateRequest(ctx context.Context, options *PeeringServiceLocationsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceLocations" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PeeringServiceLocationsClient) listHandleResponse(resp *http.Response) (PeeringServiceLocationsListResponse, error) { + result := PeeringServiceLocationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringServiceLocationListResult); err != nil { + return PeeringServiceLocationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PeeringServiceLocationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_peeringserviceprefixes_client.go b/sdk/resourcemanager/peering/armpeering/zz_generated_peeringserviceprefixes_client.go new file mode 100644 index 000000000000..4b526446a9f9 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_peeringserviceprefixes_client.go @@ -0,0 +1,241 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PeeringServicePrefixesClient contains the methods for the PeeringServicePrefixes group. +// Don't use this type directly, use NewPeeringServicePrefixesClient() instead. +type PeeringServicePrefixesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPeeringServicePrefixesClient creates a new instance of PeeringServicePrefixesClient with the specified values. +func NewPeeringServicePrefixesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PeeringServicePrefixesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PeeringServicePrefixesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Creates or updates the peering prefix. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringServicePrefixesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, peeringServicePrefix PeeringServicePrefix, options *PeeringServicePrefixesCreateOrUpdateOptions) (PeeringServicePrefixesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, peeringServiceName, prefixName, peeringServicePrefix, options) + if err != nil { + return PeeringServicePrefixesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeeringServicePrefixesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return PeeringServicePrefixesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PeeringServicePrefixesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, peeringServicePrefix PeeringServicePrefix, options *PeeringServicePrefixesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if peeringServiceName == "" { + return nil, errors.New("parameter peeringServiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringServiceName}", url.PathEscape(peeringServiceName)) + if prefixName == "" { + return nil, errors.New("parameter prefixName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{prefixName}", url.PathEscape(prefixName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, peeringServicePrefix) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PeeringServicePrefixesClient) createOrUpdateHandleResponse(resp *http.Response) (PeeringServicePrefixesCreateOrUpdateResponse, error) { + result := PeeringServicePrefixesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringServicePrefix); err != nil { + return PeeringServicePrefixesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PeeringServicePrefixesClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - removes the peering prefix. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringServicePrefixesClient) Delete(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, options *PeeringServicePrefixesDeleteOptions) (PeeringServicePrefixesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, peeringServiceName, prefixName, options) + if err != nil { + return PeeringServicePrefixesDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeeringServicePrefixesDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return PeeringServicePrefixesDeleteResponse{}, client.deleteHandleError(resp) + } + return PeeringServicePrefixesDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PeeringServicePrefixesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, options *PeeringServicePrefixesDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if peeringServiceName == "" { + return nil, errors.New("parameter peeringServiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringServiceName}", url.PathEscape(peeringServiceName)) + if prefixName == "" { + return nil, errors.New("parameter prefixName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{prefixName}", url.PathEscape(prefixName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PeeringServicePrefixesClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets the peering service prefix. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringServicePrefixesClient) Get(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, options *PeeringServicePrefixesGetOptions) (PeeringServicePrefixesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, peeringServiceName, prefixName, options) + if err != nil { + return PeeringServicePrefixesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeeringServicePrefixesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PeeringServicePrefixesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PeeringServicePrefixesClient) getCreateRequest(ctx context.Context, resourceGroupName string, peeringServiceName string, prefixName string, options *PeeringServicePrefixesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if peeringServiceName == "" { + return nil, errors.New("parameter peeringServiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringServiceName}", url.PathEscape(peeringServiceName)) + if prefixName == "" { + return nil, errors.New("parameter prefixName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{prefixName}", url.PathEscape(prefixName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PeeringServicePrefixesClient) getHandleResponse(resp *http.Response) (PeeringServicePrefixesGetResponse, error) { + result := PeeringServicePrefixesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringServicePrefix); err != nil { + return PeeringServicePrefixesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PeeringServicePrefixesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_peeringserviceproviders_client.go b/sdk/resourcemanager/peering/armpeering/zz_generated_peeringserviceproviders_client.go new file mode 100644 index 000000000000..97f168ca1d94 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_peeringserviceproviders_client.go @@ -0,0 +1,97 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PeeringServiceProvidersClient contains the methods for the PeeringServiceProviders group. +// Don't use this type directly, use NewPeeringServiceProvidersClient() instead. +type PeeringServiceProvidersClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPeeringServiceProvidersClient creates a new instance of PeeringServiceProvidersClient with the specified values. +func NewPeeringServiceProvidersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PeeringServiceProvidersClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PeeringServiceProvidersClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists all of the available peering service locations for the specified kind of peering. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringServiceProvidersClient) List(options *PeeringServiceProvidersListOptions) *PeeringServiceProvidersListPager { + return &PeeringServiceProvidersListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp PeeringServiceProvidersListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PeeringServiceProviderListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *PeeringServiceProvidersClient) listCreateRequest(ctx context.Context, options *PeeringServiceProvidersListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceProviders" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PeeringServiceProvidersClient) listHandleResponse(resp *http.Response) (PeeringServiceProvidersListResponse, error) { + result := PeeringServiceProvidersListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringServiceProviderListResult); err != nil { + return PeeringServiceProvidersListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PeeringServiceProvidersClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_peeringservices_client.go b/sdk/resourcemanager/peering/armpeering/zz_generated_peeringservices_client.go new file mode 100644 index 000000000000..12cc9620edb9 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_peeringservices_client.go @@ -0,0 +1,406 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PeeringServicesClient contains the methods for the PeeringServices group. +// Don't use this type directly, use NewPeeringServicesClient() instead. +type PeeringServicesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPeeringServicesClient creates a new instance of PeeringServicesClient with the specified values. +func NewPeeringServicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PeeringServicesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PeeringServicesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Creates a new peering service or updates an existing peering with the specified name under the given subscription and resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, peeringServiceName string, peeringService PeeringService, options *PeeringServicesCreateOrUpdateOptions) (PeeringServicesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, peeringServiceName, peeringService, options) + if err != nil { + return PeeringServicesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeeringServicesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return PeeringServicesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PeeringServicesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, peeringServiceName string, peeringService PeeringService, options *PeeringServicesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if peeringServiceName == "" { + return nil, errors.New("parameter peeringServiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringServiceName}", url.PathEscape(peeringServiceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, peeringService) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PeeringServicesClient) createOrUpdateHandleResponse(resp *http.Response) (PeeringServicesCreateOrUpdateResponse, error) { + result := PeeringServicesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringService); err != nil { + return PeeringServicesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PeeringServicesClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Deletes an existing peering service with the specified name under the given subscription and resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringServicesClient) Delete(ctx context.Context, resourceGroupName string, peeringServiceName string, options *PeeringServicesDeleteOptions) (PeeringServicesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, peeringServiceName, options) + if err != nil { + return PeeringServicesDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeeringServicesDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return PeeringServicesDeleteResponse{}, client.deleteHandleError(resp) + } + return PeeringServicesDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PeeringServicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, peeringServiceName string, options *PeeringServicesDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if peeringServiceName == "" { + return nil, errors.New("parameter peeringServiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringServiceName}", url.PathEscape(peeringServiceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PeeringServicesClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets an existing peering service with the specified name under the given subscription and resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringServicesClient) Get(ctx context.Context, resourceGroupName string, peeringServiceName string, options *PeeringServicesGetOptions) (PeeringServicesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, peeringServiceName, options) + if err != nil { + return PeeringServicesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeeringServicesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PeeringServicesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PeeringServicesClient) getCreateRequest(ctx context.Context, resourceGroupName string, peeringServiceName string, options *PeeringServicesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if peeringServiceName == "" { + return nil, errors.New("parameter peeringServiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringServiceName}", url.PathEscape(peeringServiceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PeeringServicesClient) getHandleResponse(resp *http.Response) (PeeringServicesGetResponse, error) { + result := PeeringServicesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringService); err != nil { + return PeeringServicesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PeeringServicesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - Lists all of the peering services under the given subscription and resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringServicesClient) ListByResourceGroup(resourceGroupName string, options *PeeringServicesListByResourceGroupOptions) *PeeringServicesListByResourceGroupPager { + return &PeeringServicesListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp PeeringServicesListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PeeringServiceListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *PeeringServicesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *PeeringServicesListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *PeeringServicesClient) listByResourceGroupHandleResponse(resp *http.Response) (PeeringServicesListByResourceGroupResponse, error) { + result := PeeringServicesListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringServiceListResult); err != nil { + return PeeringServicesListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *PeeringServicesClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - Lists all of the peerings under the given subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringServicesClient) ListBySubscription(options *PeeringServicesListBySubscriptionOptions) *PeeringServicesListBySubscriptionPager { + return &PeeringServicesListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp PeeringServicesListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PeeringServiceListResult.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *PeeringServicesClient) listBySubscriptionCreateRequest(ctx context.Context, options *PeeringServicesListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServices" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *PeeringServicesClient) listBySubscriptionHandleResponse(resp *http.Response) (PeeringServicesListBySubscriptionResponse, error) { + result := PeeringServicesListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringServiceListResult); err != nil { + return PeeringServicesListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *PeeringServicesClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Updates tags for a peering service with the specified name under the given subscription and resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PeeringServicesClient) Update(ctx context.Context, resourceGroupName string, peeringServiceName string, tags ResourceTags, options *PeeringServicesUpdateOptions) (PeeringServicesUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, peeringServiceName, tags, options) + if err != nil { + return PeeringServicesUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PeeringServicesUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PeeringServicesUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *PeeringServicesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, peeringServiceName string, tags ResourceTags, options *PeeringServicesUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if peeringServiceName == "" { + return nil, errors.New("parameter peeringServiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringServiceName}", url.PathEscape(peeringServiceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, tags) +} + +// updateHandleResponse handles the Update response. +func (client *PeeringServicesClient) updateHandleResponse(resp *http.Response) (PeeringServicesUpdateResponse, error) { + result := PeeringServicesUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringService); err != nil { + return PeeringServicesUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *PeeringServicesClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_prefixes_client.go b/sdk/resourcemanager/peering/armpeering/zz_generated_prefixes_client.go new file mode 100644 index 000000000000..5276eae91c57 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_prefixes_client.go @@ -0,0 +1,105 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PrefixesClient contains the methods for the Prefixes group. +// Don't use this type directly, use NewPrefixesClient() instead. +type PrefixesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPrefixesClient creates a new instance of PrefixesClient with the specified values. +func NewPrefixesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PrefixesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PrefixesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// ListByPeeringService - Lists the peerings prefix in the resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrefixesClient) ListByPeeringService(resourceGroupName string, peeringServiceName string, options *PrefixesListByPeeringServiceOptions) *PrefixesListByPeeringServicePager { + return &PrefixesListByPeeringServicePager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByPeeringServiceCreateRequest(ctx, resourceGroupName, peeringServiceName, options) + }, + advancer: func(ctx context.Context, resp PrefixesListByPeeringServiceResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PeeringServicePrefixListResult.NextLink) + }, + } +} + +// listByPeeringServiceCreateRequest creates the ListByPeeringService request. +func (client *PrefixesClient) listByPeeringServiceCreateRequest(ctx context.Context, resourceGroupName string, peeringServiceName string, options *PrefixesListByPeeringServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if peeringServiceName == "" { + return nil, errors.New("parameter peeringServiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{peeringServiceName}", url.PathEscape(peeringServiceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByPeeringServiceHandleResponse handles the ListByPeeringService response. +func (client *PrefixesClient) listByPeeringServiceHandleResponse(resp *http.Response) (PrefixesListByPeeringServiceResponse, error) { + result := PrefixesListByPeeringServiceResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PeeringServicePrefixListResult); err != nil { + return PrefixesListByPeeringServiceResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByPeeringServiceHandleError handles the ListByPeeringService error response. +func (client *PrefixesClient) listByPeeringServiceHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/peering/armpeering/zz_generated_response_types.go b/sdk/resourcemanager/peering/armpeering/zz_generated_response_types.go new file mode 100644 index 000000000000..16cf0dd8ef23 --- /dev/null +++ b/sdk/resourcemanager/peering/armpeering/zz_generated_response_types.go @@ -0,0 +1,299 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armpeering + +import "net/http" + +// LegacyPeeringsListResponse contains the response from method LegacyPeerings.List. +type LegacyPeeringsListResponse struct { + LegacyPeeringsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LegacyPeeringsListResult contains the result from method LegacyPeerings.List. +type LegacyPeeringsListResult struct { + PeeringListResult +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} + +// PeerAsnsCreateOrUpdateResponse contains the response from method PeerAsns.CreateOrUpdate. +type PeerAsnsCreateOrUpdateResponse struct { + PeerAsnsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeerAsnsCreateOrUpdateResult contains the result from method PeerAsns.CreateOrUpdate. +type PeerAsnsCreateOrUpdateResult struct { + PeerAsn +} + +// PeerAsnsDeleteResponse contains the response from method PeerAsns.Delete. +type PeerAsnsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeerAsnsGetResponse contains the response from method PeerAsns.Get. +type PeerAsnsGetResponse struct { + PeerAsnsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeerAsnsGetResult contains the result from method PeerAsns.Get. +type PeerAsnsGetResult struct { + PeerAsn +} + +// PeerAsnsListBySubscriptionResponse contains the response from method PeerAsns.ListBySubscription. +type PeerAsnsListBySubscriptionResponse struct { + PeerAsnsListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeerAsnsListBySubscriptionResult contains the result from method PeerAsns.ListBySubscription. +type PeerAsnsListBySubscriptionResult struct { + PeerAsnListResult +} + +// PeeringLocationsListResponse contains the response from method PeeringLocations.List. +type PeeringLocationsListResponse struct { + PeeringLocationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringLocationsListResult contains the result from method PeeringLocations.List. +type PeeringLocationsListResult struct { + PeeringLocationListResult +} + +// PeeringManagementClientCheckServiceProviderAvailabilityResponse contains the response from method PeeringManagementClient.CheckServiceProviderAvailability. +type PeeringManagementClientCheckServiceProviderAvailabilityResponse struct { + PeeringManagementClientCheckServiceProviderAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringManagementClientCheckServiceProviderAvailabilityResult contains the result from method PeeringManagementClient.CheckServiceProviderAvailability. +type PeeringManagementClientCheckServiceProviderAvailabilityResult struct { + Value *Enum0 +} + +// PeeringServiceLocationsListResponse contains the response from method PeeringServiceLocations.List. +type PeeringServiceLocationsListResponse struct { + PeeringServiceLocationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringServiceLocationsListResult contains the result from method PeeringServiceLocations.List. +type PeeringServiceLocationsListResult struct { + PeeringServiceLocationListResult +} + +// PeeringServicePrefixesCreateOrUpdateResponse contains the response from method PeeringServicePrefixes.CreateOrUpdate. +type PeeringServicePrefixesCreateOrUpdateResponse struct { + PeeringServicePrefixesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringServicePrefixesCreateOrUpdateResult contains the result from method PeeringServicePrefixes.CreateOrUpdate. +type PeeringServicePrefixesCreateOrUpdateResult struct { + PeeringServicePrefix +} + +// PeeringServicePrefixesDeleteResponse contains the response from method PeeringServicePrefixes.Delete. +type PeeringServicePrefixesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringServicePrefixesGetResponse contains the response from method PeeringServicePrefixes.Get. +type PeeringServicePrefixesGetResponse struct { + PeeringServicePrefixesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringServicePrefixesGetResult contains the result from method PeeringServicePrefixes.Get. +type PeeringServicePrefixesGetResult struct { + PeeringServicePrefix +} + +// PeeringServiceProvidersListResponse contains the response from method PeeringServiceProviders.List. +type PeeringServiceProvidersListResponse struct { + PeeringServiceProvidersListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringServiceProvidersListResult contains the result from method PeeringServiceProviders.List. +type PeeringServiceProvidersListResult struct { + PeeringServiceProviderListResult +} + +// PeeringServicesCreateOrUpdateResponse contains the response from method PeeringServices.CreateOrUpdate. +type PeeringServicesCreateOrUpdateResponse struct { + PeeringServicesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringServicesCreateOrUpdateResult contains the result from method PeeringServices.CreateOrUpdate. +type PeeringServicesCreateOrUpdateResult struct { + PeeringService +} + +// PeeringServicesDeleteResponse contains the response from method PeeringServices.Delete. +type PeeringServicesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringServicesGetResponse contains the response from method PeeringServices.Get. +type PeeringServicesGetResponse struct { + PeeringServicesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringServicesGetResult contains the result from method PeeringServices.Get. +type PeeringServicesGetResult struct { + PeeringService +} + +// PeeringServicesListByResourceGroupResponse contains the response from method PeeringServices.ListByResourceGroup. +type PeeringServicesListByResourceGroupResponse struct { + PeeringServicesListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringServicesListByResourceGroupResult contains the result from method PeeringServices.ListByResourceGroup. +type PeeringServicesListByResourceGroupResult struct { + PeeringServiceListResult +} + +// PeeringServicesListBySubscriptionResponse contains the response from method PeeringServices.ListBySubscription. +type PeeringServicesListBySubscriptionResponse struct { + PeeringServicesListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringServicesListBySubscriptionResult contains the result from method PeeringServices.ListBySubscription. +type PeeringServicesListBySubscriptionResult struct { + PeeringServiceListResult +} + +// PeeringServicesUpdateResponse contains the response from method PeeringServices.Update. +type PeeringServicesUpdateResponse struct { + PeeringServicesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringServicesUpdateResult contains the result from method PeeringServices.Update. +type PeeringServicesUpdateResult struct { + PeeringService +} + +// PeeringsCreateOrUpdateResponse contains the response from method Peerings.CreateOrUpdate. +type PeeringsCreateOrUpdateResponse struct { + PeeringsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringsCreateOrUpdateResult contains the result from method Peerings.CreateOrUpdate. +type PeeringsCreateOrUpdateResult struct { + Peering +} + +// PeeringsDeleteResponse contains the response from method Peerings.Delete. +type PeeringsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringsGetResponse contains the response from method Peerings.Get. +type PeeringsGetResponse struct { + PeeringsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringsGetResult contains the result from method Peerings.Get. +type PeeringsGetResult struct { + Peering +} + +// PeeringsListByResourceGroupResponse contains the response from method Peerings.ListByResourceGroup. +type PeeringsListByResourceGroupResponse struct { + PeeringsListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringsListByResourceGroupResult contains the result from method Peerings.ListByResourceGroup. +type PeeringsListByResourceGroupResult struct { + PeeringListResult +} + +// PeeringsListBySubscriptionResponse contains the response from method Peerings.ListBySubscription. +type PeeringsListBySubscriptionResponse struct { + PeeringsListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringsListBySubscriptionResult contains the result from method Peerings.ListBySubscription. +type PeeringsListBySubscriptionResult struct { + PeeringListResult +} + +// PeeringsUpdateResponse contains the response from method Peerings.Update. +type PeeringsUpdateResponse struct { + PeeringsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PeeringsUpdateResult contains the result from method Peerings.Update. +type PeeringsUpdateResult struct { + Peering +} + +// PrefixesListByPeeringServiceResponse contains the response from method Prefixes.ListByPeeringService. +type PrefixesListByPeeringServiceResponse struct { + PrefixesListByPeeringServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrefixesListByPeeringServiceResult contains the result from method Prefixes.ListByPeeringService. +type PrefixesListByPeeringServiceResult struct { + PeeringServicePrefixListResult +}