From 1147c1d64c6e99a44ccdf0e45b4e75a91aa3cf6a Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 10 Dec 2021 02:57:22 +0000 Subject: [PATCH] CodeGen from PR 17000 in Azure/azure-rest-api-specs [Go] Track2 modify readme.go.md 9 (#17000) * [Go] Track2 modify readme.go.md 9 * fix --- .../storagecache/armstoragecache/CHANGELOG.md | 5 + .../storagecache/armstoragecache/LICENSE.txt | 21 + .../storagecache/armstoragecache/README.md | 75 ++ .../storagecache/armstoragecache/autorest.md | 13 + .../storagecache/armstoragecache/build.go | 7 + .../storagecache/armstoragecache/ci.yml | 27 + .../storagecache/armstoragecache/go.mod | 8 + .../storagecache/armstoragecache/go.sum | 37 + .../armstoragecache/go_mod_tidy_hack.go | 13 + .../zz_generated_ascoperations_client.go | 108 ++ .../zz_generated_caches_client.go | 823 ++++++++++++ .../armstoragecache/zz_generated_constants.go | 370 ++++++ .../armstoragecache/zz_generated_models.go | 1181 +++++++++++++++++ .../zz_generated_operations_client.go | 89 ++ .../armstoragecache/zz_generated_pagers.go | 341 +++++ .../armstoragecache/zz_generated_pollers.go | 574 ++++++++ .../zz_generated_response_types.go | 746 +++++++++++ .../zz_generated_skus_client.go | 97 ++ .../zz_generated_storagetarget_client.go | 285 ++++ .../zz_generated_storagetargets_client.go | 428 ++++++ .../zz_generated_time_rfc3339.go | 85 ++ .../zz_generated_usagemodels_client.go | 97 ++ 22 files changed, 5430 insertions(+) create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/CHANGELOG.md create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/LICENSE.txt create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/README.md create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/autorest.md create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/build.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/ci.yml create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/go.mod create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/go.sum create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/go_mod_tidy_hack.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_ascoperations_client.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_caches_client.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_constants.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_models.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_operations_client.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_pagers.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_pollers.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_response_types.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_skus_client.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_storagetarget_client.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_storagetargets_client.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_time_rfc3339.go create mode 100644 sdk/resourcemanager/storagecache/armstoragecache/zz_generated_usagemodels_client.go diff --git a/sdk/resourcemanager/storagecache/armstoragecache/CHANGELOG.md b/sdk/resourcemanager/storagecache/armstoragecache/CHANGELOG.md new file mode 100644 index 000000000000..17b9dceace74 --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-10) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/storagecache/armstoragecache/LICENSE.txt b/sdk/resourcemanager/storagecache/armstoragecache/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/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/storagecache/armstoragecache/README.md b/sdk/resourcemanager/storagecache/armstoragecache/README.md new file mode 100644 index 000000000000..d9bb3bee8e3a --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/README.md @@ -0,0 +1,75 @@ +# Azure Storagecache Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armstoragecache)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armstoragecache) + +The `armstoragecache` module provides operations for working with Azure Storagecache. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/storagecache/armstoragecache) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Storagecache module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armstoragecache +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Storagecache. 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 Storagecache 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 := armstoragecache.NewStorageTargetClient(, 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 := armstoragecache.NewStorageTargetClient(, 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 `Storagecache` 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/storagecache/armstoragecache/autorest.md b/sdk/resourcemanager/storagecache/armstoragecache/autorest.md new file mode 100644 index 000000000000..6f42b2a903da --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/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/storagecache/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/storagecache/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/storagecache/armstoragecache/build.go b/sdk/resourcemanager/storagecache/armstoragecache/build.go new file mode 100644 index 000000000000..4b5ceb34064b --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/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/storagecache/armstoragecache + +package armstoragecache diff --git a/sdk/resourcemanager/storagecache/armstoragecache/ci.yml b/sdk/resourcemanager/storagecache/armstoragecache/ci.yml new file mode 100644 index 000000000000..ecf2bea4e81e --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/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/storagecache/armstoragecache/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/storagecache/armstoragecache/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/storagecache/armstoragecache' diff --git a/sdk/resourcemanager/storagecache/armstoragecache/go.mod b/sdk/resourcemanager/storagecache/armstoragecache/go.mod new file mode 100644 index 000000000000..843628010ffc --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armstoragecache + +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 +) diff --git a/sdk/resourcemanager/storagecache/armstoragecache/go.sum b/sdk/resourcemanager/storagecache/armstoragecache/go.sum new file mode 100644 index 000000000000..960c6c966a3f --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/go.sum @@ -0,0 +1,37 @@ +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/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 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/storagecache/armstoragecache/go_mod_tidy_hack.go b/sdk/resourcemanager/storagecache/armstoragecache/go_mod_tidy_hack.go new file mode 100644 index 000000000000..8b5dce9944f7 --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/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 armstoragecache + +// 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/storagecache/armstoragecache/zz_generated_ascoperations_client.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_ascoperations_client.go new file mode 100644 index 000000000000..42f29e744421 --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_ascoperations_client.go @@ -0,0 +1,108 @@ +//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 armstoragecache + +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" +) + +// AscOperationsClient contains the methods for the AscOperations group. +// Don't use this type directly, use NewAscOperationsClient() instead. +type AscOperationsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewAscOperationsClient creates a new instance of AscOperationsClient with the specified values. +func NewAscOperationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *AscOperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &AscOperationsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Gets the status of an asynchronous operation for the Azure HPC Cache +// If the operation fails it returns the *CloudError error type. +func (client *AscOperationsClient) Get(ctx context.Context, location string, operationID string, options *AscOperationsGetOptions) (AscOperationsGetResponse, error) { + req, err := client.getCreateRequest(ctx, location, operationID, options) + if err != nil { + return AscOperationsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AscOperationsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AscOperationsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AscOperationsClient) getCreateRequest(ctx context.Context, location string, operationID string, options *AscOperationsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/locations/{location}/ascOperations/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AscOperationsClient) getHandleResponse(resp *http.Response) (AscOperationsGetResponse, error) { + result := AscOperationsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AscOperation); err != nil { + return AscOperationsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *AscOperationsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/storagecache/armstoragecache/zz_generated_caches_client.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_caches_client.go new file mode 100644 index 000000000000..845993d11991 --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_caches_client.go @@ -0,0 +1,823 @@ +//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 armstoragecache + +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" +) + +// CachesClient contains the methods for the Caches group. +// Don't use this type directly, use NewCachesClient() instead. +type CachesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewCachesClient creates a new instance of CachesClient with the specified values. +func NewCachesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *CachesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &CachesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update a Cache. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginCreateOrUpdateOptions) (CachesCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, cacheName, options) + if err != nil { + return CachesCreateOrUpdatePollerResponse{}, err + } + result := CachesCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("CachesClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return CachesCreateOrUpdatePollerResponse{}, err + } + result.Poller = &CachesCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update a Cache. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) createOrUpdate(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, cacheName, 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, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CachesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Cache != nil { + return req, runtime.MarshalAsJSON(req, *options.Cache) + } + return req, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *CachesClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginDebugInfo - Tells a Cache to write generate debug info for support to process. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) BeginDebugInfo(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginDebugInfoOptions) (CachesDebugInfoPollerResponse, error) { + resp, err := client.debugInfo(ctx, resourceGroupName, cacheName, options) + if err != nil { + return CachesDebugInfoPollerResponse{}, err + } + result := CachesDebugInfoPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("CachesClient.DebugInfo", "azure-async-operation", resp, client.pl, client.debugInfoHandleError) + if err != nil { + return CachesDebugInfoPollerResponse{}, err + } + result.Poller = &CachesDebugInfoPoller{ + pt: pt, + } + return result, nil +} + +// DebugInfo - Tells a Cache to write generate debug info for support to process. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) debugInfo(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginDebugInfoOptions) (*http.Response, error) { + req, err := client.debugInfoCreateRequest(ctx, resourceGroupName, cacheName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.debugInfoHandleError(resp) + } + return resp, nil +} + +// debugInfoCreateRequest creates the DebugInfo request. +func (client *CachesClient) debugInfoCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginDebugInfoOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/debugInfo" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// debugInfoHandleError handles the DebugInfo error response. +func (client *CachesClient) debugInfoHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Schedules a Cache for deletion. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) BeginDelete(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginDeleteOptions) (CachesDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, cacheName, options) + if err != nil { + return CachesDeletePollerResponse{}, err + } + result := CachesDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("CachesClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return CachesDeletePollerResponse{}, err + } + result.Poller = &CachesDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Schedules a Cache for deletion. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) deleteOperation(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, cacheName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CachesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + 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.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *CachesClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginFlush - Tells a Cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors returned until the flush is complete. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) BeginFlush(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginFlushOptions) (CachesFlushPollerResponse, error) { + resp, err := client.flush(ctx, resourceGroupName, cacheName, options) + if err != nil { + return CachesFlushPollerResponse{}, err + } + result := CachesFlushPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("CachesClient.Flush", "azure-async-operation", resp, client.pl, client.flushHandleError) + if err != nil { + return CachesFlushPollerResponse{}, err + } + result.Poller = &CachesFlushPoller{ + pt: pt, + } + return result, nil +} + +// Flush - Tells a Cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors returned until the flush is complete. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) flush(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginFlushOptions) (*http.Response, error) { + req, err := client.flushCreateRequest(ctx, resourceGroupName, cacheName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.flushHandleError(resp) + } + return resp, nil +} + +// flushCreateRequest creates the Flush request. +func (client *CachesClient) flushCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginFlushOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// flushHandleError handles the Flush error response. +func (client *CachesClient) flushHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Returns a Cache. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) Get(ctx context.Context, resourceGroupName string, cacheName string, options *CachesGetOptions) (CachesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, cacheName, options) + if err != nil { + return CachesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CachesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CachesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CachesClient) getCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *CachesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CachesClient) getHandleResponse(resp *http.Response) (CachesGetResponse, error) { + result := CachesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Cache); err != nil { + return CachesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *CachesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Returns all Caches the user has access to under a subscription. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) List(options *CachesListOptions) *CachesListPager { + return &CachesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp CachesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.CachesListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *CachesClient) listCreateRequest(ctx context.Context, options *CachesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/caches" + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *CachesClient) listHandleResponse(resp *http.Response) (CachesListResponse, error) { + result := CachesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CachesListResult); err != nil { + return CachesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *CachesClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - Returns all Caches the user has access to under a resource group. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) ListByResourceGroup(resourceGroupName string, options *CachesListByResourceGroupOptions) *CachesListByResourceGroupPager { + return &CachesListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp CachesListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.CachesListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *CachesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CachesListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *CachesClient) listByResourceGroupHandleResponse(resp *http.Response) (CachesListByResourceGroupResponse, error) { + result := CachesListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CachesListResult); err != nil { + return CachesListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *CachesClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginStart - Tells a Stopped state Cache to transition to Active state. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) BeginStart(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginStartOptions) (CachesStartPollerResponse, error) { + resp, err := client.start(ctx, resourceGroupName, cacheName, options) + if err != nil { + return CachesStartPollerResponse{}, err + } + result := CachesStartPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("CachesClient.Start", "azure-async-operation", resp, client.pl, client.startHandleError) + if err != nil { + return CachesStartPollerResponse{}, err + } + result.Poller = &CachesStartPoller{ + pt: pt, + } + return result, nil +} + +// Start - Tells a Stopped state Cache to transition to Active state. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) start(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginStartOptions) (*http.Response, error) { + req, err := client.startCreateRequest(ctx, resourceGroupName, cacheName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.startHandleError(resp) + } + return resp, nil +} + +// startCreateRequest creates the Start request. +func (client *CachesClient) startCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginStartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// startHandleError handles the Start error response. +func (client *CachesClient) startHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginStop - Tells an Active Cache to transition to Stopped state. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) BeginStop(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginStopOptions) (CachesStopPollerResponse, error) { + resp, err := client.stop(ctx, resourceGroupName, cacheName, options) + if err != nil { + return CachesStopPollerResponse{}, err + } + result := CachesStopPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("CachesClient.Stop", "azure-async-operation", resp, client.pl, client.stopHandleError) + if err != nil { + return CachesStopPollerResponse{}, err + } + result.Poller = &CachesStopPoller{ + pt: pt, + } + return result, nil +} + +// Stop - Tells an Active Cache to transition to Stopped state. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) stop(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginStopOptions) (*http.Response, error) { + req, err := client.stopCreateRequest(ctx, resourceGroupName, cacheName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.stopHandleError(resp) + } + return resp, nil +} + +// stopCreateRequest creates the Stop request. +func (client *CachesClient) stopCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginStopOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// stopHandleError handles the Stop error response. +func (client *CachesClient) stopHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Update a Cache instance. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) Update(ctx context.Context, resourceGroupName string, cacheName string, options *CachesUpdateOptions) (CachesUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, cacheName, options) + if err != nil { + return CachesUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CachesUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CachesUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *CachesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *CachesUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Cache != nil { + return req, runtime.MarshalAsJSON(req, *options.Cache) + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *CachesClient) updateHandleResponse(resp *http.Response) (CachesUpdateResponse, error) { + result := CachesUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Cache); err != nil { + return CachesUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *CachesClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginUpgradeFirmware - Upgrade a Cache's firmware if a new version is available. Otherwise, this operation has no effect. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) BeginUpgradeFirmware(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginUpgradeFirmwareOptions) (CachesUpgradeFirmwarePollerResponse, error) { + resp, err := client.upgradeFirmware(ctx, resourceGroupName, cacheName, options) + if err != nil { + return CachesUpgradeFirmwarePollerResponse{}, err + } + result := CachesUpgradeFirmwarePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("CachesClient.UpgradeFirmware", "azure-async-operation", resp, client.pl, client.upgradeFirmwareHandleError) + if err != nil { + return CachesUpgradeFirmwarePollerResponse{}, err + } + result.Poller = &CachesUpgradeFirmwarePoller{ + pt: pt, + } + return result, nil +} + +// UpgradeFirmware - Upgrade a Cache's firmware if a new version is available. Otherwise, this operation has no effect. +// If the operation fails it returns the *CloudError error type. +func (client *CachesClient) upgradeFirmware(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginUpgradeFirmwareOptions) (*http.Response, error) { + req, err := client.upgradeFirmwareCreateRequest(ctx, resourceGroupName, cacheName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusCreated, http.StatusAccepted, http.StatusNoContent) { + return nil, client.upgradeFirmwareHandleError(resp) + } + return resp, nil +} + +// upgradeFirmwareCreateRequest creates the UpgradeFirmware request. +func (client *CachesClient) upgradeFirmwareCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *CachesBeginUpgradeFirmwareOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// upgradeFirmwareHandleError handles the UpgradeFirmware error response. +func (client *CachesClient) upgradeFirmwareHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/storagecache/armstoragecache/zz_generated_constants.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_constants.go new file mode 100644 index 000000000000..1ca7d9a9312c --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_constants.go @@ -0,0 +1,370 @@ +//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 armstoragecache + +const ( + module = "armstoragecache" + version = "v0.1.0" +) + +// CacheIdentityType - The type of identity used for the cache +type CacheIdentityType string + +const ( + CacheIdentityTypeSystemAssigned CacheIdentityType = "SystemAssigned" + CacheIdentityTypeUserAssigned CacheIdentityType = "UserAssigned" + CacheIdentityTypeSystemAssignedUserAssigned CacheIdentityType = "SystemAssigned, UserAssigned" + CacheIdentityTypeNone CacheIdentityType = "None" +) + +// PossibleCacheIdentityTypeValues returns the possible values for the CacheIdentityType const type. +func PossibleCacheIdentityTypeValues() []CacheIdentityType { + return []CacheIdentityType{ + CacheIdentityTypeSystemAssigned, + CacheIdentityTypeUserAssigned, + CacheIdentityTypeSystemAssignedUserAssigned, + CacheIdentityTypeNone, + } +} + +// ToPtr returns a *CacheIdentityType pointing to the current value. +func (c CacheIdentityType) ToPtr() *CacheIdentityType { + 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 +} + +// DomainJoinedType - True if the HPC Cache is joined to the Active Directory domain. +type DomainJoinedType string + +const ( + DomainJoinedTypeError DomainJoinedType = "Error" + DomainJoinedTypeNo DomainJoinedType = "No" + DomainJoinedTypeYes DomainJoinedType = "Yes" +) + +// PossibleDomainJoinedTypeValues returns the possible values for the DomainJoinedType const type. +func PossibleDomainJoinedTypeValues() []DomainJoinedType { + return []DomainJoinedType{ + DomainJoinedTypeError, + DomainJoinedTypeNo, + DomainJoinedTypeYes, + } +} + +// ToPtr returns a *DomainJoinedType pointing to the current value. +func (c DomainJoinedType) ToPtr() *DomainJoinedType { + return &c +} + +// FirmwareStatusType - True if there is a firmware update ready to install on this Cache. The firmware will automatically be installed after firmwareUpdateDeadline +// if not triggered earlier via the upgrade operation. +type FirmwareStatusType string + +const ( + FirmwareStatusTypeAvailable FirmwareStatusType = "available" + FirmwareStatusTypeUnavailable FirmwareStatusType = "unavailable" +) + +// PossibleFirmwareStatusTypeValues returns the possible values for the FirmwareStatusType const type. +func PossibleFirmwareStatusTypeValues() []FirmwareStatusType { + return []FirmwareStatusType{ + FirmwareStatusTypeAvailable, + FirmwareStatusTypeUnavailable, + } +} + +// ToPtr returns a *FirmwareStatusType pointing to the current value. +func (c FirmwareStatusType) ToPtr() *FirmwareStatusType { + return &c +} + +// HealthStateType - List of Cache health states. +type HealthStateType string + +const ( + HealthStateTypeDegraded HealthStateType = "Degraded" + HealthStateTypeDown HealthStateType = "Down" + HealthStateTypeFlushing HealthStateType = "Flushing" + HealthStateTypeHealthy HealthStateType = "Healthy" + HealthStateTypeStopped HealthStateType = "Stopped" + HealthStateTypeStopping HealthStateType = "Stopping" + HealthStateTypeTransitioning HealthStateType = "Transitioning" + HealthStateTypeUnknown HealthStateType = "Unknown" + HealthStateTypeUpgrading HealthStateType = "Upgrading" +) + +// PossibleHealthStateTypeValues returns the possible values for the HealthStateType const type. +func PossibleHealthStateTypeValues() []HealthStateType { + return []HealthStateType{ + HealthStateTypeDegraded, + HealthStateTypeDown, + HealthStateTypeFlushing, + HealthStateTypeHealthy, + HealthStateTypeStopped, + HealthStateTypeStopping, + HealthStateTypeTransitioning, + HealthStateTypeUnknown, + HealthStateTypeUpgrading, + } +} + +// ToPtr returns a *HealthStateType pointing to the current value. +func (c HealthStateType) ToPtr() *HealthStateType { + return &c +} + +type MetricAggregationType string + +const ( + MetricAggregationTypeAverage MetricAggregationType = "Average" + MetricAggregationTypeCount MetricAggregationType = "Count" + MetricAggregationTypeMaximum MetricAggregationType = "Maximum" + MetricAggregationTypeMinimum MetricAggregationType = "Minimum" + MetricAggregationTypeNone MetricAggregationType = "None" + MetricAggregationTypeNotSpecified MetricAggregationType = "NotSpecified" + MetricAggregationTypeTotal MetricAggregationType = "Total" +) + +// PossibleMetricAggregationTypeValues returns the possible values for the MetricAggregationType const type. +func PossibleMetricAggregationTypeValues() []MetricAggregationType { + return []MetricAggregationType{ + MetricAggregationTypeAverage, + MetricAggregationTypeCount, + MetricAggregationTypeMaximum, + MetricAggregationTypeMinimum, + MetricAggregationTypeNone, + MetricAggregationTypeNotSpecified, + MetricAggregationTypeTotal, + } +} + +// ToPtr returns a *MetricAggregationType pointing to the current value. +func (c MetricAggregationType) ToPtr() *MetricAggregationType { + return &c +} + +// NfsAccessRuleAccess - Access allowed by this rule. +type NfsAccessRuleAccess string + +const ( + NfsAccessRuleAccessNo NfsAccessRuleAccess = "no" + NfsAccessRuleAccessRo NfsAccessRuleAccess = "ro" + NfsAccessRuleAccessRw NfsAccessRuleAccess = "rw" +) + +// PossibleNfsAccessRuleAccessValues returns the possible values for the NfsAccessRuleAccess const type. +func PossibleNfsAccessRuleAccessValues() []NfsAccessRuleAccess { + return []NfsAccessRuleAccess{ + NfsAccessRuleAccessNo, + NfsAccessRuleAccessRo, + NfsAccessRuleAccessRw, + } +} + +// ToPtr returns a *NfsAccessRuleAccess pointing to the current value. +func (c NfsAccessRuleAccess) ToPtr() *NfsAccessRuleAccess { + return &c +} + +// NfsAccessRuleScope - Scope for this rule. The scope and filter determine which clients match the rule. +type NfsAccessRuleScope string + +const ( + NfsAccessRuleScopeDefault NfsAccessRuleScope = "default" + NfsAccessRuleScopeHost NfsAccessRuleScope = "host" + NfsAccessRuleScopeNetwork NfsAccessRuleScope = "network" +) + +// PossibleNfsAccessRuleScopeValues returns the possible values for the NfsAccessRuleScope const type. +func PossibleNfsAccessRuleScopeValues() []NfsAccessRuleScope { + return []NfsAccessRuleScope{ + NfsAccessRuleScopeDefault, + NfsAccessRuleScopeHost, + NfsAccessRuleScopeNetwork, + } +} + +// ToPtr returns a *NfsAccessRuleScope pointing to the current value. +func (c NfsAccessRuleScope) ToPtr() *NfsAccessRuleScope { + return &c +} + +// OperationalStateType - Storage target operational state. +type OperationalStateType string + +const ( + OperationalStateTypeBusy OperationalStateType = "Busy" + OperationalStateTypeFlushing OperationalStateType = "Flushing" + OperationalStateTypeReady OperationalStateType = "Ready" + OperationalStateTypeSuspended OperationalStateType = "Suspended" +) + +// PossibleOperationalStateTypeValues returns the possible values for the OperationalStateType const type. +func PossibleOperationalStateTypeValues() []OperationalStateType { + return []OperationalStateType{ + OperationalStateTypeBusy, + OperationalStateTypeFlushing, + OperationalStateTypeReady, + OperationalStateTypeSuspended, + } +} + +// ToPtr returns a *OperationalStateType pointing to the current value. +func (c OperationalStateType) ToPtr() *OperationalStateType { + return &c +} + +// ProvisioningStateType - ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property +type ProvisioningStateType string + +const ( + ProvisioningStateTypeCancelled ProvisioningStateType = "Cancelled" + ProvisioningStateTypeCreating ProvisioningStateType = "Creating" + ProvisioningStateTypeDeleting ProvisioningStateType = "Deleting" + ProvisioningStateTypeFailed ProvisioningStateType = "Failed" + ProvisioningStateTypeSucceeded ProvisioningStateType = "Succeeded" + ProvisioningStateTypeUpdating ProvisioningStateType = "Updating" +) + +// PossibleProvisioningStateTypeValues returns the possible values for the ProvisioningStateType const type. +func PossibleProvisioningStateTypeValues() []ProvisioningStateType { + return []ProvisioningStateType{ + ProvisioningStateTypeCancelled, + ProvisioningStateTypeCreating, + ProvisioningStateTypeDeleting, + ProvisioningStateTypeFailed, + ProvisioningStateTypeSucceeded, + ProvisioningStateTypeUpdating, + } +} + +// ToPtr returns a *ProvisioningStateType pointing to the current value. +func (c ProvisioningStateType) ToPtr() *ProvisioningStateType { + return &c +} + +// ReasonCode - The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". "QuotaId" is set when the SKU has requiredQuotas +// parameter as the subscription does not belong to that +// quota. "NotAvailableForSubscription" is related to capacity at the datacenter. +type ReasonCode string + +const ( + ReasonCodeNotAvailableForSubscription ReasonCode = "NotAvailableForSubscription" + ReasonCodeQuotaID ReasonCode = "QuotaId" +) + +// PossibleReasonCodeValues returns the possible values for the ReasonCode const type. +func PossibleReasonCodeValues() []ReasonCode { + return []ReasonCode{ + ReasonCodeNotAvailableForSubscription, + ReasonCodeQuotaID, + } +} + +// ToPtr returns a *ReasonCode pointing to the current value. +func (c ReasonCode) ToPtr() *ReasonCode { + return &c +} + +// StorageTargetType - Type of the Storage Target. +type StorageTargetType string + +const ( + StorageTargetTypeBlobNfs StorageTargetType = "blobNfs" + StorageTargetTypeClfs StorageTargetType = "clfs" + StorageTargetTypeNfs3 StorageTargetType = "nfs3" + StorageTargetTypeUnknown StorageTargetType = "unknown" +) + +// PossibleStorageTargetTypeValues returns the possible values for the StorageTargetType const type. +func PossibleStorageTargetTypeValues() []StorageTargetType { + return []StorageTargetType{ + StorageTargetTypeBlobNfs, + StorageTargetTypeClfs, + StorageTargetTypeNfs3, + StorageTargetTypeUnknown, + } +} + +// ToPtr returns a *StorageTargetType pointing to the current value. +func (c StorageTargetType) ToPtr() *StorageTargetType { + return &c +} + +// UsernameDownloadedType - Indicates whether or not the HPC Cache has performed the username download successfully. +type UsernameDownloadedType string + +const ( + UsernameDownloadedTypeError UsernameDownloadedType = "Error" + UsernameDownloadedTypeNo UsernameDownloadedType = "No" + UsernameDownloadedTypeYes UsernameDownloadedType = "Yes" +) + +// PossibleUsernameDownloadedTypeValues returns the possible values for the UsernameDownloadedType const type. +func PossibleUsernameDownloadedTypeValues() []UsernameDownloadedType { + return []UsernameDownloadedType{ + UsernameDownloadedTypeError, + UsernameDownloadedTypeNo, + UsernameDownloadedTypeYes, + } +} + +// ToPtr returns a *UsernameDownloadedType pointing to the current value. +func (c UsernameDownloadedType) ToPtr() *UsernameDownloadedType { + return &c +} + +// UsernameSource - This setting determines how the cache gets username and group names for clients. +type UsernameSource string + +const ( + UsernameSourceAD UsernameSource = "AD" + UsernameSourceFile UsernameSource = "File" + UsernameSourceLDAP UsernameSource = "LDAP" + UsernameSourceNone UsernameSource = "None" +) + +// PossibleUsernameSourceValues returns the possible values for the UsernameSource const type. +func PossibleUsernameSourceValues() []UsernameSource { + return []UsernameSource{ + UsernameSourceAD, + UsernameSourceFile, + UsernameSourceLDAP, + UsernameSourceNone, + } +} + +// ToPtr returns a *UsernameSource pointing to the current value. +func (c UsernameSource) ToPtr() *UsernameSource { + return &c +} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_models.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_models.go new file mode 100644 index 000000000000..8774e9510d45 --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_models.go @@ -0,0 +1,1181 @@ +//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 armstoragecache + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// APIOperation - REST API operation description: see https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/openapi-authoring-automated-guidelines.md#r3023-operationsapiimplementation +type APIOperation struct { + // The object that represents the operation. + Display *APIOperationDisplay `json:"display,omitempty"` + + // The flag that indicates whether the operation applies to data plane. + IsDataAction *bool `json:"isDataAction,omitempty"` + + // Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + + // Origin of the operation. + Origin *string `json:"origin,omitempty"` + + // Additional details about an operation. + Properties *APIOperationProperties `json:"properties,omitempty"` +} + +// APIOperationDisplay - The object that represents the operation. +type APIOperationDisplay struct { + // The description of the operation + Description *string `json:"description,omitempty"` + + // Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + + // Service provider: Microsoft.StorageCache + Provider *string `json:"provider,omitempty"` + + // Resource on which the operation is performed: Cache, etc. + Resource *string `json:"resource,omitempty"` +} + +// APIOperationListResult - Result of the request to list Resource Provider operations. It contains a list of operations and a URL link to get the next +// set of results. +type APIOperationListResult struct { + // URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // List of Resource Provider operations supported by the Microsoft.StorageCache resource provider. + Value []*APIOperation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIOperationListResult. +func (a APIOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// APIOperationProperties - Additional details about an operation. +type APIOperationProperties struct { + // Specification of the all the metrics provided for a resource type. + ServiceSpecification *APIOperationPropertiesServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// APIOperationPropertiesServiceSpecification - Specification of the all the metrics provided for a resource type. +type APIOperationPropertiesServiceSpecification struct { + // Details about operations related to metrics. + MetricSpecifications []*MetricSpecification `json:"metricSpecifications,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIOperationPropertiesServiceSpecification. +func (a APIOperationPropertiesServiceSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "metricSpecifications", a.MetricSpecifications) + return json.Marshal(objectMap) +} + +// AscOperation - The status of operation. +type AscOperation struct { + // The end time of the operation. + EndTime *string `json:"endTime,omitempty"` + + // The error detail of the operation if any. + Error *ErrorResponse `json:"error,omitempty"` + + // The operation Id. + ID *string `json:"id,omitempty"` + + // The operation name. + Name *string `json:"name,omitempty"` + + // Additional operation-specific properties + Properties *AscOperationProperties `json:"properties,omitempty"` + + // The start time of the operation. + StartTime *string `json:"startTime,omitempty"` + + // The status of the operation. + Status *string `json:"status,omitempty"` +} + +// AscOperationProperties - Additional operation-specific output. +type AscOperationProperties struct { + // Additional operation-specific output. + Output map[string]map[string]interface{} `json:"output,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AscOperationProperties. +func (a AscOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "output", a.Output) + return json.Marshal(objectMap) +} + +// AscOperationsGetOptions contains the optional parameters for the AscOperations.Get method. +type AscOperationsGetOptions struct { + // placeholder for future optional parameters +} + +// BlobNfsTarget - Properties pertaining to the BlobNfsTarget. +type BlobNfsTarget struct { + // Resource ID of the storage container. + Target *string `json:"target,omitempty"` + + // Identifies the StorageCache usage model to be used for this storage target. + UsageModel *string `json:"usageModel,omitempty"` +} + +// Cache - A Cache instance. Follows Azure Resource Manager standards: https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/resource-api-reference.md +type Cache struct { + // The identity of the cache, if configured. + Identity *CacheIdentity `json:"identity,omitempty"` + + // Region name string. + Location *string `json:"location,omitempty"` + + // Properties of the Cache. + Properties *CacheProperties `json:"properties,omitempty"` + + // SKU for the Cache. + SKU *CacheSKU `json:"sku,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource ID of the Cache. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of Cache. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Type of the Cache; Microsoft.StorageCache/Cache + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Cache. +func (c Cache) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", c.ID) + populate(objectMap, "identity", c.Identity) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "sku", c.SKU) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// CacheActiveDirectorySettings - Active Directory settings used to join a cache to a domain. +type CacheActiveDirectorySettings struct { + // REQUIRED; The NetBIOS name to assign to the HPC Cache when it joins the Active Directory domain as a server. Length must 1-15 characters from the class + // [-0-9a-zA-Z]. + CacheNetBiosName *string `json:"cacheNetBiosName,omitempty"` + + // REQUIRED; The fully qualified domain name of the Active Directory domain controller. + DomainName *string `json:"domainName,omitempty"` + + // REQUIRED; The Active Directory domain's NetBIOS name. + DomainNetBiosName *string `json:"domainNetBiosName,omitempty"` + + // REQUIRED; Primary DNS IP address used to resolve the Active Directory domain controller's fully qualified domain name. + PrimaryDNSIPAddress *string `json:"primaryDnsIpAddress,omitempty"` + + // Active Directory admin credentials used to join the HPC Cache to a domain. + Credentials *CacheActiveDirectorySettingsCredentials `json:"credentials,omitempty"` + + // Secondary DNS IP address used to resolve the Active Directory domain controller's fully qualified domain name. + SecondaryDNSIPAddress *string `json:"secondaryDnsIpAddress,omitempty"` + + // READ-ONLY; True if the HPC Cache is joined to the Active Directory domain. + DomainJoined *DomainJoinedType `json:"domainJoined,omitempty" azure:"ro"` +} + +// CacheActiveDirectorySettingsCredentials - Active Directory admin credentials used to join the HPC Cache to a domain. +type CacheActiveDirectorySettingsCredentials struct { + // REQUIRED; Plain text password of the Active Directory domain administrator. This value is stored encrypted and not returned on response. + Password *string `json:"password,omitempty"` + + // REQUIRED; Username of the Active Directory domain administrator. This value is stored encrypted and not returned on response. + Username *string `json:"username,omitempty"` +} + +// CacheDirectorySettings - Cache Directory Services settings. +type CacheDirectorySettings struct { + // Specifies settings for joining the HPC Cache to an Active Directory domain. + ActiveDirectory *CacheActiveDirectorySettings `json:"activeDirectory,omitempty"` + + // Specifies settings for Extended Groups. Extended Groups allows users to be members of more than 16 groups. + UsernameDownload *CacheUsernameDownloadSettings `json:"usernameDownload,omitempty"` +} + +// CacheEncryptionSettings - Cache encryption settings. +type CacheEncryptionSettings struct { + // Specifies the location of the key encryption key in Key Vault. + KeyEncryptionKey *KeyVaultKeyReference `json:"keyEncryptionKey,omitempty"` + + // Specifies whether the service will automatically rotate to the newest version of the key in the Key Vault. + RotationToLatestKeyVersionEnabled *bool `json:"rotationToLatestKeyVersionEnabled,omitempty"` +} + +// CacheHealth - An indication of Cache health. Gives more information about health than just that related to provisioning. +type CacheHealth struct { + // List of Cache health states. + State *HealthStateType `json:"state,omitempty"` + + // Describes explanation of state. + StatusDescription *string `json:"statusDescription,omitempty"` + + // READ-ONLY; Outstanding conditions that need to be investigated and resolved. + Conditions []*Condition `json:"conditions,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CacheHealth. +func (c CacheHealth) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "conditions", c.Conditions) + populate(objectMap, "state", c.State) + populate(objectMap, "statusDescription", c.StatusDescription) + return json.Marshal(objectMap) +} + +// CacheIdentity - Cache identity properties. +type CacheIdentity struct { + // The type of identity used for the cache + Type *CacheIdentityType `json:"type,omitempty"` + + // A dictionary where each key is a user assigned identity resource ID, and each key's value is an empty dictionary. + UserAssignedIdentities map[string]*UserAssignedIdentitiesValue `json:"userAssignedIdentities,omitempty"` + + // READ-ONLY; The principal ID for the system-assigned identity of the cache. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID associated with the cache. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CacheIdentity. +func (c CacheIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", c.PrincipalID) + populate(objectMap, "tenantId", c.TenantID) + populate(objectMap, "type", c.Type) + populate(objectMap, "userAssignedIdentities", c.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// CacheNetworkSettings - Cache network settings. +type CacheNetworkSettings struct { + // DNS search domain + DNSSearchDomain *string `json:"dnsSearchDomain,omitempty"` + + // DNS servers for the cache to use. It will be set from the network configuration if no value is provided. + DNSServers []*string `json:"dnsServers,omitempty"` + + // The IPv4 maximum transmission unit configured for the subnet. + Mtu *int32 `json:"mtu,omitempty"` + + // NTP server IP Address or FQDN for the cache to use. The default is time.windows.com. + NtpServer *string `json:"ntpServer,omitempty"` + + // READ-ONLY; Array of additional IP addresses used by this Cache. + UtilityAddresses []*string `json:"utilityAddresses,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CacheNetworkSettings. +func (c CacheNetworkSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dnsSearchDomain", c.DNSSearchDomain) + populate(objectMap, "dnsServers", c.DNSServers) + populate(objectMap, "mtu", c.Mtu) + populate(objectMap, "ntpServer", c.NtpServer) + populate(objectMap, "utilityAddresses", c.UtilityAddresses) + return json.Marshal(objectMap) +} + +// CacheProperties - Properties of the Cache. +type CacheProperties struct { + // The size of this Cache, in GB. + CacheSizeGB *int32 `json:"cacheSizeGB,omitempty"` + + // Specifies Directory Services settings of the cache. + DirectoryServicesSettings *CacheDirectorySettings `json:"directoryServicesSettings,omitempty"` + + // Specifies encryption settings of the cache. + EncryptionSettings *CacheEncryptionSettings `json:"encryptionSettings,omitempty"` + + // Specifies network settings of the cache. + NetworkSettings *CacheNetworkSettings `json:"networkSettings,omitempty"` + + // Specifies security settings of the cache. + SecuritySettings *CacheSecuritySettings `json:"securitySettings,omitempty"` + + // Subnet used for the Cache. + Subnet *string `json:"subnet,omitempty"` + + // READ-ONLY; Health of the Cache. + Health *CacheHealth `json:"health,omitempty" azure:"ro"` + + // READ-ONLY; Array of IP addresses that can be used by clients mounting this Cache. + MountAddresses []*string `json:"mountAddresses,omitempty" azure:"ro"` + + // READ-ONLY; ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property + ProvisioningState *ProvisioningStateType `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Upgrade status of the Cache. + UpgradeStatus *CacheUpgradeStatus `json:"upgradeStatus,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CacheProperties. +func (c CacheProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "cacheSizeGB", c.CacheSizeGB) + populate(objectMap, "directoryServicesSettings", c.DirectoryServicesSettings) + populate(objectMap, "encryptionSettings", c.EncryptionSettings) + populate(objectMap, "health", c.Health) + populate(objectMap, "mountAddresses", c.MountAddresses) + populate(objectMap, "networkSettings", c.NetworkSettings) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "securitySettings", c.SecuritySettings) + populate(objectMap, "subnet", c.Subnet) + populate(objectMap, "upgradeStatus", c.UpgradeStatus) + return json.Marshal(objectMap) +} + +// CacheSKU - SKU for the Cache. +type CacheSKU struct { + // SKU name for this Cache. + Name *string `json:"name,omitempty"` +} + +// CacheSecuritySettings - Cache security settings. +type CacheSecuritySettings struct { + // NFS access policies defined for this cache. + AccessPolicies []*NfsAccessPolicy `json:"accessPolicies,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CacheSecuritySettings. +func (c CacheSecuritySettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "accessPolicies", c.AccessPolicies) + return json.Marshal(objectMap) +} + +// CacheUpgradeStatus - Properties describing the software upgrade state of the Cache. +type CacheUpgradeStatus struct { + // READ-ONLY; Version string of the firmware currently installed on this Cache. + CurrentFirmwareVersion *string `json:"currentFirmwareVersion,omitempty" azure:"ro"` + + // READ-ONLY; Time at which the pending firmware update will automatically be installed on the Cache. + FirmwareUpdateDeadline *time.Time `json:"firmwareUpdateDeadline,omitempty" azure:"ro"` + + // READ-ONLY; True if there is a firmware update ready to install on this Cache. The firmware will automatically be installed after firmwareUpdateDeadline + // if not triggered earlier via the upgrade operation. + FirmwareUpdateStatus *FirmwareStatusType `json:"firmwareUpdateStatus,omitempty" azure:"ro"` + + // READ-ONLY; Time of the last successful firmware update. + LastFirmwareUpdate *time.Time `json:"lastFirmwareUpdate,omitempty" azure:"ro"` + + // READ-ONLY; When firmwareUpdateAvailable is true, this field holds the version string for the update. + PendingFirmwareVersion *string `json:"pendingFirmwareVersion,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CacheUpgradeStatus. +func (c CacheUpgradeStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "currentFirmwareVersion", c.CurrentFirmwareVersion) + populateTimeRFC3339(objectMap, "firmwareUpdateDeadline", c.FirmwareUpdateDeadline) + populate(objectMap, "firmwareUpdateStatus", c.FirmwareUpdateStatus) + populateTimeRFC3339(objectMap, "lastFirmwareUpdate", c.LastFirmwareUpdate) + populate(objectMap, "pendingFirmwareVersion", c.PendingFirmwareVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CacheUpgradeStatus. +func (c *CacheUpgradeStatus) 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 "currentFirmwareVersion": + err = unpopulate(val, &c.CurrentFirmwareVersion) + delete(rawMsg, key) + case "firmwareUpdateDeadline": + err = unpopulateTimeRFC3339(val, &c.FirmwareUpdateDeadline) + delete(rawMsg, key) + case "firmwareUpdateStatus": + err = unpopulate(val, &c.FirmwareUpdateStatus) + delete(rawMsg, key) + case "lastFirmwareUpdate": + err = unpopulateTimeRFC3339(val, &c.LastFirmwareUpdate) + delete(rawMsg, key) + case "pendingFirmwareVersion": + err = unpopulate(val, &c.PendingFirmwareVersion) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// CacheUsernameDownloadSettings - Settings for Extended Groups username and group download. +type CacheUsernameDownloadSettings struct { + // Determines if the certificate should be automatically downloaded. This applies to 'caCertificateURI' only if 'requireValidCertificate' is true. + AutoDownloadCertificate *bool `json:"autoDownloadCertificate,omitempty"` + + // The URI of the CA certificate to validate the LDAP secure connection. This field must be populated when 'requireValidCertificate' is set to true. + CaCertificateURI *string `json:"caCertificateURI,omitempty"` + + // When present, these are the credentials for the secure LDAP connection. + Credentials *CacheUsernameDownloadSettingsCredentials `json:"credentials,omitempty"` + + // Whether or not the LDAP connection should be encrypted. + EncryptLdapConnection *bool `json:"encryptLdapConnection,omitempty"` + + // Whether or not Extended Groups is enabled. + ExtendedGroups *bool `json:"extendedGroups,omitempty"` + + // The URI of the file containing group information (in /etc/group file format). This field must be populated when 'usernameSource' is set to 'File'. + GroupFileURI *string `json:"groupFileURI,omitempty"` + + // The base distinguished name for the LDAP domain. + LdapBaseDN *string `json:"ldapBaseDN,omitempty"` + + // The fully qualified domain name or IP address of the LDAP server to use. + LdapServer *string `json:"ldapServer,omitempty"` + + // Determines if the certificates must be validated by a certificate authority. When true, caCertificateURI must be provided. + RequireValidCertificate *bool `json:"requireValidCertificate,omitempty"` + + // The URI of the file containing user information (in /etc/passwd file format). This field must be populated when 'usernameSource' is set to 'File'. + UserFileURI *string `json:"userFileURI,omitempty"` + + // This setting determines how the cache gets username and group names for clients. + UsernameSource *UsernameSource `json:"usernameSource,omitempty"` + + // READ-ONLY; Indicates whether or not the HPC Cache has performed the username download successfully. + UsernameDownloaded *UsernameDownloadedType `json:"usernameDownloaded,omitempty" azure:"ro"` +} + +// CacheUsernameDownloadSettingsCredentials - When present, these are the credentials for the secure LDAP connection. +type CacheUsernameDownloadSettingsCredentials struct { + // The Bind Distinguished Name identity to be used in the secure LDAP connection. This value is stored encrypted and not returned on response. + BindDn *string `json:"bindDn,omitempty"` + + // The Bind password to be used in the secure LDAP connection. This value is stored encrypted and not returned on response. + BindPassword *string `json:"bindPassword,omitempty"` +} + +// CachesBeginCreateOrUpdateOptions contains the optional parameters for the Caches.BeginCreateOrUpdate method. +type CachesBeginCreateOrUpdateOptions struct { + // Object containing the user-selectable properties of the new Cache. If read-only properties are included, they must match the existing values of those + // properties. + Cache *Cache +} + +// CachesBeginDebugInfoOptions contains the optional parameters for the Caches.BeginDebugInfo method. +type CachesBeginDebugInfoOptions struct { + // placeholder for future optional parameters +} + +// CachesBeginDeleteOptions contains the optional parameters for the Caches.BeginDelete method. +type CachesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// CachesBeginFlushOptions contains the optional parameters for the Caches.BeginFlush method. +type CachesBeginFlushOptions struct { + // placeholder for future optional parameters +} + +// CachesBeginStartOptions contains the optional parameters for the Caches.BeginStart method. +type CachesBeginStartOptions struct { + // placeholder for future optional parameters +} + +// CachesBeginStopOptions contains the optional parameters for the Caches.BeginStop method. +type CachesBeginStopOptions struct { + // placeholder for future optional parameters +} + +// CachesBeginUpgradeFirmwareOptions contains the optional parameters for the Caches.BeginUpgradeFirmware method. +type CachesBeginUpgradeFirmwareOptions struct { + // placeholder for future optional parameters +} + +// CachesGetOptions contains the optional parameters for the Caches.Get method. +type CachesGetOptions struct { + // placeholder for future optional parameters +} + +// CachesListByResourceGroupOptions contains the optional parameters for the Caches.ListByResourceGroup method. +type CachesListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// CachesListOptions contains the optional parameters for the Caches.List method. +type CachesListOptions struct { + // placeholder for future optional parameters +} + +// CachesListResult - Result of the request to list Caches. It contains a list of Caches and a URL link to get the next set of results. +type CachesListResult struct { + // URL to get the next set of Cache list results, if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // List of Caches. + Value []*Cache `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CachesListResult. +func (c CachesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CachesUpdateOptions contains the optional parameters for the Caches.Update method. +type CachesUpdateOptions struct { + // Object containing the user-selectable properties of the Cache. If read-only properties are included, they must match the existing values of those properties. + Cache *Cache +} + +// ClfsTarget - Properties pertaining to the ClfsTarget +type ClfsTarget struct { + // Resource ID of storage container. + Target *string `json:"target,omitempty"` +} + +// CloudError - An error response. +// Implements the error and azcore.HTTPResponse interfaces. +type CloudError struct { + raw string + // The body of the error. + InnerError *CloudErrorBody `json:"error,omitempty"` +} + +// Error implements the error interface for type CloudError. +// The contents of the error text are not contractual and subject to change. +func (e CloudError) Error() string { + return e.raw +} + +// CloudErrorBody - An error response. +type CloudErrorBody struct { + // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + + // A list of additional details about the error. + Details []*CloudErrorBody `json:"details,omitempty"` + + // A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` + + // The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CloudErrorBody. +func (c CloudErrorBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", c.Code) + populate(objectMap, "details", c.Details) + populate(objectMap, "message", c.Message) + populate(objectMap, "target", c.Target) + return json.Marshal(objectMap) +} + +// Condition - Outstanding conditions that will need to be resolved. +type Condition struct { + // READ-ONLY; The issue requiring attention. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The time when the condition was raised. + Timestamp *time.Time `json:"timestamp,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Condition. +func (c Condition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "message", c.Message) + populateTimeRFC3339(objectMap, "timestamp", c.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Condition. +func (c *Condition) 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 "message": + err = unpopulate(val, &c.Message) + delete(rawMsg, key) + case "timestamp": + err = unpopulateTimeRFC3339(val, &c.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ErrorResponse - Describes the format of Error response. +type ErrorResponse struct { + // Error code + Code *string `json:"code,omitempty"` + + // Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// KeyVaultKeyReference - Describes a reference to Key Vault Key. +type KeyVaultKeyReference struct { + // REQUIRED; The URL referencing a key encryption key in Key Vault. + KeyURL *string `json:"keyUrl,omitempty"` + + // REQUIRED; Describes a resource Id to source Key Vault. + SourceVault *KeyVaultKeyReferenceSourceVault `json:"sourceVault,omitempty"` +} + +// KeyVaultKeyReferenceSourceVault - Describes a resource Id to source Key Vault. +type KeyVaultKeyReferenceSourceVault struct { + // Resource Id. + ID *string `json:"id,omitempty"` +} + +// MetricDimension - Specifications of the Dimension of metrics. +type MetricDimension struct { + // Localized friendly display name of the dimension + DisplayName *string `json:"displayName,omitempty"` + + // Internal name of the dimension. + InternalName *string `json:"internalName,omitempty"` + + // Name of the dimension + Name *string `json:"name,omitempty"` + + // To be exported to shoe box. + ToBeExportedForShoebox *bool `json:"toBeExportedForShoebox,omitempty"` +} + +// MetricSpecification - Details about operation related to metrics. +type MetricSpecification struct { + // The type of metric aggregation. + AggregationType *string `json:"aggregationType,omitempty"` + + // Dimensions of the metric + Dimensions []*MetricDimension `json:"dimensions,omitempty"` + + // The description of the metric. + DisplayDescription *string `json:"displayDescription,omitempty"` + + // Localized display name of the metric. + DisplayName *string `json:"displayName,omitempty"` + + // Type of metrics. + MetricClass *string `json:"metricClass,omitempty"` + + // The name of the metric. + Name *string `json:"name,omitempty"` + + // Support metric aggregation type. + SupportedAggregationTypes []*MetricAggregationType `json:"supportedAggregationTypes,omitempty"` + + // The unit that the metric is measured in. + Unit *string `json:"unit,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricSpecification. +func (m MetricSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregationType", m.AggregationType) + populate(objectMap, "dimensions", m.Dimensions) + populate(objectMap, "displayDescription", m.DisplayDescription) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "metricClass", m.MetricClass) + populate(objectMap, "name", m.Name) + populate(objectMap, "supportedAggregationTypes", m.SupportedAggregationTypes) + populate(objectMap, "unit", m.Unit) + return json.Marshal(objectMap) +} + +// NamespaceJunction - A namespace junction. +type NamespaceJunction struct { + // Namespace path on a Cache for a Storage Target. + NamespacePath *string `json:"namespacePath,omitempty"` + + // Name of the access policy applied to this junction. + NfsAccessPolicy *string `json:"nfsAccessPolicy,omitempty"` + + // NFS export where targetPath exists. + NfsExport *string `json:"nfsExport,omitempty"` + + // Path in Storage Target to which namespacePath points. + TargetPath *string `json:"targetPath,omitempty"` +} + +// Nfs3Target - Properties pertaining to the Nfs3Target +type Nfs3Target struct { + // IP address or host name of an NFSv3 host (e.g., 10.0.44.44). + Target *string `json:"target,omitempty"` + + // Identifies the StorageCache usage model to be used for this storage target. + UsageModel *string `json:"usageModel,omitempty"` +} + +// NfsAccessPolicy - A set of rules describing access policies applied to NFSv3 clients of the cache. +type NfsAccessPolicy struct { + // REQUIRED; The set of rules describing client accesses allowed under this policy. + AccessRules []*NfsAccessRule `json:"accessRules,omitempty"` + + // REQUIRED; Name identifying this policy. Access Policy names are not case sensitive. + Name *string `json:"name,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NfsAccessPolicy. +func (n NfsAccessPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "accessRules", n.AccessRules) + populate(objectMap, "name", n.Name) + return json.Marshal(objectMap) +} + +// NfsAccessRule - Rule to place restrictions on portions of the cache namespace being presented to clients. +type NfsAccessRule struct { + // REQUIRED; Access allowed by this rule. + Access *NfsAccessRuleAccess `json:"access,omitempty"` + + // REQUIRED; Scope for this rule. The scope and filter determine which clients match the rule. + Scope *NfsAccessRuleScope `json:"scope,omitempty"` + + // GID value that replaces 0 when rootSquash is true. This will use the value of anonymousUID if not provided. + AnonymousGID *string `json:"anonymousGID,omitempty"` + + // UID value that replaces 0 when rootSquash is true. 65534 will be used if not provided. + AnonymousUID *string `json:"anonymousUID,omitempty"` + + // Filter applied to the scope for this rule. The filter's format depends on its scope. 'default' scope matches all clients and has no filter value. 'network' + // scope takes a filter in CIDR format (for + // example, 10.99.1.0/24). 'host' takes an IP address or fully qualified domain name as filter. If a client does not match any filter rule and there is + // no default rule, access is denied. + Filter *string `json:"filter,omitempty"` + + // Map root accesses to anonymousUID and anonymousGID. + RootSquash *bool `json:"rootSquash,omitempty"` + + // For the default policy, allow access to subdirectories under the root export. If this is set to no, clients can only mount the path '/'. If set to yes, + // clients can mount a deeper path, like '/a/b'. + SubmountAccess *bool `json:"submountAccess,omitempty"` + + // Allow SUID semantics. + Suid *bool `json:"suid,omitempty"` +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// ResourceSKU - A resource SKU. +type ResourceSKU struct { + // A list of capabilities of this SKU, such as throughput or ops/sec. + Capabilities []*ResourceSKUCapabilities `json:"capabilities,omitempty"` + + // The set of locations where the SKU is available. + LocationInfo []*ResourceSKULocationInfo `json:"locationInfo,omitempty"` + + // The name of this SKU. + Name *string `json:"name,omitempty"` + + // The restrictions preventing this SKU from being used. This is empty if there are no restrictions. + Restrictions []*Restriction `json:"restrictions,omitempty"` + + // READ-ONLY; The set of locations where the SKU is available. This is the supported and registered Azure Geo Regions (e.g., West US, East US, Southeast + // Asia, etc.). + Locations []*string `json:"locations,omitempty" azure:"ro"` + + // READ-ONLY; The type of resource the SKU applies to. + ResourceType *string `json:"resourceType,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceSKU. +func (r ResourceSKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "capabilities", r.Capabilities) + populate(objectMap, "locationInfo", r.LocationInfo) + populate(objectMap, "locations", r.Locations) + populate(objectMap, "name", r.Name) + populate(objectMap, "resourceType", r.ResourceType) + populate(objectMap, "restrictions", r.Restrictions) + return json.Marshal(objectMap) +} + +// ResourceSKUCapabilities - A resource SKU capability. +type ResourceSKUCapabilities struct { + // Name of a capability, such as ops/sec. + Name *string `json:"name,omitempty"` + + // Quantity, if the capability is measured by quantity. + Value *string `json:"value,omitempty"` +} + +// ResourceSKULocationInfo - Resource SKU location information. +type ResourceSKULocationInfo struct { + // Location where this SKU is available. + Location *string `json:"location,omitempty"` + + // Zones if any. + Zones []*string `json:"zones,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceSKULocationInfo. +func (r ResourceSKULocationInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", r.Location) + populate(objectMap, "zones", r.Zones) + return json.Marshal(objectMap) +} + +// ResourceSKUsResult - The response from the List Cache SKUs operation. +type ResourceSKUsResult struct { + // The URI to fetch the next page of Cache SKUs. + NextLink *string `json:"nextLink,omitempty"` + + // READ-ONLY; The list of SKUs available for the subscription. + Value []*ResourceSKU `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceSKUsResult. +func (r ResourceSKUsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// Restriction - The restrictions preventing this SKU from being used. +type Restriction struct { + // The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". "QuotaId" is set when the SKU has requiredQuotas parameter + // as the subscription does not belong to that + // quota. "NotAvailableForSubscription" is related to capacity at the datacenter. + ReasonCode *ReasonCode `json:"reasonCode,omitempty"` + + // READ-ONLY; The type of restrictions. In this version, the only possible value for this is location. + Type *string `json:"type,omitempty" azure:"ro"` + + // READ-ONLY; The value of restrictions. If the restriction type is set to location, then this would be the different locations where the SKU is restricted. + Values []*string `json:"values,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Restriction. +func (r Restriction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "reasonCode", r.ReasonCode) + populate(objectMap, "type", r.Type) + populate(objectMap, "values", r.Values) + return json.Marshal(objectMap) +} + +// SKUsListOptions contains the optional parameters for the SKUs.List method. +type SKUsListOptions struct { + // placeholder for future optional parameters +} + +// StorageTarget - Type of the Storage Target. +type StorageTarget struct { + StorageTargetResource + // StorageTarget properties + Properties *StorageTargetProperties `json:"properties,omitempty"` +} + +// StorageTargetBeginFlushOptions contains the optional parameters for the StorageTarget.BeginFlush method. +type StorageTargetBeginFlushOptions struct { + // placeholder for future optional parameters +} + +// StorageTargetBeginResumeOptions contains the optional parameters for the StorageTarget.BeginResume method. +type StorageTargetBeginResumeOptions struct { + // placeholder for future optional parameters +} + +// StorageTargetBeginSuspendOptions contains the optional parameters for the StorageTarget.BeginSuspend method. +type StorageTargetBeginSuspendOptions struct { + // placeholder for future optional parameters +} + +// StorageTargetProperties - Properties of the Storage Target. +type StorageTargetProperties struct { + // REQUIRED; Type of the Storage Target. + TargetType *StorageTargetType `json:"targetType,omitempty"` + + // Properties when targetType is blobNfs. + BlobNfs *BlobNfsTarget `json:"blobNfs,omitempty"` + + // Properties when targetType is clfs. + Clfs *ClfsTarget `json:"clfs,omitempty"` + + // List of Cache namespace junctions to target for namespace associations. + Junctions []*NamespaceJunction `json:"junctions,omitempty"` + + // Properties when targetType is nfs3. + Nfs3 *Nfs3Target `json:"nfs3,omitempty"` + + // Storage target operational state. + State *OperationalStateType `json:"state,omitempty"` + + // Properties when targetType is unknown. + Unknown *UnknownTarget `json:"unknown,omitempty"` + + // READ-ONLY; ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property + ProvisioningState *ProvisioningStateType `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type StorageTargetProperties. +func (s StorageTargetProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "blobNfs", s.BlobNfs) + populate(objectMap, "clfs", s.Clfs) + populate(objectMap, "junctions", s.Junctions) + populate(objectMap, "nfs3", s.Nfs3) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "state", s.State) + populate(objectMap, "targetType", s.TargetType) + populate(objectMap, "unknown", s.Unknown) + return json.Marshal(objectMap) +} + +// StorageTargetResource - Resource used by a Cache. +type StorageTargetResource struct { + // READ-ONLY; Resource ID of the Storage Target. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Region name string. + Location *string `json:"location,omitempty" azure:"ro"` + + // READ-ONLY; Name of the Storage Target. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Type of the Storage Target; Microsoft.StorageCache/Cache/StorageTarget + Type *string `json:"type,omitempty" azure:"ro"` +} + +// StorageTargetsBeginCreateOrUpdateOptions contains the optional parameters for the StorageTargets.BeginCreateOrUpdate method. +type StorageTargetsBeginCreateOrUpdateOptions struct { + // Object containing the definition of a Storage Target. + Storagetarget *StorageTarget +} + +// StorageTargetsBeginDNSRefreshOptions contains the optional parameters for the StorageTargets.BeginDNSRefresh method. +type StorageTargetsBeginDNSRefreshOptions struct { + // placeholder for future optional parameters +} + +// StorageTargetsBeginDeleteOptions contains the optional parameters for the StorageTargets.BeginDelete method. +type StorageTargetsBeginDeleteOptions struct { + // Boolean value requesting the force delete operation for a storage target. Force delete discards unwritten-data in the cache instead of flushing it to + // back-end storage. + Force *string +} + +// StorageTargetsGetOptions contains the optional parameters for the StorageTargets.Get method. +type StorageTargetsGetOptions struct { + // placeholder for future optional parameters +} + +// StorageTargetsListByCacheOptions contains the optional parameters for the StorageTargets.ListByCache method. +type StorageTargetsListByCacheOptions struct { + // placeholder for future optional parameters +} + +// StorageTargetsResult - A list of Storage Targets. +type StorageTargetsResult struct { + // The URI to fetch the next page of Storage Targets. + NextLink *string `json:"nextLink,omitempty"` + + // The list of Storage Targets defined for the Cache. + Value []*StorageTarget `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type StorageTargetsResult. +func (s StorageTargetsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + 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 +} + +// UnknownTarget - Properties pertaining to the UnknownTarget +type UnknownTarget struct { + // Dictionary of string->string pairs containing information about the Storage Target. + Attributes map[string]*string `json:"attributes,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UnknownTarget. +func (u UnknownTarget) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "attributes", u.Attributes) + return json.Marshal(objectMap) +} + +// UsageModel - A usage model. +type UsageModel struct { + // Localized information describing this usage model. + Display *UsageModelDisplay `json:"display,omitempty"` + + // Non-localized keyword name for this usage model. + ModelName *string `json:"modelName,omitempty"` + + // The type of Storage Target to which this model is applicable (only nfs3 as of this version). + TargetType *string `json:"targetType,omitempty"` +} + +// UsageModelDisplay - Localized information describing this usage model. +type UsageModelDisplay struct { + // String to display for this usage model. + Description *string `json:"description,omitempty"` +} + +// UsageModelsListOptions contains the optional parameters for the UsageModels.List method. +type UsageModelsListOptions struct { + // placeholder for future optional parameters +} + +// UsageModelsResult - A list of Cache usage models. +type UsageModelsResult struct { + // The URI to fetch the next page of Cache usage models. + NextLink *string `json:"nextLink,omitempty"` + + // The list of usage models available for the subscription. + Value []*UsageModel `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UsageModelsResult. +func (u UsageModelsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", u.NextLink) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) +} + +type UserAssignedIdentitiesValue struct { + // READ-ONLY; The client ID of the user-assigned identity. + ClientID *string `json:"clientId,omitempty" azure:"ro"` + + // READ-ONLY; The principal ID of the 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/storagecache/armstoragecache/zz_generated_operations_client.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_operations_client.go new file mode 100644 index 000000000000..e4133d1397ab --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/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 armstoragecache + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists all of the available Resource Provider operations. +// If the operation fails it returns the *CloudError error type. +func (client *OperationsClient) List(options *OperationsListOptions) *OperationsListPager { + return &OperationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.APIOperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.StorageCache/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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.APIOperationListResult); err != nil { + return OperationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/storagecache/armstoragecache/zz_generated_pagers.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_pagers.go new file mode 100644 index 000000000000..04a023e10bce --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_pagers.go @@ -0,0 +1,341 @@ +//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 armstoragecache + +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" +) + +// CachesListByResourceGroupPager provides operations for iterating over paged responses. +type CachesListByResourceGroupPager struct { + client *CachesClient + current CachesListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, CachesListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *CachesListByResourceGroupPager) 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 *CachesListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CachesListResult.NextLink == nil || len(*p.current.CachesListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current CachesListByResourceGroupResponse page. +func (p *CachesListByResourceGroupPager) PageResponse() CachesListByResourceGroupResponse { + return p.current +} + +// CachesListPager provides operations for iterating over paged responses. +type CachesListPager struct { + client *CachesClient + current CachesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, CachesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *CachesListPager) 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 *CachesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CachesListResult.NextLink == nil || len(*p.current.CachesListResult.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 CachesListResponse page. +func (p *CachesListPager) PageResponse() CachesListResponse { + return p.current +} + +// OperationsListPager provides operations for iterating over paged responses. +type OperationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *OperationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.APIOperationListResult.NextLink == nil || len(*p.current.APIOperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationsListResponse page. +func (p *OperationsListPager) PageResponse() OperationsListResponse { + return p.current +} + +// SKUsListPager provides operations for iterating over paged responses. +type SKUsListPager struct { + client *SKUsClient + current SKUsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, SKUsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *SKUsListPager) 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 *SKUsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ResourceSKUsResult.NextLink == nil || len(*p.current.ResourceSKUsResult.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 SKUsListResponse page. +func (p *SKUsListPager) PageResponse() SKUsListResponse { + return p.current +} + +// StorageTargetsListByCachePager provides operations for iterating over paged responses. +type StorageTargetsListByCachePager struct { + client *StorageTargetsClient + current StorageTargetsListByCacheResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, StorageTargetsListByCacheResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *StorageTargetsListByCachePager) 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 *StorageTargetsListByCachePager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.StorageTargetsResult.NextLink == nil || len(*p.current.StorageTargetsResult.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.listByCacheHandleError(resp) + return false + } + result, err := p.client.listByCacheHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current StorageTargetsListByCacheResponse page. +func (p *StorageTargetsListByCachePager) PageResponse() StorageTargetsListByCacheResponse { + return p.current +} + +// UsageModelsListPager provides operations for iterating over paged responses. +type UsageModelsListPager struct { + client *UsageModelsClient + current UsageModelsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, UsageModelsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *UsageModelsListPager) 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 *UsageModelsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.UsageModelsResult.NextLink == nil || len(*p.current.UsageModelsResult.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 UsageModelsListResponse page. +func (p *UsageModelsListPager) PageResponse() UsageModelsListResponse { + return p.current +} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_pollers.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_pollers.go new file mode 100644 index 000000000000..51a15b90f7b8 --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_pollers.go @@ -0,0 +1,574 @@ +//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 armstoragecache + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// CachesCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type CachesCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *CachesCreateOrUpdatePoller) 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 *CachesCreateOrUpdatePoller) 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 CachesCreateOrUpdateResponse will be returned. +func (p *CachesCreateOrUpdatePoller) FinalResponse(ctx context.Context) (CachesCreateOrUpdateResponse, error) { + respType := CachesCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Cache) + if err != nil { + return CachesCreateOrUpdateResponse{}, 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 *CachesCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// CachesDebugInfoPoller provides polling facilities until the operation reaches a terminal state. +type CachesDebugInfoPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *CachesDebugInfoPoller) 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 *CachesDebugInfoPoller) 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 CachesDebugInfoResponse will be returned. +func (p *CachesDebugInfoPoller) FinalResponse(ctx context.Context) (CachesDebugInfoResponse, error) { + respType := CachesDebugInfoResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return CachesDebugInfoResponse{}, 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 *CachesDebugInfoPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// CachesDeletePoller provides polling facilities until the operation reaches a terminal state. +type CachesDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *CachesDeletePoller) 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 *CachesDeletePoller) 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 CachesDeleteResponse will be returned. +func (p *CachesDeletePoller) FinalResponse(ctx context.Context) (CachesDeleteResponse, error) { + respType := CachesDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return CachesDeleteResponse{}, 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 *CachesDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// CachesFlushPoller provides polling facilities until the operation reaches a terminal state. +type CachesFlushPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *CachesFlushPoller) 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 *CachesFlushPoller) 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 CachesFlushResponse will be returned. +func (p *CachesFlushPoller) FinalResponse(ctx context.Context) (CachesFlushResponse, error) { + respType := CachesFlushResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return CachesFlushResponse{}, 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 *CachesFlushPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// CachesStartPoller provides polling facilities until the operation reaches a terminal state. +type CachesStartPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *CachesStartPoller) 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 *CachesStartPoller) 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 CachesStartResponse will be returned. +func (p *CachesStartPoller) FinalResponse(ctx context.Context) (CachesStartResponse, error) { + respType := CachesStartResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return CachesStartResponse{}, 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 *CachesStartPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// CachesStopPoller provides polling facilities until the operation reaches a terminal state. +type CachesStopPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *CachesStopPoller) 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 *CachesStopPoller) 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 CachesStopResponse will be returned. +func (p *CachesStopPoller) FinalResponse(ctx context.Context) (CachesStopResponse, error) { + respType := CachesStopResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return CachesStopResponse{}, 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 *CachesStopPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// CachesUpgradeFirmwarePoller provides polling facilities until the operation reaches a terminal state. +type CachesUpgradeFirmwarePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *CachesUpgradeFirmwarePoller) 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 *CachesUpgradeFirmwarePoller) 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 CachesUpgradeFirmwareResponse will be returned. +func (p *CachesUpgradeFirmwarePoller) FinalResponse(ctx context.Context) (CachesUpgradeFirmwareResponse, error) { + respType := CachesUpgradeFirmwareResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return CachesUpgradeFirmwareResponse{}, 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 *CachesUpgradeFirmwarePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// StorageTargetFlushPoller provides polling facilities until the operation reaches a terminal state. +type StorageTargetFlushPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *StorageTargetFlushPoller) 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 *StorageTargetFlushPoller) 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 StorageTargetFlushResponse will be returned. +func (p *StorageTargetFlushPoller) FinalResponse(ctx context.Context) (StorageTargetFlushResponse, error) { + respType := StorageTargetFlushResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return StorageTargetFlushResponse{}, 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 *StorageTargetFlushPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// StorageTargetResumePoller provides polling facilities until the operation reaches a terminal state. +type StorageTargetResumePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *StorageTargetResumePoller) 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 *StorageTargetResumePoller) 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 StorageTargetResumeResponse will be returned. +func (p *StorageTargetResumePoller) FinalResponse(ctx context.Context) (StorageTargetResumeResponse, error) { + respType := StorageTargetResumeResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return StorageTargetResumeResponse{}, 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 *StorageTargetResumePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// StorageTargetSuspendPoller provides polling facilities until the operation reaches a terminal state. +type StorageTargetSuspendPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *StorageTargetSuspendPoller) 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 *StorageTargetSuspendPoller) 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 StorageTargetSuspendResponse will be returned. +func (p *StorageTargetSuspendPoller) FinalResponse(ctx context.Context) (StorageTargetSuspendResponse, error) { + respType := StorageTargetSuspendResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return StorageTargetSuspendResponse{}, 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 *StorageTargetSuspendPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// StorageTargetsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type StorageTargetsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *StorageTargetsCreateOrUpdatePoller) 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 *StorageTargetsCreateOrUpdatePoller) 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 StorageTargetsCreateOrUpdateResponse will be returned. +func (p *StorageTargetsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (StorageTargetsCreateOrUpdateResponse, error) { + respType := StorageTargetsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.StorageTarget) + if err != nil { + return StorageTargetsCreateOrUpdateResponse{}, 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 *StorageTargetsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// StorageTargetsDNSRefreshPoller provides polling facilities until the operation reaches a terminal state. +type StorageTargetsDNSRefreshPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *StorageTargetsDNSRefreshPoller) 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 *StorageTargetsDNSRefreshPoller) 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 StorageTargetsDNSRefreshResponse will be returned. +func (p *StorageTargetsDNSRefreshPoller) FinalResponse(ctx context.Context) (StorageTargetsDNSRefreshResponse, error) { + respType := StorageTargetsDNSRefreshResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return StorageTargetsDNSRefreshResponse{}, 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 *StorageTargetsDNSRefreshPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// StorageTargetsDeletePoller provides polling facilities until the operation reaches a terminal state. +type StorageTargetsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *StorageTargetsDeletePoller) 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 *StorageTargetsDeletePoller) 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 StorageTargetsDeleteResponse will be returned. +func (p *StorageTargetsDeletePoller) FinalResponse(ctx context.Context) (StorageTargetsDeleteResponse, error) { + respType := StorageTargetsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return StorageTargetsDeleteResponse{}, 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 *StorageTargetsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_response_types.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_response_types.go new file mode 100644 index 000000000000..03bd5c5c3bde --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_response_types.go @@ -0,0 +1,746 @@ +//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 armstoragecache + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// AscOperationsGetResponse contains the response from method AscOperations.Get. +type AscOperationsGetResponse struct { + AscOperationsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AscOperationsGetResult contains the result from method AscOperations.Get. +type AscOperationsGetResult struct { + AscOperation +} + +// CachesCreateOrUpdatePollerResponse contains the response from method Caches.CreateOrUpdate. +type CachesCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *CachesCreateOrUpdatePoller + + // 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 CachesCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (CachesCreateOrUpdateResponse, error) { + respType := CachesCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Cache) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a CachesCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *CachesCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *CachesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("CachesClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &CachesCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// CachesCreateOrUpdateResponse contains the response from method Caches.CreateOrUpdate. +type CachesCreateOrUpdateResponse struct { + CachesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CachesCreateOrUpdateResult contains the result from method Caches.CreateOrUpdate. +type CachesCreateOrUpdateResult struct { + Cache +} + +// CachesDebugInfoPollerResponse contains the response from method Caches.DebugInfo. +type CachesDebugInfoPollerResponse struct { + // Poller contains an initialized poller. + Poller *CachesDebugInfoPoller + + // 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 CachesDebugInfoPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (CachesDebugInfoResponse, error) { + respType := CachesDebugInfoResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a CachesDebugInfoPollerResponse from the provided client and resume token. +func (l *CachesDebugInfoPollerResponse) Resume(ctx context.Context, client *CachesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("CachesClient.DebugInfo", token, client.pl, client.debugInfoHandleError) + if err != nil { + return err + } + poller := &CachesDebugInfoPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// CachesDebugInfoResponse contains the response from method Caches.DebugInfo. +type CachesDebugInfoResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CachesDeletePollerResponse contains the response from method Caches.Delete. +type CachesDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *CachesDeletePoller + + // 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 CachesDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (CachesDeleteResponse, error) { + respType := CachesDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a CachesDeletePollerResponse from the provided client and resume token. +func (l *CachesDeletePollerResponse) Resume(ctx context.Context, client *CachesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("CachesClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &CachesDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// CachesDeleteResponse contains the response from method Caches.Delete. +type CachesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CachesFlushPollerResponse contains the response from method Caches.Flush. +type CachesFlushPollerResponse struct { + // Poller contains an initialized poller. + Poller *CachesFlushPoller + + // 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 CachesFlushPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (CachesFlushResponse, error) { + respType := CachesFlushResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a CachesFlushPollerResponse from the provided client and resume token. +func (l *CachesFlushPollerResponse) Resume(ctx context.Context, client *CachesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("CachesClient.Flush", token, client.pl, client.flushHandleError) + if err != nil { + return err + } + poller := &CachesFlushPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// CachesFlushResponse contains the response from method Caches.Flush. +type CachesFlushResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CachesGetResponse contains the response from method Caches.Get. +type CachesGetResponse struct { + CachesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CachesGetResult contains the result from method Caches.Get. +type CachesGetResult struct { + Cache +} + +// CachesListByResourceGroupResponse contains the response from method Caches.ListByResourceGroup. +type CachesListByResourceGroupResponse struct { + CachesListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CachesListByResourceGroupResult contains the result from method Caches.ListByResourceGroup. +type CachesListByResourceGroupResult struct { + CachesListResult +} + +// CachesListResponse contains the response from method Caches.List. +type CachesListResponse struct { + CachesListResultEnvelope + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CachesListResultEnvelope contains the result from method Caches.List. +type CachesListResultEnvelope struct { + CachesListResult +} + +// CachesStartPollerResponse contains the response from method Caches.Start. +type CachesStartPollerResponse struct { + // Poller contains an initialized poller. + Poller *CachesStartPoller + + // 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 CachesStartPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (CachesStartResponse, error) { + respType := CachesStartResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a CachesStartPollerResponse from the provided client and resume token. +func (l *CachesStartPollerResponse) Resume(ctx context.Context, client *CachesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("CachesClient.Start", token, client.pl, client.startHandleError) + if err != nil { + return err + } + poller := &CachesStartPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// CachesStartResponse contains the response from method Caches.Start. +type CachesStartResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CachesStopPollerResponse contains the response from method Caches.Stop. +type CachesStopPollerResponse struct { + // Poller contains an initialized poller. + Poller *CachesStopPoller + + // 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 CachesStopPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (CachesStopResponse, error) { + respType := CachesStopResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a CachesStopPollerResponse from the provided client and resume token. +func (l *CachesStopPollerResponse) Resume(ctx context.Context, client *CachesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("CachesClient.Stop", token, client.pl, client.stopHandleError) + if err != nil { + return err + } + poller := &CachesStopPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// CachesStopResponse contains the response from method Caches.Stop. +type CachesStopResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CachesUpdateResponse contains the response from method Caches.Update. +type CachesUpdateResponse struct { + CachesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CachesUpdateResult contains the result from method Caches.Update. +type CachesUpdateResult struct { + Cache +} + +// CachesUpgradeFirmwarePollerResponse contains the response from method Caches.UpgradeFirmware. +type CachesUpgradeFirmwarePollerResponse struct { + // Poller contains an initialized poller. + Poller *CachesUpgradeFirmwarePoller + + // 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 CachesUpgradeFirmwarePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (CachesUpgradeFirmwareResponse, error) { + respType := CachesUpgradeFirmwareResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a CachesUpgradeFirmwarePollerResponse from the provided client and resume token. +func (l *CachesUpgradeFirmwarePollerResponse) Resume(ctx context.Context, client *CachesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("CachesClient.UpgradeFirmware", token, client.pl, client.upgradeFirmwareHandleError) + if err != nil { + return err + } + poller := &CachesUpgradeFirmwarePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// CachesUpgradeFirmwareResponse contains the response from method Caches.UpgradeFirmware. +type CachesUpgradeFirmwareResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + APIOperationListResult +} + +// SKUsListResponse contains the response from method SKUs.List. +type SKUsListResponse struct { + SKUsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SKUsListResult contains the result from method SKUs.List. +type SKUsListResult struct { + ResourceSKUsResult +} + +// StorageTargetFlushPollerResponse contains the response from method StorageTarget.Flush. +type StorageTargetFlushPollerResponse struct { + // Poller contains an initialized poller. + Poller *StorageTargetFlushPoller + + // 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 StorageTargetFlushPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (StorageTargetFlushResponse, error) { + respType := StorageTargetFlushResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a StorageTargetFlushPollerResponse from the provided client and resume token. +func (l *StorageTargetFlushPollerResponse) Resume(ctx context.Context, client *StorageTargetClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("StorageTargetClient.Flush", token, client.pl, client.flushHandleError) + if err != nil { + return err + } + poller := &StorageTargetFlushPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// StorageTargetFlushResponse contains the response from method StorageTarget.Flush. +type StorageTargetFlushResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageTargetResumePollerResponse contains the response from method StorageTarget.Resume. +type StorageTargetResumePollerResponse struct { + // Poller contains an initialized poller. + Poller *StorageTargetResumePoller + + // 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 StorageTargetResumePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (StorageTargetResumeResponse, error) { + respType := StorageTargetResumeResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a StorageTargetResumePollerResponse from the provided client and resume token. +func (l *StorageTargetResumePollerResponse) Resume(ctx context.Context, client *StorageTargetClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("StorageTargetClient.Resume", token, client.pl, client.resumeHandleError) + if err != nil { + return err + } + poller := &StorageTargetResumePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// StorageTargetResumeResponse contains the response from method StorageTarget.Resume. +type StorageTargetResumeResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageTargetSuspendPollerResponse contains the response from method StorageTarget.Suspend. +type StorageTargetSuspendPollerResponse struct { + // Poller contains an initialized poller. + Poller *StorageTargetSuspendPoller + + // 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 StorageTargetSuspendPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (StorageTargetSuspendResponse, error) { + respType := StorageTargetSuspendResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a StorageTargetSuspendPollerResponse from the provided client and resume token. +func (l *StorageTargetSuspendPollerResponse) Resume(ctx context.Context, client *StorageTargetClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("StorageTargetClient.Suspend", token, client.pl, client.suspendHandleError) + if err != nil { + return err + } + poller := &StorageTargetSuspendPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// StorageTargetSuspendResponse contains the response from method StorageTarget.Suspend. +type StorageTargetSuspendResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageTargetsCreateOrUpdatePollerResponse contains the response from method StorageTargets.CreateOrUpdate. +type StorageTargetsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *StorageTargetsCreateOrUpdatePoller + + // 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 StorageTargetsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (StorageTargetsCreateOrUpdateResponse, error) { + respType := StorageTargetsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.StorageTarget) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a StorageTargetsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *StorageTargetsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *StorageTargetsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("StorageTargetsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &StorageTargetsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// StorageTargetsCreateOrUpdateResponse contains the response from method StorageTargets.CreateOrUpdate. +type StorageTargetsCreateOrUpdateResponse struct { + StorageTargetsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageTargetsCreateOrUpdateResult contains the result from method StorageTargets.CreateOrUpdate. +type StorageTargetsCreateOrUpdateResult struct { + StorageTarget +} + +// StorageTargetsDNSRefreshPollerResponse contains the response from method StorageTargets.DNSRefresh. +type StorageTargetsDNSRefreshPollerResponse struct { + // Poller contains an initialized poller. + Poller *StorageTargetsDNSRefreshPoller + + // 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 StorageTargetsDNSRefreshPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (StorageTargetsDNSRefreshResponse, error) { + respType := StorageTargetsDNSRefreshResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a StorageTargetsDNSRefreshPollerResponse from the provided client and resume token. +func (l *StorageTargetsDNSRefreshPollerResponse) Resume(ctx context.Context, client *StorageTargetsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("StorageTargetsClient.DNSRefresh", token, client.pl, client.dnsRefreshHandleError) + if err != nil { + return err + } + poller := &StorageTargetsDNSRefreshPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// StorageTargetsDNSRefreshResponse contains the response from method StorageTargets.DNSRefresh. +type StorageTargetsDNSRefreshResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageTargetsDeletePollerResponse contains the response from method StorageTargets.Delete. +type StorageTargetsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *StorageTargetsDeletePoller + + // 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 StorageTargetsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (StorageTargetsDeleteResponse, error) { + respType := StorageTargetsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a StorageTargetsDeletePollerResponse from the provided client and resume token. +func (l *StorageTargetsDeletePollerResponse) Resume(ctx context.Context, client *StorageTargetsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("StorageTargetsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &StorageTargetsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// StorageTargetsDeleteResponse contains the response from method StorageTargets.Delete. +type StorageTargetsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageTargetsGetResponse contains the response from method StorageTargets.Get. +type StorageTargetsGetResponse struct { + StorageTargetsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageTargetsGetResult contains the result from method StorageTargets.Get. +type StorageTargetsGetResult struct { + StorageTarget +} + +// StorageTargetsListByCacheResponse contains the response from method StorageTargets.ListByCache. +type StorageTargetsListByCacheResponse struct { + StorageTargetsListByCacheResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageTargetsListByCacheResult contains the result from method StorageTargets.ListByCache. +type StorageTargetsListByCacheResult struct { + StorageTargetsResult +} + +// UsageModelsListResponse contains the response from method UsageModels.List. +type UsageModelsListResponse struct { + UsageModelsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UsageModelsListResult contains the result from method UsageModels.List. +type UsageModelsListResult struct { + UsageModelsResult +} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_skus_client.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_skus_client.go new file mode 100644 index 000000000000..0e2cc66aea9a --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_skus_client.go @@ -0,0 +1,97 @@ +//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 armstoragecache + +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" +) + +// SKUsClient contains the methods for the SKUs group. +// Don't use this type directly, use NewSKUsClient() instead. +type SKUsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewSKUsClient creates a new instance of SKUsClient with the specified values. +func NewSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *SKUsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &SKUsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Get the list of StorageCache.Cache SKUs available to this subscription. +// If the operation fails it returns the *CloudError error type. +func (client *SKUsClient) List(options *SKUsListOptions) *SKUsListPager { + return &SKUsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp SKUsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ResourceSKUsResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *SKUsClient) listCreateRequest(ctx context.Context, options *SKUsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/skus" + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SKUsClient) listHandleResponse(resp *http.Response) (SKUsListResponse, error) { + result := SKUsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ResourceSKUsResult); err != nil { + return SKUsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *SKUsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/storagecache/armstoragecache/zz_generated_storagetarget_client.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_storagetarget_client.go new file mode 100644 index 000000000000..6ae47de8b9f9 --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_storagetarget_client.go @@ -0,0 +1,285 @@ +//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 armstoragecache + +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" +) + +// StorageTargetClient contains the methods for the StorageTarget group. +// Don't use this type directly, use NewStorageTargetClient() instead. +type StorageTargetClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewStorageTargetClient creates a new instance of StorageTargetClient with the specified values. +func NewStorageTargetClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *StorageTargetClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &StorageTargetClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginFlush - Tells the cache to write all dirty data to the Storage Target's backend storage. Client requests to this storage target's namespace will +// return errors until the flush operation completes. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetClient) BeginFlush(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetBeginFlushOptions) (StorageTargetFlushPollerResponse, error) { + resp, err := client.flush(ctx, resourceGroupName, cacheName, storageTargetName, options) + if err != nil { + return StorageTargetFlushPollerResponse{}, err + } + result := StorageTargetFlushPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("StorageTargetClient.Flush", "azure-async-operation", resp, client.pl, client.flushHandleError) + if err != nil { + return StorageTargetFlushPollerResponse{}, err + } + result.Poller = &StorageTargetFlushPoller{ + pt: pt, + } + return result, nil +} + +// Flush - Tells the cache to write all dirty data to the Storage Target's backend storage. Client requests to this storage target's namespace will return +// errors until the flush operation completes. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetClient) flush(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetBeginFlushOptions) (*http.Response, error) { + req, err := client.flushCreateRequest(ctx, resourceGroupName, cacheName, storageTargetName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.flushHandleError(resp) + } + return resp, nil +} + +// flushCreateRequest creates the Flush request. +func (client *StorageTargetClient) flushCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetBeginFlushOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/flush" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if storageTargetName == "" { + return nil, errors.New("parameter storageTargetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// flushHandleError handles the Flush error response. +func (client *StorageTargetClient) flushHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginResume - Resumes client access to a previously suspended storage target. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetClient) BeginResume(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetBeginResumeOptions) (StorageTargetResumePollerResponse, error) { + resp, err := client.resume(ctx, resourceGroupName, cacheName, storageTargetName, options) + if err != nil { + return StorageTargetResumePollerResponse{}, err + } + result := StorageTargetResumePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("StorageTargetClient.Resume", "azure-async-operation", resp, client.pl, client.resumeHandleError) + if err != nil { + return StorageTargetResumePollerResponse{}, err + } + result.Poller = &StorageTargetResumePoller{ + pt: pt, + } + return result, nil +} + +// Resume - Resumes client access to a previously suspended storage target. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetClient) resume(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetBeginResumeOptions) (*http.Response, error) { + req, err := client.resumeCreateRequest(ctx, resourceGroupName, cacheName, storageTargetName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.resumeHandleError(resp) + } + return resp, nil +} + +// resumeCreateRequest creates the Resume request. +func (client *StorageTargetClient) resumeCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetBeginResumeOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/resume" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if storageTargetName == "" { + return nil, errors.New("parameter storageTargetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// resumeHandleError handles the Resume error response. +func (client *StorageTargetClient) resumeHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginSuspend - Suspends client access to a storage target. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetClient) BeginSuspend(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetBeginSuspendOptions) (StorageTargetSuspendPollerResponse, error) { + resp, err := client.suspend(ctx, resourceGroupName, cacheName, storageTargetName, options) + if err != nil { + return StorageTargetSuspendPollerResponse{}, err + } + result := StorageTargetSuspendPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("StorageTargetClient.Suspend", "azure-async-operation", resp, client.pl, client.suspendHandleError) + if err != nil { + return StorageTargetSuspendPollerResponse{}, err + } + result.Poller = &StorageTargetSuspendPoller{ + pt: pt, + } + return result, nil +} + +// Suspend - Suspends client access to a storage target. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetClient) suspend(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetBeginSuspendOptions) (*http.Response, error) { + req, err := client.suspendCreateRequest(ctx, resourceGroupName, cacheName, storageTargetName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.suspendHandleError(resp) + } + return resp, nil +} + +// suspendCreateRequest creates the Suspend request. +func (client *StorageTargetClient) suspendCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetBeginSuspendOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/suspend" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if storageTargetName == "" { + return nil, errors.New("parameter storageTargetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// suspendHandleError handles the Suspend error response. +func (client *StorageTargetClient) suspendHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/storagecache/armstoragecache/zz_generated_storagetargets_client.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_storagetargets_client.go new file mode 100644 index 000000000000..20fb21fef866 --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_storagetargets_client.go @@ -0,0 +1,428 @@ +//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 armstoragecache + +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" +) + +// StorageTargetsClient contains the methods for the StorageTargets group. +// Don't use this type directly, use NewStorageTargetsClient() instead. +type StorageTargetsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewStorageTargetsClient creates a new instance of StorageTargetsClient with the specified values. +func NewStorageTargetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *StorageTargetsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &StorageTargetsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update a Storage Target. This operation is allowed at any time, but if the Cache is down or unhealthy, the actual creation/modification +// of the Storage Target may be delayed until the Cache +// is healthy again. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetsBeginCreateOrUpdateOptions) (StorageTargetsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, cacheName, storageTargetName, options) + if err != nil { + return StorageTargetsCreateOrUpdatePollerResponse{}, err + } + result := StorageTargetsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("StorageTargetsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return StorageTargetsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &StorageTargetsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update a Storage Target. This operation is allowed at any time, but if the Cache is down or unhealthy, the actual creation/modification +// of the Storage Target may be delayed until the Cache +// is healthy again. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetsClient) createOrUpdate(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, cacheName, storageTargetName, 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, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *StorageTargetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if storageTargetName == "" { + return nil, errors.New("parameter storageTargetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Storagetarget != nil { + return req, runtime.MarshalAsJSON(req, *options.Storagetarget) + } + return req, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *StorageTargetsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginDNSRefresh - Tells a storage target to refresh its DNS information. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetsClient) BeginDNSRefresh(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetsBeginDNSRefreshOptions) (StorageTargetsDNSRefreshPollerResponse, error) { + resp, err := client.dNSRefresh(ctx, resourceGroupName, cacheName, storageTargetName, options) + if err != nil { + return StorageTargetsDNSRefreshPollerResponse{}, err + } + result := StorageTargetsDNSRefreshPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("StorageTargetsClient.DNSRefresh", "azure-async-operation", resp, client.pl, client.dnsRefreshHandleError) + if err != nil { + return StorageTargetsDNSRefreshPollerResponse{}, err + } + result.Poller = &StorageTargetsDNSRefreshPoller{ + pt: pt, + } + return result, nil +} + +// DNSRefresh - Tells a storage target to refresh its DNS information. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetsClient) dNSRefresh(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetsBeginDNSRefreshOptions) (*http.Response, error) { + req, err := client.dnsRefreshCreateRequest(ctx, resourceGroupName, cacheName, storageTargetName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.dnsRefreshHandleError(resp) + } + return resp, nil +} + +// dnsRefreshCreateRequest creates the DNSRefresh request. +func (client *StorageTargetsClient) dnsRefreshCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetsBeginDNSRefreshOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/dnsRefresh" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if storageTargetName == "" { + return nil, errors.New("parameter storageTargetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// dnsRefreshHandleError handles the DNSRefresh error response. +func (client *StorageTargetsClient) dnsRefreshHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Removes a Storage Target from a Cache. This operation is allowed at any time, but if the Cache is down or unhealthy, the actual removal +// of the Storage Target may be delayed until the Cache is healthy +// again. Note that if the Cache has data to flush to the Storage Target, the data will be flushed before the Storage Target will be deleted. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetsClient) BeginDelete(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetsBeginDeleteOptions) (StorageTargetsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, cacheName, storageTargetName, options) + if err != nil { + return StorageTargetsDeletePollerResponse{}, err + } + result := StorageTargetsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("StorageTargetsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return StorageTargetsDeletePollerResponse{}, err + } + result.Poller = &StorageTargetsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Removes a Storage Target from a Cache. This operation is allowed at any time, but if the Cache is down or unhealthy, the actual removal of the +// Storage Target may be delayed until the Cache is healthy +// again. Note that if the Cache has data to flush to the Storage Target, the data will be flushed before the Storage Target will be deleted. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetsClient) deleteOperation(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, cacheName, storageTargetName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *StorageTargetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if storageTargetName == "" { + return nil, errors.New("parameter storageTargetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) + 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-01") + if options != nil && options.Force != nil { + reqQP.Set("force", *options.Force) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *StorageTargetsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Returns a Storage Target from a Cache. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetsClient) Get(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetsGetOptions) (StorageTargetsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, cacheName, storageTargetName, options) + if err != nil { + return StorageTargetsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return StorageTargetsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return StorageTargetsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *StorageTargetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, options *StorageTargetsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + if storageTargetName == "" { + return nil, errors.New("parameter storageTargetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *StorageTargetsClient) getHandleResponse(resp *http.Response) (StorageTargetsGetResponse, error) { + result := StorageTargetsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.StorageTarget); err != nil { + return StorageTargetsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *StorageTargetsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListByCache - Returns a list of Storage Targets for the specified Cache. +// If the operation fails it returns the *CloudError error type. +func (client *StorageTargetsClient) ListByCache(resourceGroupName string, cacheName string, options *StorageTargetsListByCacheOptions) *StorageTargetsListByCachePager { + return &StorageTargetsListByCachePager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByCacheCreateRequest(ctx, resourceGroupName, cacheName, options) + }, + advancer: func(ctx context.Context, resp StorageTargetsListByCacheResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.StorageTargetsResult.NextLink) + }, + } +} + +// listByCacheCreateRequest creates the ListByCache request. +func (client *StorageTargetsClient) listByCacheCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, options *StorageTargetsListByCacheOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if cacheName == "" { + return nil, errors.New("parameter cacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByCacheHandleResponse handles the ListByCache response. +func (client *StorageTargetsClient) listByCacheHandleResponse(resp *http.Response) (StorageTargetsListByCacheResponse, error) { + result := StorageTargetsListByCacheResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.StorageTargetsResult); err != nil { + return StorageTargetsListByCacheResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByCacheHandleError handles the ListByCache error response. +func (client *StorageTargetsClient) listByCacheHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/storagecache/armstoragecache/zz_generated_time_rfc3339.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..d24ce55d620b --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/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 armstoragecache + +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 +} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_usagemodels_client.go b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_usagemodels_client.go new file mode 100644 index 000000000000..3622a0b4acb8 --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/zz_generated_usagemodels_client.go @@ -0,0 +1,97 @@ +//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 armstoragecache + +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" +) + +// UsageModelsClient contains the methods for the UsageModels group. +// Don't use this type directly, use NewUsageModelsClient() instead. +type UsageModelsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewUsageModelsClient creates a new instance of UsageModelsClient with the specified values. +func NewUsageModelsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *UsageModelsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &UsageModelsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Get the list of Cache Usage Models available to this subscription. +// If the operation fails it returns the *CloudError error type. +func (client *UsageModelsClient) List(options *UsageModelsListOptions) *UsageModelsListPager { + return &UsageModelsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp UsageModelsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.UsageModelsResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *UsageModelsClient) listCreateRequest(ctx context.Context, options *UsageModelsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/usageModels" + 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-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *UsageModelsClient) listHandleResponse(resp *http.Response) (UsageModelsListResponse, error) { + result := UsageModelsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.UsageModelsResult); err != nil { + return UsageModelsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *UsageModelsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +}