From f03678aa4bbd22bb4d32a3e60de4a1e248b270ad Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 17 Feb 2022 08:46:49 +0000 Subject: [PATCH] CodeGen from PR 17667 in Azure/azure-rest-api-specs Add Swagger spec of MICROSOFT.DASHBOARD for Public Preview (#17667) * Add Swagger spec of MICROSOFT.DASHBOARD for Public Preview * Add sdk files * Use ErrorResponse from common-types * Update GrafanaResource to follow TrackedResources from common-types * Update specification/dashboard/resource-manager/readme.typescript.md Co-authored-by: Wei Dong <40835867+dw511214992@users.noreply.github.com> * Update specification/dashboard/resource-manager/readme.typescript.md Co-authored-by: Wei Dong <40835867+dw511214992@users.noreply.github.com> * Update specification/dashboard/resource-manager/readme.csharp.md Co-authored-by: Wei Dong <40835867+dw511214992@users.noreply.github.com> * Remove location from PATCH * Refer to OperationList from common types * Fix Swagger ModelValidation error * Remove GrafanaResourcePropertiesUpdateParameters * Update specification/dashboard/resource-manager/readme.md Co-authored-by: Wei Dong <40835867+dw511214992@users.noreply.github.com> * Update readme.python.md * Update specification/dashboard/resource-manager/readme.go.md * Update specification/dashboard/resource-manager/readme.md * Update readme.python.md * Update readme.md * Update specification/dashboard/resource-manager/readme.csharp.md Co-authored-by: Wei Dong <40835867+dw511214992@users.noreply.github.com> Co-authored-by: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Co-authored-by: Yuchao Yan --- .../dashboard/armdashboard/CHANGELOG.md | 5 + .../dashboard/armdashboard/LICENSE.txt | 21 + .../dashboard/armdashboard/README.md | 75 ++++ .../dashboard/armdashboard/autorest.md | 13 + .../dashboard/armdashboard/build.go | 7 + .../dashboard/armdashboard/ci.yml | 27 ++ .../dashboard/armdashboard/go.mod | 8 + .../dashboard/armdashboard/go.sum | 37 ++ .../armdashboard/go_mod_tidy_hack.go | 13 + .../armdashboard/zz_generated_constants.go | 181 ++++++++ .../zz_generated_grafana_client.go | 399 ++++++++++++++++++ .../armdashboard/zz_generated_models.go | 305 +++++++++++++ .../zz_generated_operations_client.go | 82 ++++ .../armdashboard/zz_generated_pagers.go | 179 ++++++++ .../armdashboard/zz_generated_pollers.go | 101 +++++ .../zz_generated_response_types.go | 174 ++++++++ .../armdashboard/zz_generated_time_rfc3339.go | 85 ++++ 17 files changed, 1712 insertions(+) create mode 100644 sdk/resourcemanager/dashboard/armdashboard/CHANGELOG.md create mode 100644 sdk/resourcemanager/dashboard/armdashboard/LICENSE.txt create mode 100644 sdk/resourcemanager/dashboard/armdashboard/README.md create mode 100644 sdk/resourcemanager/dashboard/armdashboard/autorest.md create mode 100644 sdk/resourcemanager/dashboard/armdashboard/build.go create mode 100644 sdk/resourcemanager/dashboard/armdashboard/ci.yml create mode 100644 sdk/resourcemanager/dashboard/armdashboard/go.mod create mode 100644 sdk/resourcemanager/dashboard/armdashboard/go.sum create mode 100644 sdk/resourcemanager/dashboard/armdashboard/go_mod_tidy_hack.go create mode 100644 sdk/resourcemanager/dashboard/armdashboard/zz_generated_constants.go create mode 100644 sdk/resourcemanager/dashboard/armdashboard/zz_generated_grafana_client.go create mode 100644 sdk/resourcemanager/dashboard/armdashboard/zz_generated_models.go create mode 100644 sdk/resourcemanager/dashboard/armdashboard/zz_generated_operations_client.go create mode 100644 sdk/resourcemanager/dashboard/armdashboard/zz_generated_pagers.go create mode 100644 sdk/resourcemanager/dashboard/armdashboard/zz_generated_pollers.go create mode 100644 sdk/resourcemanager/dashboard/armdashboard/zz_generated_response_types.go create mode 100644 sdk/resourcemanager/dashboard/armdashboard/zz_generated_time_rfc3339.go diff --git a/sdk/resourcemanager/dashboard/armdashboard/CHANGELOG.md b/sdk/resourcemanager/dashboard/armdashboard/CHANGELOG.md new file mode 100644 index 000000000000..bf4988fd59d3 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2022-02-17) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/dashboard/armdashboard/LICENSE.txt b/sdk/resourcemanager/dashboard/armdashboard/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/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/dashboard/armdashboard/README.md b/sdk/resourcemanager/dashboard/armdashboard/README.md new file mode 100644 index 000000000000..64749c18b244 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/README.md @@ -0,0 +1,75 @@ +# Azure Dashboard Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard) + +The `armdashboard` module provides operations for working with Azure Dashboard. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/dashboard/armdashboard) + +# 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 Dashboard module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Dashboard. 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 Dashboard 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 := armdashboard.(, 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 := armdashboard.(, 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 `Dashboard` 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/dashboard/armdashboard/autorest.md b/sdk/resourcemanager/dashboard/armdashboard/autorest.md new file mode 100644 index 000000000000..6ef7dc468259 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/dashboard/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/dashboard/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/dashboard/armdashboard/build.go b/sdk/resourcemanager/dashboard/armdashboard/build.go new file mode 100644 index 000000000000..f2b1fa27f41b --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/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/dashboard/armdashboard + +package armdashboard diff --git a/sdk/resourcemanager/dashboard/armdashboard/ci.yml b/sdk/resourcemanager/dashboard/armdashboard/ci.yml new file mode 100644 index 000000000000..7c7c742b7a58 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/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/dashboard/armdashboard/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/dashboard/armdashboard/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/dashboard/armdashboard' diff --git a/sdk/resourcemanager/dashboard/armdashboard/go.mod b/sdk/resourcemanager/dashboard/armdashboard/go.mod new file mode 100644 index 000000000000..a1387e640ab4 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v61.5.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 +) diff --git a/sdk/resourcemanager/dashboard/armdashboard/go.sum b/sdk/resourcemanager/dashboard/armdashboard/go.sum new file mode 100644 index 000000000000..621181783406 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v61.5.0+incompatible h1:OSHSFeNm7D1InGsQrFjyN9hpxD5Ec60PdsWWudCpah4= +github.com/Azure/azure-sdk-for-go v61.5.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 h1:8wVJL0HUP5yDFXvotdewORTw7Yu88JbreWN/mobSvsQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3 h1:E+m3SkZCN0Bf5q7YdTs5lSm2CYY3CK4spn5OmUIiQtk= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/dashboard/armdashboard/go_mod_tidy_hack.go b/sdk/resourcemanager/dashboard/armdashboard/go_mod_tidy_hack.go new file mode 100644 index 000000000000..1469bb6e7eed --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/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 armdashboard + +// 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/dashboard/armdashboard/zz_generated_constants.go b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_constants.go new file mode 100644 index 000000000000..a50a95ec066c --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_constants.go @@ -0,0 +1,181 @@ +//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 armdashboard + +const ( + moduleName = "armdashboard" + moduleVersion = "v0.1.0" +) + +// ActionType - 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 +} + +// IdentityType - The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned +// identities. The type 'None' will remove any identities from the resource. +type IdentityType string + +const ( + IdentityTypeNone IdentityType = "None" + IdentityTypeSystemAssigned IdentityType = "SystemAssigned" +) + +// PossibleIdentityTypeValues returns the possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{ + IdentityTypeNone, + IdentityTypeSystemAssigned, + } +} + +// ToPtr returns a *IdentityType pointing to the current value. +func (c IdentityType) ToPtr() *IdentityType { + return &c +} + +type LastModifiedByType string + +const ( + LastModifiedByTypeApplication LastModifiedByType = "Application" + LastModifiedByTypeKey LastModifiedByType = "Key" + LastModifiedByTypeManagedIdentity LastModifiedByType = "ManagedIdentity" + LastModifiedByTypeUser LastModifiedByType = "User" +) + +// PossibleLastModifiedByTypeValues returns the possible values for the LastModifiedByType const type. +func PossibleLastModifiedByTypeValues() []LastModifiedByType { + return []LastModifiedByType{ + LastModifiedByTypeApplication, + LastModifiedByTypeKey, + LastModifiedByTypeManagedIdentity, + LastModifiedByTypeUser, + } +} + +// ToPtr returns a *LastModifiedByType pointing to the current value. +func (c LastModifiedByType) ToPtr() *LastModifiedByType { + return &c +} + +// Origin - The intended executor of the operation. +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 +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateCreating, + ProvisioningStateDeleted, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateNotSpecified, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +type ZoneRedundancy string + +const ( + ZoneRedundancyDisabled ZoneRedundancy = "Disabled" + ZoneRedundancyEnabled ZoneRedundancy = "Enabled" +) + +// PossibleZoneRedundancyValues returns the possible values for the ZoneRedundancy const type. +func PossibleZoneRedundancyValues() []ZoneRedundancy { + return []ZoneRedundancy{ + ZoneRedundancyDisabled, + ZoneRedundancyEnabled, + } +} + +// ToPtr returns a *ZoneRedundancy pointing to the current value. +func (c ZoneRedundancy) ToPtr() *ZoneRedundancy { + return &c +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/zz_generated_grafana_client.go b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_grafana_client.go new file mode 100644 index 000000000000..0344b975e8b9 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_grafana_client.go @@ -0,0 +1,399 @@ +//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 armdashboard + +import ( + "context" + "errors" + "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" +) + +// GrafanaClient contains the methods for the Grafana group. +// Don't use this type directly, use NewGrafanaClient() instead. +type GrafanaClient struct { + host string + pl runtime.Pipeline +} + +// NewGrafanaClient creates a new instance of GrafanaClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewGrafanaClient(credential azcore.TokenCredential, options *arm.ClientOptions) *GrafanaClient { + if options == nil { + options = &arm.ClientOptions{} + } + ep := options.Endpoint + if len(ep) == 0 { + ep = arm.AzurePublicCloud + } + client := &GrafanaClient{ + host: string(ep), + pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options), + } + return client +} + +// BeginCreate - Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new +// grafana or update an existing grafana. +// If the operation fails it returns an *azcore.ResponseError type. +// subscriptionID - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID +// forms part of the URI for every service call. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// workspaceName - The name of Azure Managed Workspace for Grafana. +// options - GrafanaClientBeginCreateOptions contains the optional parameters for the GrafanaClient.BeginCreate method. +func (client *GrafanaClient) BeginCreate(ctx context.Context, subscriptionID string, resourceGroupName string, workspaceName string, options *GrafanaClientBeginCreateOptions) (GrafanaClientCreatePollerResponse, error) { + resp, err := client.create(ctx, subscriptionID, resourceGroupName, workspaceName, options) + if err != nil { + return GrafanaClientCreatePollerResponse{}, err + } + result := GrafanaClientCreatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("GrafanaClient.Create", "azure-async-operation", resp, client.pl) + if err != nil { + return GrafanaClientCreatePollerResponse{}, err + } + result.Poller = &GrafanaClientCreatePoller{ + pt: pt, + } + return result, nil +} + +// Create - Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new grafana +// or update an existing grafana. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *GrafanaClient) create(ctx context.Context, subscriptionID string, resourceGroupName string, workspaceName string, options *GrafanaClientBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, subscriptionID, resourceGroupName, workspaceName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *GrafanaClient) createCreateRequest(ctx context.Context, subscriptionID string, resourceGroupName string, workspaceName string, options *GrafanaClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, runtime.MarshalAsJSON(req, *options.Body) + } + return req, nil +} + +// BeginDelete - Delete a workspace for Grafana resource. +// If the operation fails it returns an *azcore.ResponseError type. +// subscriptionID - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID +// forms part of the URI for every service call. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// workspaceName - The name of Azure Managed Workspace for Grafana. +// options - GrafanaClientBeginDeleteOptions contains the optional parameters for the GrafanaClient.BeginDelete method. +func (client *GrafanaClient) BeginDelete(ctx context.Context, subscriptionID string, resourceGroupName string, workspaceName string, options *GrafanaClientBeginDeleteOptions) (GrafanaClientDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, subscriptionID, resourceGroupName, workspaceName, options) + if err != nil { + return GrafanaClientDeletePollerResponse{}, err + } + result := GrafanaClientDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("GrafanaClient.Delete", "azure-async-operation", resp, client.pl) + if err != nil { + return GrafanaClientDeletePollerResponse{}, err + } + result.Poller = &GrafanaClientDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a workspace for Grafana resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *GrafanaClient) deleteOperation(ctx context.Context, subscriptionID string, resourceGroupName string, workspaceName string, options *GrafanaClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, subscriptionID, resourceGroupName, workspaceName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *GrafanaClient) deleteCreateRequest(ctx context.Context, subscriptionID string, resourceGroupName string, workspaceName string, options *GrafanaClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// Get - Get the properties of a specific workspace for Grafana resource. +// If the operation fails it returns an *azcore.ResponseError type. +// subscriptionID - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID +// forms part of the URI for every service call. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// workspaceName - The name of Azure Managed Workspace for Grafana. +// options - GrafanaClientGetOptions contains the optional parameters for the GrafanaClient.Get method. +func (client *GrafanaClient) Get(ctx context.Context, subscriptionID string, resourceGroupName string, workspaceName string, options *GrafanaClientGetOptions) (GrafanaClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, subscriptionID, resourceGroupName, workspaceName, options) + if err != nil { + return GrafanaClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GrafanaClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GrafanaClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *GrafanaClient) getCreateRequest(ctx context.Context, subscriptionID string, resourceGroupName string, workspaceName string, options *GrafanaClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *GrafanaClient) getHandleResponse(resp *http.Response) (GrafanaClientGetResponse, error) { + result := GrafanaClientGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GrafanaResource); err != nil { + return GrafanaClientGetResponse{}, err + } + return result, nil +} + +// List - List all resources of workspaces for Grafana under the specified subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// subscriptionID - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID +// forms part of the URI for every service call. +// options - GrafanaClientListOptions contains the optional parameters for the GrafanaClient.List method. +func (client *GrafanaClient) List(subscriptionID string, options *GrafanaClientListOptions) *GrafanaClientListPager { + return &GrafanaClientListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, subscriptionID, options) + }, + advancer: func(ctx context.Context, resp GrafanaClientListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.GrafanaResourceListResponse.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *GrafanaClient) listCreateRequest(ctx context.Context, subscriptionID string, options *GrafanaClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/grafana" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *GrafanaClient) listHandleResponse(resp *http.Response) (GrafanaClientListResponse, error) { + result := GrafanaClientListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GrafanaResourceListResponse); err != nil { + return GrafanaClientListResponse{}, err + } + return result, nil +} + +// ListByResourceGroup - List all resources of workspaces for Grafana under the specified resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// subscriptionID - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID +// forms part of the URI for every service call. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// options - GrafanaClientListByResourceGroupOptions contains the optional parameters for the GrafanaClient.ListByResourceGroup +// method. +func (client *GrafanaClient) ListByResourceGroup(subscriptionID string, resourceGroupName string, options *GrafanaClientListByResourceGroupOptions) *GrafanaClientListByResourceGroupPager { + return &GrafanaClientListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, subscriptionID, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp GrafanaClientListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.GrafanaResourceListResponse.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *GrafanaClient) listByResourceGroupCreateRequest(ctx context.Context, subscriptionID string, resourceGroupName string, options *GrafanaClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *GrafanaClient) listByResourceGroupHandleResponse(resp *http.Response) (GrafanaClientListByResourceGroupResponse, error) { + result := GrafanaClientListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GrafanaResourceListResponse); err != nil { + return GrafanaClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// Update - Update a workspace for Grafana resource. +// If the operation fails it returns an *azcore.ResponseError type. +// subscriptionID - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID +// forms part of the URI for every service call. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// workspaceName - The name of Azure Managed Workspace for Grafana. +// options - GrafanaClientUpdateOptions contains the optional parameters for the GrafanaClient.Update method. +func (client *GrafanaClient) Update(ctx context.Context, subscriptionID string, resourceGroupName string, workspaceName string, options *GrafanaClientUpdateOptions) (GrafanaClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, subscriptionID, resourceGroupName, workspaceName, options) + if err != nil { + return GrafanaClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GrafanaClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GrafanaClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *GrafanaClient) updateCreateRequest(ctx context.Context, subscriptionID string, resourceGroupName string, workspaceName string, options *GrafanaClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}" + if subscriptionID == "" { + return nil, errors.New("parameter subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, runtime.MarshalAsJSON(req, *options.Body) + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *GrafanaClient) updateHandleResponse(resp *http.Response) (GrafanaClientUpdateResponse, error) { + result := GrafanaClientUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GrafanaResource); err != nil { + return GrafanaClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/zz_generated_models.go b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_models.go new file mode 100644 index 000000000000..49c5b131a2da --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_models.go @@ -0,0 +1,305 @@ +//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 armdashboard + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// GrafanaClientBeginCreateOptions contains the optional parameters for the GrafanaClient.BeginCreate method. +type GrafanaClientBeginCreateOptions struct { + Body *GrafanaResource +} + +// GrafanaClientBeginDeleteOptions contains the optional parameters for the GrafanaClient.BeginDelete method. +type GrafanaClientBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// GrafanaClientGetOptions contains the optional parameters for the GrafanaClient.Get method. +type GrafanaClientGetOptions struct { + // placeholder for future optional parameters +} + +// GrafanaClientListByResourceGroupOptions contains the optional parameters for the GrafanaClient.ListByResourceGroup method. +type GrafanaClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// GrafanaClientListOptions contains the optional parameters for the GrafanaClient.List method. +type GrafanaClientListOptions struct { + // placeholder for future optional parameters +} + +// GrafanaClientUpdateOptions contains the optional parameters for the GrafanaClient.Update method. +type GrafanaClientUpdateOptions struct { + Body *GrafanaResourceUpdateParameters +} + +// GrafanaResource - The grafana resource type. +type GrafanaResource struct { + // The managed identity of the grafana resource. + Identity *ManagedIdentity `json:"identity,omitempty"` + + // The geo-location where the grafana resource lives + Location *string `json:"location,omitempty"` + + // Properties specific to the grafana resource. + Properties *GrafanaResourceProperties `json:"properties,omitempty"` + + // The Sku of the grafana resource. + SKU *ResourceSKU `json:"sku,omitempty"` + + // The tags for grafana resource. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; ARM id of the grafana resource + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the grafana resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The system meta data relating to this grafana resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the grafana resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type GrafanaResource. +func (g GrafanaResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", g.ID) + populate(objectMap, "identity", g.Identity) + populate(objectMap, "location", g.Location) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "sku", g.SKU) + populate(objectMap, "systemData", g.SystemData) + populate(objectMap, "tags", g.Tags) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +type GrafanaResourceListResponse struct { + NextLink *string `json:"nextLink,omitempty"` + Value []*GrafanaResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GrafanaResourceListResponse. +func (g GrafanaResourceListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// GrafanaResourceProperties - Properties specific to the grafana resource. +type GrafanaResourceProperties struct { + // Provisioning state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ZoneRedundancy *ZoneRedundancy `json:"zoneRedundancy,omitempty"` + + // READ-ONLY; The endpoint of the Grafana instance. + Endpoint *string `json:"endpoint,omitempty" azure:"ro"` + + // READ-ONLY; The Grafana software version. + GrafanaVersion *string `json:"grafanaVersion,omitempty" azure:"ro"` +} + +// GrafanaResourceUpdateParameters - The parameters for a PATCH request to a grafana resource. +type GrafanaResourceUpdateParameters struct { + // The managed identity of the grafana resource. + Identity *ManagedIdentity `json:"identity,omitempty"` + + // The new tags of the grafana resource. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GrafanaResourceUpdateParameters. +func (g GrafanaResourceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", g.Identity) + populate(objectMap, "tags", g.Tags) + return json.Marshal(objectMap) +} + +// ManagedIdentity - The managed identity of a resource. +type ManagedIdentity struct { + // The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. + // The type 'None' will remove any identities from the resource. + Type *IdentityType `json:"type,omitempty"` + + // Dictionary of user assigned identities. + UserAssignedIdentities map[string]*UserAssignedIdentity `json:"userAssignedIdentities,omitempty"` + + // READ-ONLY; The principal id of the system assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant id of the system assigned identity. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedIdentity. +func (m ManagedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; Description of the operation, e.g., 'Read grafana'. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Operation type, e.g., read, write, delete, etc. + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, i.e., Microsoft.Dashboard. + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation, e.g., 'grafana'. + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of REST API operations supported by Microsoft.Dashboard 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 Microsoft.Dashboard provider. + Value []*OperationResult `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) +} + +// OperationResult - A Microsoft.Dashboard REST API operation. +type OperationResult struct { + // Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Indicates whether the operation applies to data-plane. Set "true" for data-plane operations and "false" for + // ARM/control-plane operations. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; Operation name, i.e., {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation. + Origin *Origin `json:"origin,omitempty" azure:"ro"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +type ResourceSKU struct { + // REQUIRED + Name *string `json:"name,omitempty"` +} + +type SystemData struct { + CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *LastModifiedByType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +type UserAssignedIdentity struct { + // READ-ONLY; The client id of user assigned identity. + ClientID *string `json:"clientId,omitempty" azure:"ro"` + + // READ-ONLY; The principal id of user assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` +} + +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/dashboard/armdashboard/zz_generated_operations_client.go b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_operations_client.go new file mode 100644 index 000000000000..d8c962e61e39 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_operations_client.go @@ -0,0 +1,82 @@ +//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 armdashboard + +import ( + "context" + "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 { + host string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + if options == nil { + options = &arm.ClientOptions{} + } + ep := options.Endpoint + if len(ep) == 0 { + ep = arm.AzurePublicCloud + } + client := &OperationsClient{ + host: string(ep), + pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options), + } + return client +} + +// List - List all available API operations provided by Microsoft.Dashboard. +// If the operation fails it returns an *azcore.ResponseError type. +// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +func (client *OperationsClient) List(options *OperationsClientListOptions) *OperationsClientListPager { + return &OperationsClientListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsClientListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Dashboard/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/zz_generated_pagers.go b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_pagers.go new file mode 100644 index 000000000000..6c58e21efeb7 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_pagers.go @@ -0,0 +1,179 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdashboard + +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" +) + +// GrafanaClientListByResourceGroupPager provides operations for iterating over paged responses. +type GrafanaClientListByResourceGroupPager struct { + client *GrafanaClient + current GrafanaClientListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, GrafanaClientListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *GrafanaClientListByResourceGroupPager) 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 *GrafanaClientListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.GrafanaResourceListResponse.NextLink == nil || len(*p.current.GrafanaResourceListResponse.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 = runtime.NewResponseError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current GrafanaClientListByResourceGroupResponse page. +func (p *GrafanaClientListByResourceGroupPager) PageResponse() GrafanaClientListByResourceGroupResponse { + return p.current +} + +// GrafanaClientListPager provides operations for iterating over paged responses. +type GrafanaClientListPager struct { + client *GrafanaClient + current GrafanaClientListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, GrafanaClientListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *GrafanaClientListPager) 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 *GrafanaClientListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.GrafanaResourceListResponse.NextLink == nil || len(*p.current.GrafanaResourceListResponse.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 = runtime.NewResponseError(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 GrafanaClientListResponse page. +func (p *GrafanaClientListPager) PageResponse() GrafanaClientListResponse { + return p.current +} + +// OperationsClientListPager provides operations for iterating over paged responses. +type OperationsClientListPager struct { + client *OperationsClient + current OperationsClientListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsClientListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsClientListPager) 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 *OperationsClientListPager) 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 = runtime.NewResponseError(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 OperationsClientListResponse page. +func (p *OperationsClientListPager) PageResponse() OperationsClientListResponse { + return p.current +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/zz_generated_pollers.go b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_pollers.go new file mode 100644 index 000000000000..c50d931d7fbf --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/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 armdashboard + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// GrafanaClientCreatePoller provides polling facilities until the operation reaches a terminal state. +type GrafanaClientCreatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *GrafanaClientCreatePoller) 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 *GrafanaClientCreatePoller) 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 GrafanaClientCreateResponse will be returned. +func (p *GrafanaClientCreatePoller) FinalResponse(ctx context.Context) (GrafanaClientCreateResponse, error) { + respType := GrafanaClientCreateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.GrafanaResource) + if err != nil { + return GrafanaClientCreateResponse{}, 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 *GrafanaClientCreatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// GrafanaClientDeletePoller provides polling facilities until the operation reaches a terminal state. +type GrafanaClientDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *GrafanaClientDeletePoller) 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 *GrafanaClientDeletePoller) 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 GrafanaClientDeleteResponse will be returned. +func (p *GrafanaClientDeletePoller) FinalResponse(ctx context.Context) (GrafanaClientDeleteResponse, error) { + respType := GrafanaClientDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return GrafanaClientDeleteResponse{}, 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 *GrafanaClientDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/zz_generated_response_types.go b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_response_types.go new file mode 100644 index 000000000000..01200eb3fadf --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_response_types.go @@ -0,0 +1,174 @@ +//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 armdashboard + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// GrafanaClientCreatePollerResponse contains the response from method GrafanaClient.Create. +type GrafanaClientCreatePollerResponse struct { + // Poller contains an initialized poller. + Poller *GrafanaClientCreatePoller + + // 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 GrafanaClientCreatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (GrafanaClientCreateResponse, error) { + respType := GrafanaClientCreateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.GrafanaResource) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a GrafanaClientCreatePollerResponse from the provided client and resume token. +func (l *GrafanaClientCreatePollerResponse) Resume(ctx context.Context, client *GrafanaClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("GrafanaClient.Create", token, client.pl) + if err != nil { + return err + } + poller := &GrafanaClientCreatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// GrafanaClientCreateResponse contains the response from method GrafanaClient.Create. +type GrafanaClientCreateResponse struct { + GrafanaClientCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GrafanaClientCreateResult contains the result from method GrafanaClient.Create. +type GrafanaClientCreateResult struct { + GrafanaResource +} + +// GrafanaClientDeletePollerResponse contains the response from method GrafanaClient.Delete. +type GrafanaClientDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *GrafanaClientDeletePoller + + // 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 GrafanaClientDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (GrafanaClientDeleteResponse, error) { + respType := GrafanaClientDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a GrafanaClientDeletePollerResponse from the provided client and resume token. +func (l *GrafanaClientDeletePollerResponse) Resume(ctx context.Context, client *GrafanaClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("GrafanaClient.Delete", token, client.pl) + if err != nil { + return err + } + poller := &GrafanaClientDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// GrafanaClientDeleteResponse contains the response from method GrafanaClient.Delete. +type GrafanaClientDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GrafanaClientGetResponse contains the response from method GrafanaClient.Get. +type GrafanaClientGetResponse struct { + GrafanaClientGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GrafanaClientGetResult contains the result from method GrafanaClient.Get. +type GrafanaClientGetResult struct { + GrafanaResource +} + +// GrafanaClientListByResourceGroupResponse contains the response from method GrafanaClient.ListByResourceGroup. +type GrafanaClientListByResourceGroupResponse struct { + GrafanaClientListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GrafanaClientListByResourceGroupResult contains the result from method GrafanaClient.ListByResourceGroup. +type GrafanaClientListByResourceGroupResult struct { + GrafanaResourceListResponse +} + +// GrafanaClientListResponse contains the response from method GrafanaClient.List. +type GrafanaClientListResponse struct { + GrafanaClientListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GrafanaClientListResult contains the result from method GrafanaClient.List. +type GrafanaClientListResult struct { + GrafanaResourceListResponse +} + +// GrafanaClientUpdateResponse contains the response from method GrafanaClient.Update. +type GrafanaClientUpdateResponse struct { + GrafanaClientUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GrafanaClientUpdateResult contains the result from method GrafanaClient.Update. +type GrafanaClientUpdateResult struct { + GrafanaResource +} + +// OperationsClientListResponse contains the response from method OperationsClient.List. +type OperationsClientListResponse struct { + OperationsClientListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsClientListResult contains the result from method OperationsClient.List. +type OperationsClientListResult struct { + OperationListResult +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/zz_generated_time_rfc3339.go b/sdk/resourcemanager/dashboard/armdashboard/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..0d416cd3899d --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/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 armdashboard + +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 +}