From 58106b7800c9cc3a643523ec878ea30032ffb3b4 Mon Sep 17 00:00:00 2001 From: Jiahui Peng <46921893+Alancere@users.noreply.github.com> Date: Tue, 7 Dec 2021 17:09:45 +0800 Subject: [PATCH] [Release] sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/0.1.0 (#16383) * [Release] sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/0.1.0 generation from spec commit: 3c5135f8325eaf79be7b137cae363bdcba028c17 * Update CHANGELOG.md Co-authored-by: Dapeng Zhang --- .../armhybridkubernetes/CHANGELOG.md | 5 + .../armhybridkubernetes/LICENSE.txt | 21 + .../armhybridkubernetes/README.md | 75 +++ .../armhybridkubernetes/autorest.md | 13 + .../armhybridkubernetes/build.go | 7 + .../armhybridkubernetes/ci.yml | 27 + .../armhybridkubernetes/go.mod | 9 + .../armhybridkubernetes/go.sum | 45 ++ .../armhybridkubernetes/go_mod_tidy_hack.go | 13 + ...ed_example_connectedcluster_client_test.go | 157 +++++ ...enerated_example_operations_client_test.go | 33 ++ .../zz_generated_connectedcluster_client.go | 502 ++++++++++++++++ .../zz_generated_constants.go | 163 ++++++ .../zz_generated_models.go | 554 ++++++++++++++++++ .../zz_generated_operations_client.go | 89 +++ .../zz_generated_pagers.go | 179 ++++++ .../zz_generated_pollers.go | 101 ++++ .../zz_generated_response_types.go | 186 ++++++ .../zz_generated_time_rfc3339.go | 85 +++ 19 files changed, 2264 insertions(+) create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/CHANGELOG.md create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/LICENSE.txt create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/README.md create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/autorest.md create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/build.go create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/ci.yml create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/go.mod create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/go.sum create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/go_mod_tidy_hack.go create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/ze_generated_example_connectedcluster_client_test.go create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/ze_generated_example_operations_client_test.go create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_connectedcluster_client.go create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_constants.go create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_models.go create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_operations_client.go create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_pagers.go create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_pollers.go create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_response_types.go create mode 100644 sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_time_rfc3339.go diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/CHANGELOG.md b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/CHANGELOG.md new file mode 100644 index 0000000000..549748e293 --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-07) + +- Init release. diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/LICENSE.txt b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/LICENSE.txt new file mode 100644 index 0000000000..dc0c2ffb3d --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/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/hybridkubernetes/armhybridkubernetes/README.md b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/README.md new file mode 100644 index 0000000000..36d0d1f118 --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/README.md @@ -0,0 +1,75 @@ +# Azure Kubernetes Connect Service Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes) + +The `armhybridkubernetes` module provides operations for working with Azure Kubernetes Connect Service. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes) + +# 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 Kubernetes Connect Service module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Kubernetes Connect Service. 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 Kubernetes Connect Service 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 := armhybridkubernetes.NewConnectedClusterClient(, 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 := armhybridkubernetes.NewConnectedClusterClient(, 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 `Kubernetes Connect Service` 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/hybridkubernetes/armhybridkubernetes/autorest.md b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/autorest.md new file mode 100644 index 0000000000..4c7f47ea68 --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/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/3c5135f8325eaf79be7b137cae363bdcba028c17/specification/hybridkubernetes/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/3c5135f8325eaf79be7b137cae363bdcba028c17/specification/hybridkubernetes/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/hybridkubernetes/armhybridkubernetes/build.go b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/build.go new file mode 100644 index 0000000000..a45dbdf99a --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/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/hybridkubernetes/armhybridkubernetes + +package armhybridkubernetes diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/ci.yml b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/ci.yml new file mode 100644 index 0000000000..5fe3cd13ca --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/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/hybridkubernetes/armhybridkubernetes/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/hybridkubernetes/armhybridkubernetes' diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/go.mod b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/go.mod new file mode 100644 index 0000000000..fa64e0646e --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/go.mod @@ -0,0 +1,9 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v59.4.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/hybridkubernetes/armhybridkubernetes/go.sum b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/go.sum new file mode 100644 index 0000000000..b5602e3433 --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/go.sum @@ -0,0 +1,45 @@ +github.com/Azure/azure-sdk-for-go v59.4.0+incompatible h1:gDA8odnngdNd3KYHL2NoK1j9vpWBgEnFSjKKLpkC8Aw= +github.com/Azure/azure-sdk-for-go v59.4.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/hybridkubernetes/armhybridkubernetes/go_mod_tidy_hack.go b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/go_mod_tidy_hack.go new file mode 100644 index 0000000000..97f8f1be2c --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/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 armhybridkubernetes + +// 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/hybridkubernetes/armhybridkubernetes/ze_generated_example_connectedcluster_client_test.go b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/ze_generated_example_connectedcluster_client_test.go new file mode 100644 index 0000000000..d805650e16 --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/ze_generated_example_connectedcluster_client_test.go @@ -0,0 +1,157 @@ +//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 armhybridkubernetes_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes" +) + +// x-ms-original-file: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/stable/2021-10-01/examples/CreateClusterExample.json +func ExampleConnectedClusterClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armhybridkubernetes.NewConnectedClusterClient("", cred, nil) + poller, err := client.BeginCreate(ctx, + "", + "", + armhybridkubernetes.ConnectedCluster{}, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("ConnectedCluster.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/stable/2021-10-01/examples/UpdateClusterExample.json +func ExampleConnectedClusterClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armhybridkubernetes.NewConnectedClusterClient("", cred, nil) + res, err := client.Update(ctx, + "", + "", + armhybridkubernetes.ConnectedClusterPatch{}, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("ConnectedCluster.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/stable/2021-10-01/examples/GetClusterExample.json +func ExampleConnectedClusterClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armhybridkubernetes.NewConnectedClusterClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("ConnectedCluster.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/stable/2021-10-01/examples/DeleteClusterExample.json +func ExampleConnectedClusterClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armhybridkubernetes.NewConnectedClusterClient("", 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/hybridkubernetes/resource-manager/Microsoft.Kubernetes/stable/2021-10-01/examples/ConnectedClustersListClusterCredentialResultHPAAD.json +func ExampleConnectedClusterClient_ListClusterUserCredential() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armhybridkubernetes.NewConnectedClusterClient("", cred, nil) + _, err = client.ListClusterUserCredential(ctx, + "", + "", + armhybridkubernetes.ListClusterUserCredentialProperties{}, + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/stable/2021-10-01/examples/GetClustersByResourceGroupExample.json +func ExampleConnectedClusterClient_ListByResourceGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armhybridkubernetes.NewConnectedClusterClient("", cred, nil) + pager := client.ListByResourceGroup("", + nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("ConnectedCluster.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/stable/2021-10-01/examples/GetClustersBySubscriptionExample.json +func ExampleConnectedClusterClient_ListBySubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armhybridkubernetes.NewConnectedClusterClient("", cred, nil) + pager := client.ListBySubscription(nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("ConnectedCluster.ID: %s\n", *v.ID) + } + } +} diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/ze_generated_example_operations_client_test.go new file mode 100644 index 0000000000..7907086c97 --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/ze_generated_example_operations_client_test.go @@ -0,0 +1,33 @@ +//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 armhybridkubernetes_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes" +) + +// x-ms-original-file: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/stable/2021-10-01/examples/ListConnectedClusterOperationsExample.json +func ExampleOperationsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armhybridkubernetes.NewOperationsClient(cred, nil) + pager := client.Get(nil) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + } +} diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_connectedcluster_client.go b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_connectedcluster_client.go new file mode 100644 index 0000000000..4476451cf5 --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_connectedcluster_client.go @@ -0,0 +1,502 @@ +//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 armhybridkubernetes + +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" +) + +// ConnectedClusterClient contains the methods for the ConnectedCluster group. +// Don't use this type directly, use NewConnectedClusterClient() instead. +type ConnectedClusterClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewConnectedClusterClient creates a new instance of ConnectedClusterClient with the specified values. +func NewConnectedClusterClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ConnectedClusterClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ConnectedClusterClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreate - API to register a new Kubernetes cluster and create a tracked resource in Azure Resource Manager (ARM). +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedClusterClient) BeginCreate(ctx context.Context, resourceGroupName string, clusterName string, connectedCluster ConnectedCluster, options *ConnectedClusterBeginCreateOptions) (ConnectedClusterCreatePollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, clusterName, connectedCluster, options) + if err != nil { + return ConnectedClusterCreatePollerResponse{}, err + } + result := ConnectedClusterCreatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ConnectedClusterClient.Create", "azure-async-operation", resp, client.pl, client.createHandleError) + if err != nil { + return ConnectedClusterCreatePollerResponse{}, err + } + result.Poller = &ConnectedClusterCreatePoller{ + pt: pt, + } + return result, nil +} + +// Create - API to register a new Kubernetes cluster and create a tracked resource in Azure Resource Manager (ARM). +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedClusterClient) create(ctx context.Context, resourceGroupName string, clusterName string, connectedCluster ConnectedCluster, options *ConnectedClusterBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, clusterName, connectedCluster, 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.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *ConnectedClusterClient) createCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, connectedCluster ConnectedCluster, options *ConnectedClusterBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, connectedCluster) +} + +// createHandleError handles the Create error response. +func (client *ConnectedClusterClient) createHandleError(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 connected cluster, removing the tracked resource in Azure Resource Manager (ARM). +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedClusterClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, options *ConnectedClusterBeginDeleteOptions) (ConnectedClusterDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ConnectedClusterDeletePollerResponse{}, err + } + result := ConnectedClusterDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ConnectedClusterClient.Delete", "location", resp, client.pl, client.deleteHandleError) + if err != nil { + return ConnectedClusterDeletePollerResponse{}, err + } + result.Poller = &ConnectedClusterDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a connected cluster, removing the tracked resource in Azure Resource Manager (ARM). +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedClusterClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, options *ConnectedClusterBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, 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 *ConnectedClusterClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ConnectedClusterBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ConnectedClusterClient) 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 the properties of the specified connected cluster, including name, identity, properties, and additional cluster details. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedClusterClient) Get(ctx context.Context, resourceGroupName string, clusterName string, options *ConnectedClusterGetOptions) (ConnectedClusterGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ConnectedClusterGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ConnectedClusterGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ConnectedClusterGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ConnectedClusterClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ConnectedClusterGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ConnectedClusterClient) getHandleResponse(resp *http.Response) (ConnectedClusterGetResponse, error) { + result := ConnectedClusterGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ConnectedCluster); err != nil { + return ConnectedClusterGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ConnectedClusterClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - API to enumerate registered connected K8s clusters under a Resource Group +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedClusterClient) ListByResourceGroup(resourceGroupName string, options *ConnectedClusterListByResourceGroupOptions) *ConnectedClusterListByResourceGroupPager { + return &ConnectedClusterListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp ConnectedClusterListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ConnectedClusterList.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ConnectedClusterClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ConnectedClusterListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ConnectedClusterClient) listByResourceGroupHandleResponse(resp *http.Response) (ConnectedClusterListByResourceGroupResponse, error) { + result := ConnectedClusterListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ConnectedClusterList); err != nil { + return ConnectedClusterListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *ConnectedClusterClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - API to enumerate registered connected K8s clusters under a Subscription +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedClusterClient) ListBySubscription(options *ConnectedClusterListBySubscriptionOptions) *ConnectedClusterListBySubscriptionPager { + return &ConnectedClusterListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp ConnectedClusterListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ConnectedClusterList.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ConnectedClusterClient) listBySubscriptionCreateRequest(ctx context.Context, options *ConnectedClusterListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Kubernetes/connectedClusters" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *ConnectedClusterClient) listBySubscriptionHandleResponse(resp *http.Response) (ConnectedClusterListBySubscriptionResponse, error) { + result := ConnectedClusterListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ConnectedClusterList); err != nil { + return ConnectedClusterListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *ConnectedClusterClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListClusterUserCredential - Gets cluster user credentials of the connected cluster with a specified resource group and name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedClusterClient) ListClusterUserCredential(ctx context.Context, resourceGroupName string, clusterName string, properties ListClusterUserCredentialProperties, options *ConnectedClusterListClusterUserCredentialOptions) (ConnectedClusterListClusterUserCredentialResponse, error) { + req, err := client.listClusterUserCredentialCreateRequest(ctx, resourceGroupName, clusterName, properties, options) + if err != nil { + return ConnectedClusterListClusterUserCredentialResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ConnectedClusterListClusterUserCredentialResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ConnectedClusterListClusterUserCredentialResponse{}, client.listClusterUserCredentialHandleError(resp) + } + return client.listClusterUserCredentialHandleResponse(resp) +} + +// listClusterUserCredentialCreateRequest creates the ListClusterUserCredential request. +func (client *ConnectedClusterClient) listClusterUserCredentialCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, properties ListClusterUserCredentialProperties, options *ConnectedClusterListClusterUserCredentialOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}/listClusterUserCredential" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, properties) +} + +// listClusterUserCredentialHandleResponse handles the ListClusterUserCredential response. +func (client *ConnectedClusterClient) listClusterUserCredentialHandleResponse(resp *http.Response) (ConnectedClusterListClusterUserCredentialResponse, error) { + result := ConnectedClusterListClusterUserCredentialResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CredentialResults); err != nil { + return ConnectedClusterListClusterUserCredentialResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listClusterUserCredentialHandleError handles the ListClusterUserCredential error response. +func (client *ConnectedClusterClient) listClusterUserCredentialHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - API to update certain properties of the connected cluster resource +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedClusterClient) Update(ctx context.Context, resourceGroupName string, clusterName string, connectedClusterPatch ConnectedClusterPatch, options *ConnectedClusterUpdateOptions) (ConnectedClusterUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterName, connectedClusterPatch, options) + if err != nil { + return ConnectedClusterUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ConnectedClusterUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ConnectedClusterUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ConnectedClusterClient) updateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, connectedClusterPatch ConnectedClusterPatch, options *ConnectedClusterUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, connectedClusterPatch) +} + +// updateHandleResponse handles the Update response. +func (client *ConnectedClusterClient) updateHandleResponse(resp *http.Response) (ConnectedClusterUpdateResponse, error) { + result := ConnectedClusterUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ConnectedCluster); err != nil { + return ConnectedClusterUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *ConnectedClusterClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_constants.go b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_constants.go new file mode 100644 index 0000000000..ad8d2b4a1d --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_constants.go @@ -0,0 +1,163 @@ +//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 armhybridkubernetes + +const ( + module = "armhybridkubernetes" + version = "v0.1.0" +) + +// AuthenticationMethod - The mode of client authentication. +type AuthenticationMethod string + +const ( + AuthenticationMethodAAD AuthenticationMethod = "AAD" + AuthenticationMethodToken AuthenticationMethod = "Token" +) + +// PossibleAuthenticationMethodValues returns the possible values for the AuthenticationMethod const type. +func PossibleAuthenticationMethodValues() []AuthenticationMethod { + return []AuthenticationMethod{ + AuthenticationMethodAAD, + AuthenticationMethodToken, + } +} + +// ToPtr returns a *AuthenticationMethod pointing to the current value. +func (c AuthenticationMethod) ToPtr() *AuthenticationMethod { + return &c +} + +// ConnectivityStatus - Represents the connectivity status of the connected cluster. +type ConnectivityStatus string + +const ( + ConnectivityStatusConnected ConnectivityStatus = "Connected" + ConnectivityStatusConnecting ConnectivityStatus = "Connecting" + ConnectivityStatusExpired ConnectivityStatus = "Expired" + ConnectivityStatusOffline ConnectivityStatus = "Offline" +) + +// PossibleConnectivityStatusValues returns the possible values for the ConnectivityStatus const type. +func PossibleConnectivityStatusValues() []ConnectivityStatus { + return []ConnectivityStatus{ + ConnectivityStatusConnected, + ConnectivityStatusConnecting, + ConnectivityStatusExpired, + ConnectivityStatusOffline, + } +} + +// ToPtr returns a *ConnectivityStatus pointing to the current value. +func (c ConnectivityStatus) ToPtr() *ConnectivityStatus { + 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 +} + +// LastModifiedByType - The type of identity that last modified the resource. +type LastModifiedByType string + +const ( + LastModifiedByTypeApplication LastModifiedByType = "Application" + LastModifiedByTypeKey LastModifiedByType = "Key" + LastModifiedByTypeManagedIdentity LastModifiedByType = "ManagedIdentity" + LastModifiedByTypeUser LastModifiedByType = "User" +) + +// PossibleLastModifiedByTypeValues returns the possible values for the LastModifiedByType const type. +func PossibleLastModifiedByTypeValues() []LastModifiedByType { + return []LastModifiedByType{ + LastModifiedByTypeApplication, + LastModifiedByTypeKey, + LastModifiedByTypeManagedIdentity, + LastModifiedByTypeUser, + } +} + +// ToPtr returns a *LastModifiedByType pointing to the current value. +func (c LastModifiedByType) ToPtr() *LastModifiedByType { + return &c +} + +// ProvisioningState - The current deployment state of connectedClusters. +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// ResourceIdentityType - The type of identity used for the connected cluster. The type 'SystemAssigned, includes a system created identity. The type 'None' +// means no identity is assigned to the connected cluster. +type ResourceIdentityType string + +const ( + ResourceIdentityTypeNone ResourceIdentityType = "None" + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" +) + +// PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ + ResourceIdentityTypeNone, + ResourceIdentityTypeSystemAssigned, + } +} + +// ToPtr returns a *ResourceIdentityType pointing to the current value. +func (c ResourceIdentityType) ToPtr() *ResourceIdentityType { + return &c +} diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_models.go b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_models.go new file mode 100644 index 0000000000..0158e60d0b --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_models.go @@ -0,0 +1,554 @@ +//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 armhybridkubernetes + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "reflect" + "time" +) + +// ConnectedCluster - Represents a connected cluster. +type ConnectedCluster struct { + TrackedResource + // REQUIRED; The identity of the connected cluster. + Identity *ConnectedClusterIdentity `json:"identity,omitempty"` + + // REQUIRED; Describes the connected cluster resource properties. + Properties *ConnectedClusterProperties `json:"properties,omitempty"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ConnectedCluster. +func (c ConnectedCluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "identity", c.Identity) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + return json.Marshal(objectMap) +} + +// ConnectedClusterBeginCreateOptions contains the optional parameters for the ConnectedCluster.BeginCreate method. +type ConnectedClusterBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// ConnectedClusterBeginDeleteOptions contains the optional parameters for the ConnectedCluster.BeginDelete method. +type ConnectedClusterBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ConnectedClusterGetOptions contains the optional parameters for the ConnectedCluster.Get method. +type ConnectedClusterGetOptions struct { + // placeholder for future optional parameters +} + +// ConnectedClusterIdentity - Identity for the connected cluster. +type ConnectedClusterIdentity struct { + // REQUIRED; The type of identity used for the connected cluster. The type 'SystemAssigned, includes a system created identity. The type 'None' means no + // identity is assigned to the connected cluster. + Type *ResourceIdentityType `json:"type,omitempty"` + + // READ-ONLY; The principal id of connected cluster identity. This property will only be provided for a system assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant id associated with the connected cluster. This property will only be provided for a system assigned identity. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// ConnectedClusterList - The paginated list of connected Clusters +type ConnectedClusterList struct { + // The link to fetch the next page of connected cluster + NextLink *string `json:"nextLink,omitempty"` + + // The list of connected clusters + Value []*ConnectedCluster `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ConnectedClusterList. +func (c ConnectedClusterList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ConnectedClusterListByResourceGroupOptions contains the optional parameters for the ConnectedCluster.ListByResourceGroup method. +type ConnectedClusterListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ConnectedClusterListBySubscriptionOptions contains the optional parameters for the ConnectedCluster.ListBySubscription method. +type ConnectedClusterListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ConnectedClusterListClusterUserCredentialOptions contains the optional parameters for the ConnectedCluster.ListClusterUserCredential method. +type ConnectedClusterListClusterUserCredentialOptions struct { + // placeholder for future optional parameters +} + +// ConnectedClusterPatch - Object containing updates for patch operations. +type ConnectedClusterPatch struct { + // Describes the connected cluster resource properties that can be updated during PATCH operation. + Properties map[string]interface{} `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ConnectedClusterPatch. +func (c ConnectedClusterPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// ConnectedClusterProperties - Properties of the connected cluster. +type ConnectedClusterProperties struct { + // REQUIRED; Base64 encoded public certificate used by the agent to do the initial handshake to the backend services in Azure. + AgentPublicKeyCertificate *string `json:"agentPublicKeyCertificate,omitempty"` + + // The Kubernetes distribution running on this connected cluster. + Distribution *string `json:"distribution,omitempty"` + + // The infrastructure on which the Kubernetes cluster represented by this connected cluster is running on. + Infrastructure *string `json:"infrastructure,omitempty"` + + // Provisioning state of the connected cluster resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + + // READ-ONLY; Version of the agent running on the connected cluster resource + AgentVersion *string `json:"agentVersion,omitempty" azure:"ro"` + + // READ-ONLY; Represents the connectivity status of the connected cluster. + ConnectivityStatus *ConnectivityStatus `json:"connectivityStatus,omitempty" azure:"ro"` + + // READ-ONLY; The Kubernetes version of the connected cluster resource + KubernetesVersion *string `json:"kubernetesVersion,omitempty" azure:"ro"` + + // READ-ONLY; Time representing the last instance when heart beat was received from the cluster + LastConnectivityTime *time.Time `json:"lastConnectivityTime,omitempty" azure:"ro"` + + // READ-ONLY; Expiration time of the managed identity certificate + ManagedIdentityCertificateExpirationTime *time.Time `json:"managedIdentityCertificateExpirationTime,omitempty" azure:"ro"` + + // READ-ONLY; Connected cluster offering + Offering *string `json:"offering,omitempty" azure:"ro"` + + // READ-ONLY; Number of CPU cores present in the connected cluster resource + TotalCoreCount *int32 `json:"totalCoreCount,omitempty" azure:"ro"` + + // READ-ONLY; Number of nodes present in the connected cluster resource + TotalNodeCount *int32 `json:"totalNodeCount,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ConnectedClusterProperties. +func (c ConnectedClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "agentPublicKeyCertificate", c.AgentPublicKeyCertificate) + populate(objectMap, "agentVersion", c.AgentVersion) + populate(objectMap, "connectivityStatus", c.ConnectivityStatus) + populate(objectMap, "distribution", c.Distribution) + populate(objectMap, "infrastructure", c.Infrastructure) + populate(objectMap, "kubernetesVersion", c.KubernetesVersion) + populateTimeRFC3339(objectMap, "lastConnectivityTime", c.LastConnectivityTime) + populateTimeRFC3339(objectMap, "managedIdentityCertificateExpirationTime", c.ManagedIdentityCertificateExpirationTime) + populate(objectMap, "offering", c.Offering) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "totalCoreCount", c.TotalCoreCount) + populate(objectMap, "totalNodeCount", c.TotalNodeCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConnectedClusterProperties. +func (c *ConnectedClusterProperties) 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 "agentPublicKeyCertificate": + err = unpopulate(val, &c.AgentPublicKeyCertificate) + delete(rawMsg, key) + case "agentVersion": + err = unpopulate(val, &c.AgentVersion) + delete(rawMsg, key) + case "connectivityStatus": + err = unpopulate(val, &c.ConnectivityStatus) + delete(rawMsg, key) + case "distribution": + err = unpopulate(val, &c.Distribution) + delete(rawMsg, key) + case "infrastructure": + err = unpopulate(val, &c.Infrastructure) + delete(rawMsg, key) + case "kubernetesVersion": + err = unpopulate(val, &c.KubernetesVersion) + delete(rawMsg, key) + case "lastConnectivityTime": + err = unpopulateTimeRFC3339(val, &c.LastConnectivityTime) + delete(rawMsg, key) + case "managedIdentityCertificateExpirationTime": + err = unpopulateTimeRFC3339(val, &c.ManagedIdentityCertificateExpirationTime) + delete(rawMsg, key) + case "offering": + err = unpopulate(val, &c.Offering) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &c.ProvisioningState) + delete(rawMsg, key) + case "totalCoreCount": + err = unpopulate(val, &c.TotalCoreCount) + delete(rawMsg, key) + case "totalNodeCount": + err = unpopulate(val, &c.TotalNodeCount) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ConnectedClusterUpdateOptions contains the optional parameters for the ConnectedCluster.Update method. +type ConnectedClusterUpdateOptions struct { + // placeholder for future optional parameters +} + +// CredentialResult - The credential result response. +type CredentialResult struct { + // READ-ONLY; The name of the credential. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Base64-encoded Kubernetes configuration file. + Value []byte `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CredentialResult. +func (c CredentialResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", c.Name) + populateByteArray(objectMap, "value", c.Value, runtime.Base64StdFormat) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CredentialResult. +func (c *CredentialResult) 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, &c.Name) + delete(rawMsg, key) + case "value": + err = runtime.DecodeByteArray(string(val), &c.Value, runtime.Base64StdFormat) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// CredentialResults - The list of credential result response. +type CredentialResults struct { + // READ-ONLY; Contains the REP (rendezvous endpoint) and “Sender” access token. + HybridConnectionConfig *HybridConnectionConfig `json:"hybridConnectionConfig,omitempty" azure:"ro"` + + // READ-ONLY; Base64-encoded Kubernetes configuration file. + Kubeconfigs []*CredentialResult `json:"kubeconfigs,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CredentialResults. +func (c CredentialResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "hybridConnectionConfig", c.HybridConnectionConfig) + populate(objectMap, "kubeconfigs", c.Kubeconfigs) + return json.Marshal(objectMap) +} + +// 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 +} + +// HybridConnectionConfig - Contains the REP (rendezvous endpoint) and “Sender” access token. +type HybridConnectionConfig struct { + // READ-ONLY; Timestamp when this token will be expired. + ExpirationTime *int64 `json:"expirationTime,omitempty" azure:"ro"` + + // READ-ONLY; Name of the connection + HybridConnectionName *string `json:"hybridConnectionName,omitempty" azure:"ro"` + + // READ-ONLY; Name of the relay. + Relay *string `json:"relay,omitempty" azure:"ro"` + + // READ-ONLY; Sender access token + Token *string `json:"token,omitempty" azure:"ro"` +} + +type ListClusterUserCredentialProperties struct { + // REQUIRED; The mode of client authentication. + AuthenticationMethod *AuthenticationMethod `json:"authenticationMethod,omitempty"` + + // REQUIRED; Boolean value to indicate whether the request is for client side proxy or not + ClientProxy *bool `json:"clientProxy,omitempty"` +} + +// Operation - The Connected cluster API operation +type Operation struct { + // READ-ONLY; The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty" azure:"ro"` + + // READ-ONLY; Operation name: {Microsoft.Kubernetes}/{resource}/{operation} + Name *string `json:"name,omitempty" azure:"ro"` +} + +// OperationDisplay - The object that represents the operation. +type OperationDisplay struct { + // Description of the operation. + Description *string `json:"description,omitempty"` + + // Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + + // Service provider: Microsoft.connectedClusters + Provider *string `json:"provider,omitempty"` + + // Connected Cluster Resource on which the operation is performed + Resource *string `json:"resource,omitempty"` +} + +// OperationList - The paginated list of connected cluster API operations. +type OperationList struct { + // The link to fetch the next page of connected cluster API operations. + NextLink *string `json:"nextLink,omitempty"` + + // READ-ONLY; The list of connected cluster API operations. + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationList. +func (o OperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsGetOptions contains the optional parameters for the Operations.Get method. +type OperationsGetOptions struct { + // placeholder for future optional parameters +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) +} + +// 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 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 *LastModifiedByType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' +type TrackedResource struct { + Resource + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal(objectMap map[string]interface{}) { + t.Resource.marshalInternal(objectMap) + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func populateByteArray(m map[string]interface{}, k string, b []byte, f runtime.Base64Encoding) { + if azcore.IsNullValue(b) { + m[k] = nil + } else if len(b) == 0 { + return + } else { + m[k] = runtime.EncodeByteArray(b, f) + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_operations_client.go b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_operations_client.go new file mode 100644 index 0000000000..dd95b55f3b --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/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 armhybridkubernetes + +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)} +} + +// Get - Lists all of the available API operations for Connected Cluster resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) Get(options *OperationsGetOptions) *OperationsGetPager { + return &OperationsGetPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.getCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsGetResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationList.NextLink) + }, + } +} + +// getCreateRequest creates the Get request. +func (client *OperationsClient) getCreateRequest(ctx context.Context, options *OperationsGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Kubernetes/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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OperationsClient) getHandleResponse(resp *http.Response) (OperationsGetResponse, error) { + result := OperationsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationList); err != nil { + return OperationsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *OperationsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_pagers.go b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_pagers.go new file mode 100644 index 0000000000..ce833c7c5d --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_pagers.go @@ -0,0 +1,179 @@ +//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 armhybridkubernetes + +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" +) + +// ConnectedClusterListByResourceGroupPager provides operations for iterating over paged responses. +type ConnectedClusterListByResourceGroupPager struct { + client *ConnectedClusterClient + current ConnectedClusterListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ConnectedClusterListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ConnectedClusterListByResourceGroupPager) 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 *ConnectedClusterListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ConnectedClusterList.NextLink == nil || len(*p.current.ConnectedClusterList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ConnectedClusterListByResourceGroupResponse page. +func (p *ConnectedClusterListByResourceGroupPager) PageResponse() ConnectedClusterListByResourceGroupResponse { + return p.current +} + +// ConnectedClusterListBySubscriptionPager provides operations for iterating over paged responses. +type ConnectedClusterListBySubscriptionPager struct { + client *ConnectedClusterClient + current ConnectedClusterListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ConnectedClusterListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ConnectedClusterListBySubscriptionPager) 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 *ConnectedClusterListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ConnectedClusterList.NextLink == nil || len(*p.current.ConnectedClusterList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ConnectedClusterListBySubscriptionResponse page. +func (p *ConnectedClusterListBySubscriptionPager) PageResponse() ConnectedClusterListBySubscriptionResponse { + return p.current +} + +// OperationsGetPager provides operations for iterating over paged responses. +type OperationsGetPager struct { + client *OperationsClient + current OperationsGetResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsGetResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsGetPager) 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 *OperationsGetPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationList.NextLink == nil || len(*p.current.OperationList.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.getHandleError(resp) + return false + } + result, err := p.client.getHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationsGetResponse page. +func (p *OperationsGetPager) PageResponse() OperationsGetResponse { + return p.current +} diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_pollers.go b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_pollers.go new file mode 100644 index 0000000000..2b08abb7b5 --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_pollers.go @@ -0,0 +1,101 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armhybridkubernetes + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// ConnectedClusterCreatePoller provides polling facilities until the operation reaches a terminal state. +type ConnectedClusterCreatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ConnectedClusterCreatePoller) 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 *ConnectedClusterCreatePoller) 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 ConnectedClusterCreateResponse will be returned. +func (p *ConnectedClusterCreatePoller) FinalResponse(ctx context.Context) (ConnectedClusterCreateResponse, error) { + respType := ConnectedClusterCreateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ConnectedCluster) + if err != nil { + return ConnectedClusterCreateResponse{}, 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 *ConnectedClusterCreatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ConnectedClusterDeletePoller provides polling facilities until the operation reaches a terminal state. +type ConnectedClusterDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ConnectedClusterDeletePoller) 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 *ConnectedClusterDeletePoller) 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 ConnectedClusterDeleteResponse will be returned. +func (p *ConnectedClusterDeletePoller) FinalResponse(ctx context.Context) (ConnectedClusterDeleteResponse, error) { + respType := ConnectedClusterDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ConnectedClusterDeleteResponse{}, 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 *ConnectedClusterDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_response_types.go b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_response_types.go new file mode 100644 index 0000000000..3650436324 --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_response_types.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 armhybridkubernetes + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// ConnectedClusterCreatePollerResponse contains the response from method ConnectedCluster.Create. +type ConnectedClusterCreatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ConnectedClusterCreatePoller + + // 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 ConnectedClusterCreatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ConnectedClusterCreateResponse, error) { + respType := ConnectedClusterCreateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ConnectedCluster) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ConnectedClusterCreatePollerResponse from the provided client and resume token. +func (l *ConnectedClusterCreatePollerResponse) Resume(ctx context.Context, client *ConnectedClusterClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ConnectedClusterClient.Create", token, client.pl, client.createHandleError) + if err != nil { + return err + } + poller := &ConnectedClusterCreatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ConnectedClusterCreateResponse contains the response from method ConnectedCluster.Create. +type ConnectedClusterCreateResponse struct { + ConnectedClusterCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConnectedClusterCreateResult contains the result from method ConnectedCluster.Create. +type ConnectedClusterCreateResult struct { + ConnectedCluster +} + +// ConnectedClusterDeletePollerResponse contains the response from method ConnectedCluster.Delete. +type ConnectedClusterDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *ConnectedClusterDeletePoller + + // 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 ConnectedClusterDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ConnectedClusterDeleteResponse, error) { + respType := ConnectedClusterDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ConnectedClusterDeletePollerResponse from the provided client and resume token. +func (l *ConnectedClusterDeletePollerResponse) Resume(ctx context.Context, client *ConnectedClusterClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ConnectedClusterClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &ConnectedClusterDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ConnectedClusterDeleteResponse contains the response from method ConnectedCluster.Delete. +type ConnectedClusterDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConnectedClusterGetResponse contains the response from method ConnectedCluster.Get. +type ConnectedClusterGetResponse struct { + ConnectedClusterGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConnectedClusterGetResult contains the result from method ConnectedCluster.Get. +type ConnectedClusterGetResult struct { + ConnectedCluster +} + +// ConnectedClusterListByResourceGroupResponse contains the response from method ConnectedCluster.ListByResourceGroup. +type ConnectedClusterListByResourceGroupResponse struct { + ConnectedClusterListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConnectedClusterListByResourceGroupResult contains the result from method ConnectedCluster.ListByResourceGroup. +type ConnectedClusterListByResourceGroupResult struct { + ConnectedClusterList +} + +// ConnectedClusterListBySubscriptionResponse contains the response from method ConnectedCluster.ListBySubscription. +type ConnectedClusterListBySubscriptionResponse struct { + ConnectedClusterListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConnectedClusterListBySubscriptionResult contains the result from method ConnectedCluster.ListBySubscription. +type ConnectedClusterListBySubscriptionResult struct { + ConnectedClusterList +} + +// ConnectedClusterListClusterUserCredentialResponse contains the response from method ConnectedCluster.ListClusterUserCredential. +type ConnectedClusterListClusterUserCredentialResponse struct { + ConnectedClusterListClusterUserCredentialResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConnectedClusterListClusterUserCredentialResult contains the result from method ConnectedCluster.ListClusterUserCredential. +type ConnectedClusterListClusterUserCredentialResult struct { + CredentialResults +} + +// ConnectedClusterUpdateResponse contains the response from method ConnectedCluster.Update. +type ConnectedClusterUpdateResponse struct { + ConnectedClusterUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConnectedClusterUpdateResult contains the result from method ConnectedCluster.Update. +type ConnectedClusterUpdateResult struct { + ConnectedCluster +} + +// OperationsGetResponse contains the response from method Operations.Get. +type OperationsGetResponse struct { + OperationsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsGetResult contains the result from method Operations.Get. +type OperationsGetResult struct { + OperationList +} diff --git a/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_time_rfc3339.go b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/zz_generated_time_rfc3339.go new file mode 100644 index 0000000000..6160184c60 --- /dev/null +++ b/sdk/resourcemanager/hybridkubernetes/armhybridkubernetes/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 armhybridkubernetes + +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 +}