From 40cecbf786014c1799068c905ed0f36cc0a9e49b Mon Sep 17 00:00:00 2001 From: 804873052 <804873052@qq.com> Date: Tue, 14 Dec 2021 11:40:42 +0800 Subject: [PATCH 1/2] [Release] sdk/resourcemanager/chaos/armchaos/0.1.0 generation from spec commit: 91c198e26991291a67ecb3aab163b255746d0b58 --- .../chaos/armchaos/CHANGELOG.md | 5 + .../chaos/armchaos/LICENSE.txt | 21 + sdk/resourcemanager/chaos/armchaos/README.md | 75 ++ .../chaos/armchaos/autorest.md | 13 + sdk/resourcemanager/chaos/armchaos/build.go | 7 + sdk/resourcemanager/chaos/armchaos/ci.yml | 27 + sdk/resourcemanager/chaos/armchaos/go.mod | 9 + sdk/resourcemanager/chaos/armchaos/go.sum | 45 + .../chaos/armchaos/go_mod_tidy_hack.go | 13 + ...erated_example_capabilities_client_test.go | 109 ++ ...ted_example_capabilitytypes_client_test.go | 57 + ...nerated_example_experiments_client_test.go | 271 ++++ ...e_generated_example_targets_client_test.go | 113 ++ ...nerated_example_targettypes_client_test.go | 56 + .../zz_generated_capabilities_client.go | 354 +++++ .../zz_generated_capabilitytypes_client.go | 177 +++ .../chaos/armchaos/zz_generated_constants.go | 127 ++ .../zz_generated_experiments_client.go | 768 +++++++++++ .../chaos/armchaos/zz_generated_models.go | 1153 +++++++++++++++++ .../zz_generated_operations_client.go | 89 ++ .../chaos/armchaos/zz_generated_pagers.go | 503 +++++++ .../chaos/armchaos/zz_generated_pollers.go | 101 ++ .../zz_generated_polymorphic_helpers.go | 65 + .../armchaos/zz_generated_response_types.go | 366 ++++++ .../armchaos/zz_generated_targets_client.go | 338 +++++ .../zz_generated_targettypes_client.go | 169 +++ .../armchaos/zz_generated_time_rfc3339.go | 85 ++ 27 files changed, 5116 insertions(+) create mode 100644 sdk/resourcemanager/chaos/armchaos/CHANGELOG.md create mode 100644 sdk/resourcemanager/chaos/armchaos/LICENSE.txt create mode 100644 sdk/resourcemanager/chaos/armchaos/README.md create mode 100644 sdk/resourcemanager/chaos/armchaos/autorest.md create mode 100644 sdk/resourcemanager/chaos/armchaos/build.go create mode 100644 sdk/resourcemanager/chaos/armchaos/ci.yml create mode 100644 sdk/resourcemanager/chaos/armchaos/go.mod create mode 100644 sdk/resourcemanager/chaos/armchaos/go.sum create mode 100644 sdk/resourcemanager/chaos/armchaos/go_mod_tidy_hack.go create mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilities_client_test.go create mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilitytypes_client_test.go create mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_experiments_client_test.go create mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_targets_client_test.go create mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_targettypes_client_test.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_capabilities_client.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_capabilitytypes_client.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_constants.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_experiments_client.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_models.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_operations_client.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_pagers.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_pollers.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_polymorphic_helpers.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_response_types.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_targets_client.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_targettypes_client.go create mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_time_rfc3339.go diff --git a/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md b/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md new file mode 100644 index 000000000000..c12e9f9b576d --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-14) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/chaos/armchaos/LICENSE.txt b/sdk/resourcemanager/chaos/armchaos/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/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/chaos/armchaos/README.md b/sdk/resourcemanager/chaos/armchaos/README.md new file mode 100644 index 000000000000..9d397e654787 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/README.md @@ -0,0 +1,75 @@ +# Azure Chaos Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos) + +The `armchaos` module provides operations for working with Azure Chaos. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/chaos/armchaos) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.16 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 Chaos module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Chaos. 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 Chaos 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 := armchaos.NewExperimentsClient(, 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 := armchaos.NewExperimentsClient(, 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 `Chaos` 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/chaos/armchaos/autorest.md b/sdk/resourcemanager/chaos/armchaos/autorest.md new file mode 100644 index 000000000000..9aab2d1a9b57 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/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/91c198e26991291a67ecb3aab163b255746d0b58/specification/chaos/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/91c198e26991291a67ecb3aab163b255746d0b58/specification/chaos/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/chaos/armchaos/build.go b/sdk/resourcemanager/chaos/armchaos/build.go new file mode 100644 index 000000000000..11625df766c1 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/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/chaos/armchaos + +package armchaos diff --git a/sdk/resourcemanager/chaos/armchaos/ci.yml b/sdk/resourcemanager/chaos/armchaos/ci.yml new file mode 100644 index 000000000000..40f6808cc413 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/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/chaos/armchaos/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/chaos/armchaos/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/chaos/armchaos' diff --git a/sdk/resourcemanager/chaos/armchaos/go.mod b/sdk/resourcemanager/chaos/armchaos/go.mod new file mode 100644 index 000000000000..f6ba28555850 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/go.mod @@ -0,0 +1,9 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v60.1.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0 +) diff --git a/sdk/resourcemanager/chaos/armchaos/go.sum b/sdk/resourcemanager/chaos/armchaos/go.sum new file mode 100644 index 000000000000..35739a609db5 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/go.sum @@ -0,0 +1,45 @@ +github.com/Azure/azure-sdk-for-go v60.1.0+incompatible h1:j6y8ddurcaiyLfwBwPmJFaunp6BDzyQTuAgMrm1r++o= +github.com/Azure/azure-sdk-for-go v60.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/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/chaos/armchaos/go_mod_tidy_hack.go b/sdk/resourcemanager/chaos/armchaos/go_mod_tidy_hack.go new file mode 100644 index 000000000000..beba7a0e6277 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/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 armchaos + +// 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/chaos/armchaos/ze_generated_example_capabilities_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilities_client_test.go new file mode 100644 index 000000000000..4ad49c318412 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilities_client_test.go @@ -0,0 +1,109 @@ +//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 armchaos_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" +) + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListCapabilities.json +func ExampleCapabilitiesClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewCapabilitiesClient("", cred, nil) + pager := client.List("", + "", + "", + "", + "", + &armchaos.CapabilitiesListOptions{ContinuationToken: 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("Capability.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetACapability.json +func ExampleCapabilitiesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewCapabilitiesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Capability.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/DeleteACapability.json +func ExampleCapabilitiesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewCapabilitiesClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CreateOrUpdateACapability.json +func ExampleCapabilitiesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewCapabilitiesClient("", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "", + "", + "", + "", + "", + "", + armchaos.Capability{ + Properties: &armchaos.CapabilityProperties{}, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Capability.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilitytypes_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilitytypes_client_test.go new file mode 100644 index 000000000000..48316fadddc7 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilitytypes_client_test.go @@ -0,0 +1,57 @@ +//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 armchaos_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" +) + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListCapabilityTypes.json +func ExampleCapabilityTypesClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewCapabilityTypesClient("", cred, nil) + pager := client.List("", + "", + &armchaos.CapabilityTypesListOptions{ContinuationToken: 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("CapabilityType.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetACapabilityType.json +func ExampleCapabilityTypesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewCapabilityTypesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("CapabilityType.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_experiments_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_experiments_client_test.go new file mode 100644 index 000000000000..739258a113db --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_experiments_client_test.go @@ -0,0 +1,271 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armchaos_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" +) + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentsInASubscription.json +func ExampleExperimentsClient_ListAll() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewExperimentsClient("", cred, nil) + pager := client.ListAll(&armchaos.ExperimentsListAllOptions{Running: nil, + ContinuationToken: to.StringPtr(""), + }) + 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("Experiment.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentsInAResourceGroup.json +func ExampleExperimentsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewExperimentsClient("", cred, nil) + pager := client.List("", + &armchaos.ExperimentsListOptions{Running: nil, + ContinuationToken: to.StringPtr(""), + }) + 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("Experiment.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/DeleteAExperiment.json +func ExampleExperimentsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewExperimentsClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetAExperiment.json +func ExampleExperimentsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewExperimentsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Experiment.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CreateOrUpdateAExperiment.json +func ExampleExperimentsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewExperimentsClient("", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "", + "", + armchaos.Experiment{ + TrackedResource: armchaos.TrackedResource{ + Location: to.StringPtr(""), + }, + Identity: &armchaos.ResourceIdentity{ + Type: armchaos.ResourceIdentityTypeSystemAssigned.ToPtr(), + }, + Properties: &armchaos.ExperimentProperties{ + Selectors: []*armchaos.Selector{ + { + Type: armchaos.SelectorTypeList.ToPtr(), + ID: to.StringPtr(""), + Targets: []*armchaos.TargetReference{ + { + Type: to.StringPtr(""), + ID: to.StringPtr(""), + }}, + }}, + Steps: []*armchaos.Step{ + { + Name: to.StringPtr(""), + Branches: []*armchaos.Branch{ + { + Name: to.StringPtr(""), + Actions: []armchaos.ActionClassification{ + &armchaos.Action{ + Name: to.StringPtr(""), + Type: to.StringPtr(""), + }}, + }}, + }}, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("Experiment.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CancelAExperiment.json +func ExampleExperimentsClient_BeginCancel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewExperimentsClient("", cred, nil) + poller, err := client.BeginCancel(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/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/StartAExperiment.json +func ExampleExperimentsClient_Start() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewExperimentsClient("", cred, nil) + _, err = client.Start(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentStatuses.json +func ExampleExperimentsClient_ListAllStatuses() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewExperimentsClient("", cred, nil) + pager := client.ListAllStatuses("", + "", + 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("ExperimentStatus.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetAExperimentStatus.json +func ExampleExperimentsClient_GetStatus() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewExperimentsClient("", cred, nil) + res, err := client.GetStatus(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("ExperimentStatus.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentExecutionsDetails.json +func ExampleExperimentsClient_ListExecutionDetails() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewExperimentsClient("", cred, nil) + pager := client.ListExecutionDetails("", + "", + 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("ExperimentExecutionDetails.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetAExperimentExecutionDetails.json +func ExampleExperimentsClient_GetExecutionDetails() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewExperimentsClient("", cred, nil) + res, err := client.GetExecutionDetails(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("ExperimentExecutionDetails.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targets_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targets_client_test.go new file mode 100644 index 000000000000..67759e2c3a8b --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targets_client_test.go @@ -0,0 +1,113 @@ +//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 armchaos_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" +) + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListTargets.json +func ExampleTargetsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewTargetsClient("", cred, nil) + pager := client.List("", + "", + "", + "", + &armchaos.TargetsListOptions{ContinuationToken: to.StringPtr("")}) + 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("Target.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetATarget.json +func ExampleTargetsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewTargetsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Target.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/DeleteATarget.json +func ExampleTargetsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewTargetsClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CreateOrUpdateATarget.json +func ExampleTargetsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewTargetsClient("", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "", + "", + "", + "", + "", + armchaos.Target{ + Properties: map[string]interface{}{ + "identities": []interface{}{ + map[string]interface{}{ + "type": "CertificateSubjectIssuer", + "subject": "CN=example.subject", + }, + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("Target.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targettypes_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targettypes_client_test.go new file mode 100644 index 000000000000..b93ae3b4b6e2 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targettypes_client_test.go @@ -0,0 +1,56 @@ +//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 armchaos_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" +) + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListTargetTypes.json +func ExampleTargetTypesClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewTargetTypesClient("", cred, nil) + pager := client.List("", + &armchaos.TargetTypesListOptions{ContinuationToken: to.StringPtr("")}) + 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("TargetType.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetATargetType.json +func ExampleTargetTypesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armchaos.NewTargetTypesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("TargetType.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilities_client.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilities_client.go new file mode 100644 index 000000000000..b8d59f51915e --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilities_client.go @@ -0,0 +1,354 @@ +//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 armchaos + +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" +) + +// CapabilitiesClient contains the methods for the Capabilities group. +// Don't use this type directly, use NewCapabilitiesClient() instead. +type CapabilitiesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewCapabilitiesClient creates a new instance of CapabilitiesClient with the specified values. +func NewCapabilitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *CapabilitiesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &CapabilitiesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Create or update a Capability resource that extends a Target resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CapabilitiesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, capability Capability, options *CapabilitiesCreateOrUpdateOptions) (CapabilitiesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, capabilityName, capability, options) + if err != nil { + return CapabilitiesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CapabilitiesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CapabilitiesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CapabilitiesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, capability Capability, options *CapabilitiesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}" + 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 parentProviderNamespace == "" { + return nil, errors.New("parameter parentProviderNamespace cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) + if parentResourceType == "" { + return nil, errors.New("parameter parentResourceType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) + if parentResourceName == "" { + return nil, errors.New("parameter parentResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) + if targetName == "" { + return nil, errors.New("parameter targetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{targetName}", url.PathEscape(targetName)) + if capabilityName == "" { + return nil, errors.New("parameter capabilityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{capabilityName}", url.PathEscape(capabilityName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, capability) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *CapabilitiesClient) createOrUpdateHandleResponse(resp *http.Response) (CapabilitiesCreateOrUpdateResponse, error) { + result := CapabilitiesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Capability); err != nil { + return CapabilitiesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *CapabilitiesClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete a Capability that extends a Target resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CapabilitiesClient) Delete(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, options *CapabilitiesDeleteOptions) (CapabilitiesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, capabilityName, options) + if err != nil { + return CapabilitiesDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CapabilitiesDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return CapabilitiesDeleteResponse{}, client.deleteHandleError(resp) + } + return CapabilitiesDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CapabilitiesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, options *CapabilitiesDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}" + 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 parentProviderNamespace == "" { + return nil, errors.New("parameter parentProviderNamespace cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) + if parentResourceType == "" { + return nil, errors.New("parameter parentResourceType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) + if parentResourceName == "" { + return nil, errors.New("parameter parentResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) + if targetName == "" { + return nil, errors.New("parameter targetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{targetName}", url.PathEscape(targetName)) + if capabilityName == "" { + return nil, errors.New("parameter capabilityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{capabilityName}", url.PathEscape(capabilityName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *CapabilitiesClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get a Capability resource that extends a Target resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CapabilitiesClient) Get(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, options *CapabilitiesGetOptions) (CapabilitiesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, capabilityName, options) + if err != nil { + return CapabilitiesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CapabilitiesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CapabilitiesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CapabilitiesClient) getCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, options *CapabilitiesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}" + 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 parentProviderNamespace == "" { + return nil, errors.New("parameter parentProviderNamespace cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) + if parentResourceType == "" { + return nil, errors.New("parameter parentResourceType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) + if parentResourceName == "" { + return nil, errors.New("parameter parentResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) + if targetName == "" { + return nil, errors.New("parameter targetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{targetName}", url.PathEscape(targetName)) + if capabilityName == "" { + return nil, errors.New("parameter capabilityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{capabilityName}", url.PathEscape(capabilityName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CapabilitiesClient) getHandleResponse(resp *http.Response) (CapabilitiesGetResponse, error) { + result := CapabilitiesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Capability); err != nil { + return CapabilitiesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *CapabilitiesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Get a list of Capability resources that extend a Target resource.. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CapabilitiesClient) List(resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *CapabilitiesListOptions) *CapabilitiesListPager { + return &CapabilitiesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, options) + }, + advancer: func(ctx context.Context, resp CapabilitiesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.CapabilityListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *CapabilitiesClient) listCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *CapabilitiesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities" + 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 parentProviderNamespace == "" { + return nil, errors.New("parameter parentProviderNamespace cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) + if parentResourceType == "" { + return nil, errors.New("parameter parentResourceType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) + if parentResourceName == "" { + return nil, errors.New("parameter parentResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) + if targetName == "" { + return nil, errors.New("parameter targetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{targetName}", url.PathEscape(targetName)) + 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-09-15-preview") + if options != nil && options.ContinuationToken != nil { + reqQP.Set("continuationToken", *options.ContinuationToken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *CapabilitiesClient) listHandleResponse(resp *http.Response) (CapabilitiesListResponse, error) { + result := CapabilitiesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CapabilityListResult); err != nil { + return CapabilitiesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *CapabilitiesClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilitytypes_client.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilitytypes_client.go new file mode 100644 index 000000000000..c56fc1377456 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilitytypes_client.go @@ -0,0 +1,177 @@ +//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 armchaos + +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" +) + +// CapabilityTypesClient contains the methods for the CapabilityTypes group. +// Don't use this type directly, use NewCapabilityTypesClient() instead. +type CapabilityTypesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewCapabilityTypesClient creates a new instance of CapabilityTypesClient with the specified values. +func NewCapabilityTypesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *CapabilityTypesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &CapabilityTypesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get a Capability Type resource for given Target Type and location. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CapabilityTypesClient) Get(ctx context.Context, locationName string, targetTypeName string, capabilityTypeName string, options *CapabilityTypesGetOptions) (CapabilityTypesGetResponse, error) { + req, err := client.getCreateRequest(ctx, locationName, targetTypeName, capabilityTypeName, options) + if err != nil { + return CapabilityTypesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CapabilityTypesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CapabilityTypesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CapabilityTypesClient) getCreateRequest(ctx context.Context, locationName string, targetTypeName string, capabilityTypeName string, options *CapabilityTypesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes/{targetTypeName}/capabilityTypes/{capabilityTypeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationName == "" { + return nil, errors.New("parameter locationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + if targetTypeName == "" { + return nil, errors.New("parameter targetTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{targetTypeName}", url.PathEscape(targetTypeName)) + if capabilityTypeName == "" { + return nil, errors.New("parameter capabilityTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{capabilityTypeName}", url.PathEscape(capabilityTypeName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CapabilityTypesClient) getHandleResponse(resp *http.Response) (CapabilityTypesGetResponse, error) { + result := CapabilityTypesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CapabilityType); err != nil { + return CapabilityTypesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *CapabilityTypesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Get a list of Capability Type resources for given Target Type and location. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CapabilityTypesClient) List(locationName string, targetTypeName string, options *CapabilityTypesListOptions) *CapabilityTypesListPager { + return &CapabilityTypesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, locationName, targetTypeName, options) + }, + advancer: func(ctx context.Context, resp CapabilityTypesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.CapabilityTypeListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *CapabilityTypesClient) listCreateRequest(ctx context.Context, locationName string, targetTypeName string, options *CapabilityTypesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes/{targetTypeName}/capabilityTypes" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationName == "" { + return nil, errors.New("parameter locationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + if targetTypeName == "" { + return nil, errors.New("parameter targetTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{targetTypeName}", url.PathEscape(targetTypeName)) + 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-09-15-preview") + if options != nil && options.ContinuationToken != nil { + reqQP.Set("continuationToken", *options.ContinuationToken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *CapabilityTypesClient) listHandleResponse(resp *http.Response) (CapabilityTypesListResponse, error) { + result := CapabilityTypesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CapabilityTypeListResult); err != nil { + return CapabilityTypesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *CapabilityTypesClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_constants.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_constants.go new file mode 100644 index 000000000000..18017eac9b99 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/zz_generated_constants.go @@ -0,0 +1,127 @@ +//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 armchaos + +const ( + module = "armchaos" + version = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// ToPtr returns a *ActionType pointing to the current value. +func (c ActionType) ToPtr() *ActionType { + return &c +} + +// 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 +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ToPtr returns a *Origin pointing to the current value. +func (c Origin) ToPtr() *Origin { + return &c +} + +// ResourceIdentityType - String of the resource identity type. +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 +} + +// SelectorType - Enum of the selector type. +type SelectorType string + +const ( + SelectorTypePercent SelectorType = "Percent" + SelectorTypeRandom SelectorType = "Random" + SelectorTypeTag SelectorType = "Tag" + SelectorTypeList SelectorType = "List" +) + +// PossibleSelectorTypeValues returns the possible values for the SelectorType const type. +func PossibleSelectorTypeValues() []SelectorType { + return []SelectorType{ + SelectorTypePercent, + SelectorTypeRandom, + SelectorTypeTag, + SelectorTypeList, + } +} + +// ToPtr returns a *SelectorType pointing to the current value. +func (c SelectorType) ToPtr() *SelectorType { + return &c +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_experiments_client.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_experiments_client.go new file mode 100644 index 000000000000..eaa0ba66a436 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/zz_generated_experiments_client.go @@ -0,0 +1,768 @@ +//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 armchaos + +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" + "strconv" + "strings" +) + +// ExperimentsClient contains the methods for the Experiments group. +// Don't use this type directly, use NewExperimentsClient() instead. +type ExperimentsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewExperimentsClient creates a new instance of ExperimentsClient with the specified values. +func NewExperimentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ExperimentsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ExperimentsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCancel - Cancel a running Experiment resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) BeginCancel(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsBeginCancelOptions) (ExperimentsCancelPollerResponse, error) { + resp, err := client.cancel(ctx, resourceGroupName, experimentName, options) + if err != nil { + return ExperimentsCancelPollerResponse{}, err + } + result := ExperimentsCancelPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ExperimentsClient.Cancel", "original-uri", resp, client.pl, client.cancelHandleError) + if err != nil { + return ExperimentsCancelPollerResponse{}, err + } + result.Poller = &ExperimentsCancelPoller{ + pt: pt, + } + return result, nil +} + +// Cancel - Cancel a running Experiment resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) cancel(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsBeginCancelOptions) (*http.Response, error) { + req, err := client.cancelCreateRequest(ctx, resourceGroupName, experimentName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted) { + return nil, client.cancelHandleError(resp) + } + return resp, nil +} + +// cancelCreateRequest creates the Cancel request. +func (client *ExperimentsClient) cancelCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsBeginCancelOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel" + 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 experimentName == "" { + return nil, errors.New("parameter experimentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// cancelHandleError handles the Cancel error response. +func (client *ExperimentsClient) cancelHandleError(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) +} + +// BeginCreateOrUpdate - Create or update a Experiment resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, experimentName string, experiment Experiment, options *ExperimentsBeginCreateOrUpdateOptions) (ExperimentsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, experimentName, experiment, options) + if err != nil { + return ExperimentsCreateOrUpdatePollerResponse{}, err + } + result := ExperimentsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ExperimentsClient.CreateOrUpdate", "original-uri", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return ExperimentsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &ExperimentsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update a Experiment resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, experimentName string, experiment Experiment, options *ExperimentsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, experimentName, experiment, 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) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ExperimentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, experiment Experiment, options *ExperimentsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + 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 experimentName == "" { + return nil, errors.New("parameter experimentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, experiment) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ExperimentsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete a Experiment resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) Delete(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsDeleteOptions) (ExperimentsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, experimentName, options) + if err != nil { + return ExperimentsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ExperimentsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return ExperimentsDeleteResponse{}, client.deleteHandleError(resp) + } + return ExperimentsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ExperimentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + 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 experimentName == "" { + return nil, errors.New("parameter experimentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ExperimentsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get a Experiment resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) Get(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsGetOptions) (ExperimentsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, experimentName, options) + if err != nil { + return ExperimentsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ExperimentsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ExperimentsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ExperimentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + 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 experimentName == "" { + return nil, errors.New("parameter experimentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ExperimentsClient) getHandleResponse(resp *http.Response) (ExperimentsGetResponse, error) { + result := ExperimentsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Experiment); err != nil { + return ExperimentsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ExperimentsClient) 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) +} + +// GetExecutionDetails - Get an execution detail of a Experiment resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) GetExecutionDetails(ctx context.Context, resourceGroupName string, experimentName string, executionDetailsID string, options *ExperimentsGetExecutionDetailsOptions) (ExperimentsGetExecutionDetailsResponse, error) { + req, err := client.getExecutionDetailsCreateRequest(ctx, resourceGroupName, experimentName, executionDetailsID, options) + if err != nil { + return ExperimentsGetExecutionDetailsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ExperimentsGetExecutionDetailsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ExperimentsGetExecutionDetailsResponse{}, client.getExecutionDetailsHandleError(resp) + } + return client.getExecutionDetailsHandleResponse(resp) +} + +// getExecutionDetailsCreateRequest creates the GetExecutionDetails request. +func (client *ExperimentsClient) getExecutionDetailsCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, executionDetailsID string, options *ExperimentsGetExecutionDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executionDetails/{executionDetailsId}" + 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 experimentName == "" { + return nil, errors.New("parameter experimentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) + if executionDetailsID == "" { + return nil, errors.New("parameter executionDetailsID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{executionDetailsId}", url.PathEscape(executionDetailsID)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getExecutionDetailsHandleResponse handles the GetExecutionDetails response. +func (client *ExperimentsClient) getExecutionDetailsHandleResponse(resp *http.Response) (ExperimentsGetExecutionDetailsResponse, error) { + result := ExperimentsGetExecutionDetailsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentExecutionDetails); err != nil { + return ExperimentsGetExecutionDetailsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getExecutionDetailsHandleError handles the GetExecutionDetails error response. +func (client *ExperimentsClient) getExecutionDetailsHandleError(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) +} + +// GetStatus - Get a status of a Experiment resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) GetStatus(ctx context.Context, resourceGroupName string, experimentName string, statusID string, options *ExperimentsGetStatusOptions) (ExperimentsGetStatusResponse, error) { + req, err := client.getStatusCreateRequest(ctx, resourceGroupName, experimentName, statusID, options) + if err != nil { + return ExperimentsGetStatusResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ExperimentsGetStatusResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ExperimentsGetStatusResponse{}, client.getStatusHandleError(resp) + } + return client.getStatusHandleResponse(resp) +} + +// getStatusCreateRequest creates the GetStatus request. +func (client *ExperimentsClient) getStatusCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, statusID string, options *ExperimentsGetStatusOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/statuses/{statusId}" + 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 experimentName == "" { + return nil, errors.New("parameter experimentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) + if statusID == "" { + return nil, errors.New("parameter statusID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{statusId}", url.PathEscape(statusID)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getStatusHandleResponse handles the GetStatus response. +func (client *ExperimentsClient) getStatusHandleResponse(resp *http.Response) (ExperimentsGetStatusResponse, error) { + result := ExperimentsGetStatusResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentStatus); err != nil { + return ExperimentsGetStatusResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getStatusHandleError handles the GetStatus error response. +func (client *ExperimentsClient) getStatusHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Get a list of Experiment resources in a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) List(resourceGroupName string, options *ExperimentsListOptions) *ExperimentsListPager { + return &ExperimentsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp ExperimentsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ExperimentListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ExperimentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *ExperimentsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments" + 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-09-15-preview") + if options != nil && options.Running != nil { + reqQP.Set("running", strconv.FormatBool(*options.Running)) + } + if options != nil && options.ContinuationToken != nil { + reqQP.Set("continuationToken", *options.ContinuationToken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ExperimentsClient) listHandleResponse(resp *http.Response) (ExperimentsListResponse, error) { + result := ExperimentsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentListResult); err != nil { + return ExperimentsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ExperimentsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListAll - Get a list of Experiment resources in a subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) ListAll(options *ExperimentsListAllOptions) *ExperimentsListAllPager { + return &ExperimentsListAllPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listAllCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp ExperimentsListAllResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ExperimentListResult.NextLink) + }, + } +} + +// listAllCreateRequest creates the ListAll request. +func (client *ExperimentsClient) listAllCreateRequest(ctx context.Context, options *ExperimentsListAllOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/experiments" + 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-09-15-preview") + if options != nil && options.Running != nil { + reqQP.Set("running", strconv.FormatBool(*options.Running)) + } + if options != nil && options.ContinuationToken != nil { + reqQP.Set("continuationToken", *options.ContinuationToken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listAllHandleResponse handles the ListAll response. +func (client *ExperimentsClient) listAllHandleResponse(resp *http.Response) (ExperimentsListAllResponse, error) { + result := ExperimentsListAllResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentListResult); err != nil { + return ExperimentsListAllResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listAllHandleError handles the ListAll error response. +func (client *ExperimentsClient) listAllHandleError(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) +} + +// ListAllStatuses - Get a list of statuses of a Experiment resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) ListAllStatuses(resourceGroupName string, experimentName string, options *ExperimentsListAllStatusesOptions) *ExperimentsListAllStatusesPager { + return &ExperimentsListAllStatusesPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listAllStatusesCreateRequest(ctx, resourceGroupName, experimentName, options) + }, + advancer: func(ctx context.Context, resp ExperimentsListAllStatusesResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ExperimentStatusListResult.NextLink) + }, + } +} + +// listAllStatusesCreateRequest creates the ListAllStatuses request. +func (client *ExperimentsClient) listAllStatusesCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsListAllStatusesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/statuses" + 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 experimentName == "" { + return nil, errors.New("parameter experimentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listAllStatusesHandleResponse handles the ListAllStatuses response. +func (client *ExperimentsClient) listAllStatusesHandleResponse(resp *http.Response) (ExperimentsListAllStatusesResponse, error) { + result := ExperimentsListAllStatusesResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentStatusListResult); err != nil { + return ExperimentsListAllStatusesResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listAllStatusesHandleError handles the ListAllStatuses error response. +func (client *ExperimentsClient) listAllStatusesHandleError(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) +} + +// ListExecutionDetails - Get a list of execution details of a Experiment resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) ListExecutionDetails(resourceGroupName string, experimentName string, options *ExperimentsListExecutionDetailsOptions) *ExperimentsListExecutionDetailsPager { + return &ExperimentsListExecutionDetailsPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listExecutionDetailsCreateRequest(ctx, resourceGroupName, experimentName, options) + }, + advancer: func(ctx context.Context, resp ExperimentsListExecutionDetailsResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ExperimentExecutionDetailsListResult.NextLink) + }, + } +} + +// listExecutionDetailsCreateRequest creates the ListExecutionDetails request. +func (client *ExperimentsClient) listExecutionDetailsCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsListExecutionDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executionDetails" + 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 experimentName == "" { + return nil, errors.New("parameter experimentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listExecutionDetailsHandleResponse handles the ListExecutionDetails response. +func (client *ExperimentsClient) listExecutionDetailsHandleResponse(resp *http.Response) (ExperimentsListExecutionDetailsResponse, error) { + result := ExperimentsListExecutionDetailsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentExecutionDetailsListResult); err != nil { + return ExperimentsListExecutionDetailsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listExecutionDetailsHandleError handles the ListExecutionDetails error response. +func (client *ExperimentsClient) listExecutionDetailsHandleError(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) +} + +// Start - Start a Experiment resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExperimentsClient) Start(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsStartOptions) (ExperimentsStartResponse, error) { + req, err := client.startCreateRequest(ctx, resourceGroupName, experimentName, options) + if err != nil { + return ExperimentsStartResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ExperimentsStartResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted) { + return ExperimentsStartResponse{}, client.startHandleError(resp) + } + return client.startHandleResponse(resp) +} + +// startCreateRequest creates the Start request. +func (client *ExperimentsClient) startCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsStartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/start" + 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 experimentName == "" { + return nil, errors.New("parameter experimentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// startHandleResponse handles the Start response. +func (client *ExperimentsClient) startHandleResponse(resp *http.Response) (ExperimentsStartResponse, error) { + result := ExperimentsStartResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentStartOperationResult); err != nil { + return ExperimentsStartResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// startHandleError handles the Start error response. +func (client *ExperimentsClient) startHandleError(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/chaos/armchaos/zz_generated_models.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_models.go new file mode 100644 index 000000000000..7866cf16f405 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/zz_generated_models.go @@ -0,0 +1,1153 @@ +//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 armchaos + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// ActionClassification provides polymorphic access to related types. +// Call the interface's GetAction() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *Action +type ActionClassification interface { + // GetAction returns the Action content of the underlying type. + GetAction() *Action +} + +// Action - Model that represents the base action model. +type Action struct { + // REQUIRED; String that represents a Capability URN. + Name *string `json:"name,omitempty"` + + // REQUIRED; Enum that discriminates between action models. + Type *string `json:"type,omitempty"` +} + +// GetAction implements the ActionClassification interface for type Action. +func (a *Action) GetAction() *Action { return a } + +// ActionStatus - Model that represents the an action and its status. +type ActionStatus struct { + // READ-ONLY; The id of the action status. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the action status. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The status of the action. + Status *string `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; The array of targets. + Targets []*ExperimentExecutionActionTargetDetailsProperties `json:"targets,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ActionStatus. +func (a ActionStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "status", a.Status) + populate(objectMap, "targets", a.Targets) + return json.Marshal(objectMap) +} + +// Branch - Model that represents a branch in the step. +type Branch struct { + // REQUIRED; List of actions. + Actions []ActionClassification `json:"actions,omitempty"` + + // REQUIRED; String of the branch name. + Name *string `json:"name,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Branch. +func (b Branch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actions", b.Actions) + populate(objectMap, "name", b.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Branch. +func (b *Branch) 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 "actions": + b.Actions, err = unmarshalActionClassificationArray(val) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &b.Name) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// BranchStatus - Model that represents the a list of actions and action statuses. +type BranchStatus struct { + // READ-ONLY; The array of actions. + Actions []*ActionStatus `json:"actions,omitempty" azure:"ro"` + + // READ-ONLY; The id of the branch status. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the branch status. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The status of the branch. + Status *string `json:"status,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type BranchStatus. +func (b BranchStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actions", b.Actions) + populate(objectMap, "id", b.ID) + populate(objectMap, "name", b.Name) + populate(objectMap, "status", b.Status) + return json.Marshal(objectMap) +} + +// CapabilitiesCreateOrUpdateOptions contains the optional parameters for the Capabilities.CreateOrUpdate method. +type CapabilitiesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// CapabilitiesDeleteOptions contains the optional parameters for the Capabilities.Delete method. +type CapabilitiesDeleteOptions struct { + // placeholder for future optional parameters +} + +// CapabilitiesGetOptions contains the optional parameters for the Capabilities.Get method. +type CapabilitiesGetOptions struct { + // placeholder for future optional parameters +} + +// CapabilitiesListOptions contains the optional parameters for the Capabilities.List method. +type CapabilitiesListOptions struct { + // String that sets the continuation token. + ContinuationToken *string +} + +// Capability - Model that represents a Capability resource. +type Capability struct { + Resource + // READ-ONLY; The properties of a capability resource. + Properties *CapabilityProperties `json:"properties,omitempty" azure:"ro"` + + // READ-ONLY; The standard system metadata of a resource type. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Capability. +func (c Capability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + return json.Marshal(objectMap) +} + +// CapabilityListResult - Model that represents a list of Capability resources and a link for pagination. +type CapabilityListResult struct { + // READ-ONLY; URL to retrieve the next page of Capability resources. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of Capability resources. + Value []*Capability `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilityListResult. +func (c CapabilityListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CapabilityProperties - Model that represents the Capability properties model. +type CapabilityProperties struct { + // READ-ONLY; Localized string of the description. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; URL to retrieve JSON schema of the Capability parameters. + ParametersSchema *string `json:"parametersSchema,omitempty" azure:"ro"` + + // READ-ONLY; String of the Publisher that this Capability extends. + Publisher *string `json:"publisher,omitempty" azure:"ro"` + + // READ-ONLY; String of the Target Type that this Capability extends. + TargetType *string `json:"targetType,omitempty" azure:"ro"` + + // READ-ONLY; String of the URN for this Capability Type. + Urn *string `json:"urn,omitempty" azure:"ro"` +} + +// CapabilityType - Model that represents a Capability Type resource. +type CapabilityType struct { + Resource + // Location of the Capability Type resource. + Location *string `json:"location,omitempty"` + + // READ-ONLY; The properties of the capability type resource. + Properties *CapabilityTypeProperties `json:"properties,omitempty" azure:"ro"` + + // READ-ONLY; The system metadata properties of the capability type resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilityType. +func (c CapabilityType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.Resource.marshalInternal(objectMap) + populate(objectMap, "location", c.Location) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + return json.Marshal(objectMap) +} + +// CapabilityTypeListResult - Model that represents a list of Capability Type resources and a link for pagination. +type CapabilityTypeListResult struct { + // READ-ONLY; URL to retrieve the next page of Capability Type resources. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of Capability Type resources. + Value []*CapabilityType `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilityTypeListResult. +func (c CapabilityTypeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CapabilityTypeProperties - Model that represents the Capability Type properties model. +type CapabilityTypeProperties struct { + // READ-ONLY; Localized string of the description. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Localized string of the display name. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; URL to retrieve JSON schema of the Capability Type parameters. + ParametersSchema *string `json:"parametersSchema,omitempty" azure:"ro"` + + // READ-ONLY; String of the Publisher that this Capability Type extends. + Publisher *string `json:"publisher,omitempty" azure:"ro"` + + // READ-ONLY; String of the Target Type that this Capability Type extends. + TargetType *string `json:"targetType,omitempty" azure:"ro"` + + // READ-ONLY; String of the URN for this Capability Type. + Urn *string `json:"urn,omitempty" azure:"ro"` +} + +// CapabilityTypesGetOptions contains the optional parameters for the CapabilityTypes.Get method. +type CapabilityTypesGetOptions struct { + // placeholder for future optional parameters +} + +// CapabilityTypesListOptions contains the optional parameters for the CapabilityTypes.List method. +type CapabilityTypesListOptions struct { + // String that sets the continuation token. + ContinuationToken *string +} + +// 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 +} + +// Experiment - Model that represents a Experiment resource. +type Experiment struct { + TrackedResource + // REQUIRED; The properties of the experiment resource. + Properties *ExperimentProperties `json:"properties,omitempty"` + + // The identity of the experiment resource. + Identity *ResourceIdentity `json:"identity,omitempty"` + + // READ-ONLY; The system metadata of the experiment resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Experiment. +func (e Experiment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "identity", e.Identity) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + return json.Marshal(objectMap) +} + +// ExperimentCancelOperationResult - Model that represents the result of a cancel Experiment operation. +type ExperimentCancelOperationResult struct { + // READ-ONLY; String of the Experiment name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; URL to retrieve the Experiment status. + StatusURL *string `json:"statusUrl,omitempty" azure:"ro"` +} + +// ExperimentExecutionActionTargetDetailsError - Model that represents the Experiment action target details error model. +type ExperimentExecutionActionTargetDetailsError struct { + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error message + Message *string `json:"message,omitempty" azure:"ro"` +} + +// ExperimentExecutionActionTargetDetailsProperties - Model that represents the Experiment action target details properties model. +type ExperimentExecutionActionTargetDetailsProperties struct { + // READ-ONLY; String that represents the completed date time. + CompletedDateUTC *time.Time `json:"completedDateUtc,omitempty" azure:"ro"` + + // READ-ONLY; The error of the action. + Error *ExperimentExecutionActionTargetDetailsError `json:"error,omitempty" azure:"ro"` + + // READ-ONLY; String that represents the failed date time. + FailedDateUTC *time.Time `json:"failedDateUtc,omitempty" azure:"ro"` + + // READ-ONLY; The status of the execution. + Status *string `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; The target for the action. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionActionTargetDetailsProperties. +func (e ExperimentExecutionActionTargetDetailsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "completedDateUtc", e.CompletedDateUTC) + populate(objectMap, "error", e.Error) + populateTimeRFC3339(objectMap, "failedDateUtc", e.FailedDateUTC) + populate(objectMap, "status", e.Status) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionActionTargetDetailsProperties. +func (e *ExperimentExecutionActionTargetDetailsProperties) 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 "completedDateUtc": + err = unpopulateTimeRFC3339(val, &e.CompletedDateUTC) + delete(rawMsg, key) + case "error": + err = unpopulate(val, &e.Error) + delete(rawMsg, key) + case "failedDateUtc": + err = unpopulateTimeRFC3339(val, &e.FailedDateUTC) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &e.Status) + delete(rawMsg, key) + case "target": + err = unpopulate(val, &e.Target) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ExperimentExecutionDetails - Model that represents the execution details of a Experiment. +type ExperimentExecutionDetails struct { + // READ-ONLY; String of the fully qualified resource ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; String of the resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The properties of the experiment execution details. + Properties *ExperimentExecutionDetailsProperties `json:"properties,omitempty" azure:"ro"` + + // READ-ONLY; String of the resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ExperimentExecutionDetailsListResult - Model that represents a list of Experiment execution details and a link for pagination. +type ExperimentExecutionDetailsListResult struct { + // READ-ONLY; URL to retrieve the next page of Experiment execution details. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of Experiment execution details. + Value []*ExperimentExecutionDetails `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionDetailsListResult. +func (e ExperimentExecutionDetailsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// ExperimentExecutionDetailsProperties - Model that represents the Experiment execution details properties model. +type ExperimentExecutionDetailsProperties struct { + // READ-ONLY; String that represents the created date time. + CreatedDateUTC *time.Time `json:"createdDateUtc,omitempty" azure:"ro"` + + // READ-ONLY; The id of the experiment. + ExperimentID *string `json:"experimentId,omitempty" azure:"ro"` + + // READ-ONLY; The reason why the execution failed. + FailureReason *string `json:"failureReason,omitempty" azure:"ro"` + + // READ-ONLY; String that represents the last action date time. + LastActionDateUTC *time.Time `json:"lastActionDateUtc,omitempty" azure:"ro"` + + // READ-ONLY; The information of the experiment run. + RunInformation *ExperimentExecutionDetailsPropertiesRunInformation `json:"runInformation,omitempty" azure:"ro"` + + // READ-ONLY; String that represents the start date time. + StartDateUTC *time.Time `json:"startDateUtc,omitempty" azure:"ro"` + + // READ-ONLY; The value of the status of the experiment execution. + Status *string `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; String that represents the stop date time. + StopDateUTC *time.Time `json:"stopDateUtc,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionDetailsProperties. +func (e ExperimentExecutionDetailsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdDateUtc", e.CreatedDateUTC) + populate(objectMap, "experimentId", e.ExperimentID) + populate(objectMap, "failureReason", e.FailureReason) + populateTimeRFC3339(objectMap, "lastActionDateUtc", e.LastActionDateUTC) + populate(objectMap, "runInformation", e.RunInformation) + populateTimeRFC3339(objectMap, "startDateUtc", e.StartDateUTC) + populate(objectMap, "status", e.Status) + populateTimeRFC3339(objectMap, "stopDateUtc", e.StopDateUTC) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionDetailsProperties. +func (e *ExperimentExecutionDetailsProperties) 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 "createdDateUtc": + err = unpopulateTimeRFC3339(val, &e.CreatedDateUTC) + delete(rawMsg, key) + case "experimentId": + err = unpopulate(val, &e.ExperimentID) + delete(rawMsg, key) + case "failureReason": + err = unpopulate(val, &e.FailureReason) + delete(rawMsg, key) + case "lastActionDateUtc": + err = unpopulateTimeRFC3339(val, &e.LastActionDateUTC) + delete(rawMsg, key) + case "runInformation": + err = unpopulate(val, &e.RunInformation) + delete(rawMsg, key) + case "startDateUtc": + err = unpopulateTimeRFC3339(val, &e.StartDateUTC) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &e.Status) + delete(rawMsg, key) + case "stopDateUtc": + err = unpopulateTimeRFC3339(val, &e.StopDateUTC) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ExperimentExecutionDetailsPropertiesRunInformation - The information of the experiment run. +type ExperimentExecutionDetailsPropertiesRunInformation struct { + // READ-ONLY; The steps of the experiment run. + Steps []*StepStatus `json:"steps,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionDetailsPropertiesRunInformation. +func (e ExperimentExecutionDetailsPropertiesRunInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "steps", e.Steps) + return json.Marshal(objectMap) +} + +// ExperimentListResult - Model that represents a list of Experiment resources and a link for pagination. +type ExperimentListResult struct { + // READ-ONLY; URL to retrieve the next page of Experiment resources. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of Experiment resources. + Value []*Experiment `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentListResult. +func (e ExperimentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// ExperimentProperties - Model that represents the Experiment properties model. +type ExperimentProperties struct { + // REQUIRED; List of selectors. + Selectors []*Selector `json:"selectors,omitempty"` + + // REQUIRED; List of steps. + Steps []*Step `json:"steps,omitempty"` + + // A boolean value that indicates if experiment should be started on creation or not. + StartOnCreation *bool `json:"startOnCreation,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentProperties. +func (e ExperimentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "selectors", e.Selectors) + populate(objectMap, "startOnCreation", e.StartOnCreation) + populate(objectMap, "steps", e.Steps) + return json.Marshal(objectMap) +} + +// ExperimentStartOperationResult - Model that represents the result of a start Experiment operation. +type ExperimentStartOperationResult struct { + // READ-ONLY; String of the Experiment name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; URL to retrieve the Experiment status. + StatusURL *string `json:"statusUrl,omitempty" azure:"ro"` +} + +// ExperimentStatus - Model that represents the status of a Experiment. +type ExperimentStatus struct { + // The properties of experiment execution status. + Properties *ExperimentStatusProperties `json:"properties,omitempty"` + + // READ-ONLY; String of the fully qualified resource ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; String of the resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; String of the resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ExperimentStatusListResult - Model that represents a list of Experiment statuses and a link for pagination. +type ExperimentStatusListResult struct { + // READ-ONLY; URL to retrieve the next page of Experiment statuses. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of Experiment statuses. + Value []*ExperimentStatus `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentStatusListResult. +func (e ExperimentStatusListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// ExperimentStatusProperties - Model that represents the Experiment status properties model. +type ExperimentStatusProperties struct { + // READ-ONLY; String that represents the created date time of a Experiment. + CreatedDateUTC *time.Time `json:"createdDateUtc,omitempty" azure:"ro"` + + // READ-ONLY; String that represents the end date time of a Experiment. + EndDateUTC *time.Time `json:"endDateUtc,omitempty" azure:"ro"` + + // READ-ONLY; String that represents the status of a Experiment. + Status *string `json:"status,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentStatusProperties. +func (e ExperimentStatusProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdDateUtc", e.CreatedDateUTC) + populateTimeRFC3339(objectMap, "endDateUtc", e.EndDateUTC) + populate(objectMap, "status", e.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentStatusProperties. +func (e *ExperimentStatusProperties) 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 "createdDateUtc": + err = unpopulateTimeRFC3339(val, &e.CreatedDateUTC) + delete(rawMsg, key) + case "endDateUtc": + err = unpopulateTimeRFC3339(val, &e.EndDateUTC) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &e.Status) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ExperimentsBeginCancelOptions contains the optional parameters for the Experiments.BeginCancel method. +type ExperimentsBeginCancelOptions struct { + // placeholder for future optional parameters +} + +// ExperimentsBeginCreateOrUpdateOptions contains the optional parameters for the Experiments.BeginCreateOrUpdate method. +type ExperimentsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ExperimentsDeleteOptions contains the optional parameters for the Experiments.Delete method. +type ExperimentsDeleteOptions struct { + // placeholder for future optional parameters +} + +// ExperimentsGetExecutionDetailsOptions contains the optional parameters for the Experiments.GetExecutionDetails method. +type ExperimentsGetExecutionDetailsOptions struct { + // placeholder for future optional parameters +} + +// ExperimentsGetOptions contains the optional parameters for the Experiments.Get method. +type ExperimentsGetOptions struct { + // placeholder for future optional parameters +} + +// ExperimentsGetStatusOptions contains the optional parameters for the Experiments.GetStatus method. +type ExperimentsGetStatusOptions struct { + // placeholder for future optional parameters +} + +// ExperimentsListAllOptions contains the optional parameters for the Experiments.ListAll method. +type ExperimentsListAllOptions struct { + // String that sets the continuation token. + ContinuationToken *string + // Optional value that indicates whether to filter results based on if the Experiment is currently running. If null, then the results will not be filtered. + Running *bool +} + +// ExperimentsListAllStatusesOptions contains the optional parameters for the Experiments.ListAllStatuses method. +type ExperimentsListAllStatusesOptions struct { + // placeholder for future optional parameters +} + +// ExperimentsListExecutionDetailsOptions contains the optional parameters for the Experiments.ListExecutionDetails method. +type ExperimentsListExecutionDetailsOptions struct { + // placeholder for future optional parameters +} + +// ExperimentsListOptions contains the optional parameters for the Experiments.List method. +type ExperimentsListOptions struct { + // String that sets the continuation token. + ContinuationToken *string + // Optional value that indicates whether to filter results based on if the Experiment is currently running. If null, then the results will not be filtered. + Running *bool +} + +// ExperimentsStartOptions contains the optional parameters for the Experiments.Start method. +type ExperimentsStartOptions struct { + // placeholder for future optional parameters +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" + Origin *Origin `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual + // Machine". + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListAllOptions contains the optional parameters for the Operations.ListAll method. +type OperationsListAllOptions 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) +} + +// ResourceIdentity - The managed identity of a resource. +type ResourceIdentity struct { + // REQUIRED; String of the resource identity type. + Type *ResourceIdentityType `json:"type,omitempty"` + + // READ-ONLY; GUID that represents the principal ID of this resource identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; GUID that represents the tenant ID of this resource identity. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// Selector - Model that represents a selector in the Experiment resource. +type Selector struct { + // REQUIRED; String of the selector ID. + ID *string `json:"id,omitempty"` + + // REQUIRED; List of Target references. + Targets []*TargetReference `json:"targets,omitempty"` + + // REQUIRED; Enum of the selector type. + Type *SelectorType `json:"type,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Selector. +func (s Selector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", s.ID) + populate(objectMap, "targets", s.Targets) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// Step - Model that represents a step in the Experiment resource. +type Step struct { + // REQUIRED; List of branches. + Branches []*Branch `json:"branches,omitempty"` + + // REQUIRED; String of the step name. + Name *string `json:"name,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Step. +func (s Step) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "branches", s.Branches) + populate(objectMap, "name", s.Name) + return json.Marshal(objectMap) +} + +// StepStatus - Model that represents the a list of branches and branch statuses. +type StepStatus struct { + // READ-ONLY; The array of branches. + Branches []*BranchStatus `json:"branches,omitempty" azure:"ro"` + + // READ-ONLY; The id of the step. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the step. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The value of the status of the step. + Status *string `json:"status,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type StepStatus. +func (s StepStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "branches", s.Branches) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// Target - Model that represents a Target resource. +type Target struct { + Resource + // REQUIRED; The properties of the target resource. + Properties map[string]interface{} `json:"properties,omitempty"` + + // Location of the target resource. + Location *string `json:"location,omitempty"` + + // READ-ONLY; The system metadata of the target resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Target. +func (t Target) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.Resource.marshalInternal(objectMap) + populate(objectMap, "location", t.Location) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + return json.Marshal(objectMap) +} + +// TargetListResult - Model that represents a list of Target resources and a link for pagination. +type TargetListResult struct { + // READ-ONLY; URL to retrieve the next page of Target resources. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of Target resources. + Value []*Target `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type TargetListResult. +func (t TargetListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// TargetReference - Model that represents a reference to a Target in the selector. +type TargetReference struct { + // REQUIRED; String of the resource ID of a Target resource. + ID *string `json:"id,omitempty"` + + // REQUIRED; Enum of the Target reference type. + Type *string `json:"type,omitempty"` +} + +// TargetType - Model that represents a Target Type resource. +type TargetType struct { + Resource + // REQUIRED; The properties of the target type resource. + Properties *TargetTypeProperties `json:"properties,omitempty"` + + // Location of the Target Type resource. + Location *string `json:"location,omitempty"` + + // READ-ONLY; The system metadata properties of the target type resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type TargetType. +func (t TargetType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.Resource.marshalInternal(objectMap) + populate(objectMap, "location", t.Location) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + return json.Marshal(objectMap) +} + +// TargetTypeListResult - Model that represents a list of Target Type resources and a link for pagination. +type TargetTypeListResult struct { + // READ-ONLY; URL to retrieve the next page of Target Type resources. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of Target Type resources. + Value []*TargetType `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type TargetTypeListResult. +func (t TargetTypeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// TargetTypeProperties - Model that represents the base Target Type properties model. +type TargetTypeProperties struct { + // READ-ONLY; Localized string of the description. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Localized string of the display name. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; URL to retrieve JSON schema of the Target Type properties. + PropertiesSchema *string `json:"propertiesSchema,omitempty" azure:"ro"` + + // READ-ONLY; List of resource types this Target Type can extend. + ResourceTypes []*string `json:"resourceTypes,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type TargetTypeProperties. +func (t TargetTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", t.Description) + populate(objectMap, "displayName", t.DisplayName) + populate(objectMap, "propertiesSchema", t.PropertiesSchema) + populate(objectMap, "resourceTypes", t.ResourceTypes) + return json.Marshal(objectMap) +} + +// TargetTypesGetOptions contains the optional parameters for the TargetTypes.Get method. +type TargetTypesGetOptions struct { + // placeholder for future optional parameters +} + +// TargetTypesListOptions contains the optional parameters for the TargetTypes.List method. +type TargetTypesListOptions struct { + // String that sets the continuation token. + ContinuationToken *string +} + +// TargetsCreateOrUpdateOptions contains the optional parameters for the Targets.CreateOrUpdate method. +type TargetsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// TargetsDeleteOptions contains the optional parameters for the Targets.Delete method. +type TargetsDeleteOptions struct { + // placeholder for future optional parameters +} + +// TargetsGetOptions contains the optional parameters for the Targets.Get method. +type TargetsGetOptions struct { + // placeholder for future optional parameters +} + +// TargetsListOptions contains the optional parameters for the Targets.List method. +type TargetsListOptions struct { + // String that sets the continuation token. + ContinuationToken *string +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' +type TrackedResource struct { + Resource + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal(objectMap map[string]interface{}) { + t.Resource.marshalInternal(objectMap) + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_operations_client.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_operations_client.go new file mode 100644 index 000000000000..a03170387aaa --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/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 armchaos + +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)} +} + +// ListAll - Get a list all available Operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) ListAll(options *OperationsListAllOptions) *OperationsListAllPager { + return &OperationsListAllPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listAllCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListAllResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listAllCreateRequest creates the ListAll request. +func (client *OperationsClient) listAllCreateRequest(ctx context.Context, options *OperationsListAllOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Chaos/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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listAllHandleResponse handles the ListAll response. +func (client *OperationsClient) listAllHandleResponse(resp *http.Response) (OperationsListAllResponse, error) { + result := OperationsListAllResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListAllResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listAllHandleError handles the ListAll error response. +func (client *OperationsClient) listAllHandleError(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/chaos/armchaos/zz_generated_pagers.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_pagers.go new file mode 100644 index 000000000000..e5e9a0697500 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/zz_generated_pagers.go @@ -0,0 +1,503 @@ +//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 armchaos + +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" +) + +// CapabilitiesListPager provides operations for iterating over paged responses. +type CapabilitiesListPager struct { + client *CapabilitiesClient + current CapabilitiesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, CapabilitiesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *CapabilitiesListPager) 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 *CapabilitiesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CapabilityListResult.NextLink == nil || len(*p.current.CapabilityListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current CapabilitiesListResponse page. +func (p *CapabilitiesListPager) PageResponse() CapabilitiesListResponse { + return p.current +} + +// CapabilityTypesListPager provides operations for iterating over paged responses. +type CapabilityTypesListPager struct { + client *CapabilityTypesClient + current CapabilityTypesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, CapabilityTypesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *CapabilityTypesListPager) 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 *CapabilityTypesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CapabilityTypeListResult.NextLink == nil || len(*p.current.CapabilityTypeListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current CapabilityTypesListResponse page. +func (p *CapabilityTypesListPager) PageResponse() CapabilityTypesListResponse { + return p.current +} + +// ExperimentsListAllPager provides operations for iterating over paged responses. +type ExperimentsListAllPager struct { + client *ExperimentsClient + current ExperimentsListAllResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ExperimentsListAllResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ExperimentsListAllPager) 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 *ExperimentsListAllPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ExperimentListResult.NextLink == nil || len(*p.current.ExperimentListResult.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.listAllHandleError(resp) + return false + } + result, err := p.client.listAllHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ExperimentsListAllResponse page. +func (p *ExperimentsListAllPager) PageResponse() ExperimentsListAllResponse { + return p.current +} + +// ExperimentsListAllStatusesPager provides operations for iterating over paged responses. +type ExperimentsListAllStatusesPager struct { + client *ExperimentsClient + current ExperimentsListAllStatusesResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ExperimentsListAllStatusesResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ExperimentsListAllStatusesPager) 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 *ExperimentsListAllStatusesPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ExperimentStatusListResult.NextLink == nil || len(*p.current.ExperimentStatusListResult.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.listAllStatusesHandleError(resp) + return false + } + result, err := p.client.listAllStatusesHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ExperimentsListAllStatusesResponse page. +func (p *ExperimentsListAllStatusesPager) PageResponse() ExperimentsListAllStatusesResponse { + return p.current +} + +// ExperimentsListExecutionDetailsPager provides operations for iterating over paged responses. +type ExperimentsListExecutionDetailsPager struct { + client *ExperimentsClient + current ExperimentsListExecutionDetailsResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ExperimentsListExecutionDetailsResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ExperimentsListExecutionDetailsPager) 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 *ExperimentsListExecutionDetailsPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ExperimentExecutionDetailsListResult.NextLink == nil || len(*p.current.ExperimentExecutionDetailsListResult.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.listExecutionDetailsHandleError(resp) + return false + } + result, err := p.client.listExecutionDetailsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ExperimentsListExecutionDetailsResponse page. +func (p *ExperimentsListExecutionDetailsPager) PageResponse() ExperimentsListExecutionDetailsResponse { + return p.current +} + +// ExperimentsListPager provides operations for iterating over paged responses. +type ExperimentsListPager struct { + client *ExperimentsClient + current ExperimentsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ExperimentsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ExperimentsListPager) 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 *ExperimentsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ExperimentListResult.NextLink == nil || len(*p.current.ExperimentListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ExperimentsListResponse page. +func (p *ExperimentsListPager) PageResponse() ExperimentsListResponse { + return p.current +} + +// OperationsListAllPager provides operations for iterating over paged responses. +type OperationsListAllPager struct { + client *OperationsClient + current OperationsListAllResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsListAllResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsListAllPager) 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 *OperationsListAllPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listAllHandleError(resp) + return false + } + result, err := p.client.listAllHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationsListAllResponse page. +func (p *OperationsListAllPager) PageResponse() OperationsListAllResponse { + return p.current +} + +// TargetTypesListPager provides operations for iterating over paged responses. +type TargetTypesListPager struct { + client *TargetTypesClient + current TargetTypesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, TargetTypesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *TargetTypesListPager) 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 *TargetTypesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TargetTypeListResult.NextLink == nil || len(*p.current.TargetTypeListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current TargetTypesListResponse page. +func (p *TargetTypesListPager) PageResponse() TargetTypesListResponse { + return p.current +} + +// TargetsListPager provides operations for iterating over paged responses. +type TargetsListPager struct { + client *TargetsClient + current TargetsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, TargetsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *TargetsListPager) 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 *TargetsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TargetListResult.NextLink == nil || len(*p.current.TargetListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current TargetsListResponse page. +func (p *TargetsListPager) PageResponse() TargetsListResponse { + return p.current +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_pollers.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_pollers.go new file mode 100644 index 000000000000..888ccd3ac6a7 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/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 armchaos + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// ExperimentsCancelPoller provides polling facilities until the operation reaches a terminal state. +type ExperimentsCancelPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ExperimentsCancelPoller) 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 *ExperimentsCancelPoller) 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 ExperimentsCancelResponse will be returned. +func (p *ExperimentsCancelPoller) FinalResponse(ctx context.Context) (ExperimentsCancelResponse, error) { + respType := ExperimentsCancelResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ExperimentCancelOperationResult) + if err != nil { + return ExperimentsCancelResponse{}, 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 *ExperimentsCancelPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ExperimentsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ExperimentsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ExperimentsCreateOrUpdatePoller) 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 *ExperimentsCreateOrUpdatePoller) 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 ExperimentsCreateOrUpdateResponse will be returned. +func (p *ExperimentsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (ExperimentsCreateOrUpdateResponse, error) { + respType := ExperimentsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Experiment) + if err != nil { + return ExperimentsCreateOrUpdateResponse{}, 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 *ExperimentsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_polymorphic_helpers.go new file mode 100644 index 000000000000..4be71bb388ee --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/zz_generated_polymorphic_helpers.go @@ -0,0 +1,65 @@ +//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 armchaos + +import "encoding/json" + +func unmarshalActionClassification(rawMsg json.RawMessage) (ActionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b ActionClassification + switch m["type"] { + default: + b = &Action{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalActionClassificationArray(rawMsg json.RawMessage) ([]ActionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]ActionClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalActionClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalActionClassificationMap(rawMsg json.RawMessage) (map[string]ActionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]ActionClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalActionClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_response_types.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_response_types.go new file mode 100644 index 000000000000..5e5ed176a3c5 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/zz_generated_response_types.go @@ -0,0 +1,366 @@ +//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 armchaos + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// CapabilitiesCreateOrUpdateResponse contains the response from method Capabilities.CreateOrUpdate. +type CapabilitiesCreateOrUpdateResponse struct { + CapabilitiesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CapabilitiesCreateOrUpdateResult contains the result from method Capabilities.CreateOrUpdate. +type CapabilitiesCreateOrUpdateResult struct { + Capability +} + +// CapabilitiesDeleteResponse contains the response from method Capabilities.Delete. +type CapabilitiesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CapabilitiesGetResponse contains the response from method Capabilities.Get. +type CapabilitiesGetResponse struct { + CapabilitiesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CapabilitiesGetResult contains the result from method Capabilities.Get. +type CapabilitiesGetResult struct { + Capability +} + +// CapabilitiesListResponse contains the response from method Capabilities.List. +type CapabilitiesListResponse struct { + CapabilitiesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CapabilitiesListResult contains the result from method Capabilities.List. +type CapabilitiesListResult struct { + CapabilityListResult +} + +// CapabilityTypesGetResponse contains the response from method CapabilityTypes.Get. +type CapabilityTypesGetResponse struct { + CapabilityTypesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CapabilityTypesGetResult contains the result from method CapabilityTypes.Get. +type CapabilityTypesGetResult struct { + CapabilityType +} + +// CapabilityTypesListResponse contains the response from method CapabilityTypes.List. +type CapabilityTypesListResponse struct { + CapabilityTypesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CapabilityTypesListResult contains the result from method CapabilityTypes.List. +type CapabilityTypesListResult struct { + CapabilityTypeListResult +} + +// ExperimentsCancelPollerResponse contains the response from method Experiments.Cancel. +type ExperimentsCancelPollerResponse struct { + // Poller contains an initialized poller. + Poller *ExperimentsCancelPoller + + // 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 ExperimentsCancelPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ExperimentsCancelResponse, error) { + respType := ExperimentsCancelResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ExperimentCancelOperationResult) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ExperimentsCancelPollerResponse from the provided client and resume token. +func (l *ExperimentsCancelPollerResponse) Resume(ctx context.Context, client *ExperimentsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ExperimentsClient.Cancel", token, client.pl, client.cancelHandleError) + if err != nil { + return err + } + poller := &ExperimentsCancelPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ExperimentsCancelResponse contains the response from method Experiments.Cancel. +type ExperimentsCancelResponse struct { + ExperimentsCancelResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExperimentsCancelResult contains the result from method Experiments.Cancel. +type ExperimentsCancelResult struct { + ExperimentCancelOperationResult +} + +// ExperimentsCreateOrUpdatePollerResponse contains the response from method Experiments.CreateOrUpdate. +type ExperimentsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ExperimentsCreateOrUpdatePoller + + // 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 ExperimentsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ExperimentsCreateOrUpdateResponse, error) { + respType := ExperimentsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Experiment) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ExperimentsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *ExperimentsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *ExperimentsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ExperimentsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &ExperimentsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ExperimentsCreateOrUpdateResponse contains the response from method Experiments.CreateOrUpdate. +type ExperimentsCreateOrUpdateResponse struct { + ExperimentsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExperimentsCreateOrUpdateResult contains the result from method Experiments.CreateOrUpdate. +type ExperimentsCreateOrUpdateResult struct { + Experiment +} + +// ExperimentsDeleteResponse contains the response from method Experiments.Delete. +type ExperimentsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExperimentsGetExecutionDetailsResponse contains the response from method Experiments.GetExecutionDetails. +type ExperimentsGetExecutionDetailsResponse struct { + ExperimentsGetExecutionDetailsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExperimentsGetExecutionDetailsResult contains the result from method Experiments.GetExecutionDetails. +type ExperimentsGetExecutionDetailsResult struct { + ExperimentExecutionDetails +} + +// ExperimentsGetResponse contains the response from method Experiments.Get. +type ExperimentsGetResponse struct { + ExperimentsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExperimentsGetResult contains the result from method Experiments.Get. +type ExperimentsGetResult struct { + Experiment +} + +// ExperimentsGetStatusResponse contains the response from method Experiments.GetStatus. +type ExperimentsGetStatusResponse struct { + ExperimentsGetStatusResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExperimentsGetStatusResult contains the result from method Experiments.GetStatus. +type ExperimentsGetStatusResult struct { + ExperimentStatus +} + +// ExperimentsListAllResponse contains the response from method Experiments.ListAll. +type ExperimentsListAllResponse struct { + ExperimentsListAllResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExperimentsListAllResult contains the result from method Experiments.ListAll. +type ExperimentsListAllResult struct { + ExperimentListResult +} + +// ExperimentsListAllStatusesResponse contains the response from method Experiments.ListAllStatuses. +type ExperimentsListAllStatusesResponse struct { + ExperimentsListAllStatusesResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExperimentsListAllStatusesResult contains the result from method Experiments.ListAllStatuses. +type ExperimentsListAllStatusesResult struct { + ExperimentStatusListResult +} + +// ExperimentsListExecutionDetailsResponse contains the response from method Experiments.ListExecutionDetails. +type ExperimentsListExecutionDetailsResponse struct { + ExperimentsListExecutionDetailsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExperimentsListExecutionDetailsResult contains the result from method Experiments.ListExecutionDetails. +type ExperimentsListExecutionDetailsResult struct { + ExperimentExecutionDetailsListResult +} + +// ExperimentsListResponse contains the response from method Experiments.List. +type ExperimentsListResponse struct { + ExperimentsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExperimentsListResult contains the result from method Experiments.List. +type ExperimentsListResult struct { + ExperimentListResult +} + +// ExperimentsStartResponse contains the response from method Experiments.Start. +type ExperimentsStartResponse struct { + ExperimentsStartResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExperimentsStartResult contains the result from method Experiments.Start. +type ExperimentsStartResult struct { + ExperimentStartOperationResult +} + +// OperationsListAllResponse contains the response from method Operations.ListAll. +type OperationsListAllResponse struct { + OperationsListAllResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListAllResult contains the result from method Operations.ListAll. +type OperationsListAllResult struct { + OperationListResult +} + +// TargetTypesGetResponse contains the response from method TargetTypes.Get. +type TargetTypesGetResponse struct { + TargetTypesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TargetTypesGetResult contains the result from method TargetTypes.Get. +type TargetTypesGetResult struct { + TargetType +} + +// TargetTypesListResponse contains the response from method TargetTypes.List. +type TargetTypesListResponse struct { + TargetTypesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TargetTypesListResult contains the result from method TargetTypes.List. +type TargetTypesListResult struct { + TargetTypeListResult +} + +// TargetsCreateOrUpdateResponse contains the response from method Targets.CreateOrUpdate. +type TargetsCreateOrUpdateResponse struct { + TargetsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TargetsCreateOrUpdateResult contains the result from method Targets.CreateOrUpdate. +type TargetsCreateOrUpdateResult struct { + Target +} + +// TargetsDeleteResponse contains the response from method Targets.Delete. +type TargetsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TargetsGetResponse contains the response from method Targets.Get. +type TargetsGetResponse struct { + TargetsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TargetsGetResult contains the result from method Targets.Get. +type TargetsGetResult struct { + Target +} + +// TargetsListResponse contains the response from method Targets.List. +type TargetsListResponse struct { + TargetsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TargetsListResult contains the result from method Targets.List. +type TargetsListResult struct { + TargetListResult +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_targets_client.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_targets_client.go new file mode 100644 index 000000000000..523f593b029c --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/zz_generated_targets_client.go @@ -0,0 +1,338 @@ +//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 armchaos + +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" +) + +// TargetsClient contains the methods for the Targets group. +// Don't use this type directly, use NewTargetsClient() instead. +type TargetsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewTargetsClient creates a new instance of TargetsClient with the specified values. +func NewTargetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *TargetsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &TargetsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Create or update a Target resource that extends a tracked regional resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TargetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, target Target, options *TargetsCreateOrUpdateOptions) (TargetsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, target, options) + if err != nil { + return TargetsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TargetsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TargetsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *TargetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, target Target, options *TargetsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}" + 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 parentProviderNamespace == "" { + return nil, errors.New("parameter parentProviderNamespace cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) + if parentResourceType == "" { + return nil, errors.New("parameter parentResourceType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) + if parentResourceName == "" { + return nil, errors.New("parameter parentResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) + if targetName == "" { + return nil, errors.New("parameter targetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{targetName}", url.PathEscape(targetName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, target) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *TargetsClient) createOrUpdateHandleResponse(resp *http.Response) (TargetsCreateOrUpdateResponse, error) { + result := TargetsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Target); err != nil { + return TargetsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *TargetsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete a Target resource that extends a tracked regional resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TargetsClient) Delete(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *TargetsDeleteOptions) (TargetsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, options) + if err != nil { + return TargetsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TargetsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return TargetsDeleteResponse{}, client.deleteHandleError(resp) + } + return TargetsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TargetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *TargetsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}" + 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 parentProviderNamespace == "" { + return nil, errors.New("parameter parentProviderNamespace cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) + if parentResourceType == "" { + return nil, errors.New("parameter parentResourceType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) + if parentResourceName == "" { + return nil, errors.New("parameter parentResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) + if targetName == "" { + return nil, errors.New("parameter targetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{targetName}", url.PathEscape(targetName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *TargetsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get a Target resource that extends a tracked regional resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TargetsClient) Get(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *TargetsGetOptions) (TargetsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, options) + if err != nil { + return TargetsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TargetsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TargetsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TargetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *TargetsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}" + 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 parentProviderNamespace == "" { + return nil, errors.New("parameter parentProviderNamespace cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) + if parentResourceType == "" { + return nil, errors.New("parameter parentResourceType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) + if parentResourceName == "" { + return nil, errors.New("parameter parentResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) + if targetName == "" { + return nil, errors.New("parameter targetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{targetName}", url.PathEscape(targetName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TargetsClient) getHandleResponse(resp *http.Response) (TargetsGetResponse, error) { + result := TargetsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Target); err != nil { + return TargetsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *TargetsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Get a list of Target resources that extend a tracked regional resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TargetsClient) List(resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, options *TargetsListOptions) *TargetsListPager { + return &TargetsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, options) + }, + advancer: func(ctx context.Context, resp TargetsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.TargetListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *TargetsClient) listCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, options *TargetsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets" + 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 parentProviderNamespace == "" { + return nil, errors.New("parameter parentProviderNamespace cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) + if parentResourceType == "" { + return nil, errors.New("parameter parentResourceType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) + if parentResourceName == "" { + return nil, errors.New("parameter parentResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) + 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-09-15-preview") + if options != nil && options.ContinuationToken != nil { + reqQP.Set("continuationToken", *options.ContinuationToken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *TargetsClient) listHandleResponse(resp *http.Response) (TargetsListResponse, error) { + result := TargetsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.TargetListResult); err != nil { + return TargetsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *TargetsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_targettypes_client.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_targettypes_client.go new file mode 100644 index 000000000000..13e0a24e993b --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/zz_generated_targettypes_client.go @@ -0,0 +1,169 @@ +//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 armchaos + +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" +) + +// TargetTypesClient contains the methods for the TargetTypes group. +// Don't use this type directly, use NewTargetTypesClient() instead. +type TargetTypesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewTargetTypesClient creates a new instance of TargetTypesClient with the specified values. +func NewTargetTypesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *TargetTypesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &TargetTypesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get a Target Type resources for given location. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TargetTypesClient) Get(ctx context.Context, locationName string, targetTypeName string, options *TargetTypesGetOptions) (TargetTypesGetResponse, error) { + req, err := client.getCreateRequest(ctx, locationName, targetTypeName, options) + if err != nil { + return TargetTypesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TargetTypesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TargetTypesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TargetTypesClient) getCreateRequest(ctx context.Context, locationName string, targetTypeName string, options *TargetTypesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes/{targetTypeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationName == "" { + return nil, errors.New("parameter locationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + if targetTypeName == "" { + return nil, errors.New("parameter targetTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{targetTypeName}", url.PathEscape(targetTypeName)) + 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-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TargetTypesClient) getHandleResponse(resp *http.Response) (TargetTypesGetResponse, error) { + result := TargetTypesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.TargetType); err != nil { + return TargetTypesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *TargetTypesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Get a list of Target Type resources for given location. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TargetTypesClient) List(locationName string, options *TargetTypesListOptions) *TargetTypesListPager { + return &TargetTypesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, locationName, options) + }, + advancer: func(ctx context.Context, resp TargetTypesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.TargetTypeListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *TargetTypesClient) listCreateRequest(ctx context.Context, locationName string, options *TargetTypesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationName == "" { + return nil, errors.New("parameter locationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + 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-09-15-preview") + if options != nil && options.ContinuationToken != nil { + reqQP.Set("continuationToken", *options.ContinuationToken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *TargetTypesClient) listHandleResponse(resp *http.Response) (TargetTypesListResponse, error) { + result := TargetTypesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.TargetTypeListResult); err != nil { + return TargetTypesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *TargetTypesClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_time_rfc3339.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..e5b4a3bcceda --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/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 armchaos + +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 +} From 2658927ba1e86fefffed7c5b9c63f65a99a2152d Mon Sep 17 00:00:00 2001 From: Dapeng Zhang Date: Thu, 16 Dec 2021 13:14:48 +0800 Subject: [PATCH 2/2] Update CHANGELOG.md --- sdk/resourcemanager/chaos/armchaos/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md b/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md index c12e9f9b576d..34ac19703899 100644 --- a/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md +++ b/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md @@ -1,5 +1,5 @@ # Release History -## 0.1.0 (2021-12-14) +## 0.1.0 (2021-12-16) -- Init release. \ No newline at end of file +- Init release.