diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/CHANGELOG.md b/sdk/resourcemanager/trafficmanager/armtrafficmanager/CHANGELOG.md new file mode 100644 index 000000000000..17b9dceace74 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/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/trafficmanager/armtrafficmanager/LICENSE.txt b/sdk/resourcemanager/trafficmanager/armtrafficmanager/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/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/trafficmanager/armtrafficmanager/README.md b/sdk/resourcemanager/trafficmanager/armtrafficmanager/README.md new file mode 100644 index 000000000000..c526573f6259 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/README.md @@ -0,0 +1,75 @@ +# Azure Trafficmanager Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager) + +The `armtrafficmanager` module provides operations for working with Azure Trafficmanager. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/trafficmanager/armtrafficmanager) + +# 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 Trafficmanager module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Trafficmanager. 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 Trafficmanager 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 := armtrafficmanager.NewTrafficManagerUserMetricsKeysClient(, 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 := armtrafficmanager.NewTrafficManagerUserMetricsKeysClient(, 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 `Trafficmanager` 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/trafficmanager/armtrafficmanager/autorest.md b/sdk/resourcemanager/trafficmanager/armtrafficmanager/autorest.md new file mode 100644 index 000000000000..91aace7d6aee --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/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/trafficmanager/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/trafficmanager/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/trafficmanager/armtrafficmanager/build.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/build.go new file mode 100644 index 000000000000..78654e7c0b87 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/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/trafficmanager/armtrafficmanager + +package armtrafficmanager diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/ci.yml b/sdk/resourcemanager/trafficmanager/armtrafficmanager/ci.yml new file mode 100644 index 000000000000..d82d4713dcee --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/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/trafficmanager/armtrafficmanager/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/trafficmanager/armtrafficmanager/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/trafficmanager/armtrafficmanager' diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/go.mod b/sdk/resourcemanager/trafficmanager/armtrafficmanager/go.mod new file mode 100644 index 000000000000..6e0c7b6c81a0 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager + +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/trafficmanager/armtrafficmanager/go.sum b/sdk/resourcemanager/trafficmanager/armtrafficmanager/go.sum new file mode 100644 index 000000000000..960c6c966a3f --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/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/trafficmanager/armtrafficmanager/go_mod_tidy_hack.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/go_mod_tidy_hack.go new file mode 100644 index 000000000000..8bd9eaa79474 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/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 armtrafficmanager + +// 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/trafficmanager/armtrafficmanager/zz_generated_constants.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_constants.go new file mode 100644 index 000000000000..095502d74543 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_constants.go @@ -0,0 +1,229 @@ +//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 armtrafficmanager + +const ( + module = "armtrafficmanager" + version = "v0.1.0" +) + +// AllowedEndpointRecordType - The allowed type DNS record types for this profile. +type AllowedEndpointRecordType string + +const ( + AllowedEndpointRecordTypeAny AllowedEndpointRecordType = "Any" + AllowedEndpointRecordTypeDomainName AllowedEndpointRecordType = "DomainName" + AllowedEndpointRecordTypeIPv4Address AllowedEndpointRecordType = "IPv4Address" + AllowedEndpointRecordTypeIPv6Address AllowedEndpointRecordType = "IPv6Address" +) + +// PossibleAllowedEndpointRecordTypeValues returns the possible values for the AllowedEndpointRecordType const type. +func PossibleAllowedEndpointRecordTypeValues() []AllowedEndpointRecordType { + return []AllowedEndpointRecordType{ + AllowedEndpointRecordTypeAny, + AllowedEndpointRecordTypeDomainName, + AllowedEndpointRecordTypeIPv4Address, + AllowedEndpointRecordTypeIPv6Address, + } +} + +// ToPtr returns a *AllowedEndpointRecordType pointing to the current value. +func (c AllowedEndpointRecordType) ToPtr() *AllowedEndpointRecordType { + return &c +} + +// EndpointMonitorStatus - The monitoring status of the endpoint. +type EndpointMonitorStatus string + +const ( + EndpointMonitorStatusCheckingEndpoint EndpointMonitorStatus = "CheckingEndpoint" + EndpointMonitorStatusDegraded EndpointMonitorStatus = "Degraded" + EndpointMonitorStatusDisabled EndpointMonitorStatus = "Disabled" + EndpointMonitorStatusInactive EndpointMonitorStatus = "Inactive" + EndpointMonitorStatusOnline EndpointMonitorStatus = "Online" + EndpointMonitorStatusStopped EndpointMonitorStatus = "Stopped" +) + +// PossibleEndpointMonitorStatusValues returns the possible values for the EndpointMonitorStatus const type. +func PossibleEndpointMonitorStatusValues() []EndpointMonitorStatus { + return []EndpointMonitorStatus{ + EndpointMonitorStatusCheckingEndpoint, + EndpointMonitorStatusDegraded, + EndpointMonitorStatusDisabled, + EndpointMonitorStatusInactive, + EndpointMonitorStatusOnline, + EndpointMonitorStatusStopped, + } +} + +// ToPtr returns a *EndpointMonitorStatus pointing to the current value. +func (c EndpointMonitorStatus) ToPtr() *EndpointMonitorStatus { + return &c +} + +// EndpointStatus - The status of the endpoint. If the endpoint is Enabled, it is probed for endpoint health and is included in the traffic routing method. +type EndpointStatus string + +const ( + EndpointStatusDisabled EndpointStatus = "Disabled" + EndpointStatusEnabled EndpointStatus = "Enabled" +) + +// PossibleEndpointStatusValues returns the possible values for the EndpointStatus const type. +func PossibleEndpointStatusValues() []EndpointStatus { + return []EndpointStatus{ + EndpointStatusDisabled, + EndpointStatusEnabled, + } +} + +// ToPtr returns a *EndpointStatus pointing to the current value. +func (c EndpointStatus) ToPtr() *EndpointStatus { + return &c +} + +type Enum8 string + +const ( + Enum8Default Enum8 = "default" +) + +// PossibleEnum8Values returns the possible values for the Enum8 const type. +func PossibleEnum8Values() []Enum8 { + return []Enum8{ + Enum8Default, + } +} + +// ToPtr returns a *Enum8 pointing to the current value. +func (c Enum8) ToPtr() *Enum8 { + return &c +} + +// MonitorProtocol - The protocol (HTTP, HTTPS or TCP) used to probe for endpoint health. +type MonitorProtocol string + +const ( + MonitorProtocolHTTP MonitorProtocol = "HTTP" + MonitorProtocolHTTPS MonitorProtocol = "HTTPS" + MonitorProtocolTCP MonitorProtocol = "TCP" +) + +// PossibleMonitorProtocolValues returns the possible values for the MonitorProtocol const type. +func PossibleMonitorProtocolValues() []MonitorProtocol { + return []MonitorProtocol{ + MonitorProtocolHTTP, + MonitorProtocolHTTPS, + MonitorProtocolTCP, + } +} + +// ToPtr returns a *MonitorProtocol pointing to the current value. +func (c MonitorProtocol) ToPtr() *MonitorProtocol { + return &c +} + +// ProfileMonitorStatus - The profile-level monitoring status of the Traffic Manager profile. +type ProfileMonitorStatus string + +const ( + ProfileMonitorStatusCheckingEndpoints ProfileMonitorStatus = "CheckingEndpoints" + ProfileMonitorStatusDegraded ProfileMonitorStatus = "Degraded" + ProfileMonitorStatusDisabled ProfileMonitorStatus = "Disabled" + ProfileMonitorStatusInactive ProfileMonitorStatus = "Inactive" + ProfileMonitorStatusOnline ProfileMonitorStatus = "Online" +) + +// PossibleProfileMonitorStatusValues returns the possible values for the ProfileMonitorStatus const type. +func PossibleProfileMonitorStatusValues() []ProfileMonitorStatus { + return []ProfileMonitorStatus{ + ProfileMonitorStatusCheckingEndpoints, + ProfileMonitorStatusDegraded, + ProfileMonitorStatusDisabled, + ProfileMonitorStatusInactive, + ProfileMonitorStatusOnline, + } +} + +// ToPtr returns a *ProfileMonitorStatus pointing to the current value. +func (c ProfileMonitorStatus) ToPtr() *ProfileMonitorStatus { + return &c +} + +// ProfileStatus - The status of the Traffic Manager profile. +type ProfileStatus string + +const ( + ProfileStatusDisabled ProfileStatus = "Disabled" + ProfileStatusEnabled ProfileStatus = "Enabled" +) + +// PossibleProfileStatusValues returns the possible values for the ProfileStatus const type. +func PossibleProfileStatusValues() []ProfileStatus { + return []ProfileStatus{ + ProfileStatusDisabled, + ProfileStatusEnabled, + } +} + +// ToPtr returns a *ProfileStatus pointing to the current value. +func (c ProfileStatus) ToPtr() *ProfileStatus { + return &c +} + +// TrafficRoutingMethod - The traffic routing method of the Traffic Manager profile. +type TrafficRoutingMethod string + +const ( + TrafficRoutingMethodGeographic TrafficRoutingMethod = "Geographic" + TrafficRoutingMethodMultiValue TrafficRoutingMethod = "MultiValue" + TrafficRoutingMethodPerformance TrafficRoutingMethod = "Performance" + TrafficRoutingMethodPriority TrafficRoutingMethod = "Priority" + TrafficRoutingMethodSubnet TrafficRoutingMethod = "Subnet" + TrafficRoutingMethodWeighted TrafficRoutingMethod = "Weighted" +) + +// PossibleTrafficRoutingMethodValues returns the possible values for the TrafficRoutingMethod const type. +func PossibleTrafficRoutingMethodValues() []TrafficRoutingMethod { + return []TrafficRoutingMethod{ + TrafficRoutingMethodGeographic, + TrafficRoutingMethodMultiValue, + TrafficRoutingMethodPerformance, + TrafficRoutingMethodPriority, + TrafficRoutingMethodSubnet, + TrafficRoutingMethodWeighted, + } +} + +// ToPtr returns a *TrafficRoutingMethod pointing to the current value. +func (c TrafficRoutingMethod) ToPtr() *TrafficRoutingMethod { + return &c +} + +// TrafficViewEnrollmentStatus - Indicates whether Traffic View is 'Enabled' or 'Disabled' for the Traffic Manager profile. Null, indicates 'Disabled'. +// Enabling this feature will increase the cost of the Traffic Manage profile. +type TrafficViewEnrollmentStatus string + +const ( + TrafficViewEnrollmentStatusDisabled TrafficViewEnrollmentStatus = "Disabled" + TrafficViewEnrollmentStatusEnabled TrafficViewEnrollmentStatus = "Enabled" +) + +// PossibleTrafficViewEnrollmentStatusValues returns the possible values for the TrafficViewEnrollmentStatus const type. +func PossibleTrafficViewEnrollmentStatusValues() []TrafficViewEnrollmentStatus { + return []TrafficViewEnrollmentStatus{ + TrafficViewEnrollmentStatusDisabled, + TrafficViewEnrollmentStatusEnabled, + } +} + +// ToPtr returns a *TrafficViewEnrollmentStatus pointing to the current value. +func (c TrafficViewEnrollmentStatus) ToPtr() *TrafficViewEnrollmentStatus { + return &c +} diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_endpoints_client.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_endpoints_client.go new file mode 100644 index 000000000000..addca3420eb0 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_endpoints_client.go @@ -0,0 +1,335 @@ +//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 armtrafficmanager + +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" +) + +// EndpointsClient contains the methods for the Endpoints group. +// Don't use this type directly, use NewEndpointsClient() instead. +type EndpointsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewEndpointsClient creates a new instance of EndpointsClient with the specified values. +func NewEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *EndpointsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &EndpointsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Create or update a Traffic Manager endpoint. +// If the operation fails it returns the *CloudError error type. +func (client *EndpointsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint, options *EndpointsCreateOrUpdateOptions) (EndpointsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, profileName, endpointType, endpointName, parameters, options) + if err != nil { + return EndpointsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EndpointsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return EndpointsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *EndpointsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint, options *EndpointsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if profileName == "" { + return nil, errors.New("parameter profileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) + if endpointType == "" { + return nil, errors.New("parameter endpointType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointType}", url.PathEscape(endpointType)) + if endpointName == "" { + return nil, errors.New("parameter endpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointName}", url.PathEscape(endpointName)) + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *EndpointsClient) createOrUpdateHandleResponse(resp *http.Response) (EndpointsCreateOrUpdateResponse, error) { + result := EndpointsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Endpoint); err != nil { + return EndpointsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *EndpointsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a Traffic Manager endpoint. +// If the operation fails it returns the *CloudError error type. +func (client *EndpointsClient) Delete(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string, options *EndpointsDeleteOptions) (EndpointsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, profileName, endpointType, endpointName, options) + if err != nil { + return EndpointsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EndpointsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return EndpointsDeleteResponse{}, client.deleteHandleError(resp) + } + return client.deleteHandleResponse(resp) +} + +// deleteCreateRequest creates the Delete request. +func (client *EndpointsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string, options *EndpointsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if profileName == "" { + return nil, errors.New("parameter profileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) + if endpointType == "" { + return nil, errors.New("parameter endpointType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointType}", url.PathEscape(endpointType)) + if endpointName == "" { + return nil, errors.New("parameter endpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointName}", url.PathEscape(endpointName)) + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleResponse handles the Delete response. +func (client *EndpointsClient) deleteHandleResponse(resp *http.Response) (EndpointsDeleteResponse, error) { + result := EndpointsDeleteResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DeleteOperationResult); err != nil { + return EndpointsDeleteResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// deleteHandleError handles the Delete error response. +func (client *EndpointsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a Traffic Manager endpoint. +// If the operation fails it returns the *CloudError error type. +func (client *EndpointsClient) Get(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string, options *EndpointsGetOptions) (EndpointsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, profileName, endpointType, endpointName, options) + if err != nil { + return EndpointsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EndpointsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EndpointsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *EndpointsClient) getCreateRequest(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string, options *EndpointsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if profileName == "" { + return nil, errors.New("parameter profileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) + if endpointType == "" { + return nil, errors.New("parameter endpointType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointType}", url.PathEscape(endpointType)) + if endpointName == "" { + return nil, errors.New("parameter endpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointName}", url.PathEscape(endpointName)) + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *EndpointsClient) getHandleResponse(resp *http.Response) (EndpointsGetResponse, error) { + result := EndpointsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Endpoint); err != nil { + return EndpointsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *EndpointsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Update a Traffic Manager endpoint. +// If the operation fails it returns the *CloudError error type. +func (client *EndpointsClient) Update(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint, options *EndpointsUpdateOptions) (EndpointsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, profileName, endpointType, endpointName, parameters, options) + if err != nil { + return EndpointsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EndpointsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EndpointsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *EndpointsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint, options *EndpointsUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if profileName == "" { + return nil, errors.New("parameter profileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) + if endpointType == "" { + return nil, errors.New("parameter endpointType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointType}", url.PathEscape(endpointType)) + if endpointName == "" { + return nil, errors.New("parameter endpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointName}", url.PathEscape(endpointName)) + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleResponse handles the Update response. +func (client *EndpointsClient) updateHandleResponse(resp *http.Response) (EndpointsUpdateResponse, error) { + result := EndpointsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Endpoint); err != nil { + return EndpointsUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *EndpointsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/trafficmanager/armtrafficmanager/zz_generated_geographichierarchies_client.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_geographichierarchies_client.go new file mode 100644 index 000000000000..d2d47cf48d8a --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_geographichierarchies_client.go @@ -0,0 +1,92 @@ +//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 armtrafficmanager + +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" +) + +// GeographicHierarchiesClient contains the methods for the GeographicHierarchies group. +// Don't use this type directly, use NewGeographicHierarchiesClient() instead. +type GeographicHierarchiesClient struct { + ep string + pl runtime.Pipeline +} + +// NewGeographicHierarchiesClient creates a new instance of GeographicHierarchiesClient with the specified values. +func NewGeographicHierarchiesClient(credential azcore.TokenCredential, options *arm.ClientOptions) *GeographicHierarchiesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &GeographicHierarchiesClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// GetDefault - Gets the default Geographic Hierarchy used by the Geographic traffic routing method. +// If the operation fails it returns the *CloudError error type. +func (client *GeographicHierarchiesClient) GetDefault(ctx context.Context, options *GeographicHierarchiesGetDefaultOptions) (GeographicHierarchiesGetDefaultResponse, error) { + req, err := client.getDefaultCreateRequest(ctx, options) + if err != nil { + return GeographicHierarchiesGetDefaultResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GeographicHierarchiesGetDefaultResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GeographicHierarchiesGetDefaultResponse{}, client.getDefaultHandleError(resp) + } + return client.getDefaultHandleResponse(resp) +} + +// getDefaultCreateRequest creates the GetDefault request. +func (client *GeographicHierarchiesClient) getDefaultCreateRequest(ctx context.Context, options *GeographicHierarchiesGetDefaultOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Network/trafficManagerGeographicHierarchies/default" + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getDefaultHandleResponse handles the GetDefault response. +func (client *GeographicHierarchiesClient) getDefaultHandleResponse(resp *http.Response) (GeographicHierarchiesGetDefaultResponse, error) { + result := GeographicHierarchiesGetDefaultResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.TrafficManagerGeographicHierarchy); err != nil { + return GeographicHierarchiesGetDefaultResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getDefaultHandleError handles the GetDefault error response. +func (client *GeographicHierarchiesClient) getDefaultHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/trafficmanager/armtrafficmanager/zz_generated_heatmap_client.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_heatmap_client.go new file mode 100644 index 000000000000..3f0084b392ab --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_heatmap_client.go @@ -0,0 +1,118 @@ +//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 armtrafficmanager + +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" +) + +// HeatMapClient contains the methods for the HeatMap group. +// Don't use this type directly, use NewHeatMapClient() instead. +type HeatMapClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewHeatMapClient creates a new instance of HeatMapClient with the specified values. +func NewHeatMapClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *HeatMapClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &HeatMapClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Gets latest heatmap for Traffic Manager profile. +// If the operation fails it returns the *CloudError error type. +func (client *HeatMapClient) Get(ctx context.Context, resourceGroupName string, profileName string, heatMapType Enum8, options *HeatMapGetOptions) (HeatMapGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, profileName, heatMapType, options) + if err != nil { + return HeatMapGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HeatMapGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HeatMapGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *HeatMapClient) getCreateRequest(ctx context.Context, resourceGroupName string, profileName string, heatMapType Enum8, options *HeatMapGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if profileName == "" { + return nil, errors.New("parameter profileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) + if heatMapType == "" { + return nil, errors.New("parameter heatMapType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{heatMapType}", url.PathEscape(string(heatMapType))) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.TopLeft != nil { + reqQP.Set("topLeft", strings.Join(strings.Fields(strings.Trim(fmt.Sprint(options.TopLeft), "[]")), ",")) + } + if options != nil && options.BotRight != nil { + reqQP.Set("botRight", strings.Join(strings.Fields(strings.Trim(fmt.Sprint(options.BotRight), "[]")), ",")) + } + reqQP.Set("api-version", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *HeatMapClient) getHandleResponse(resp *http.Response) (HeatMapGetResponse, error) { + result := HeatMapGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.HeatMapModel); err != nil { + return HeatMapGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *HeatMapClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/trafficmanager/armtrafficmanager/zz_generated_models.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_models.go new file mode 100644 index 000000000000..508ad94445e1 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_models.go @@ -0,0 +1,680 @@ +//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 armtrafficmanager + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// CheckTrafficManagerRelativeDNSNameAvailabilityParameters - Parameters supplied to check Traffic Manager name operation. +type CheckTrafficManagerRelativeDNSNameAvailabilityParameters struct { + // The name of the resource. + Name *string `json:"name,omitempty"` + + // The type of the resource. + Type *string `json:"type,omitempty"` +} + +// CloudError - An error returned by the Azure Resource Manager +// Implements the error and azcore.HTTPResponse interfaces. +type CloudError struct { + raw string + // The content of the error. + InnerError *CloudErrorBody `json:"error,omitempty"` +} + +// Error implements the error interface for type CloudError. +// The contents of the error text are not contractual and subject to change. +func (e CloudError) Error() string { + return e.raw +} + +// CloudErrorBody - The content of an error returned by the Azure Resource Manager +type CloudErrorBody struct { + // Error code + Code *string `json:"code,omitempty"` + + // Error details + Details []*CloudErrorBody `json:"details,omitempty"` + + // Error message + Message *string `json:"message,omitempty"` + + // Error target + Target *string `json:"target,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CloudErrorBody. +func (c CloudErrorBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", c.Code) + populate(objectMap, "details", c.Details) + populate(objectMap, "message", c.Message) + populate(objectMap, "target", c.Target) + return json.Marshal(objectMap) +} + +// DNSConfig - Class containing DNS settings in a Traffic Manager profile. +type DNSConfig struct { + // The relative DNS name provided by this Traffic Manager profile. This value is combined with the DNS domain name used by Azure Traffic Manager to form + // the fully-qualified domain name (FQDN) of the + // profile. + RelativeName *string `json:"relativeName,omitempty"` + + // The DNS Time-To-Live (TTL), in seconds. This informs the local DNS resolvers and DNS clients how long to cache DNS responses provided by this Traffic + // Manager profile. + TTL *int64 `json:"ttl,omitempty"` + + // READ-ONLY; The fully-qualified domain name (FQDN) of the Traffic Manager profile. This is formed from the concatenation of the RelativeName with the + // DNS domain used by Azure Traffic Manager. + Fqdn *string `json:"fqdn,omitempty" azure:"ro"` +} + +// DeleteOperationResult - The result of the request or operation. +type DeleteOperationResult struct { + // READ-ONLY; The result of the operation or request. + OperationResult *bool `json:"boolean,omitempty" azure:"ro"` +} + +// Endpoint - Class representing a Traffic Manager endpoint. +type Endpoint struct { + ProxyResource + // The properties of the Traffic Manager endpoint. + Properties *EndpointProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Endpoint. +func (e Endpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", e.Properties) + return json.Marshal(objectMap) +} + +// EndpointProperties - Class representing a Traffic Manager endpoint properties. +type EndpointProperties struct { + // List of custom headers. + CustomHeaders []*EndpointPropertiesCustomHeadersItem `json:"customHeaders,omitempty"` + + // Specifies the location of the external or nested endpoints when using the 'Performance' traffic routing method. + EndpointLocation *string `json:"endpointLocation,omitempty"` + + // The monitoring status of the endpoint. + EndpointMonitorStatus *EndpointMonitorStatus `json:"endpointMonitorStatus,omitempty"` + + // The status of the endpoint. If the endpoint is Enabled, it is probed for endpoint health and is included in the traffic routing method. + EndpointStatus *EndpointStatus `json:"endpointStatus,omitempty"` + + // The list of countries/regions mapped to this endpoint when using the 'Geographic' traffic routing method. Please consult Traffic Manager Geographic documentation + // for a full list of accepted values. + GeoMapping []*string `json:"geoMapping,omitempty"` + + // The minimum number of endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable + // to endpoint of type 'NestedEndpoints'. + MinChildEndpoints *int64 `json:"minChildEndpoints,omitempty"` + + // The minimum number of IPv4 (DNS record type A) endpoints that must be available in the child profile in order for the parent profile to be considered + // available. Only applicable to endpoint of type + // 'NestedEndpoints'. + MinChildEndpointsIPv4 *int64 `json:"minChildEndpointsIPv4,omitempty"` + + // The minimum number of IPv6 (DNS record type AAAA) endpoints that must be available in the child profile in order for the parent profile to be considered + // available. Only applicable to endpoint of type + // 'NestedEndpoints'. + MinChildEndpointsIPv6 *int64 `json:"minChildEndpointsIPv6,omitempty"` + + // The priority of this endpoint when using the 'Priority' traffic routing method. Possible values are from 1 to 1000, lower values represent higher priority. + // This is an optional parameter. If specified, + // it must be specified on all endpoints, and no two endpoints can share the same priority value. + Priority *int64 `json:"priority,omitempty"` + + // The list of subnets, IP addresses, and/or address ranges mapped to this endpoint when using the 'Subnet' traffic routing method. An empty list will match + // all ranges not covered by other endpoints. + Subnets []*EndpointPropertiesSubnetsItem `json:"subnets,omitempty"` + + // The fully-qualified DNS name or IP address of the endpoint. Traffic Manager returns this value in DNS responses to direct traffic to this endpoint. + Target *string `json:"target,omitempty"` + + // The Azure Resource URI of the of the endpoint. Not applicable to endpoints of type 'ExternalEndpoints'. + TargetResourceID *string `json:"targetResourceId,omitempty"` + + // The weight of this endpoint when using the 'Weighted' traffic routing method. Possible values are from 1 to 1000. + Weight *int64 `json:"weight,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EndpointProperties. +func (e EndpointProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "customHeaders", e.CustomHeaders) + populate(objectMap, "endpointLocation", e.EndpointLocation) + populate(objectMap, "endpointMonitorStatus", e.EndpointMonitorStatus) + populate(objectMap, "endpointStatus", e.EndpointStatus) + populate(objectMap, "geoMapping", e.GeoMapping) + populate(objectMap, "minChildEndpoints", e.MinChildEndpoints) + populate(objectMap, "minChildEndpointsIPv4", e.MinChildEndpointsIPv4) + populate(objectMap, "minChildEndpointsIPv6", e.MinChildEndpointsIPv6) + populate(objectMap, "priority", e.Priority) + populate(objectMap, "subnets", e.Subnets) + populate(objectMap, "target", e.Target) + populate(objectMap, "targetResourceId", e.TargetResourceID) + populate(objectMap, "weight", e.Weight) + return json.Marshal(objectMap) +} + +// EndpointPropertiesCustomHeadersItem - Custom header name and value. +type EndpointPropertiesCustomHeadersItem struct { + // Header name. + Name *string `json:"name,omitempty"` + + // Header value. + Value *string `json:"value,omitempty"` +} + +// EndpointPropertiesSubnetsItem - Subnet first address, scope, and/or last address. +type EndpointPropertiesSubnetsItem struct { + // First address in the subnet. + First *string `json:"first,omitempty"` + + // Last address in the subnet. + Last *string `json:"last,omitempty"` + + // Block size (number of leading bits in the subnet mask). + Scope *int32 `json:"scope,omitempty"` +} + +// EndpointsCreateOrUpdateOptions contains the optional parameters for the Endpoints.CreateOrUpdate method. +type EndpointsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// EndpointsDeleteOptions contains the optional parameters for the Endpoints.Delete method. +type EndpointsDeleteOptions struct { + // placeholder for future optional parameters +} + +// EndpointsGetOptions contains the optional parameters for the Endpoints.Get method. +type EndpointsGetOptions struct { + // placeholder for future optional parameters +} + +// EndpointsUpdateOptions contains the optional parameters for the Endpoints.Update method. +type EndpointsUpdateOptions struct { + // placeholder for future optional parameters +} + +// GeographicHierarchiesGetDefaultOptions contains the optional parameters for the GeographicHierarchies.GetDefault method. +type GeographicHierarchiesGetDefaultOptions struct { + // placeholder for future optional parameters +} + +// GeographicHierarchyProperties - Class representing the properties of the Geographic hierarchy used with the Geographic traffic routing method. +type GeographicHierarchyProperties struct { + // The region at the root of the hierarchy from all the regions in the hierarchy can be retrieved. + GeographicHierarchy *Region `json:"geographicHierarchy,omitempty"` +} + +// HeatMapEndpoint - Class which is a sparse representation of a Traffic Manager endpoint. +type HeatMapEndpoint struct { + // A number uniquely identifying this endpoint in query experiences. + EndpointID *int32 `json:"endpointId,omitempty"` + + // The ARM Resource ID of this Traffic Manager endpoint. + ResourceID *string `json:"resourceId,omitempty"` +} + +// HeatMapGetOptions contains the optional parameters for the HeatMap.Get method. +type HeatMapGetOptions struct { + // The bottom right latitude,longitude pair of the rectangular viewport to query for. + BotRight []float64 + // The top left latitude,longitude pair of the rectangular viewport to query for. + TopLeft []float64 +} + +// HeatMapModel - Class representing a Traffic Manager HeatMap. +type HeatMapModel struct { + ProxyResource + // The properties of the Traffic Manager HeatMap. + Properties *HeatMapProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type HeatMapModel. +func (h HeatMapModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + h.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", h.Properties) + return json.Marshal(objectMap) +} + +// HeatMapProperties - Class representing a Traffic Manager HeatMap properties. +type HeatMapProperties struct { + // The ending of the time window for this HeatMap, exclusive. + EndTime *time.Time `json:"endTime,omitempty"` + + // The endpoints used in this HeatMap calculation. + Endpoints []*HeatMapEndpoint `json:"endpoints,omitempty"` + + // The beginning of the time window for this HeatMap, inclusive. + StartTime *time.Time `json:"startTime,omitempty"` + + // The traffic flows produced in this HeatMap calculation. + TrafficFlows []*TrafficFlow `json:"trafficFlows,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type HeatMapProperties. +func (h HeatMapProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "endTime", h.EndTime) + populate(objectMap, "endpoints", h.Endpoints) + populateTimeRFC3339(objectMap, "startTime", h.StartTime) + populate(objectMap, "trafficFlows", h.TrafficFlows) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HeatMapProperties. +func (h *HeatMapProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "endTime": + err = unpopulateTimeRFC3339(val, &h.EndTime) + delete(rawMsg, key) + case "endpoints": + err = unpopulate(val, &h.Endpoints) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, &h.StartTime) + delete(rawMsg, key) + case "trafficFlows": + err = unpopulate(val, &h.TrafficFlows) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// MonitorConfig - Class containing endpoint monitoring settings in a Traffic Manager profile. +type MonitorConfig struct { + // List of custom headers. + CustomHeaders []*MonitorConfigCustomHeadersItem `json:"customHeaders,omitempty"` + + // List of expected status code ranges. + ExpectedStatusCodeRanges []*MonitorConfigExpectedStatusCodeRangesItem `json:"expectedStatusCodeRanges,omitempty"` + + // The monitor interval for endpoints in this profile. This is the interval at which Traffic Manager will check the health of each endpoint in this profile. + IntervalInSeconds *int64 `json:"intervalInSeconds,omitempty"` + + // The path relative to the endpoint domain name used to probe for endpoint health. + Path *string `json:"path,omitempty"` + + // The TCP port used to probe for endpoint health. + Port *int64 `json:"port,omitempty"` + + // The profile-level monitoring status of the Traffic Manager profile. + ProfileMonitorStatus *ProfileMonitorStatus `json:"profileMonitorStatus,omitempty"` + + // The protocol (HTTP, HTTPS or TCP) used to probe for endpoint health. + Protocol *MonitorProtocol `json:"protocol,omitempty"` + + // The monitor timeout for endpoints in this profile. This is the time that Traffic Manager allows endpoints in this profile to response to the health check. + TimeoutInSeconds *int64 `json:"timeoutInSeconds,omitempty"` + + // The number of consecutive failed health check that Traffic Manager tolerates before declaring an endpoint in this profile Degraded after the next failed + // health check. + ToleratedNumberOfFailures *int64 `json:"toleratedNumberOfFailures,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MonitorConfig. +func (m MonitorConfig) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "customHeaders", m.CustomHeaders) + populate(objectMap, "expectedStatusCodeRanges", m.ExpectedStatusCodeRanges) + populate(objectMap, "intervalInSeconds", m.IntervalInSeconds) + populate(objectMap, "path", m.Path) + populate(objectMap, "port", m.Port) + populate(objectMap, "profileMonitorStatus", m.ProfileMonitorStatus) + populate(objectMap, "protocol", m.Protocol) + populate(objectMap, "timeoutInSeconds", m.TimeoutInSeconds) + populate(objectMap, "toleratedNumberOfFailures", m.ToleratedNumberOfFailures) + return json.Marshal(objectMap) +} + +// MonitorConfigCustomHeadersItem - Custom header name and value. +type MonitorConfigCustomHeadersItem struct { + // Header name. + Name *string `json:"name,omitempty"` + + // Header value. + Value *string `json:"value,omitempty"` +} + +// MonitorConfigExpectedStatusCodeRangesItem - Min and max value of a status code range. +type MonitorConfigExpectedStatusCodeRangesItem struct { + // Max status code. + Max *int32 `json:"max,omitempty"` + + // Min status code. + Min *int32 `json:"min,omitempty"` +} + +// Profile - Class representing a Traffic Manager profile. +type Profile struct { + TrackedResource + // The properties of the Traffic Manager profile. + Properties *ProfileProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Profile. +func (p Profile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// ProfileListResult - The list Traffic Manager profiles operation response. +type ProfileListResult struct { + // Gets the list of Traffic manager profiles. + Value []*Profile `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ProfileListResult. +func (p ProfileListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// ProfileProperties - Class representing the Traffic Manager profile properties. +type ProfileProperties struct { + // The list of allowed endpoint record types. + AllowedEndpointRecordTypes []*AllowedEndpointRecordType `json:"allowedEndpointRecordTypes,omitempty"` + + // The DNS settings of the Traffic Manager profile. + DNSConfig *DNSConfig `json:"dnsConfig,omitempty"` + + // The list of endpoints in the Traffic Manager profile. + Endpoints []*Endpoint `json:"endpoints,omitempty"` + + // Maximum number of endpoints to be returned for MultiValue routing type. + MaxReturn *int64 `json:"maxReturn,omitempty"` + + // The endpoint monitoring settings of the Traffic Manager profile. + MonitorConfig *MonitorConfig `json:"monitorConfig,omitempty"` + + // The status of the Traffic Manager profile. + ProfileStatus *ProfileStatus `json:"profileStatus,omitempty"` + + // The traffic routing method of the Traffic Manager profile. + TrafficRoutingMethod *TrafficRoutingMethod `json:"trafficRoutingMethod,omitempty"` + + // Indicates whether Traffic View is 'Enabled' or 'Disabled' for the Traffic Manager profile. Null, indicates 'Disabled'. Enabling this feature will increase + // the cost of the Traffic Manage profile. + TrafficViewEnrollmentStatus *TrafficViewEnrollmentStatus `json:"trafficViewEnrollmentStatus,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ProfileProperties. +func (p ProfileProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "allowedEndpointRecordTypes", p.AllowedEndpointRecordTypes) + populate(objectMap, "dnsConfig", p.DNSConfig) + populate(objectMap, "endpoints", p.Endpoints) + populate(objectMap, "maxReturn", p.MaxReturn) + populate(objectMap, "monitorConfig", p.MonitorConfig) + populate(objectMap, "profileStatus", p.ProfileStatus) + populate(objectMap, "trafficRoutingMethod", p.TrafficRoutingMethod) + populate(objectMap, "trafficViewEnrollmentStatus", p.TrafficViewEnrollmentStatus) + return json.Marshal(objectMap) +} + +// ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityOptions contains the optional parameters for the Profiles.CheckTrafficManagerRelativeDNSNameAvailability +// method. +type ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// ProfilesCreateOrUpdateOptions contains the optional parameters for the Profiles.CreateOrUpdate method. +type ProfilesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ProfilesDeleteOptions contains the optional parameters for the Profiles.Delete method. +type ProfilesDeleteOptions struct { + // placeholder for future optional parameters +} + +// ProfilesGetOptions contains the optional parameters for the Profiles.Get method. +type ProfilesGetOptions struct { + // placeholder for future optional parameters +} + +// ProfilesListByResourceGroupOptions contains the optional parameters for the Profiles.ListByResourceGroup method. +type ProfilesListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ProfilesListBySubscriptionOptions contains the optional parameters for the Profiles.ListBySubscription method. +type ProfilesListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ProfilesUpdateOptions contains the optional parameters for the Profiles.Update method. +type ProfilesUpdateOptions struct { + // placeholder for future optional parameters +} + +// ProxyResource - The resource model definition for a ARM proxy resource. It will have everything other than required location and tags +type ProxyResource struct { + Resource +} + +func (p ProxyResource) marshalInternal(objectMap map[string]interface{}) { + p.Resource.marshalInternal(objectMap) +} + +// QueryExperience - Class representing a Traffic Manager HeatMap query experience properties. +type QueryExperience struct { + // REQUIRED; The id of the endpoint from the 'endpoints' array which these queries were routed to. + EndpointID *int32 `json:"endpointId,omitempty"` + + // REQUIRED; The number of queries originating from this location. + QueryCount *int32 `json:"queryCount,omitempty"` + + // The latency experienced by queries originating from this location. + Latency *float64 `json:"latency,omitempty"` +} + +// Region - Class representing a region in the Geographic hierarchy used with the Geographic traffic routing method. +type Region struct { + // The code of the region + Code *string `json:"code,omitempty"` + + // The name of the region + Name *string `json:"name,omitempty"` + + // The list of Regions grouped under this Region in the Geographic Hierarchy. + Regions []*Region `json:"regions,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Region. +func (r Region) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", r.Code) + populate(objectMap, "name", r.Name) + populate(objectMap, "regions", r.Regions) + return json.Marshal(objectMap) +} + +// Resource - The core properties of ARM resources +type Resource struct { + // Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{resourceName} + ID *string `json:"id,omitempty"` + + // The name of the resource + Name *string `json:"name,omitempty"` + + // The type of the resource. Ex- Microsoft.Network/trafficManagerProfiles. + Type *string `json:"type,omitempty"` +} + +// 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) +} + +// TrackedResource - The resource model definition for a ARM tracked top level resource +type TrackedResource struct { + Resource + // The Azure Region where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal(objectMap map[string]interface{}) { + t.Resource.marshalInternal(objectMap) + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) +} + +// TrafficFlow - Class representing a Traffic Manager HeatMap traffic flow properties. +type TrafficFlow struct { + // The approximate latitude that these queries originated from. + Latitude *float64 `json:"latitude,omitempty"` + + // The approximate longitude that these queries originated from. + Longitude *float64 `json:"longitude,omitempty"` + + // The query experiences produced in this HeatMap calculation. + QueryExperiences []*QueryExperience `json:"queryExperiences,omitempty"` + + // The IP address that this query experience originated from. + SourceIP *string `json:"sourceIp,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrafficFlow. +func (t TrafficFlow) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "latitude", t.Latitude) + populate(objectMap, "longitude", t.Longitude) + populate(objectMap, "queryExperiences", t.QueryExperiences) + populate(objectMap, "sourceIp", t.SourceIP) + return json.Marshal(objectMap) +} + +// TrafficManagerGeographicHierarchy - Class representing the Geographic hierarchy used with the Geographic traffic routing method. +type TrafficManagerGeographicHierarchy struct { + ProxyResource + // The properties of the Geographic Hierarchy resource. + Properties *GeographicHierarchyProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrafficManagerGeographicHierarchy. +func (t TrafficManagerGeographicHierarchy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// TrafficManagerNameAvailability - Class representing a Traffic Manager Name Availability response. +type TrafficManagerNameAvailability struct { + // Descriptive message that explains why the name is not available, when applicable. + Message *string `json:"message,omitempty"` + + // The relative name. + Name *string `json:"name,omitempty"` + + // Describes whether the relative name is available or not. + NameAvailable *bool `json:"nameAvailable,omitempty"` + + // The reason why the name is not available, when applicable. + Reason *string `json:"reason,omitempty"` + + // Traffic Manager profile resource type. + Type *string `json:"type,omitempty"` +} + +// TrafficManagerUserMetricsKeysCreateOrUpdateOptions contains the optional parameters for the TrafficManagerUserMetricsKeys.CreateOrUpdate method. +type TrafficManagerUserMetricsKeysCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// TrafficManagerUserMetricsKeysDeleteOptions contains the optional parameters for the TrafficManagerUserMetricsKeys.Delete method. +type TrafficManagerUserMetricsKeysDeleteOptions struct { + // placeholder for future optional parameters +} + +// TrafficManagerUserMetricsKeysGetOptions contains the optional parameters for the TrafficManagerUserMetricsKeys.Get method. +type TrafficManagerUserMetricsKeysGetOptions struct { + // placeholder for future optional parameters +} + +// UserMetricsModel - Class representing Traffic Manager User Metrics. +type UserMetricsModel struct { + ProxyResource + // The properties of the Traffic Manager User Metrics. + Properties *UserMetricsProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserMetricsModel. +func (u UserMetricsModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + u.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", u.Properties) + return json.Marshal(objectMap) +} + +// UserMetricsProperties - Class representing a Traffic Manager Real User Metrics key response. +type UserMetricsProperties struct { + // The key returned by the User Metrics operation. + Key *string `json:"key,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 + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_profiles_client.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_profiles_client.go new file mode 100644 index 000000000000..be1ad110bbdf --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_profiles_client.go @@ -0,0 +1,474 @@ +//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 armtrafficmanager + +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" +) + +// ProfilesClient contains the methods for the Profiles group. +// Don't use this type directly, use NewProfilesClient() instead. +type ProfilesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewProfilesClient creates a new instance of ProfilesClient with the specified values. +func NewProfilesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ProfilesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ProfilesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckTrafficManagerRelativeDNSNameAvailability - Checks the availability of a Traffic Manager Relative DNS name. +// If the operation fails it returns the *CloudError error type. +func (client *ProfilesClient) CheckTrafficManagerRelativeDNSNameAvailability(ctx context.Context, parameters CheckTrafficManagerRelativeDNSNameAvailabilityParameters, options *ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityOptions) (ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityResponse, error) { + req, err := client.checkTrafficManagerRelativeDNSNameAvailabilityCreateRequest(ctx, parameters, options) + if err != nil { + return ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityResponse{}, client.checkTrafficManagerRelativeDNSNameAvailabilityHandleError(resp) + } + return client.checkTrafficManagerRelativeDNSNameAvailabilityHandleResponse(resp) +} + +// checkTrafficManagerRelativeDNSNameAvailabilityCreateRequest creates the CheckTrafficManagerRelativeDNSNameAvailability request. +func (client *ProfilesClient) checkTrafficManagerRelativeDNSNameAvailabilityCreateRequest(ctx context.Context, parameters CheckTrafficManagerRelativeDNSNameAvailabilityParameters, options *ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Network/checkTrafficManagerNameAvailability" + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// checkTrafficManagerRelativeDNSNameAvailabilityHandleResponse handles the CheckTrafficManagerRelativeDNSNameAvailability response. +func (client *ProfilesClient) checkTrafficManagerRelativeDNSNameAvailabilityHandleResponse(resp *http.Response) (ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityResponse, error) { + result := ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.TrafficManagerNameAvailability); err != nil { + return ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkTrafficManagerRelativeDNSNameAvailabilityHandleError handles the CheckTrafficManagerRelativeDNSNameAvailability error response. +func (client *ProfilesClient) checkTrafficManagerRelativeDNSNameAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// CreateOrUpdate - Create or update a Traffic Manager profile. +// If the operation fails it returns the *CloudError error type. +func (client *ProfilesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, profileName string, parameters Profile, options *ProfilesCreateOrUpdateOptions) (ProfilesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, profileName, parameters, options) + if err != nil { + return ProfilesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProfilesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return ProfilesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ProfilesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, profileName string, parameters Profile, options *ProfilesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if profileName == "" { + return nil, errors.New("parameter profileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ProfilesClient) createOrUpdateHandleResponse(resp *http.Response) (ProfilesCreateOrUpdateResponse, error) { + result := ProfilesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Profile); err != nil { + return ProfilesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ProfilesClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a Traffic Manager profile. +// If the operation fails it returns the *CloudError error type. +func (client *ProfilesClient) Delete(ctx context.Context, resourceGroupName string, profileName string, options *ProfilesDeleteOptions) (ProfilesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, profileName, options) + if err != nil { + return ProfilesDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProfilesDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return ProfilesDeleteResponse{}, client.deleteHandleError(resp) + } + return client.deleteHandleResponse(resp) +} + +// deleteCreateRequest creates the Delete request. +func (client *ProfilesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, profileName string, options *ProfilesDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if profileName == "" { + return nil, errors.New("parameter profileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleResponse handles the Delete response. +func (client *ProfilesClient) deleteHandleResponse(resp *http.Response) (ProfilesDeleteResponse, error) { + result := ProfilesDeleteResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DeleteOperationResult); err != nil { + return ProfilesDeleteResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ProfilesClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a Traffic Manager profile. +// If the operation fails it returns the *CloudError error type. +func (client *ProfilesClient) Get(ctx context.Context, resourceGroupName string, profileName string, options *ProfilesGetOptions) (ProfilesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, profileName, options) + if err != nil { + return ProfilesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProfilesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProfilesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ProfilesClient) getCreateRequest(ctx context.Context, resourceGroupName string, profileName string, options *ProfilesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if profileName == "" { + return nil, errors.New("parameter profileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProfilesClient) getHandleResponse(resp *http.Response) (ProfilesGetResponse, error) { + result := ProfilesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Profile); err != nil { + return ProfilesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ProfilesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 Traffic Manager profiles within a resource group. +// If the operation fails it returns the *CloudError error type. +func (client *ProfilesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *ProfilesListByResourceGroupOptions) (ProfilesListByResourceGroupResponse, error) { + req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return ProfilesListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProfilesListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProfilesListByResourceGroupResponse{}, client.listByResourceGroupHandleError(resp) + } + return client.listByResourceGroupHandleResponse(resp) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ProfilesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ProfilesListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles" + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ProfilesClient) listByResourceGroupHandleResponse(resp *http.Response) (ProfilesListByResourceGroupResponse, error) { + result := ProfilesListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ProfileListResult); err != nil { + return ProfilesListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *ProfilesClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 Traffic Manager profiles within a subscription. +// If the operation fails it returns the *CloudError error type. +func (client *ProfilesClient) ListBySubscription(ctx context.Context, options *ProfilesListBySubscriptionOptions) (ProfilesListBySubscriptionResponse, error) { + req, err := client.listBySubscriptionCreateRequest(ctx, options) + if err != nil { + return ProfilesListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProfilesListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProfilesListBySubscriptionResponse{}, client.listBySubscriptionHandleError(resp) + } + return client.listBySubscriptionHandleResponse(resp) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ProfilesClient) listBySubscriptionCreateRequest(ctx context.Context, options *ProfilesListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficmanagerprofiles" + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *ProfilesClient) listBySubscriptionHandleResponse(resp *http.Response) (ProfilesListBySubscriptionResponse, error) { + result := ProfilesListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ProfileListResult); err != nil { + return ProfilesListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *ProfilesClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Update a Traffic Manager profile. +// If the operation fails it returns the *CloudError error type. +func (client *ProfilesClient) Update(ctx context.Context, resourceGroupName string, profileName string, parameters Profile, options *ProfilesUpdateOptions) (ProfilesUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, profileName, parameters, options) + if err != nil { + return ProfilesUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProfilesUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProfilesUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ProfilesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, profileName string, parameters Profile, options *ProfilesUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if profileName == "" { + return nil, errors.New("parameter profileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleResponse handles the Update response. +func (client *ProfilesClient) updateHandleResponse(resp *http.Response) (ProfilesUpdateResponse, error) { + result := ProfilesUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Profile); err != nil { + return ProfilesUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *ProfilesClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/trafficmanager/armtrafficmanager/zz_generated_response_types.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_response_types.go new file mode 100644 index 000000000000..abcbafb697d5 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_response_types.go @@ -0,0 +1,203 @@ +//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 armtrafficmanager + +import "net/http" + +// EndpointsCreateOrUpdateResponse contains the response from method Endpoints.CreateOrUpdate. +type EndpointsCreateOrUpdateResponse struct { + EndpointsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EndpointsCreateOrUpdateResult contains the result from method Endpoints.CreateOrUpdate. +type EndpointsCreateOrUpdateResult struct { + Endpoint +} + +// EndpointsDeleteResponse contains the response from method Endpoints.Delete. +type EndpointsDeleteResponse struct { + EndpointsDeleteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EndpointsDeleteResult contains the result from method Endpoints.Delete. +type EndpointsDeleteResult struct { + DeleteOperationResult +} + +// EndpointsGetResponse contains the response from method Endpoints.Get. +type EndpointsGetResponse struct { + EndpointsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EndpointsGetResult contains the result from method Endpoints.Get. +type EndpointsGetResult struct { + Endpoint +} + +// EndpointsUpdateResponse contains the response from method Endpoints.Update. +type EndpointsUpdateResponse struct { + EndpointsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EndpointsUpdateResult contains the result from method Endpoints.Update. +type EndpointsUpdateResult struct { + Endpoint +} + +// GeographicHierarchiesGetDefaultResponse contains the response from method GeographicHierarchies.GetDefault. +type GeographicHierarchiesGetDefaultResponse struct { + GeographicHierarchiesGetDefaultResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GeographicHierarchiesGetDefaultResult contains the result from method GeographicHierarchies.GetDefault. +type GeographicHierarchiesGetDefaultResult struct { + TrafficManagerGeographicHierarchy +} + +// HeatMapGetResponse contains the response from method HeatMap.Get. +type HeatMapGetResponse struct { + HeatMapGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HeatMapGetResult contains the result from method HeatMap.Get. +type HeatMapGetResult struct { + HeatMapModel +} + +// ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityResponse contains the response from method Profiles.CheckTrafficManagerRelativeDNSNameAvailability. +type ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityResponse struct { + ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityResult contains the result from method Profiles.CheckTrafficManagerRelativeDNSNameAvailability. +type ProfilesCheckTrafficManagerRelativeDNSNameAvailabilityResult struct { + TrafficManagerNameAvailability +} + +// ProfilesCreateOrUpdateResponse contains the response from method Profiles.CreateOrUpdate. +type ProfilesCreateOrUpdateResponse struct { + ProfilesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProfilesCreateOrUpdateResult contains the result from method Profiles.CreateOrUpdate. +type ProfilesCreateOrUpdateResult struct { + Profile +} + +// ProfilesDeleteResponse contains the response from method Profiles.Delete. +type ProfilesDeleteResponse struct { + ProfilesDeleteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProfilesDeleteResult contains the result from method Profiles.Delete. +type ProfilesDeleteResult struct { + DeleteOperationResult +} + +// ProfilesGetResponse contains the response from method Profiles.Get. +type ProfilesGetResponse struct { + ProfilesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProfilesGetResult contains the result from method Profiles.Get. +type ProfilesGetResult struct { + Profile +} + +// ProfilesListByResourceGroupResponse contains the response from method Profiles.ListByResourceGroup. +type ProfilesListByResourceGroupResponse struct { + ProfilesListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProfilesListByResourceGroupResult contains the result from method Profiles.ListByResourceGroup. +type ProfilesListByResourceGroupResult struct { + ProfileListResult +} + +// ProfilesListBySubscriptionResponse contains the response from method Profiles.ListBySubscription. +type ProfilesListBySubscriptionResponse struct { + ProfilesListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProfilesListBySubscriptionResult contains the result from method Profiles.ListBySubscription. +type ProfilesListBySubscriptionResult struct { + ProfileListResult +} + +// ProfilesUpdateResponse contains the response from method Profiles.Update. +type ProfilesUpdateResponse struct { + ProfilesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProfilesUpdateResult contains the result from method Profiles.Update. +type ProfilesUpdateResult struct { + Profile +} + +// TrafficManagerUserMetricsKeysCreateOrUpdateResponse contains the response from method TrafficManagerUserMetricsKeys.CreateOrUpdate. +type TrafficManagerUserMetricsKeysCreateOrUpdateResponse struct { + TrafficManagerUserMetricsKeysCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TrafficManagerUserMetricsKeysCreateOrUpdateResult contains the result from method TrafficManagerUserMetricsKeys.CreateOrUpdate. +type TrafficManagerUserMetricsKeysCreateOrUpdateResult struct { + UserMetricsModel +} + +// TrafficManagerUserMetricsKeysDeleteResponse contains the response from method TrafficManagerUserMetricsKeys.Delete. +type TrafficManagerUserMetricsKeysDeleteResponse struct { + TrafficManagerUserMetricsKeysDeleteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TrafficManagerUserMetricsKeysDeleteResult contains the result from method TrafficManagerUserMetricsKeys.Delete. +type TrafficManagerUserMetricsKeysDeleteResult struct { + DeleteOperationResult +} + +// TrafficManagerUserMetricsKeysGetResponse contains the response from method TrafficManagerUserMetricsKeys.Get. +type TrafficManagerUserMetricsKeysGetResponse struct { + TrafficManagerUserMetricsKeysGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TrafficManagerUserMetricsKeysGetResult contains the result from method TrafficManagerUserMetricsKeys.Get. +type TrafficManagerUserMetricsKeysGetResult struct { + UserMetricsModel +} diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_time_rfc3339.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..f6b538d9de80 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//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 armtrafficmanager + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_trafficmanagerusermetricskeys_client.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_trafficmanagerusermetricskeys_client.go new file mode 100644 index 000000000000..e82c9bd7c618 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/zz_generated_trafficmanagerusermetricskeys_client.go @@ -0,0 +1,214 @@ +//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 armtrafficmanager + +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" +) + +// TrafficManagerUserMetricsKeysClient contains the methods for the TrafficManagerUserMetricsKeys group. +// Don't use this type directly, use NewTrafficManagerUserMetricsKeysClient() instead. +type TrafficManagerUserMetricsKeysClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewTrafficManagerUserMetricsKeysClient creates a new instance of TrafficManagerUserMetricsKeysClient with the specified values. +func NewTrafficManagerUserMetricsKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *TrafficManagerUserMetricsKeysClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &TrafficManagerUserMetricsKeysClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Create or update a subscription-level key used for Real User Metrics collection. +// If the operation fails it returns the *CloudError error type. +func (client *TrafficManagerUserMetricsKeysClient) CreateOrUpdate(ctx context.Context, options *TrafficManagerUserMetricsKeysCreateOrUpdateOptions) (TrafficManagerUserMetricsKeysCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, options) + if err != nil { + return TrafficManagerUserMetricsKeysCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TrafficManagerUserMetricsKeysCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusCreated) { + return TrafficManagerUserMetricsKeysCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *TrafficManagerUserMetricsKeysClient) createOrUpdateCreateRequest(ctx context.Context, options *TrafficManagerUserMetricsKeysCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default" + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *TrafficManagerUserMetricsKeysClient) createOrUpdateHandleResponse(resp *http.Response) (TrafficManagerUserMetricsKeysCreateOrUpdateResponse, error) { + result := TrafficManagerUserMetricsKeysCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.UserMetricsModel); err != nil { + return TrafficManagerUserMetricsKeysCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *TrafficManagerUserMetricsKeysClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Delete a subscription-level key used for Real User Metrics collection. +// If the operation fails it returns the *CloudError error type. +func (client *TrafficManagerUserMetricsKeysClient) Delete(ctx context.Context, options *TrafficManagerUserMetricsKeysDeleteOptions) (TrafficManagerUserMetricsKeysDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, options) + if err != nil { + return TrafficManagerUserMetricsKeysDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TrafficManagerUserMetricsKeysDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TrafficManagerUserMetricsKeysDeleteResponse{}, client.deleteHandleError(resp) + } + return client.deleteHandleResponse(resp) +} + +// deleteCreateRequest creates the Delete request. +func (client *TrafficManagerUserMetricsKeysClient) deleteCreateRequest(ctx context.Context, options *TrafficManagerUserMetricsKeysDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default" + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleResponse handles the Delete response. +func (client *TrafficManagerUserMetricsKeysClient) deleteHandleResponse(resp *http.Response) (TrafficManagerUserMetricsKeysDeleteResponse, error) { + result := TrafficManagerUserMetricsKeysDeleteResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DeleteOperationResult); err != nil { + return TrafficManagerUserMetricsKeysDeleteResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// deleteHandleError handles the Delete error response. +func (client *TrafficManagerUserMetricsKeysClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Get the subscription-level key used for Real User Metrics collection. +// If the operation fails it returns the *CloudError error type. +func (client *TrafficManagerUserMetricsKeysClient) Get(ctx context.Context, options *TrafficManagerUserMetricsKeysGetOptions) (TrafficManagerUserMetricsKeysGetResponse, error) { + req, err := client.getCreateRequest(ctx, options) + if err != nil { + return TrafficManagerUserMetricsKeysGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TrafficManagerUserMetricsKeysGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TrafficManagerUserMetricsKeysGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TrafficManagerUserMetricsKeysClient) getCreateRequest(ctx context.Context, options *TrafficManagerUserMetricsKeysGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default" + 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", "2018-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TrafficManagerUserMetricsKeysClient) getHandleResponse(resp *http.Response) (TrafficManagerUserMetricsKeysGetResponse, error) { + result := TrafficManagerUserMetricsKeysGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.UserMetricsModel); err != nil { + return TrafficManagerUserMetricsKeysGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *TrafficManagerUserMetricsKeysClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +}