diff --git a/sdk/resourcemanager/maps/armmaps/CHANGELOG.md b/sdk/resourcemanager/maps/armmaps/CHANGELOG.md new file mode 100644 index 000000000000..925a954ff70d --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-07) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/maps/armmaps/LICENSE.txt b/sdk/resourcemanager/maps/armmaps/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/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/maps/armmaps/README.md b/sdk/resourcemanager/maps/armmaps/README.md new file mode 100644 index 000000000000..4a34117bc097 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/README.md @@ -0,0 +1,75 @@ +# Azure Maps Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maps/armmaps)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maps/armmaps) + +The `armmaps` module provides operations for working with Azure Maps. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/maps/armmaps) + +# 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 Maps module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maps/armmaps +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Maps. 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 Maps 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 := armmaps.NewCreatorsClient(, 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 := armmaps.NewCreatorsClient(, 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 `Maps` 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/maps/armmaps/autorest.md b/sdk/resourcemanager/maps/armmaps/autorest.md new file mode 100644 index 000000000000..5ed86ef4ea6b --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/cf36bdc6bc70308a3f05f6399efe21a0e1e9b7d8/specification/maps/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/cf36bdc6bc70308a3f05f6399efe21a0e1e9b7d8/specification/maps/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/maps/armmaps/build.go b/sdk/resourcemanager/maps/armmaps/build.go new file mode 100644 index 000000000000..e9a90f371ed0 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/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/maps/armmaps + +package armmaps diff --git a/sdk/resourcemanager/maps/armmaps/ci.yml b/sdk/resourcemanager/maps/armmaps/ci.yml new file mode 100644 index 000000000000..824ec81d6997 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/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/maps/armmaps/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/maps/armmaps/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/maps/armmaps' diff --git a/sdk/resourcemanager/maps/armmaps/go.mod b/sdk/resourcemanager/maps/armmaps/go.mod new file mode 100644 index 000000000000..11e6bfb7511e --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/go.mod @@ -0,0 +1,9 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maps/armmaps + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v60.0.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0 +) diff --git a/sdk/resourcemanager/maps/armmaps/go.sum b/sdk/resourcemanager/maps/armmaps/go.sum new file mode 100644 index 000000000000..ac069c64ed64 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/go.sum @@ -0,0 +1,45 @@ +github.com/Azure/azure-sdk-for-go v60.0.0+incompatible h1:vVRJhSSTwhIHQTzTjqoZCItFJeBwfdNSqHcgGV10FHQ= +github.com/Azure/azure-sdk-for-go v60.0.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/azidentity v0.12.0 h1:VBvHGLJbaY0+c66NZHdS9cgjHVYSH6DDa0XJMyrblsI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0/go.mod h1:GJzjM4SR9T0KyX5gKCVyz1ytD8FeWeUPCwtFCt1AyfE= +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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/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/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= +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/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/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/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/maps/armmaps/go_mod_tidy_hack.go b/sdk/resourcemanager/maps/armmaps/go_mod_tidy_hack.go new file mode 100644 index 000000000000..dac5834840a0 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/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 armmaps + +// 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/maps/armmaps/ze_generated_example_accounts_client_test.go b/sdk/resourcemanager/maps/armmaps/ze_generated_example_accounts_client_test.go new file mode 100644 index 000000000000..055097942db3 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/ze_generated_example_accounts_client_test.go @@ -0,0 +1,184 @@ +//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 armmaps_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maps/armmaps" +) + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/CreateAccountManagedIdentity.json +func ExampleAccountsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewAccountsClient("", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "", + "", + armmaps.MapsAccount{}, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("MapsAccount.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/UpdateAccountManagedIdentity.json +func ExampleAccountsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewAccountsClient("", cred, nil) + res, err := client.Update(ctx, + "", + "", + armmaps.MapsAccountUpdateParameters{}, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("MapsAccount.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/DeleteAccount.json +func ExampleAccountsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewAccountsClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetAccount.json +func ExampleAccountsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewAccountsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("MapsAccount.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/ListAccountsByResourceGroup.json +func ExampleAccountsClient_ListByResourceGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewAccountsClient("", cred, nil) + pager := client.ListByResourceGroup("", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("MapsAccount.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/ListAccountsBySubscription.json +func ExampleAccountsClient_ListBySubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewAccountsClient("", cred, nil) + pager := client.ListBySubscription(nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("MapsAccount.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/AccountListSAS.json +func ExampleAccountsClient_ListSas() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewAccountsClient("", cred, nil) + _, err = client.ListSas(ctx, + "", + "", + armmaps.AccountSasParameters{}, + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/ListKeys.json +func ExampleAccountsClient_ListKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewAccountsClient("", cred, nil) + _, err = client.ListKeys(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/RegenerateKey.json +func ExampleAccountsClient_RegenerateKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewAccountsClient("", cred, nil) + _, err = client.RegenerateKeys(ctx, + "", + "", + armmaps.MapsKeySpecification{ + KeyType: armmaps.KeyTypePrimary.ToPtr(), + }, + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/maps/armmaps/ze_generated_example_creators_client_test.go b/sdk/resourcemanager/maps/armmaps/ze_generated_example_creators_client_test.go new file mode 100644 index 000000000000..e68d4e054f2e --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/ze_generated_example_creators_client_test.go @@ -0,0 +1,115 @@ +//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 armmaps_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maps/armmaps" +) + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/ListMapsCreatorsByAccount.json +func ExampleCreatorsClient_ListByAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewCreatorsClient("", cred, nil) + pager := client.ListByAccount("", + "", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("Creator.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/CreateMapsCreator.json +func ExampleCreatorsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewCreatorsClient("", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "", + "", + "", + armmaps.Creator{}, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Creator.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/UpdateMapsCreator.json +func ExampleCreatorsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewCreatorsClient("", cred, nil) + res, err := client.Update(ctx, + "", + "", + "", + armmaps.CreatorUpdateParameters{}, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Creator.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/DeleteMapsCreator.json +func ExampleCreatorsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewCreatorsClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetMapsCreator.json +func ExampleCreatorsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewCreatorsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Creator.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/maps/armmaps/ze_generated_example_maps_client_test.go b/sdk/resourcemanager/maps/armmaps/ze_generated_example_maps_client_test.go new file mode 100644 index 000000000000..b6ef1c1e14b5 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/ze_generated_example_maps_client_test.go @@ -0,0 +1,49 @@ +//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 armmaps_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maps/armmaps" +) + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetOperations.json +func ExampleMapsClient_ListOperations() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewMapsClient("", cred, nil) + pager := client.ListOperations(nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + } +} + +// x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetOperationsSubscription.json +func ExampleMapsClient_ListSubscriptionOperations() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armmaps.NewMapsClient("", cred, nil) + pager := client.ListSubscriptionOperations(nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + } +} diff --git a/sdk/resourcemanager/maps/armmaps/zz_generated_accounts_client.go b/sdk/resourcemanager/maps/armmaps/zz_generated_accounts_client.go new file mode 100644 index 000000000000..6065750980d5 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/zz_generated_accounts_client.go @@ -0,0 +1,606 @@ +//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 armmaps + +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" +) + +// AccountsClient contains the methods for the Accounts group. +// Don't use this type directly, use NewAccountsClient() instead. +type AccountsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewAccountsClient creates a new instance of AccountsClient with the specified values. +func NewAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *AccountsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &AccountsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Create or update a Maps Account. A Maps Account holds the keys which allow access to the Maps REST APIs. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, mapsAccount MapsAccount, options *AccountsCreateOrUpdateOptions) (AccountsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, mapsAccount, options) + if err != nil { + return AccountsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return AccountsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AccountsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, mapsAccount MapsAccount, options *AccountsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, mapsAccount) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *AccountsClient) createOrUpdateHandleResponse(resp *http.Response) (AccountsCreateOrUpdateResponse, error) { + result := AccountsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MapsAccount); err != nil { + return AccountsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *AccountsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete a Maps Account. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *AccountsDeleteOptions) (AccountsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return AccountsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return AccountsDeleteResponse{}, client.deleteHandleError(resp) + } + return AccountsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *AccountsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get a Maps Account. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string, options *AccountsGetOptions) (AccountsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return AccountsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AccountsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AccountsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AccountsClient) getHandleResponse(resp *http.Response) (AccountsGetResponse, error) { + result := AccountsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MapsAccount); err != nil { + return AccountsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *AccountsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - Get all Maps Accounts in a Resource Group +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) ListByResourceGroup(resourceGroupName string, options *AccountsListByResourceGroupOptions) *AccountsListByResourceGroupPager { + return &AccountsListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp AccountsListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.MapsAccounts.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *AccountsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AccountsListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts" + 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)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *AccountsClient) listByResourceGroupHandleResponse(resp *http.Response) (AccountsListByResourceGroupResponse, error) { + result := AccountsListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MapsAccounts); err != nil { + return AccountsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *AccountsClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - Get all Maps Accounts in a Subscription +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) ListBySubscription(options *AccountsListBySubscriptionOptions) *AccountsListBySubscriptionPager { + return &AccountsListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp AccountsListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.MapsAccounts.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *AccountsClient) listBySubscriptionCreateRequest(ctx context.Context, options *AccountsListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maps/accounts" + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *AccountsClient) listBySubscriptionHandleResponse(resp *http.Response) (AccountsListBySubscriptionResponse, error) { + result := AccountsListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MapsAccounts); err != nil { + return AccountsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *AccountsClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListKeys - Get the keys to use with the Maps APIs. A key is used to authenticate and authorize access to the Maps REST APIs. Only one key is needed at +// a time; two are given to provide seamless key regeneration. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string, options *AccountsListKeysOptions) (AccountsListKeysResponse, error) { + req, err := client.listKeysCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return AccountsListKeysResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsListKeysResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AccountsListKeysResponse{}, client.listKeysHandleError(resp) + } + return client.listKeysHandleResponse(resp) +} + +// listKeysCreateRequest creates the ListKeys request. +func (client *AccountsClient) listKeysCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsListKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/listKeys" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listKeysHandleResponse handles the ListKeys response. +func (client *AccountsClient) listKeysHandleResponse(resp *http.Response) (AccountsListKeysResponse, error) { + result := AccountsListKeysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MapsAccountKeys); err != nil { + return AccountsListKeysResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listKeysHandleError handles the ListKeys error response. +func (client *AccountsClient) listKeysHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListSas - Create and list an account shared access signature token. Use this SAS token for authentication to Azure Maps REST APIs through various Azure +// Maps SDKs. As prerequisite to create a SAS Token. +// Prerequisites: +// 1. Create or have an existing User Assigned Managed Identity in the same Azure region as the account. +// 2. Create or update an Azure Map account with the same Azure region as the User Assigned Managed Identity is placed. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) ListSas(ctx context.Context, resourceGroupName string, accountName string, mapsAccountSasParameters AccountSasParameters, options *AccountsListSasOptions) (AccountsListSasResponse, error) { + req, err := client.listSasCreateRequest(ctx, resourceGroupName, accountName, mapsAccountSasParameters, options) + if err != nil { + return AccountsListSasResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsListSasResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AccountsListSasResponse{}, client.listSasHandleError(resp) + } + return client.listSasHandleResponse(resp) +} + +// listSasCreateRequest creates the ListSas request. +func (client *AccountsClient) listSasCreateRequest(ctx context.Context, resourceGroupName string, accountName string, mapsAccountSasParameters AccountSasParameters, options *AccountsListSasOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/listSas" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, mapsAccountSasParameters) +} + +// listSasHandleResponse handles the ListSas response. +func (client *AccountsClient) listSasHandleResponse(resp *http.Response) (AccountsListSasResponse, error) { + result := AccountsListSasResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MapsAccountSasToken); err != nil { + return AccountsListSasResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listSasHandleError handles the ListSas error response. +func (client *AccountsClient) listSasHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// RegenerateKeys - Regenerate either the primary or secondary key for use with the Maps APIs. The old key will stop working immediately. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, accountName string, keySpecification MapsKeySpecification, options *AccountsRegenerateKeysOptions) (AccountsRegenerateKeysResponse, error) { + req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, accountName, keySpecification, options) + if err != nil { + return AccountsRegenerateKeysResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsRegenerateKeysResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AccountsRegenerateKeysResponse{}, client.regenerateKeysHandleError(resp) + } + return client.regenerateKeysHandleResponse(resp) +} + +// regenerateKeysCreateRequest creates the RegenerateKeys request. +func (client *AccountsClient) regenerateKeysCreateRequest(ctx context.Context, resourceGroupName string, accountName string, keySpecification MapsKeySpecification, options *AccountsRegenerateKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/regenerateKey" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, keySpecification) +} + +// regenerateKeysHandleResponse handles the RegenerateKeys response. +func (client *AccountsClient) regenerateKeysHandleResponse(resp *http.Response) (AccountsRegenerateKeysResponse, error) { + result := AccountsRegenerateKeysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MapsAccountKeys); err != nil { + return AccountsRegenerateKeysResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// regenerateKeysHandleError handles the RegenerateKeys error response. +func (client *AccountsClient) regenerateKeysHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Updates a Maps Account. Only a subset of the parameters may be updated after creation, such as Sku, Tags, Properties. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, mapsAccountUpdateParameters MapsAccountUpdateParameters, options *AccountsUpdateOptions) (AccountsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, mapsAccountUpdateParameters, options) + if err != nil { + return AccountsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AccountsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *AccountsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, mapsAccountUpdateParameters MapsAccountUpdateParameters, options *AccountsUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, mapsAccountUpdateParameters) +} + +// updateHandleResponse handles the Update response. +func (client *AccountsClient) updateHandleResponse(resp *http.Response) (AccountsUpdateResponse, error) { + result := AccountsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MapsAccount); err != nil { + return AccountsUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *AccountsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/maps/armmaps/zz_generated_constants.go b/sdk/resourcemanager/maps/armmaps/zz_generated_constants.go new file mode 100644 index 000000000000..e9351aacb63c --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/zz_generated_constants.go @@ -0,0 +1,150 @@ +//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 armmaps + +const ( + module = "armmaps" + version = "v0.1.0" +) + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// ToPtr returns a *CreatedByType pointing to the current value. +func (c CreatedByType) ToPtr() *CreatedByType { + return &c +} + +// KeyType - Whether the operation refers to the primary or secondary key. +type KeyType string + +const ( + KeyTypePrimary KeyType = "primary" + KeyTypeSecondary KeyType = "secondary" +) + +// PossibleKeyTypeValues returns the possible values for the KeyType const type. +func PossibleKeyTypeValues() []KeyType { + return []KeyType{ + KeyTypePrimary, + KeyTypeSecondary, + } +} + +// ToPtr returns a *KeyType pointing to the current value. +func (c KeyType) ToPtr() *KeyType { + return &c +} + +// Kind - The Kind of the Maps Account. +type Kind string + +const ( + KindGen1 Kind = "Gen1" + KindGen2 Kind = "Gen2" +) + +// PossibleKindValues returns the possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{ + KindGen1, + KindGen2, + } +} + +// ToPtr returns a *Kind pointing to the current value. +func (c Kind) ToPtr() *Kind { + return &c +} + +// Name - The name of the SKU, in standard format (such as S0). +type Name string + +const ( + NameG2 Name = "G2" + NameS0 Name = "S0" + NameS1 Name = "S1" +) + +// PossibleNameValues returns the possible values for the Name const type. +func PossibleNameValues() []Name { + return []Name{ + NameG2, + NameS0, + NameS1, + } +} + +// ToPtr returns a *Name pointing to the current value. +func (c Name) ToPtr() *Name { + return &c +} + +// ResourceIdentityType - The identity type. +type ResourceIdentityType string + +const ( + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" + ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned" + ResourceIdentityTypeSystemAssignedUserAssigned ResourceIdentityType = "SystemAssigned, UserAssigned" + ResourceIdentityTypeNone ResourceIdentityType = "None" +) + +// PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ + ResourceIdentityTypeSystemAssigned, + ResourceIdentityTypeUserAssigned, + ResourceIdentityTypeSystemAssignedUserAssigned, + ResourceIdentityTypeNone, + } +} + +// ToPtr returns a *ResourceIdentityType pointing to the current value. +func (c ResourceIdentityType) ToPtr() *ResourceIdentityType { + return &c +} + +// SigningKey - The Map account key to use for signing. +type SigningKey string + +const ( + SigningKeyPrimaryKey SigningKey = "primaryKey" + SigningKeySecondaryKey SigningKey = "secondaryKey" +) + +// PossibleSigningKeyValues returns the possible values for the SigningKey const type. +func PossibleSigningKeyValues() []SigningKey { + return []SigningKey{ + SigningKeyPrimaryKey, + SigningKeySecondaryKey, + } +} + +// ToPtr returns a *SigningKey pointing to the current value. +func (c SigningKey) ToPtr() *SigningKey { + return &c +} diff --git a/sdk/resourcemanager/maps/armmaps/zz_generated_creators_client.go b/sdk/resourcemanager/maps/armmaps/zz_generated_creators_client.go new file mode 100644 index 000000000000..c26405d756c7 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/zz_generated_creators_client.go @@ -0,0 +1,373 @@ +//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 armmaps + +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" +) + +// CreatorsClient contains the methods for the Creators group. +// Don't use this type directly, use NewCreatorsClient() instead. +type CreatorsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewCreatorsClient creates a new instance of CreatorsClient with the specified values. +func NewCreatorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *CreatorsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &CreatorsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Create or update a Maps Creator resource. Creator resource will manage Azure resources required to populate a custom set of mapping +// data. It requires an account to exist before it can be created. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CreatorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, creatorName string, creatorResource Creator, options *CreatorsCreateOrUpdateOptions) (CreatorsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, creatorName, creatorResource, options) + if err != nil { + return CreatorsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CreatorsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return CreatorsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CreatorsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, creatorName string, creatorResource Creator, options *CreatorsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if creatorName == "" { + return nil, errors.New("parameter creatorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{creatorName}", url.PathEscape(creatorName)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, creatorResource) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *CreatorsClient) createOrUpdateHandleResponse(resp *http.Response) (CreatorsCreateOrUpdateResponse, error) { + result := CreatorsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Creator); err != nil { + return CreatorsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *CreatorsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete a Maps Creator resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CreatorsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, creatorName string, options *CreatorsDeleteOptions) (CreatorsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, creatorName, options) + if err != nil { + return CreatorsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CreatorsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return CreatorsDeleteResponse{}, client.deleteHandleError(resp) + } + return CreatorsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CreatorsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, creatorName string, options *CreatorsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if creatorName == "" { + return nil, errors.New("parameter creatorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{creatorName}", url.PathEscape(creatorName)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *CreatorsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get a Maps Creator resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CreatorsClient) Get(ctx context.Context, resourceGroupName string, accountName string, creatorName string, options *CreatorsGetOptions) (CreatorsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, creatorName, options) + if err != nil { + return CreatorsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CreatorsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CreatorsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CreatorsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, creatorName string, options *CreatorsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if creatorName == "" { + return nil, errors.New("parameter creatorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{creatorName}", url.PathEscape(creatorName)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CreatorsClient) getHandleResponse(resp *http.Response) (CreatorsGetResponse, error) { + result := CreatorsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Creator); err != nil { + return CreatorsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *CreatorsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByAccount - Get all Creator instances for an Azure Maps Account +// If the operation fails it returns the *ErrorResponse error type. +func (client *CreatorsClient) ListByAccount(resourceGroupName string, accountName string, options *CreatorsListByAccountOptions) *CreatorsListByAccountPager { + return &CreatorsListByAccountPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByAccountCreateRequest(ctx, resourceGroupName, accountName, options) + }, + advancer: func(ctx context.Context, resp CreatorsListByAccountResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.CreatorList.NextLink) + }, + } +} + +// listByAccountCreateRequest creates the ListByAccount request. +func (client *CreatorsClient) listByAccountCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *CreatorsListByAccountOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByAccountHandleResponse handles the ListByAccount response. +func (client *CreatorsClient) listByAccountHandleResponse(resp *http.Response) (CreatorsListByAccountResponse, error) { + result := CreatorsListByAccountResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CreatorList); err != nil { + return CreatorsListByAccountResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByAccountHandleError handles the ListByAccount error response. +func (client *CreatorsClient) listByAccountHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Updates the Maps Creator resource. Only a subset of the parameters may be updated after creation, such as Tags. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CreatorsClient) Update(ctx context.Context, resourceGroupName string, accountName string, creatorName string, creatorUpdateParameters CreatorUpdateParameters, options *CreatorsUpdateOptions) (CreatorsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, creatorName, creatorUpdateParameters, options) + if err != nil { + return CreatorsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CreatorsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CreatorsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *CreatorsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, creatorName string, creatorUpdateParameters CreatorUpdateParameters, options *CreatorsUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if creatorName == "" { + return nil, errors.New("parameter creatorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{creatorName}", url.PathEscape(creatorName)) + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, creatorUpdateParameters) +} + +// updateHandleResponse handles the Update response. +func (client *CreatorsClient) updateHandleResponse(resp *http.Response) (CreatorsUpdateResponse, error) { + result := CreatorsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Creator); err != nil { + return CreatorsUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *CreatorsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/maps/armmaps/zz_generated_maps_client.go b/sdk/resourcemanager/maps/armmaps/zz_generated_maps_client.go new file mode 100644 index 000000000000..74793aa7e7c4 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/zz_generated_maps_client.go @@ -0,0 +1,147 @@ +//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 armmaps + +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" +) + +// MapsClient contains the methods for the Maps group. +// Don't use this type directly, use NewMapsClient() instead. +type MapsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewMapsClient creates a new instance of MapsClient with the specified values. +func NewMapsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *MapsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &MapsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// ListOperations - List operations available for the Maps Resource Provider +// If the operation fails it returns the *ErrorResponse error type. +func (client *MapsClient) ListOperations(options *MapsListOperationsOptions) *MapsListOperationsPager { + return &MapsListOperationsPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listOperationsCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp MapsListOperationsResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.MapsOperations.NextLink) + }, + } +} + +// listOperationsCreateRequest creates the ListOperations request. +func (client *MapsClient) listOperationsCreateRequest(ctx context.Context, options *MapsListOperationsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Maps/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listOperationsHandleResponse handles the ListOperations response. +func (client *MapsClient) listOperationsHandleResponse(resp *http.Response) (MapsListOperationsResponse, error) { + result := MapsListOperationsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MapsOperations); err != nil { + return MapsListOperationsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listOperationsHandleError handles the ListOperations error response. +func (client *MapsClient) listOperationsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListSubscriptionOperations - List operations available for the Maps Resource Provider +// If the operation fails it returns the *ErrorResponse error type. +func (client *MapsClient) ListSubscriptionOperations(options *MapsListSubscriptionOperationsOptions) *MapsListSubscriptionOperationsPager { + return &MapsListSubscriptionOperationsPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listSubscriptionOperationsCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp MapsListSubscriptionOperationsResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.MapsOperations.NextLink) + }, + } +} + +// listSubscriptionOperationsCreateRequest creates the ListSubscriptionOperations request. +func (client *MapsClient) listSubscriptionOperationsCreateRequest(ctx context.Context, options *MapsListSubscriptionOperationsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maps/operations" + 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", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listSubscriptionOperationsHandleResponse handles the ListSubscriptionOperations response. +func (client *MapsClient) listSubscriptionOperationsHandleResponse(resp *http.Response) (MapsListSubscriptionOperationsResponse, error) { + result := MapsListSubscriptionOperationsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MapsOperations); err != nil { + return MapsListSubscriptionOperationsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listSubscriptionOperationsHandleError handles the ListSubscriptionOperations error response. +func (client *MapsClient) listSubscriptionOperationsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/maps/armmaps/zz_generated_models.go b/sdk/resourcemanager/maps/armmaps/zz_generated_models.go new file mode 100644 index 000000000000..c99007d17ba3 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/zz_generated_models.go @@ -0,0 +1,747 @@ +//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 armmaps + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// AccountSasParameters - Parameters used to create an account Shared Access Signature (SAS) token. The REST API access control is provided by Azure Maps +// Role Based Access (RBAC) identity and access. +type AccountSasParameters struct { + // REQUIRED; The date time offset of when the token validity expires. For example "2017-05-24T10:42:03.1567373Z" + Expiry *string `json:"expiry,omitempty"` + + // REQUIRED; Required parameter which represents the desired maximum request per second to allowed for the given SAS token. This does not guarantee perfect + // accuracy in measurements but provides application safe + // guards of abuse with eventual enforcement. + MaxRatePerSecond *int32 `json:"maxRatePerSecond,omitempty"` + + // REQUIRED; The principal Id also known as the object Id of a User Assigned Managed Identity currently assigned to the Map Account. To assign a Managed + // Identity of the account, use operation Create or Update an + // assign a User Assigned Identity resource Id. + PrincipalID *string `json:"principalId,omitempty"` + + // REQUIRED; The Map account key to use for signing. + SigningKey *SigningKey `json:"signingKey,omitempty"` + + // REQUIRED; The date time offset of when the token validity begins. For example "2017-05-24T10:42:03.1567373Z". + Start *string `json:"start,omitempty"` + + // Optional, allows control of which region locations are permitted access to Azure Maps REST APIs with the SAS token. Example: "eastus", "westus2". Omitting + // this parameter will allow all region + // locations to be accessible. + Regions []*string `json:"regions,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AccountSasParameters. +func (a AccountSasParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "expiry", a.Expiry) + populate(objectMap, "maxRatePerSecond", a.MaxRatePerSecond) + populate(objectMap, "principalId", a.PrincipalID) + populate(objectMap, "regions", a.Regions) + populate(objectMap, "signingKey", a.SigningKey) + populate(objectMap, "start", a.Start) + return json.Marshal(objectMap) +} + +// AccountsCreateOrUpdateOptions contains the optional parameters for the Accounts.CreateOrUpdate method. +type AccountsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// AccountsDeleteOptions contains the optional parameters for the Accounts.Delete method. +type AccountsDeleteOptions struct { + // placeholder for future optional parameters +} + +// AccountsGetOptions contains the optional parameters for the Accounts.Get method. +type AccountsGetOptions struct { + // placeholder for future optional parameters +} + +// AccountsListByResourceGroupOptions contains the optional parameters for the Accounts.ListByResourceGroup method. +type AccountsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// AccountsListBySubscriptionOptions contains the optional parameters for the Accounts.ListBySubscription method. +type AccountsListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// AccountsListKeysOptions contains the optional parameters for the Accounts.ListKeys method. +type AccountsListKeysOptions struct { + // placeholder for future optional parameters +} + +// AccountsListSasOptions contains the optional parameters for the Accounts.ListSas method. +type AccountsListSasOptions struct { + // placeholder for future optional parameters +} + +// AccountsRegenerateKeysOptions contains the optional parameters for the Accounts.RegenerateKeys method. +type AccountsRegenerateKeysOptions struct { + // placeholder for future optional parameters +} + +// AccountsUpdateOptions contains the optional parameters for the Accounts.Update method. +type AccountsUpdateOptions struct { + // placeholder for future optional parameters +} + +type Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties struct { + // READ-ONLY; The client id of user assigned identity. + ClientID *string `json:"clientId,omitempty" azure:"ro"` + + // READ-ONLY; The principal id of user assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` +} + +// CorsRule - Specifies a CORS rule for the Map Account. +type CorsRule struct { + // REQUIRED; Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains + AllowedOrigins []*string `json:"allowedOrigins,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CorsRule. +func (c CorsRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "allowedOrigins", c.AllowedOrigins) + return json.Marshal(objectMap) +} + +// CorsRules - Sets the CORS rules. You can include up to five CorsRule elements in the request. +type CorsRules struct { + // The list of CORS rules. You can include up to five CorsRule elements in the request. + CorsRules []*CorsRule `json:"corsRules,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CorsRules. +func (c CorsRules) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "corsRules", c.CorsRules) + return json.Marshal(objectMap) +} + +// Creator - An Azure resource which represents Maps Creator product and provides ability to manage private location data. +type Creator struct { + TrackedResource + // REQUIRED; The Creator resource properties. + Properties *CreatorProperties `json:"properties,omitempty"` + + // READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Creator. +func (c Creator) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + return json.Marshal(objectMap) +} + +// CreatorList - A list of Creator resources. +type CreatorList struct { + // URL client should use to fetch the next page (per server side paging). It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` + + // READ-ONLY; a Creator account. + Value []*Creator `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CreatorList. +func (c CreatorList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CreatorProperties - Creator resource properties +type CreatorProperties struct { + // REQUIRED; The storage units to be allocated. Integer values from 1 to 100, inclusive. + StorageUnits *int32 `json:"storageUnits,omitempty"` + + // READ-ONLY; The state of the resource provisioning, terminal states: Succeeded, Failed, Canceled + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// CreatorUpdateParameters - Parameters used to update an existing Creator resource. +type CreatorUpdateParameters struct { + // Creator resource properties. + Properties *CreatorProperties `json:"properties,omitempty"` + + // Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). + // A maximum of 15 tags can be provided for a + // resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CreatorUpdateParameters. +func (c CreatorUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// CreatorsCreateOrUpdateOptions contains the optional parameters for the Creators.CreateOrUpdate method. +type CreatorsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// CreatorsDeleteOptions contains the optional parameters for the Creators.Delete method. +type CreatorsDeleteOptions struct { + // placeholder for future optional parameters +} + +// CreatorsGetOptions contains the optional parameters for the Creators.Get method. +type CreatorsGetOptions struct { + // placeholder for future optional parameters +} + +// CreatorsListByAccountOptions contains the optional parameters for the Creators.ListByAccount method. +type CreatorsListByAccountOptions struct { + // placeholder for future optional parameters +} + +// CreatorsUpdateOptions contains the optional parameters for the Creators.Update method. +type CreatorsUpdateOptions struct { + // placeholder for future optional parameters +} + +// Dimension of map account, for example API Category, Api Name, Result Type, and Response Code. +type Dimension struct { + // Display name of dimension. + DisplayName *string `json:"displayName,omitempty"` + + // Internal metric name of the dimension. + InternalMetricName *string `json:"internalMetricName,omitempty"` + + // Internal name of the dimension. + InternalName *string `json:"internalName,omitempty"` + + // Display name of dimension. + Name *string `json:"name,omitempty"` + + // Source Mdm Namespace of the dimension. + SourceMdmNamespace *string `json:"sourceMdmNamespace,omitempty"` + + // Flag to indicate exporting to Azure Monitor. + ToBeExportedToShoebox *bool `json:"toBeExportedToShoebox,omitempty"` +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData +// error response format.). +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // The error object. + InnerError *ErrorDetail `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// LinkedResource - Linked resource is reference to a resource deployed in an Azure subscription, add the linked resource uniqueName value as an optional +// parameter for operations on Azure Maps Geospatial REST APIs. +type LinkedResource struct { + // REQUIRED; ARM resource id in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/accounts/{storageName}'. + ID *string `json:"id,omitempty"` + + // REQUIRED; A provided name which uniquely identifies the linked resource. + UniqueName *string `json:"uniqueName,omitempty"` +} + +// ManagedServiceIdentity - Identity for the resource. +type ManagedServiceIdentity struct { + // The identity type. + Type *ResourceIdentityType `json:"type,omitempty"` + + // The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + UserAssignedIdentities map[string]*Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties `json:"userAssignedIdentities,omitempty"` + + // READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// MapsAccount - An Azure resource which represents access to a suite of Maps REST APIs. +type MapsAccount struct { + TrackedResource + // REQUIRED; The SKU of this account. + SKU *SKU `json:"sku,omitempty"` + + // Sets the identity property for maps account. + Identity *ManagedServiceIdentity `json:"identity,omitempty"` + + // Get or Set Kind property. + Kind *Kind `json:"kind,omitempty"` + + // The map account properties. + Properties *MapsAccountProperties `json:"properties,omitempty"` + + // READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type MapsAccount. +func (m MapsAccount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + m.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "identity", m.Identity) + populate(objectMap, "kind", m.Kind) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "sku", m.SKU) + populate(objectMap, "systemData", m.SystemData) + return json.Marshal(objectMap) +} + +// MapsAccountKeys - The set of keys which can be used to access the Maps REST APIs. Two keys are provided for key rotation without interruption. +type MapsAccountKeys struct { + // READ-ONLY; The primary key for accessing the Maps REST APIs. + PrimaryKey *string `json:"primaryKey,omitempty" azure:"ro"` + + // READ-ONLY; The last updated date and time of the primary key. + PrimaryKeyLastUpdated *string `json:"primaryKeyLastUpdated,omitempty" azure:"ro"` + + // READ-ONLY; The secondary key for accessing the Maps REST APIs. + SecondaryKey *string `json:"secondaryKey,omitempty" azure:"ro"` + + // READ-ONLY; The last updated date and time of the secondary key. + SecondaryKeyLastUpdated *string `json:"secondaryKeyLastUpdated,omitempty" azure:"ro"` +} + +// MapsAccountProperties - Additional Map account properties +type MapsAccountProperties struct { + // Specifies CORS rules for the Blob service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request + // body, all CORS rules will be deleted, and + // CORS will be disabled for the Blob service. + Cors *CorsRules `json:"cors,omitempty"` + + // Allows toggle functionality on Azure Policy to disable Azure Maps local authentication support. This will disable Shared Keys authentication from any + // usage. + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + + // Sets the resources to be used for Managed Identities based operations for the Map account resource. + LinkedResources []*LinkedResource `json:"linkedResources,omitempty"` + + // READ-ONLY; The provisioning state of the Map account resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; A unique identifier for the maps account + UniqueID *string `json:"uniqueId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type MapsAccountProperties. +func (m MapsAccountProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "cors", m.Cors) + populate(objectMap, "disableLocalAuth", m.DisableLocalAuth) + populate(objectMap, "linkedResources", m.LinkedResources) + populate(objectMap, "provisioningState", m.ProvisioningState) + populate(objectMap, "uniqueId", m.UniqueID) + return json.Marshal(objectMap) +} + +// MapsAccountSasToken - A new Sas token which can be used to access the Maps REST APIs and is controlled by the specified Managed identity permissions +// on Azure (IAM) Role Based Access Control. +type MapsAccountSasToken struct { + // READ-ONLY; The shared access signature access token. + AccountSasToken *string `json:"accountSasToken,omitempty" azure:"ro"` +} + +// MapsAccountUpdateParameters - Parameters used to update an existing Maps Account. +type MapsAccountUpdateParameters struct { + // Sets the identity property for maps account. + Identity *ManagedServiceIdentity `json:"identity,omitempty"` + + // Get or Set Kind property. + Kind *Kind `json:"kind,omitempty"` + + // The map account properties. + Properties *MapsAccountProperties `json:"properties,omitempty"` + + // The SKU of this account. + SKU *SKU `json:"sku,omitempty"` + + // Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). + // A maximum of 15 tags can be provided for a + // resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MapsAccountUpdateParameters. +func (m MapsAccountUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", m.Identity) + populate(objectMap, "kind", m.Kind) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "sku", m.SKU) + populate(objectMap, "tags", m.Tags) + return json.Marshal(objectMap) +} + +// MapsAccounts - A list of Maps Accounts. +type MapsAccounts struct { + // URL client should use to fetch the next page (per server side paging). It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` + + // READ-ONLY; a Maps Account. + Value []*MapsAccount `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type MapsAccounts. +func (m MapsAccounts) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// MapsKeySpecification - Whether the operation refers to the primary or secondary key. +type MapsKeySpecification struct { + // REQUIRED; Whether the operation refers to the primary or secondary key. + KeyType *KeyType `json:"keyType,omitempty"` +} + +// MapsListOperationsOptions contains the optional parameters for the Maps.ListOperations method. +type MapsListOperationsOptions struct { + // placeholder for future optional parameters +} + +// MapsListSubscriptionOperationsOptions contains the optional parameters for the Maps.ListSubscriptionOperations method. +type MapsListSubscriptionOperationsOptions struct { + // placeholder for future optional parameters +} + +// MapsOperations - The set of operations available for Maps. +type MapsOperations struct { + // URL client should use to fetch the next page (per server side paging). It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` + + // READ-ONLY; An operation available for Maps. + Value []*OperationDetail `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type MapsOperations. +func (m MapsOperations) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// MetricSpecification - Metric specification of operation. +type MetricSpecification struct { + // Aggregation type could be Average. + AggregationType *string `json:"aggregationType,omitempty"` + + // The category this metric specification belong to, could be Capacity. + Category *string `json:"category,omitempty"` + + // Dimensions of map account. + Dimensions []*Dimension `json:"dimensions,omitempty"` + + // Display description of metric specification. + DisplayDescription *string `json:"displayDescription,omitempty"` + + // Display name of metric specification. + DisplayName *string `json:"displayName,omitempty"` + + // The property to decide fill gap with zero or not. + FillGapWithZero *bool `json:"fillGapWithZero,omitempty"` + + // Internal metric name. + InternalMetricName *string `json:"internalMetricName,omitempty"` + + // Name of metric specification. + Name *string `json:"name,omitempty"` + + // Account Resource Id. + ResourceIDDimensionNameOverride *string `json:"resourceIdDimensionNameOverride,omitempty"` + + // Source metrics account. + SourceMdmAccount *string `json:"sourceMdmAccount,omitempty"` + + // Unit could be Count. + Unit *string `json:"unit,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricSpecification. +func (m MetricSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregationType", m.AggregationType) + populate(objectMap, "category", m.Category) + populate(objectMap, "dimensions", m.Dimensions) + populate(objectMap, "displayDescription", m.DisplayDescription) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "fillGapWithZero", m.FillGapWithZero) + populate(objectMap, "internalMetricName", m.InternalMetricName) + populate(objectMap, "name", m.Name) + populate(objectMap, "resourceIdDimensionNameOverride", m.ResourceIDDimensionNameOverride) + populate(objectMap, "sourceMdmAccount", m.SourceMdmAccount) + populate(objectMap, "unit", m.Unit) + return json.Marshal(objectMap) +} + +// OperationDetail - Operation detail payload +type OperationDetail struct { + // Display of the operation + Display *OperationDisplay `json:"display,omitempty"` + + // Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + + // Name of the operation + Name *string `json:"name,omitempty"` + + // Origin of the operation + Origin *string `json:"origin,omitempty"` + + // Properties of the operation + Properties *OperationProperties `json:"properties,omitempty"` +} + +// OperationDisplay - Operation display payload +type OperationDisplay struct { + // Localized friendly description for the operation + Description *string `json:"description,omitempty"` + + // Localized friendly name for the operation + Operation *string `json:"operation,omitempty"` + + // Resource provider of the operation + Provider *string `json:"provider,omitempty"` + + // Resource of the operation + Resource *string `json:"resource,omitempty"` +} + +// OperationProperties - Properties of operation, include metric specifications. +type OperationProperties struct { + // One property of operation, include metric specifications. + ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) +} + +// SKU - The SKU of the Maps Account. +type SKU struct { + // REQUIRED; The name of the SKU, in standard format (such as S0). + Name *Name `json:"name,omitempty"` + + // READ-ONLY; Gets the sku tier. This is based on the SKU name. + Tier *string `json:"tier,omitempty" azure:"ro"` +} + +// ServiceSpecification - One property of operation, include metric specifications. +type ServiceSpecification struct { + // Metric specifications of operation. + MetricSpecifications []*MetricSpecification `json:"metricSpecifications,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceSpecification. +func (s ServiceSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "metricSpecifications", s.MetricSpecifications) + return json.Marshal(objectMap) +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) 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 "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' +type TrackedResource struct { + Resource + // REQUIRED; The geo-location 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) +} + +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/maps/armmaps/zz_generated_pagers.go b/sdk/resourcemanager/maps/armmaps/zz_generated_pagers.go new file mode 100644 index 000000000000..e431c4f03e3e --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/zz_generated_pagers.go @@ -0,0 +1,287 @@ +//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 armmaps + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "reflect" +) + +// AccountsListByResourceGroupPager provides operations for iterating over paged responses. +type AccountsListByResourceGroupPager struct { + client *AccountsClient + current AccountsListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, AccountsListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *AccountsListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *AccountsListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.MapsAccounts.NextLink == nil || len(*p.current.MapsAccounts.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current AccountsListByResourceGroupResponse page. +func (p *AccountsListByResourceGroupPager) PageResponse() AccountsListByResourceGroupResponse { + return p.current +} + +// AccountsListBySubscriptionPager provides operations for iterating over paged responses. +type AccountsListBySubscriptionPager struct { + client *AccountsClient + current AccountsListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, AccountsListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *AccountsListBySubscriptionPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *AccountsListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.MapsAccounts.NextLink == nil || len(*p.current.MapsAccounts.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current AccountsListBySubscriptionResponse page. +func (p *AccountsListBySubscriptionPager) PageResponse() AccountsListBySubscriptionResponse { + return p.current +} + +// CreatorsListByAccountPager provides operations for iterating over paged responses. +type CreatorsListByAccountPager struct { + client *CreatorsClient + current CreatorsListByAccountResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, CreatorsListByAccountResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *CreatorsListByAccountPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *CreatorsListByAccountPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CreatorList.NextLink == nil || len(*p.current.CreatorList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByAccountHandleError(resp) + return false + } + result, err := p.client.listByAccountHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current CreatorsListByAccountResponse page. +func (p *CreatorsListByAccountPager) PageResponse() CreatorsListByAccountResponse { + return p.current +} + +// MapsListOperationsPager provides operations for iterating over paged responses. +type MapsListOperationsPager struct { + client *MapsClient + current MapsListOperationsResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, MapsListOperationsResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *MapsListOperationsPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *MapsListOperationsPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.MapsOperations.NextLink == nil || len(*p.current.MapsOperations.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listOperationsHandleError(resp) + return false + } + result, err := p.client.listOperationsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current MapsListOperationsResponse page. +func (p *MapsListOperationsPager) PageResponse() MapsListOperationsResponse { + return p.current +} + +// MapsListSubscriptionOperationsPager provides operations for iterating over paged responses. +type MapsListSubscriptionOperationsPager struct { + client *MapsClient + current MapsListSubscriptionOperationsResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, MapsListSubscriptionOperationsResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *MapsListSubscriptionOperationsPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *MapsListSubscriptionOperationsPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.MapsOperations.NextLink == nil || len(*p.current.MapsOperations.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listSubscriptionOperationsHandleError(resp) + return false + } + result, err := p.client.listSubscriptionOperationsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current MapsListSubscriptionOperationsResponse page. +func (p *MapsListSubscriptionOperationsPager) PageResponse() MapsListSubscriptionOperationsResponse { + return p.current +} diff --git a/sdk/resourcemanager/maps/armmaps/zz_generated_response_types.go b/sdk/resourcemanager/maps/armmaps/zz_generated_response_types.go new file mode 100644 index 000000000000..e597ecd5aca4 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/zz_generated_response_types.go @@ -0,0 +1,191 @@ +//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 armmaps + +import "net/http" + +// AccountsCreateOrUpdateResponse contains the response from method Accounts.CreateOrUpdate. +type AccountsCreateOrUpdateResponse struct { + AccountsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsCreateOrUpdateResult contains the result from method Accounts.CreateOrUpdate. +type AccountsCreateOrUpdateResult struct { + MapsAccount +} + +// AccountsDeleteResponse contains the response from method Accounts.Delete. +type AccountsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsGetResponse contains the response from method Accounts.Get. +type AccountsGetResponse struct { + AccountsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsGetResult contains the result from method Accounts.Get. +type AccountsGetResult struct { + MapsAccount +} + +// AccountsListByResourceGroupResponse contains the response from method Accounts.ListByResourceGroup. +type AccountsListByResourceGroupResponse struct { + AccountsListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsListByResourceGroupResult contains the result from method Accounts.ListByResourceGroup. +type AccountsListByResourceGroupResult struct { + MapsAccounts +} + +// AccountsListBySubscriptionResponse contains the response from method Accounts.ListBySubscription. +type AccountsListBySubscriptionResponse struct { + AccountsListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsListBySubscriptionResult contains the result from method Accounts.ListBySubscription. +type AccountsListBySubscriptionResult struct { + MapsAccounts +} + +// AccountsListKeysResponse contains the response from method Accounts.ListKeys. +type AccountsListKeysResponse struct { + AccountsListKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsListKeysResult contains the result from method Accounts.ListKeys. +type AccountsListKeysResult struct { + MapsAccountKeys +} + +// AccountsListSasResponse contains the response from method Accounts.ListSas. +type AccountsListSasResponse struct { + AccountsListSasResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsListSasResult contains the result from method Accounts.ListSas. +type AccountsListSasResult struct { + MapsAccountSasToken +} + +// AccountsRegenerateKeysResponse contains the response from method Accounts.RegenerateKeys. +type AccountsRegenerateKeysResponse struct { + AccountsRegenerateKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsRegenerateKeysResult contains the result from method Accounts.RegenerateKeys. +type AccountsRegenerateKeysResult struct { + MapsAccountKeys +} + +// AccountsUpdateResponse contains the response from method Accounts.Update. +type AccountsUpdateResponse struct { + AccountsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsUpdateResult contains the result from method Accounts.Update. +type AccountsUpdateResult struct { + MapsAccount +} + +// CreatorsCreateOrUpdateResponse contains the response from method Creators.CreateOrUpdate. +type CreatorsCreateOrUpdateResponse struct { + CreatorsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CreatorsCreateOrUpdateResult contains the result from method Creators.CreateOrUpdate. +type CreatorsCreateOrUpdateResult struct { + Creator +} + +// CreatorsDeleteResponse contains the response from method Creators.Delete. +type CreatorsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CreatorsGetResponse contains the response from method Creators.Get. +type CreatorsGetResponse struct { + CreatorsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CreatorsGetResult contains the result from method Creators.Get. +type CreatorsGetResult struct { + Creator +} + +// CreatorsListByAccountResponse contains the response from method Creators.ListByAccount. +type CreatorsListByAccountResponse struct { + CreatorsListByAccountResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CreatorsListByAccountResult contains the result from method Creators.ListByAccount. +type CreatorsListByAccountResult struct { + CreatorList +} + +// CreatorsUpdateResponse contains the response from method Creators.Update. +type CreatorsUpdateResponse struct { + CreatorsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CreatorsUpdateResult contains the result from method Creators.Update. +type CreatorsUpdateResult struct { + Creator +} + +// MapsListOperationsResponse contains the response from method Maps.ListOperations. +type MapsListOperationsResponse struct { + MapsListOperationsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MapsListOperationsResult contains the result from method Maps.ListOperations. +type MapsListOperationsResult struct { + MapsOperations +} + +// MapsListSubscriptionOperationsResponse contains the response from method Maps.ListSubscriptionOperations. +type MapsListSubscriptionOperationsResponse struct { + MapsListSubscriptionOperationsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MapsListSubscriptionOperationsResult contains the result from method Maps.ListSubscriptionOperations. +type MapsListSubscriptionOperationsResult struct { + MapsOperations +} diff --git a/sdk/resourcemanager/maps/armmaps/zz_generated_time_rfc3339.go b/sdk/resourcemanager/maps/armmaps/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..4c128e180817 --- /dev/null +++ b/sdk/resourcemanager/maps/armmaps/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 armmaps + +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 +}