From 7551544efaaf8ec07574debd9178ae9723288510 Mon Sep 17 00:00:00 2001 From: Jiahui Peng <46921893+Alancere@users.noreply.github.com> Date: Thu, 9 Dec 2021 14:10:46 +0800 Subject: [PATCH] Release sdk/resourcemanager/servicelinker/armservicelinker/0.1.0 (#16527) * [Release] sdk/resourcemanager/servicelinker/armservicelinker/0.1.0 generation from spec commit: e260efc341b22e018718d1c2e85107db5af52802 * update release date --- .../armservicelinker/CHANGELOG.md | 5 + .../armservicelinker/LICENSE.txt | 21 + .../servicelinker/armservicelinker/README.md | 75 ++ .../armservicelinker/autorest.md | 13 + .../servicelinker/armservicelinker/build.go | 7 + .../servicelinker/armservicelinker/ci.yml | 27 + .../servicelinker/armservicelinker/go.mod | 9 + .../servicelinker/armservicelinker/go.sum | 45 ++ .../armservicelinker/go_mod_tidy_hack.go | 13 + ...ze_generated_example_linker_client_test.go | 186 +++++ .../zz_generated_constants.go | 166 ++++ .../zz_generated_linker_client.go | 485 ++++++++++++ .../armservicelinker/zz_generated_models.go | 707 ++++++++++++++++++ .../zz_generated_operations_client.go | 89 +++ .../armservicelinker/zz_generated_pagers.go | 125 ++++ .../armservicelinker/zz_generated_pollers.go | 187 +++++ .../zz_generated_polymorphic_helpers.go | 75 ++ .../zz_generated_response_types.go | 266 +++++++ .../zz_generated_time_rfc3339.go | 85 +++ 19 files changed, 2586 insertions(+) create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/CHANGELOG.md create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/LICENSE.txt create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/README.md create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/autorest.md create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/build.go create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/ci.yml create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/go.mod create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/go.sum create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/go_mod_tidy_hack.go create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/ze_generated_example_linker_client_test.go create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_constants.go create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_linker_client.go create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_models.go create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_operations_client.go create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_pagers.go create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_pollers.go create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_polymorphic_helpers.go create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_response_types.go create mode 100644 sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_time_rfc3339.go diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/CHANGELOG.md b/sdk/resourcemanager/servicelinker/armservicelinker/CHANGELOG.md new file mode 100644 index 000000000000..1da2f2a4c978 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-09) + +- Init release. diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/LICENSE.txt b/sdk/resourcemanager/servicelinker/armservicelinker/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/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/servicelinker/armservicelinker/README.md b/sdk/resourcemanager/servicelinker/armservicelinker/README.md new file mode 100644 index 000000000000..b690bcb9f3ba --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/README.md @@ -0,0 +1,75 @@ +# Azure Service Linker Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicelinker/armservicelinker)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicelinker/armservicelinker) + +The `armservicelinker` module provides operations for working with Azure Service Linker. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/servicelinker/armservicelinker) + +# 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 Service Linker module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicelinker/armservicelinker +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Service Linker. 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 Service Linker 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 := armservicelinker.(, 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 := armservicelinker.(, 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 `Service Linker` 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/servicelinker/armservicelinker/autorest.md b/sdk/resourcemanager/servicelinker/armservicelinker/autorest.md new file mode 100644 index 000000000000..7bfa82814669 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/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/e260efc341b22e018718d1c2e85107db5af52802/specification/servicelinker/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/e260efc341b22e018718d1c2e85107db5af52802/specification/servicelinker/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/servicelinker/armservicelinker/build.go b/sdk/resourcemanager/servicelinker/armservicelinker/build.go new file mode 100644 index 000000000000..94c08a61b572 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/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/servicelinker/armservicelinker + +package armservicelinker diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/ci.yml b/sdk/resourcemanager/servicelinker/armservicelinker/ci.yml new file mode 100644 index 000000000000..f5304eeba666 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/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/servicelinker/armservicelinker/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/servicelinker/armservicelinker/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/servicelinker/armservicelinker' diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/go.mod b/sdk/resourcemanager/servicelinker/armservicelinker/go.mod new file mode 100644 index 000000000000..0efa02fa4f18 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/go.mod @@ -0,0 +1,9 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicelinker/armservicelinker + +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/servicelinker/armservicelinker/go.sum b/sdk/resourcemanager/servicelinker/armservicelinker/go.sum new file mode 100644 index 000000000000..ac069c64ed64 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/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/servicelinker/armservicelinker/go_mod_tidy_hack.go b/sdk/resourcemanager/servicelinker/armservicelinker/go_mod_tidy_hack.go new file mode 100644 index 000000000000..663b9af62790 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/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 armservicelinker + +// 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/servicelinker/armservicelinker/ze_generated_example_linker_client_test.go b/sdk/resourcemanager/servicelinker/armservicelinker/ze_generated_example_linker_client_test.go new file mode 100644 index 000000000000..7532503e1873 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/ze_generated_example_linker_client_test.go @@ -0,0 +1,186 @@ +//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 armservicelinker_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicelinker/armservicelinker" +) + +// x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2021-11-01-preview/examples/LinkList.json +func ExampleLinkerClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armservicelinker.NewLinkerClient(cred, nil) + pager := client.List("", + 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("LinkerResource.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2021-11-01-preview/examples/Link.json +func ExampleLinkerClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armservicelinker.NewLinkerClient(cred, nil) + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("LinkerResource.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2021-11-01-preview/examples/PutLink.json +func ExampleLinkerClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armservicelinker.NewLinkerClient(cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + armservicelinker.LinkerResource{ + Properties: &armservicelinker.LinkerProperties{ + AuthInfo: &armservicelinker.SecretAuthInfo{ + AuthInfoBase: armservicelinker.AuthInfoBase{ + AuthType: armservicelinker.AuthTypeSecret.ToPtr(), + }, + Name: to.StringPtr(""), + Secret: to.StringPtr(""), + }, + TargetID: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("LinkerResource.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2021-11-01-preview/examples/DeleteLink.json +func ExampleLinkerClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armservicelinker.NewLinkerClient(cred, nil) + poller, err := client.BeginDelete(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2021-11-01-preview/examples/PatchLink.json +func ExampleLinkerClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armservicelinker.NewLinkerClient(cred, nil) + poller, err := client.BeginUpdate(ctx, + "", + "", + armservicelinker.LinkerPatch{ + Properties: &armservicelinker.LinkerProperties{ + AuthInfo: &armservicelinker.ServicePrincipalSecretAuthInfo{ + AuthInfoBase: armservicelinker.AuthInfoBase{ + AuthType: armservicelinker.AuthTypeServicePrincipalSecret.ToPtr(), + }, + ClientID: to.StringPtr(""), + PrincipalID: to.StringPtr(""), + Secret: to.StringPtr(""), + }, + TargetID: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("LinkerResource.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2021-11-01-preview/examples/ValidateLinkFailure.json +func ExampleLinkerClient_BeginValidate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armservicelinker.NewLinkerClient(cred, nil) + poller, err := client.BeginValidate(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2021-11-01-preview/examples/GetConfigurations.json +func ExampleLinkerClient_ListConfigurations() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armservicelinker.NewLinkerClient(cred, nil) + _, err = client.ListConfigurations(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_constants.go b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_constants.go new file mode 100644 index 000000000000..add1375812b1 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_constants.go @@ -0,0 +1,166 @@ +//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 armservicelinker + +const ( + module = "armservicelinker" + version = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// ToPtr returns a *ActionType pointing to the current value. +func (c ActionType) ToPtr() *ActionType { + return &c +} + +// AuthType - The authentication type. +type AuthType string + +const ( + AuthTypeSecret AuthType = "secret" + AuthTypeServicePrincipalCertificate AuthType = "servicePrincipalCertificate" + AuthTypeServicePrincipalSecret AuthType = "servicePrincipalSecret" + AuthTypeSystemAssignedIdentity AuthType = "systemAssignedIdentity" + AuthTypeUserAssignedIdentity AuthType = "userAssignedIdentity" +) + +// PossibleAuthTypeValues returns the possible values for the AuthType const type. +func PossibleAuthTypeValues() []AuthType { + return []AuthType{ + AuthTypeSecret, + AuthTypeServicePrincipalCertificate, + AuthTypeServicePrincipalSecret, + AuthTypeSystemAssignedIdentity, + AuthTypeUserAssignedIdentity, + } +} + +// ToPtr returns a *AuthType pointing to the current value. +func (c AuthType) ToPtr() *AuthType { + return &c +} + +// ClientType - The application client type +type ClientType string + +const ( + ClientTypeDjango ClientType = "django" + ClientTypeDotnet ClientType = "dotnet" + ClientTypeGo ClientType = "go" + ClientTypeJava ClientType = "java" + ClientTypeNodejs ClientType = "nodejs" + ClientTypeNone ClientType = "none" + ClientTypePhp ClientType = "php" + ClientTypePython ClientType = "python" + ClientTypeRuby ClientType = "ruby" + ClientTypeSpringBoot ClientType = "springBoot" +) + +// PossibleClientTypeValues returns the possible values for the ClientType const type. +func PossibleClientTypeValues() []ClientType { + return []ClientType{ + ClientTypeDjango, + ClientTypeDotnet, + ClientTypeGo, + ClientTypeJava, + ClientTypeNodejs, + ClientTypeNone, + ClientTypePhp, + ClientTypePython, + ClientTypeRuby, + ClientTypeSpringBoot, + } +} + +// ToPtr returns a *ClientType pointing to the current value. +func (c ClientType) ToPtr() *ClientType { + return &c +} + +// 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 +} + +// LinkerStatus - Specifies if the linker is healthy. +type LinkerStatus string + +const ( + LinkerStatusHealthy LinkerStatus = "Healthy" + LinkerStatusNotHealthy LinkerStatus = "Not healthy" +) + +// PossibleLinkerStatusValues returns the possible values for the LinkerStatus const type. +func PossibleLinkerStatusValues() []LinkerStatus { + return []LinkerStatus{ + LinkerStatusHealthy, + LinkerStatusNotHealthy, + } +} + +// ToPtr returns a *LinkerStatus pointing to the current value. +func (c LinkerStatus) ToPtr() *LinkerStatus { + return &c +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ToPtr returns a *Origin pointing to the current value. +func (c Origin) ToPtr() *Origin { + return &c +} diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_linker_client.go b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_linker_client.go new file mode 100644 index 000000000000..fb359b219f75 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_linker_client.go @@ -0,0 +1,485 @@ +//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 armservicelinker + +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" +) + +// LinkerClient contains the methods for the Linker group. +// Don't use this type directly, use NewLinkerClient() instead. +type LinkerClient struct { + ep string + pl runtime.Pipeline +} + +// NewLinkerClient creates a new instance of LinkerClient with the specified values. +func NewLinkerClient(credential azcore.TokenCredential, options *arm.ClientOptions) *LinkerClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &LinkerClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update linker resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkerClient) BeginCreateOrUpdate(ctx context.Context, resourceURI string, linkerName string, parameters LinkerResource, options *LinkerBeginCreateOrUpdateOptions) (LinkerCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceURI, linkerName, parameters, options) + if err != nil { + return LinkerCreateOrUpdatePollerResponse{}, err + } + result := LinkerCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LinkerClient.CreateOrUpdate", "azure-async-operation", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return LinkerCreateOrUpdatePollerResponse{}, err + } + result.Poller = &LinkerCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update linker resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkerClient) createOrUpdate(ctx context.Context, resourceURI string, linkerName string, parameters LinkerResource, options *LinkerBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceURI, linkerName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *LinkerClient) createOrUpdateCreateRequest(ctx context.Context, resourceURI string, linkerName string, parameters LinkerResource, options *LinkerBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if linkerName == "" { + return nil, errors.New("parameter linkerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *LinkerClient) 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) +} + +// BeginDelete - Delete a link. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkerClient) BeginDelete(ctx context.Context, resourceURI string, linkerName string, options *LinkerBeginDeleteOptions) (LinkerDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceURI, linkerName, options) + if err != nil { + return LinkerDeletePollerResponse{}, err + } + result := LinkerDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LinkerClient.Delete", "azure-async-operation", resp, client.pl, client.deleteHandleError) + if err != nil { + return LinkerDeletePollerResponse{}, err + } + result.Poller = &LinkerDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a link. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkerClient) deleteOperation(ctx context.Context, resourceURI string, linkerName string, options *LinkerBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceURI, linkerName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *LinkerClient) deleteCreateRequest(ctx context.Context, resourceURI string, linkerName string, options *LinkerBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if linkerName == "" { + return nil, errors.New("parameter linkerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) + 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-11-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 *LinkerClient) 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 - Returns Linker resource for a given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkerClient) Get(ctx context.Context, resourceURI string, linkerName string, options *LinkerGetOptions) (LinkerGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceURI, linkerName, options) + if err != nil { + return LinkerGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LinkerGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LinkerGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *LinkerClient) getCreateRequest(ctx context.Context, resourceURI string, linkerName string, options *LinkerGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if linkerName == "" { + return nil, errors.New("parameter linkerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) + 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-11-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 *LinkerClient) getHandleResponse(resp *http.Response) (LinkerGetResponse, error) { + result := LinkerGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.LinkerResource); err != nil { + return LinkerGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *LinkerClient) 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) +} + +// List - Returns list of Linkers which connects to the resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkerClient) List(resourceURI string, options *LinkerListOptions) *LinkerListPager { + return &LinkerListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceURI, options) + }, + advancer: func(ctx context.Context, resp LinkerListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.LinkerList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *LinkerClient) listCreateRequest(ctx context.Context, resourceURI string, options *LinkerListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *LinkerClient) listHandleResponse(resp *http.Response) (LinkerListResponse, error) { + result := LinkerListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.LinkerList); err != nil { + return LinkerListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *LinkerClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListConfigurations - list source configurations for a linker. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkerClient) ListConfigurations(ctx context.Context, resourceURI string, linkerName string, options *LinkerListConfigurationsOptions) (LinkerListConfigurationsResponse, error) { + req, err := client.listConfigurationsCreateRequest(ctx, resourceURI, linkerName, options) + if err != nil { + return LinkerListConfigurationsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LinkerListConfigurationsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LinkerListConfigurationsResponse{}, client.listConfigurationsHandleError(resp) + } + return client.listConfigurationsHandleResponse(resp) +} + +// listConfigurationsCreateRequest creates the ListConfigurations request. +func (client *LinkerClient) listConfigurationsCreateRequest(ctx context.Context, resourceURI string, linkerName string, options *LinkerListConfigurationsOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/listConfigurations" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if linkerName == "" { + return nil, errors.New("parameter linkerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listConfigurationsHandleResponse handles the ListConfigurations response. +func (client *LinkerClient) listConfigurationsHandleResponse(resp *http.Response) (LinkerListConfigurationsResponse, error) { + result := LinkerListConfigurationsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SourceConfigurationResult); err != nil { + return LinkerListConfigurationsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listConfigurationsHandleError handles the ListConfigurations error response. +func (client *LinkerClient) listConfigurationsHandleError(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) +} + +// BeginUpdate - Operation to update an existing link. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkerClient) BeginUpdate(ctx context.Context, resourceURI string, linkerName string, parameters LinkerPatch, options *LinkerBeginUpdateOptions) (LinkerUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceURI, linkerName, parameters, options) + if err != nil { + return LinkerUpdatePollerResponse{}, err + } + result := LinkerUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LinkerClient.Update", "azure-async-operation", resp, client.pl, client.updateHandleError) + if err != nil { + return LinkerUpdatePollerResponse{}, err + } + result.Poller = &LinkerUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Operation to update an existing link. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkerClient) update(ctx context.Context, resourceURI string, linkerName string, parameters LinkerPatch, options *LinkerBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceURI, linkerName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *LinkerClient) updateCreateRequest(ctx context.Context, resourceURI string, linkerName string, parameters LinkerPatch, options *LinkerBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if linkerName == "" { + return nil, errors.New("parameter linkerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleError handles the Update error response. +func (client *LinkerClient) 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) +} + +// BeginValidate - Validate a link. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkerClient) BeginValidate(ctx context.Context, resourceURI string, linkerName string, options *LinkerBeginValidateOptions) (LinkerValidatePollerResponse, error) { + resp, err := client.validate(ctx, resourceURI, linkerName, options) + if err != nil { + return LinkerValidatePollerResponse{}, err + } + result := LinkerValidatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LinkerClient.Validate", "azure-async-operation", resp, client.pl, client.validateHandleError) + if err != nil { + return LinkerValidatePollerResponse{}, err + } + result.Poller = &LinkerValidatePoller{ + pt: pt, + } + return result, nil +} + +// Validate - Validate a link. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LinkerClient) validate(ctx context.Context, resourceURI string, linkerName string, options *LinkerBeginValidateOptions) (*http.Response, error) { + req, err := client.validateCreateRequest(ctx, resourceURI, linkerName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.validateHandleError(resp) + } + return resp, nil +} + +// validateCreateRequest creates the Validate request. +func (client *LinkerClient) validateCreateRequest(ctx context.Context, resourceURI string, linkerName string, options *LinkerBeginValidateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/validateLinker" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if linkerName == "" { + return nil, errors.New("parameter linkerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkerName}", url.PathEscape(linkerName)) + 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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// validateHandleError handles the Validate error response. +func (client *LinkerClient) validateHandleError(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/servicelinker/armservicelinker/zz_generated_models.go b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_models.go new file mode 100644 index 000000000000..0d55c82eea28 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_models.go @@ -0,0 +1,707 @@ +//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 armservicelinker + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// AuthInfoBaseClassification provides polymorphic access to related types. +// Call the interface's GetAuthInfoBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AuthInfoBase, *SecretAuthInfo, *ServicePrincipalCertificateAuthInfo, *ServicePrincipalSecretAuthInfo, *SystemAssignedIdentityAuthInfo, +// - *UserAssignedIdentityAuthInfo +type AuthInfoBaseClassification interface { + // GetAuthInfoBase returns the AuthInfoBase content of the underlying type. + GetAuthInfoBase() *AuthInfoBase +} + +// AuthInfoBase - The authentication info +type AuthInfoBase struct { + // REQUIRED; The authentication type. + AuthType *AuthType `json:"authType,omitempty"` +} + +// GetAuthInfoBase implements the AuthInfoBaseClassification interface for type AuthInfoBase. +func (a *AuthInfoBase) GetAuthInfoBase() *AuthInfoBase { return a } + +// UnmarshalJSON implements the json.Unmarshaller interface for type AuthInfoBase. +func (a *AuthInfoBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return a.unmarshalInternal(rawMsg) +} + +func (a AuthInfoBase) marshalInternal(objectMap map[string]interface{}, discValue AuthType) { + a.AuthType = &discValue + objectMap["authType"] = a.AuthType +} + +func (a *AuthInfoBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "authType": + err = unpopulate(val, &a.AuthType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// 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 +} + +// LinkerBeginCreateOrUpdateOptions contains the optional parameters for the Linker.BeginCreateOrUpdate method. +type LinkerBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// LinkerBeginDeleteOptions contains the optional parameters for the Linker.BeginDelete method. +type LinkerBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// LinkerBeginUpdateOptions contains the optional parameters for the Linker.BeginUpdate method. +type LinkerBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// LinkerBeginValidateOptions contains the optional parameters for the Linker.BeginValidate method. +type LinkerBeginValidateOptions struct { + // placeholder for future optional parameters +} + +// LinkerGetOptions contains the optional parameters for the Linker.Get method. +type LinkerGetOptions struct { + // placeholder for future optional parameters +} + +// LinkerList - The list of Linker. +type LinkerList struct { + // The link used to get the next page of Linker list. + NextLink *string `json:"nextLink,omitempty"` + + // The list of Linkers. + Value []*LinkerResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LinkerList. +func (l LinkerList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// LinkerListConfigurationsOptions contains the optional parameters for the Linker.ListConfigurations method. +type LinkerListConfigurationsOptions struct { + // placeholder for future optional parameters +} + +// LinkerListOptions contains the optional parameters for the Linker.List method. +type LinkerListOptions struct { + // placeholder for future optional parameters +} + +// LinkerPatch - A linker to be updated. +type LinkerPatch struct { + // Linker properties + Properties *LinkerProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LinkerPatch. +func (l LinkerPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", l.Properties) + return json.Marshal(objectMap) +} + +// LinkerProperties - The properties of the linker. +type LinkerProperties struct { + // The authentication type. + AuthInfo AuthInfoBaseClassification `json:"authInfo,omitempty"` + + // The application client type + ClientType *ClientType `json:"clientType,omitempty"` + + // The resource Id of target service. + TargetID *string `json:"targetId,omitempty"` + + // READ-ONLY; The provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type LinkerProperties. +func (l LinkerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authInfo", l.AuthInfo) + populate(objectMap, "clientType", l.ClientType) + populate(objectMap, "provisioningState", l.ProvisioningState) + populate(objectMap, "targetId", l.TargetID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinkerProperties. +func (l *LinkerProperties) 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 "authInfo": + l.AuthInfo, err = unmarshalAuthInfoBaseClassification(val) + delete(rawMsg, key) + case "clientType": + err = unpopulate(val, &l.ClientType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &l.ProvisioningState) + delete(rawMsg, key) + case "targetId": + err = unpopulate(val, &l.TargetID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// LinkerResource - Linker of source and target resource +type LinkerResource struct { + ProxyResource + // REQUIRED; The properties of the linker. + Properties *LinkerProperties `json:"properties,omitempty"` + + // READ-ONLY; The system data. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" + Origin *Origin `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual + // Machine". + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location +type ProxyResource struct { + Resource +} + +// 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"` +} + +// SecretAuthInfo - The authentication info when authType is secret +type SecretAuthInfo struct { + AuthInfoBase + // Username or account name for secret auth. + Name *string `json:"name,omitempty"` + + // Password or account key for secret auth. + Secret *string `json:"secret,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SecretAuthInfo. +func (s SecretAuthInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.AuthInfoBase.marshalInternal(objectMap, AuthTypeSecret) + populate(objectMap, "name", s.Name) + populate(objectMap, "secret", s.Secret) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecretAuthInfo. +func (s *SecretAuthInfo) 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 "name": + err = unpopulate(val, &s.Name) + delete(rawMsg, key) + case "secret": + err = unpopulate(val, &s.Secret) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := s.AuthInfoBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ServicePrincipalCertificateAuthInfo - The authentication info when authType is servicePrincipal certificate +type ServicePrincipalCertificateAuthInfo struct { + AuthInfoBase + // REQUIRED; ServicePrincipal certificate for servicePrincipal auth. + Certificate *string `json:"certificate,omitempty"` + + // REQUIRED; Application clientId for servicePrincipal auth. + ClientID *string `json:"clientId,omitempty"` + + // REQUIRED; Principal Id for servicePrincipal auth. + PrincipalID *string `json:"principalId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServicePrincipalCertificateAuthInfo. +func (s ServicePrincipalCertificateAuthInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.AuthInfoBase.marshalInternal(objectMap, AuthTypeServicePrincipalCertificate) + populate(objectMap, "certificate", s.Certificate) + populate(objectMap, "clientId", s.ClientID) + populate(objectMap, "principalId", s.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServicePrincipalCertificateAuthInfo. +func (s *ServicePrincipalCertificateAuthInfo) 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 "certificate": + err = unpopulate(val, &s.Certificate) + delete(rawMsg, key) + case "clientId": + err = unpopulate(val, &s.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, &s.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := s.AuthInfoBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ServicePrincipalSecretAuthInfo - The authentication info when authType is servicePrincipal secret +type ServicePrincipalSecretAuthInfo struct { + AuthInfoBase + // REQUIRED; ServicePrincipal application clientId for servicePrincipal auth. + ClientID *string `json:"clientId,omitempty"` + + // REQUIRED; Principal Id for servicePrincipal auth. + PrincipalID *string `json:"principalId,omitempty"` + + // REQUIRED; Secret for servicePrincipal auth. + Secret *string `json:"secret,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServicePrincipalSecretAuthInfo. +func (s ServicePrincipalSecretAuthInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.AuthInfoBase.marshalInternal(objectMap, AuthTypeServicePrincipalSecret) + populate(objectMap, "clientId", s.ClientID) + populate(objectMap, "principalId", s.PrincipalID) + populate(objectMap, "secret", s.Secret) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServicePrincipalSecretAuthInfo. +func (s *ServicePrincipalSecretAuthInfo) 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 "clientId": + err = unpopulate(val, &s.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, &s.PrincipalID) + delete(rawMsg, key) + case "secret": + err = unpopulate(val, &s.Secret) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := s.AuthInfoBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// SourceConfiguration - A configuration item for source resource +type SourceConfiguration struct { + // The name of setting. + Name *string `json:"name,omitempty"` + + // The value of setting + Value *string `json:"value,omitempty"` +} + +// SourceConfigurationResult - Configurations for source resource, include appSettings, connectionString and serviceBindings +type SourceConfigurationResult struct { + // The configuration properties for source resource. + Configurations []*SourceConfiguration `json:"configurations,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SourceConfigurationResult. +func (s SourceConfigurationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "configurations", s.Configurations) + return json.Marshal(objectMap) +} + +// SystemAssignedIdentityAuthInfo - The authentication info when authType is systemAssignedIdentity +type SystemAssignedIdentityAuthInfo struct { + AuthInfoBase +} + +// MarshalJSON implements the json.Marshaller interface for type SystemAssignedIdentityAuthInfo. +func (s SystemAssignedIdentityAuthInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.AuthInfoBase.marshalInternal(objectMap, AuthTypeSystemAssignedIdentity) + 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 +} + +// UserAssignedIdentityAuthInfo - The authentication info when authType is userAssignedIdentity +type UserAssignedIdentityAuthInfo struct { + AuthInfoBase + // REQUIRED; Client Id for userAssignedIdentity. + ClientID *string `json:"clientId,omitempty"` + + // REQUIRED; Subscription id for userAssignedIdentity. + SubscriptionID *string `json:"subscriptionId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentityAuthInfo. +func (u UserAssignedIdentityAuthInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + u.AuthInfoBase.marshalInternal(objectMap, AuthTypeUserAssignedIdentity) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "subscriptionId", u.SubscriptionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentityAuthInfo. +func (u *UserAssignedIdentityAuthInfo) 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 "clientId": + err = unpopulate(val, &u.ClientID) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, &u.SubscriptionID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := u.AuthInfoBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ValidateResult - The validation result for a linker. +type ValidateResult struct { + // The authentication type. + AuthType *AuthType `json:"authType,omitempty"` + + // Specifies if the linker is healthy. + LinkerStatus *LinkerStatus `json:"linkerStatus,omitempty"` + + // The linker name. + Name *string `json:"name,omitempty"` + + // The reason of the error. + Reason *string `json:"reason,omitempty"` + + // The end time of the validation report. + ReportEndTimeUTC *time.Time `json:"reportEndTimeUtc,omitempty"` + + // The start time of the validation report. + ReportStartTimeUTC *time.Time `json:"reportStartTimeUtc,omitempty"` + + // The resource Id of target service. + TargetID *string `json:"targetId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ValidateResult. +func (v ValidateResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authType", v.AuthType) + populate(objectMap, "linkerStatus", v.LinkerStatus) + populate(objectMap, "name", v.Name) + populate(objectMap, "reason", v.Reason) + populateTimeRFC3339(objectMap, "reportEndTimeUtc", v.ReportEndTimeUTC) + populateTimeRFC3339(objectMap, "reportStartTimeUtc", v.ReportStartTimeUTC) + populate(objectMap, "targetId", v.TargetID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateResult. +func (v *ValidateResult) 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 "authType": + err = unpopulate(val, &v.AuthType) + delete(rawMsg, key) + case "linkerStatus": + err = unpopulate(val, &v.LinkerStatus) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &v.Name) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, &v.Reason) + delete(rawMsg, key) + case "reportEndTimeUtc": + err = unpopulateTimeRFC3339(val, &v.ReportEndTimeUTC) + delete(rawMsg, key) + case "reportStartTimeUtc": + err = unpopulateTimeRFC3339(val, &v.ReportStartTimeUTC) + delete(rawMsg, key) + case "targetId": + err = unpopulate(val, &v.TargetID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +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/servicelinker/armservicelinker/zz_generated_operations_client.go b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_operations_client.go new file mode 100644 index 000000000000..91fd33d3d629 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_operations_client.go @@ -0,0 +1,89 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armservicelinker + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists the available ServiceLinker REST API operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(options *OperationsListOptions) *OperationsListPager { + return &OperationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ServiceLinker/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-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_pagers.go b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_pagers.go new file mode 100644 index 000000000000..72a47161ae0b --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_pagers.go @@ -0,0 +1,125 @@ +//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 armservicelinker + +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" +) + +// LinkerListPager provides operations for iterating over paged responses. +type LinkerListPager struct { + client *LinkerClient + current LinkerListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, LinkerListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *LinkerListPager) 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 *LinkerListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.LinkerList.NextLink == nil || len(*p.current.LinkerList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current LinkerListResponse page. +func (p *LinkerListPager) PageResponse() LinkerListResponse { + return p.current +} + +// OperationsListPager provides operations for iterating over paged responses. +type OperationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *OperationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationsListResponse page. +func (p *OperationsListPager) PageResponse() OperationsListResponse { + return p.current +} diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_pollers.go b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_pollers.go new file mode 100644 index 000000000000..ee4faed830c9 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_pollers.go @@ -0,0 +1,187 @@ +//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 armservicelinker + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// LinkerCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type LinkerCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LinkerCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *LinkerCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final LinkerCreateOrUpdateResponse will be returned. +func (p *LinkerCreateOrUpdatePoller) FinalResponse(ctx context.Context) (LinkerCreateOrUpdateResponse, error) { + respType := LinkerCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.LinkerResource) + if err != nil { + return LinkerCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *LinkerCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// LinkerDeletePoller provides polling facilities until the operation reaches a terminal state. +type LinkerDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LinkerDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *LinkerDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final LinkerDeleteResponse will be returned. +func (p *LinkerDeletePoller) FinalResponse(ctx context.Context) (LinkerDeleteResponse, error) { + respType := LinkerDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return LinkerDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *LinkerDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// LinkerUpdatePoller provides polling facilities until the operation reaches a terminal state. +type LinkerUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LinkerUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *LinkerUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final LinkerUpdateResponse will be returned. +func (p *LinkerUpdatePoller) FinalResponse(ctx context.Context) (LinkerUpdateResponse, error) { + respType := LinkerUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.LinkerResource) + if err != nil { + return LinkerUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *LinkerUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// LinkerValidatePoller provides polling facilities until the operation reaches a terminal state. +type LinkerValidatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LinkerValidatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *LinkerValidatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final LinkerValidateResponse will be returned. +func (p *LinkerValidatePoller) FinalResponse(ctx context.Context) (LinkerValidateResponse, error) { + respType := LinkerValidateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ValidateResult) + if err != nil { + return LinkerValidateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *LinkerValidatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_polymorphic_helpers.go new file mode 100644 index 000000000000..e142adf8c6de --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_polymorphic_helpers.go @@ -0,0 +1,75 @@ +//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 armservicelinker + +import "encoding/json" + +func unmarshalAuthInfoBaseClassification(rawMsg json.RawMessage) (AuthInfoBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b AuthInfoBaseClassification + switch m["authType"] { + case string(AuthTypeSecret): + b = &SecretAuthInfo{} + case string(AuthTypeServicePrincipalCertificate): + b = &ServicePrincipalCertificateAuthInfo{} + case string(AuthTypeServicePrincipalSecret): + b = &ServicePrincipalSecretAuthInfo{} + case string(AuthTypeSystemAssignedIdentity): + b = &SystemAssignedIdentityAuthInfo{} + case string(AuthTypeUserAssignedIdentity): + b = &UserAssignedIdentityAuthInfo{} + default: + b = &AuthInfoBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalAuthInfoBaseClassificationArray(rawMsg json.RawMessage) ([]AuthInfoBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]AuthInfoBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalAuthInfoBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalAuthInfoBaseClassificationMap(rawMsg json.RawMessage) (map[string]AuthInfoBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]AuthInfoBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalAuthInfoBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_response_types.go b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_response_types.go new file mode 100644 index 000000000000..51aa0d7cca91 --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_response_types.go @@ -0,0 +1,266 @@ +//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 armservicelinker + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// LinkerCreateOrUpdatePollerResponse contains the response from method Linker.CreateOrUpdate. +type LinkerCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *LinkerCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l LinkerCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LinkerCreateOrUpdateResponse, error) { + respType := LinkerCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.LinkerResource) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LinkerCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *LinkerCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *LinkerClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LinkerClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &LinkerCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LinkerCreateOrUpdateResponse contains the response from method Linker.CreateOrUpdate. +type LinkerCreateOrUpdateResponse struct { + LinkerCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkerCreateOrUpdateResult contains the result from method Linker.CreateOrUpdate. +type LinkerCreateOrUpdateResult struct { + LinkerResource +} + +// LinkerDeletePollerResponse contains the response from method Linker.Delete. +type LinkerDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *LinkerDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l LinkerDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LinkerDeleteResponse, error) { + respType := LinkerDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LinkerDeletePollerResponse from the provided client and resume token. +func (l *LinkerDeletePollerResponse) Resume(ctx context.Context, client *LinkerClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LinkerClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &LinkerDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LinkerDeleteResponse contains the response from method Linker.Delete. +type LinkerDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkerGetResponse contains the response from method Linker.Get. +type LinkerGetResponse struct { + LinkerGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkerGetResult contains the result from method Linker.Get. +type LinkerGetResult struct { + LinkerResource +} + +// LinkerListConfigurationsResponse contains the response from method Linker.ListConfigurations. +type LinkerListConfigurationsResponse struct { + LinkerListConfigurationsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkerListConfigurationsResult contains the result from method Linker.ListConfigurations. +type LinkerListConfigurationsResult struct { + SourceConfigurationResult +} + +// LinkerListResponse contains the response from method Linker.List. +type LinkerListResponse struct { + LinkerListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkerListResult contains the result from method Linker.List. +type LinkerListResult struct { + LinkerList +} + +// LinkerUpdatePollerResponse contains the response from method Linker.Update. +type LinkerUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *LinkerUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l LinkerUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LinkerUpdateResponse, error) { + respType := LinkerUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.LinkerResource) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LinkerUpdatePollerResponse from the provided client and resume token. +func (l *LinkerUpdatePollerResponse) Resume(ctx context.Context, client *LinkerClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LinkerClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &LinkerUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LinkerUpdateResponse contains the response from method Linker.Update. +type LinkerUpdateResponse struct { + LinkerUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkerUpdateResult contains the result from method Linker.Update. +type LinkerUpdateResult struct { + LinkerResource +} + +// LinkerValidatePollerResponse contains the response from method Linker.Validate. +type LinkerValidatePollerResponse struct { + // Poller contains an initialized poller. + Poller *LinkerValidatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l LinkerValidatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LinkerValidateResponse, error) { + respType := LinkerValidateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ValidateResult) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LinkerValidatePollerResponse from the provided client and resume token. +func (l *LinkerValidatePollerResponse) Resume(ctx context.Context, client *LinkerClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LinkerClient.Validate", token, client.pl, client.validateHandleError) + if err != nil { + return err + } + poller := &LinkerValidatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LinkerValidateResponse contains the response from method Linker.Validate. +type LinkerValidateResponse struct { + LinkerValidateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkerValidateResult contains the result from method Linker.Validate. +type LinkerValidateResult struct { + ValidateResult +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} diff --git a/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_time_rfc3339.go b/sdk/resourcemanager/servicelinker/armservicelinker/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..a161b8a25e4d --- /dev/null +++ b/sdk/resourcemanager/servicelinker/armservicelinker/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 armservicelinker + +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 +}