From 53369f4c29a72b08fcb31b427da008b93439cbbe Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 19 Apr 2022 13:23:36 +0000 Subject: [PATCH] CodeGen from PR 18731 in Azure/azure-rest-api-specs Merge 506f744df987ff34242729896089235f12fc3980 into d8700f40abc50e363891802af12261eae32b6abc --- .../elasticsans/armelasticsans/CHANGELOG.md | 5 + .../elasticsans/armelasticsans/LICENSE.txt | 21 + .../elasticsans/armelasticsans/README.md | 77 +++ .../elasticsans/armelasticsans/autorest.md | 13 + .../elasticsans/armelasticsans/build.go | 7 + .../elasticsans/armelasticsans/ci.yml | 28 + .../elasticsans/armelasticsans/go.mod | 11 + .../elasticsans/armelasticsans/go.sum | 32 + .../armelasticsans/zz_generated_client.go | 423 ++++++++++++ .../armelasticsans/zz_generated_constants.go | 214 ++++++ .../armelasticsans/zz_generated_models.go | 612 ++++++++++++++++++ .../zz_generated_models_serde.go | 256 ++++++++ .../zz_generated_operations_client.go | 97 +++ .../zz_generated_response_types.go | 99 +++ .../zz_generated_skus_client.go | 100 +++ .../zz_generated_time_rfc3339.go | 85 +++ .../zz_generated_volumegroups_client.go | 394 +++++++++++ .../zz_generated_volumes_client.go | 412 ++++++++++++ 18 files changed, 2886 insertions(+) create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/CHANGELOG.md create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/LICENSE.txt create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/README.md create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/autorest.md create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/build.go create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/ci.yml create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/go.mod create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/go.sum create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_client.go create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_constants.go create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_models.go create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_models_serde.go create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_operations_client.go create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_response_types.go create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_skus_client.go create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_time_rfc3339.go create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_volumegroups_client.go create mode 100644 sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_volumes_client.go diff --git a/sdk/resourcemanager/elasticsans/armelasticsans/CHANGELOG.md b/sdk/resourcemanager/elasticsans/armelasticsans/CHANGELOG.md new file mode 100644 index 000000000000..3bb18a9bf7e7 --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2022-04-19) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/elasticsans/armelasticsans/LICENSE.txt b/sdk/resourcemanager/elasticsans/armelasticsans/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/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/elasticsans/armelasticsans/README.md b/sdk/resourcemanager/elasticsans/armelasticsans/README.md new file mode 100644 index 000000000000..e37aade1a74a --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/README.md @@ -0,0 +1,77 @@ +# Azure Elasticsans Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsans/armelasticsans)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsans/armelasticsans) + +The `armelasticsans` module provides operations for working with Azure Elasticsans. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/elasticsans/armelasticsans) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 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 Elasticsans module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsans/armelasticsans +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Elasticsans. 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 Elasticsans 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, err := armelasticsans.NewVolumeGroupsClient(, 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{ + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +client, err := armelasticsans.NewVolumeGroupsClient(, 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 `Elasticsans` 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/elasticsans/armelasticsans/autorest.md b/sdk/resourcemanager/elasticsans/armelasticsans/autorest.md new file mode 100644 index 000000000000..0f0ef5dd678f --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/elasticsan/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/elasticsan/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/elasticsans/armelasticsans/build.go b/sdk/resourcemanager/elasticsans/armelasticsans/build.go new file mode 100644 index 000000000000..3ee50afb820f --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/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/elasticsans/armelasticsans + +package armelasticsans diff --git a/sdk/resourcemanager/elasticsans/armelasticsans/ci.yml b/sdk/resourcemanager/elasticsans/armelasticsans/ci.yml new file mode 100644 index 000000000000..0c07a7f8fd6e --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/ci.yml @@ -0,0 +1,28 @@ +# 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/elasticsans/armelasticsans/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/elasticsans/armelasticsans/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/elasticsans/armelasticsans' diff --git a/sdk/resourcemanager/elasticsans/armelasticsans/go.mod b/sdk/resourcemanager/elasticsans/armelasticsans/go.mod new file mode 100644 index 000000000000..2f26c54c617f --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/go.mod @@ -0,0 +1,11 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsans/armelasticsans + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 // indirect + golang.org/x/net v0.0.0-20210610132358-84b48f89b13b // indirect + golang.org/x/text v0.3.6 // indirect +) diff --git a/sdk/resourcemanager/elasticsans/armelasticsans/go.sum b/sdk/resourcemanager/elasticsans/armelasticsans/go.sum new file mode 100644 index 000000000000..a7eaa30576c1 --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/go.sum @@ -0,0 +1,32 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 h1:D7l5jspkc4kwBYRWoZE4DQnu6LVpLwDsMZjBKS4wZLQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0/go.mod h1:w5pDIZuawUmY3Bj4tVx3Xb8KS96ToB0j315w9rqpAg0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 h1:sLZ/Y+P/5RRtsXWylBjB5lkgixYfm0MQPiwrSX//JSo= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.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/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/elasticsans/armelasticsans/zz_generated_client.go b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_client.go new file mode 100644 index 000000000000..bcada18731ca --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_client.go @@ -0,0 +1,423 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armelasticsans + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// Client contains the methods for the ElasticSans group. +// Don't use this type directly, use NewClient() instead. +type Client struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewClient creates a new instance of Client with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &Client{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreate - Create ElasticSan. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// parameters - Elastic San object. +// options - ClientBeginCreateOptions contains the optional parameters for the Client.BeginCreate method. +func (client *Client) BeginCreate(ctx context.Context, resourceGroupName string, elasticSanName string, parameters ElasticSan, options *ClientBeginCreateOptions) (*armruntime.Poller[ClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, elasticSanName, parameters, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[ClientCreateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[ClientCreateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Create - Create ElasticSan. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *Client) create(ctx context.Context, resourceGroupName string, elasticSanName string, parameters ElasticSan, options *ClientBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, elasticSanName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *Client) createCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, parameters ElasticSan, options *ClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// BeginDelete - Delete a Elastic San. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// options - ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. +func (client *Client) BeginDelete(ctx context.Context, resourceGroupName string, elasticSanName string, options *ClientBeginDeleteOptions) (*armruntime.Poller[ClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, elasticSanName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[ClientDeleteResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[ClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Delete a Elastic San. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *Client) deleteOperation(ctx context.Context, resourceGroupName string, elasticSanName string, options *ClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, elasticSanName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, options *ClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.ForceDeleteVolumeGroups != nil { + req.Raw().Header.Set("x-ms-delete-volumegroups", strconv.FormatBool(*options.ForceDeleteVolumeGroups)) + } + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// Get - Get a ElasticSan. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// options - ClientGetOptions contains the optional parameters for the Client.Get method. +func (client *Client) Get(ctx context.Context, resourceGroupName string, elasticSanName string, options *ClientGetOptions) (ClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, elasticSanName, options) + if err != nil { + return ClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, options *ClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, error) { + result := ClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ElasticSan); err != nil { + return ClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Gets a list of ElasticSan in a resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// options - ClientListByResourceGroupOptions contains the optional parameters for the Client.ListByResourceGroup method. +func (client *Client) NewListByResourceGroupPager(resourceGroupName string, options *ClientListByResourceGroupOptions) *runtime.Pager[ClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[ClientListByResourceGroupResponse]{ + More: func(page ClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListByResourceGroupResponse) (ClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *Client) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *Client) listByResourceGroupHandleResponse(resp *http.Response) (ClientListByResourceGroupResponse, error) { + result := ClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ElasticSanList); err != nil { + return ClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Gets a list of ElasticSans in a subscription +// If the operation fails it returns an *azcore.ResponseError type. +// options - ClientListBySubscriptionOptions contains the optional parameters for the Client.ListBySubscription method. +func (client *Client) NewListBySubscriptionPager(options *ClientListBySubscriptionOptions) *runtime.Pager[ClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PageProcessor[ClientListBySubscriptionResponse]{ + More: func(page ClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListBySubscriptionResponse) (ClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *Client) listBySubscriptionCreateRequest(ctx context.Context, options *ClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ElasticSan/elasticSans" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *Client) listBySubscriptionHandleResponse(resp *http.Response) (ClientListBySubscriptionResponse, error) { + result := ClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ElasticSanList); err != nil { + return ClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a Elastic San. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// parameters - Elastic San object. +// options - ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. +func (client *Client) BeginUpdate(ctx context.Context, resourceGroupName string, elasticSanName string, parameters ElasticSanUpdate, options *ClientBeginUpdateOptions) (*armruntime.Poller[ClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, elasticSanName, parameters, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[ClientUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[ClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Update a Elastic San. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *Client) update(ctx context.Context, resourceGroupName string, elasticSanName string, parameters ElasticSanUpdate, options *ClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, elasticSanName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *Client) updateCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, parameters ElasticSanUpdate, options *ClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} diff --git a/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_constants.go b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_constants.go new file mode 100644 index 000000000000..ca32171e9e4d --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_constants.go @@ -0,0 +1,214 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armelasticsans + +const ( + moduleName = "armelasticsans" + moduleVersion = "v0.1.0" +) + +// 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, + } +} + +// EncryptionType - The type of key used to encrypt the data of the disk. +type EncryptionType string + +const ( + // EncryptionTypeEncryptionAtRestWithCustomerKey - Volume is encrypted at rest with Customer managed key that can be changed + // and revoked by a customer. + EncryptionTypeEncryptionAtRestWithCustomerKey EncryptionType = "EncryptionAtRestWithCustomerKey" + // EncryptionTypeEncryptionAtRestWithPlatformAndCustomerKeys - Volume is encrypted at rest with 2 layers of encryption. One + // of the keys is Customer managed and the other key is Platform managed. + EncryptionTypeEncryptionAtRestWithPlatformAndCustomerKeys EncryptionType = "EncryptionAtRestWithPlatformAndCustomerKeys" + // EncryptionTypeEncryptionAtRestWithPlatformKey - Volume is encrypted at rest with Platform managed key. It is the default + // encryption type. This is not a valid encryption type for disk encryption sets. + EncryptionTypeEncryptionAtRestWithPlatformKey EncryptionType = "EncryptionAtRestWithPlatformKey" +) + +// PossibleEncryptionTypeValues returns the possible values for the EncryptionType const type. +func PossibleEncryptionTypeValues() []EncryptionType { + return []EncryptionType{ + EncryptionTypeEncryptionAtRestWithCustomerKey, + EncryptionTypeEncryptionAtRestWithPlatformAndCustomerKeys, + EncryptionTypeEncryptionAtRestWithPlatformKey, + } +} + +// Name - The sku name. +type Name string + +const ( + // NamePremiumLRS - Premium locally redundant storage + NamePremiumLRS Name = "Premium_LRS" + // NameStandardLRS - Standard locally redundant storage + NameStandardLRS Name = "Standard_LRS" + // NameStandardZRS - Standard zone redundant storage + NameStandardZRS Name = "Standard_ZRS" +) + +// PossibleNameValues returns the possible values for the Name const type. +func PossibleNameValues() []Name { + return []Name{ + NamePremiumLRS, + NameStandardLRS, + NameStandardZRS, + } +} + +// OperationalStatus - Operational status of the resource. +type OperationalStatus string + +const ( + OperationalStatusHealthy OperationalStatus = "Healthy" + OperationalStatusInvalid OperationalStatus = "Invalid" + OperationalStatusRunning OperationalStatus = "Running" + OperationalStatusStopped OperationalStatus = "Stopped" + OperationalStatusStoppedDeallocated OperationalStatus = "Stopped (deallocated)" + OperationalStatusUnhealthy OperationalStatus = "Unhealthy" + OperationalStatusUnknown OperationalStatus = "Unknown" + OperationalStatusUpdating OperationalStatus = "Updating" +) + +// PossibleOperationalStatusValues returns the possible values for the OperationalStatus const type. +func PossibleOperationalStatusValues() []OperationalStatus { + return []OperationalStatus{ + OperationalStatusHealthy, + OperationalStatusInvalid, + OperationalStatusRunning, + OperationalStatusStopped, + OperationalStatusStoppedDeallocated, + OperationalStatusUnhealthy, + OperationalStatusUnknown, + OperationalStatusUpdating, + } +} + +// ProvisioningStates - Provisioning state of the iSCSI Target. +type ProvisioningStates string + +const ( + ProvisioningStatesCanceled ProvisioningStates = "Canceled" + ProvisioningStatesCreating ProvisioningStates = "Creating" + ProvisioningStatesDeleting ProvisioningStates = "Deleting" + ProvisioningStatesFailed ProvisioningStates = "Failed" + ProvisioningStatesInvalid ProvisioningStates = "Invalid" + ProvisioningStatesPending ProvisioningStates = "Pending" + ProvisioningStatesSucceeded ProvisioningStates = "Succeeded" + ProvisioningStatesUpdating ProvisioningStates = "Updating" +) + +// PossibleProvisioningStatesValues returns the possible values for the ProvisioningStates const type. +func PossibleProvisioningStatesValues() []ProvisioningStates { + return []ProvisioningStates{ + ProvisioningStatesCanceled, + ProvisioningStatesCreating, + ProvisioningStatesDeleting, + ProvisioningStatesFailed, + ProvisioningStatesInvalid, + ProvisioningStatesPending, + ProvisioningStatesSucceeded, + ProvisioningStatesUpdating, + } +} + +// State - Gets the state of virtual network rule. +type State string + +const ( + StateProvisioning State = "provisioning" + StateDeprovisioning State = "deprovisioning" + StateSucceeded State = "succeeded" + StateFailed State = "failed" + StateNetworkSourceDeleted State = "networkSourceDeleted" +) + +// PossibleStateValues returns the possible values for the State const type. +func PossibleStateValues() []State { + return []State{ + StateProvisioning, + StateDeprovisioning, + StateSucceeded, + StateFailed, + StateNetworkSourceDeleted, + } +} + +// StorageTargetType - Storage Target type. +type StorageTargetType string + +const ( + StorageTargetTypeIscsi StorageTargetType = "Iscsi" + StorageTargetTypeNone StorageTargetType = "None" +) + +// PossibleStorageTargetTypeValues returns the possible values for the StorageTargetType const type. +func PossibleStorageTargetTypeValues() []StorageTargetType { + return []StorageTargetType{ + StorageTargetTypeIscsi, + StorageTargetTypeNone, + } +} + +// Tier - The sku tier. +type Tier string + +const ( + // TierHero - Hero + TierHero Tier = "Hero" + // TierHub - Hub + TierHub Tier = "Hub" + // TierSatellite - Satellite + TierSatellite Tier = "Satellite" +) + +// PossibleTierValues returns the possible values for the Tier const type. +func PossibleTierValues() []Tier { + return []Tier{ + TierHero, + TierHub, + TierSatellite, + } +} + +// VolumeCreateOption - This enumerates the possible sources of a volume creation. +type VolumeCreateOption string + +const ( + VolumeCreateOptionNone VolumeCreateOption = "None" + VolumeCreateOptionFromVolume VolumeCreateOption = "FromVolume" + VolumeCreateOptionFromDiskSnapshot VolumeCreateOption = "FromDiskSnapshot" + VolumeCreateOptionExport VolumeCreateOption = "Export" +) + +// PossibleVolumeCreateOptionValues returns the possible values for the VolumeCreateOption const type. +func PossibleVolumeCreateOptionValues() []VolumeCreateOption { + return []VolumeCreateOption{ + VolumeCreateOptionNone, + VolumeCreateOptionFromVolume, + VolumeCreateOptionFromDiskSnapshot, + VolumeCreateOptionExport, + } +} diff --git a/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_models.go b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_models.go new file mode 100644 index 000000000000..38f2252c9972 --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_models.go @@ -0,0 +1,612 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armelasticsans + +import "time" + +// ClientBeginCreateOptions contains the optional parameters for the Client.BeginCreate method. +type ClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. +type ClientBeginDeleteOptions struct { + // Required if the San has associated Volume Groups + ForceDeleteVolumeGroups *bool + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. +type ClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ClientGetOptions contains the optional parameters for the Client.Get method. +type ClientGetOptions struct { + // placeholder for future optional parameters +} + +// ClientListByResourceGroupOptions contains the optional parameters for the Client.ListByResourceGroup method. +type ClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientListBySubscriptionOptions contains the optional parameters for the Client.ListBySubscription method. +type ClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ElasticSan - Response for ElasticSan request. +type ElasticSan struct { + // The geo-location where the resource lives. + Location *string `json:"location,omitempty"` + + // Properties of ElasticSan. + Properties *ElasticSanProperties `json:"properties,omitempty"` + + // Azure resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Azure resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource metadata required by ARM RPC + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ElasticSanList - List of Elastic Sans +type ElasticSanList struct { + // REQUIRED; An array of Elastic San objects. + Value []*ElasticSan `json:"value,omitempty"` + + // READ-ONLY; URI to fetch the next section of the paginated response. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// ElasticSanOperationDisplay - Metadata about an operation. +type ElasticSanOperationDisplay struct { + // REQUIRED; Localized friendly description for the operation, as it should be shown to the user. + Description *string `json:"description,omitempty"` + + // REQUIRED; Localized friendly name for the operation, as it should be shown to the user. + Operation *string `json:"operation,omitempty"` + + // REQUIRED; Localized friendly form of the resource provider name. + Provider *string `json:"provider,omitempty"` + + // REQUIRED; Localized friendly form of the resource type related to this action/operation. + Resource *string `json:"resource,omitempty"` +} + +// ElasticSanOperationListResult - List of operations supported by the RP. +type ElasticSanOperationListResult struct { + // REQUIRED; An array of operations supported by the ElasticSan RP. + Value []*ElasticSanRPOperation `json:"value,omitempty"` + + // URI to fetch the next section of the paginated response. + NextLink *string `json:"nextLink,omitempty"` +} + +// ElasticSanProperties - Elastic San response properties. +type ElasticSanProperties struct { + // REQUIRED; Logical zone for Elastic San resource; example: ["1"]. + AvailabilityZones []*string `json:"availabilityZones,omitempty"` + + // REQUIRED; Base size of the Elastic San appliance in TiB. + BaseSizeTiB *int64 `json:"baseSizeTiB,omitempty"` + + // REQUIRED; Extended size of the Elastic San appliance in TiB. + ExtendedCapacitySizeTiB *int64 `json:"extendedCapacitySizeTiB,omitempty"` + + // resource sku + SKU *SKU `json:"sku,omitempty"` + + // READ-ONLY; Provisioned MBps Elastic San appliance. + ProvisionedMBps *int64 `json:"provisionedMBps,omitempty" azure:"ro"` + + // READ-ONLY; State of the operation on the resource. + ProvisioningState *ProvisioningStates `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Total Provisioned IOPS of the Elastic San appliance. + TotalIops *int64 `json:"totalIops,omitempty" azure:"ro"` + + // READ-ONLY; Total Provisioned MBps Elastic San appliance. + TotalMBps *int64 `json:"totalMBps,omitempty" azure:"ro"` + + // READ-ONLY; Total size of the provisioned Volumes in GiB. + TotalVolumeSizeGiB *int64 `json:"totalVolumeSizeGiB,omitempty" azure:"ro"` + + // READ-ONLY; Total number of volume groups in this Elastic San appliance. + VolumeGroupCount *int64 `json:"volumeGroupCount,omitempty" azure:"ro"` +} + +// ElasticSanRPOperation - Description of a ElasticSan RP Operation +type ElasticSanRPOperation struct { + // REQUIRED; The name of the operation being performed on this particular object + Name *string `json:"name,omitempty"` + + // READ-ONLY; Additional metadata about RP operation. + Display *ElasticSanOperationDisplay `json:"display,omitempty" azure:"ro"` + + // READ-ONLY; Indicates whether the operation applies to data-plane. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` +} + +// ElasticSanUpdate - Response for ElasticSan update request. +type ElasticSanUpdate struct { + // Properties of ElasticSan. + Properties *ElasticSanUpdateProperties `json:"properties,omitempty"` + + // Update tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// ElasticSanUpdateProperties - Elastic San update properties. +type ElasticSanUpdateProperties struct { + // REQUIRED; Base size of the Elastic San appliance in TiB. + BaseSizeTiB *int64 `json:"baseSizeTiB,omitempty"` + + // REQUIRED; Extended size of the Elastic San appliance in TiB. + ExtendedCapacitySizeTiB *int64 `json:"extendedCapacitySizeTiB,omitempty"` +} + +// Error - The resource management error response. +type Error struct { + // RP error response. + Error *ErrorResponse `json:"error,omitempty"` +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorResponse - The resource management error response. +type ErrorResponse struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorResponse `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// IscsiTargetInfo - Iscsi target information +type IscsiTargetInfo struct { + // Operational status of the iSCSI Target. + Status *OperationalStatus `json:"status,omitempty"` + + // READ-ONLY; State of the operation on the resource. + ProvisioningState *ProvisioningStates `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; iSCSI Target IQN (iSCSI Qualified Name); example: "iqn.2005-03.org.iscsi:server". + TargetIqn *string `json:"targetIqn,omitempty" azure:"ro"` + + // READ-ONLY; iSCSI Target Portal Host Name + TargetPortalHostname *string `json:"targetPortalHostname,omitempty" azure:"ro"` + + // READ-ONLY; iSCSI Target Portal Port + TargetPortalPort *int32 `json:"targetPortalPort,omitempty" azure:"ro"` +} + +// NetworkRuleSet - A set of rules governing the network accessibility. +type NetworkRuleSet struct { + // The list of virtual network rules. + VirtualNetworkRules []*VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// Resource - The resource model definition. +type Resource struct { + // Azure resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Azure resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ResourceTypeSKU - SkuInformation object +type ResourceTypeSKU struct { + // The Sku tier + SKU *SKU `json:"sku,omitempty"` + + // Scalability targets for the San account for a given tier + San *SanTierInfo `json:"san,omitempty"` + + // Volume targets for the San account for a given tier + Volume *VolumeTierInfo `json:"volume,omitempty"` + + // Volume Group targets for the San account for a given tier + VolumeGroup *VolumeGroupTierInfo `json:"volumeGroup,omitempty"` + + // READ-ONLY; Availability of the SKU for the location/zone + LocationInfo []*SKULocationInfo `json:"locationInfo,omitempty" azure:"ro"` +} + +// SKU - The SKU name. Required for account creation; optional for update. +type SKU struct { + // The sku name. + Name *Name `json:"name,omitempty"` + + // The sku tier. + Tier *Tier `json:"tier,omitempty"` +} + +// SKUInformationList - List of SKU Information objects +type SKUInformationList struct { + // READ-ONLY; Links to the next set of results + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of ResourceType Sku + Value []*ResourceTypeSKU `json:"value,omitempty" azure:"ro"` +} + +// SKULocationInfo - The location info. +type SKULocationInfo struct { + // READ-ONLY; The location. + Location *string `json:"location,omitempty" azure:"ro"` + + // READ-ONLY; The zones. + Zones []*string `json:"zones,omitempty" azure:"ro"` +} + +// SKUsClientListOptions contains the optional parameters for the SKUsClient.List method. +type SKUsClientListOptions struct { + // Specify $filter='location eq ' to filter on location. + Filter *string +} + +// SanTierInfo - San scalability target +type SanTierInfo struct { + // READ-ONLY; Maximum IOPS per BaseTiB + IopsPerBaseTiB *int64 `json:"iopsPerBaseTiB,omitempty" azure:"ro"` + + // READ-ONLY; Maximum IOPS + MaxIops *int64 `json:"maxIops,omitempty" azure:"ro"` + + // READ-ONLY; Maximum MBps + MaxMBps *int64 `json:"maxMBps,omitempty" azure:"ro"` + + // READ-ONLY; Maximum San account capacity in TiB + MaxSizeTiB *int64 `json:"maxSizeTiB,omitempty" azure:"ro"` + + // READ-ONLY; Maximum number of volume groups per San account + MaxVolumeGroupCount *int64 `json:"maxVolumeGroupCount,omitempty" azure:"ro"` + + // READ-ONLY; Maximum MBps per BaseTiB + MbpsPerBaseTiB *int64 `json:"mbpsPerBaseTiB,omitempty" azure:"ro"` + + // READ-ONLY; Increment the San capacity in TiB + MinIncrementSizeTiB *int64 `json:"minIncrementSizeTiB,omitempty" azure:"ro"` + + // READ-ONLY; Minimum San account capacity in TiB + MinSizeTiB *int64 `json:"minSizeTiB,omitempty" azure:"ro"` +} + +// SourceCreationData - Data used when creating a disk. +type SourceCreationData struct { + // REQUIRED; This enumerates the possible sources of a volume creation. + CreateSource *VolumeCreateOption `json:"createSource,omitempty"` + + // If createOption is Copy, this is the ARM id of the source snapshot or disk. If createOption is Restore, this is the ARM-like + // id of the source disk restore point. + SourceURI *string `json:"sourceUri,omitempty"` +} + +// 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"` +} + +// TargetCreationData - Data used when creating a disk. +type TargetCreationData struct { + // REQUIRED; Target location for the source to be copied or exported + TargetURI *string `json:"targetUri,omitempty"` +} + +// TrackedResource - The resource model definition for a ARM tracked top level resource. +type TrackedResource struct { + // The geo-location where the resource lives. + Location *string `json:"location,omitempty"` + + // Azure resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Azure resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// VirtualNetworkRule - Virtual Network rule. +type VirtualNetworkRule struct { + // REQUIRED; Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + VirtualNetworkResourceID *string `json:"id,omitempty"` + + // The action of virtual network rule. + Action *string `json:"action,omitempty"` + + // READ-ONLY; Gets the state of virtual network rule. + State *State `json:"state,omitempty" azure:"ro"` +} + +// Volume - Response for Volume request. +type Volume struct { + // The geo-location where the resource lives. + Location *string `json:"location,omitempty"` + + // Properties of Volume. + Properties *VolumeProperties `json:"properties,omitempty"` + + // Azure resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Azure resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource metadata required by ARM RPC + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// VolumeGroup - Response for Volume Group request. +type VolumeGroup struct { + // The geo-location where the resource lives. + Location *string `json:"location,omitempty"` + + // Properties of VolumeGroup. + Properties *VolumeGroupProperties `json:"properties,omitempty"` + + // Azure resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Azure resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource metadata required by ARM RPC + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// VolumeGroupList - List of Volume Groups +type VolumeGroupList struct { + // REQUIRED; An array of Volume Groups objects. + Value []*VolumeGroup `json:"value,omitempty"` + + // READ-ONLY; URI to fetch the next section of the paginated response. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// VolumeGroupProperties - VolumeGroup response properties. +type VolumeGroupProperties struct { + // REQUIRED; Type of encryption + Encryption *EncryptionType `json:"encryption,omitempty"` + + // REQUIRED; Type of storage target + ProtocolType *StorageTargetType `json:"protocolType,omitempty"` + + // A collection of rules governing the accessibility from specific network locations. + NetworkACLs *NetworkRuleSet `json:"networkAcls,omitempty"` + + // READ-ONLY; State of the operation on the resource. + ProvisioningState *ProvisioningStates `json:"provisioningState,omitempty" azure:"ro"` +} + +// VolumeGroupTierInfo - Volume Group scalability target +type VolumeGroupTierInfo struct { + // READ-ONLY; Maximum number of Volumes per Volume Groups per San account + MaxVolumeCount *int64 `json:"maxVolumeCount,omitempty" azure:"ro"` +} + +// VolumeGroupUpdate - Volume Group request. +type VolumeGroupUpdate struct { + // Properties of VolumeGroup. + Properties *VolumeGroupUpdateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// VolumeGroupUpdateProperties - VolumeGroup response properties. +type VolumeGroupUpdateProperties struct { + // REQUIRED; Type of encryption + Encryption *EncryptionType `json:"encryption,omitempty"` + + // REQUIRED; Type of storage target + ProtocolType *StorageTargetType `json:"protocolType,omitempty"` + + // A collection of rules governing the accessibility from specific network locations. + NetworkACLs *NetworkRuleSet `json:"networkAcls,omitempty"` +} + +// VolumeGroupsClientBeginCreateOptions contains the optional parameters for the VolumeGroupsClient.BeginCreate method. +type VolumeGroupsClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VolumeGroupsClientBeginDeleteOptions contains the optional parameters for the VolumeGroupsClient.BeginDelete method. +type VolumeGroupsClientBeginDeleteOptions struct { + // Required if the Volume Group has associated volumes + ForceDeleteVolumes *bool + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VolumeGroupsClientBeginUpdateOptions contains the optional parameters for the VolumeGroupsClient.BeginUpdate method. +type VolumeGroupsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VolumeGroupsClientGetOptions contains the optional parameters for the VolumeGroupsClient.Get method. +type VolumeGroupsClientGetOptions struct { + // placeholder for future optional parameters +} + +// VolumeGroupsClientListByElasticSanOptions contains the optional parameters for the VolumeGroupsClient.ListByElasticSan +// method. +type VolumeGroupsClientListByElasticSanOptions struct { + // placeholder for future optional parameters +} + +// VolumeList - List of Volumes +type VolumeList struct { + // REQUIRED; An array of Volume objects. + Value []*Volume `json:"value,omitempty"` + + // READ-ONLY; URI to fetch the next section of the paginated response. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// VolumeProperties - Volume response properties. +type VolumeProperties struct { + // State of the operation on the resource. + CreationData *SourceCreationData `json:"creationData,omitempty"` + + // Volume size. + SizeGiB *int64 `json:"sizeGiB,omitempty"` + + // READ-ONLY; Storage target information + StorageTarget *IscsiTargetInfo `json:"storageTarget,omitempty" azure:"ro"` + + // READ-ONLY; Unique Id of the volume in GUID format + VolumeID *string `json:"volumeId,omitempty" azure:"ro"` +} + +// VolumeTierInfo - Volume scalability target +type VolumeTierInfo struct { + // READ-ONLY; Maximum number of connected clients count per Volume + MaxConnectedClientCount *int64 `json:"maxConnectedClientCount,omitempty" azure:"ro"` + + // READ-ONLY; Maximum IOPS + MaxIops *int64 `json:"maxIops,omitempty" azure:"ro"` + + // READ-ONLY; Maximum IOPS per GiB + MaxIopsPerGiB *int64 `json:"maxIopsPerGiB,omitempty" azure:"ro"` + + // READ-ONLY; Maximum MBps + MaxMBps *int64 `json:"maxMBps,omitempty" azure:"ro"` + + // READ-ONLY; Maximum MBps + MaxMBpsPerGiB *int64 `json:"maxMBpsPerGiB,omitempty" azure:"ro"` + + // READ-ONLY; Maximum volume capacity in GiB + MaxSizeGiB *int64 `json:"maxSizeGiB,omitempty" azure:"ro"` + + // READ-ONLY; Increment volume capacity in GiB + MinIncrementSizeGiB *int64 `json:"minIncrementSizeGiB,omitempty" azure:"ro"` + + // READ-ONLY; Minimum volume capacity in GiB + MinSizeGiB *int64 `json:"minSizeGiB,omitempty" azure:"ro"` +} + +// VolumeUpdate - Response for Volume request. +type VolumeUpdate struct { + // Properties of Volume. + Properties *VolumeUpdateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// VolumeUpdateProperties - Volume response properties. +type VolumeUpdateProperties struct { + // Volume size. + SizeGiB *int64 `json:"sizeGiB,omitempty"` +} + +// VolumesClientBeginCreateOptions contains the optional parameters for the VolumesClient.BeginCreate method. +type VolumesClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VolumesClientBeginDeleteOptions contains the optional parameters for the VolumesClient.BeginDelete method. +type VolumesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VolumesClientBeginUpdateOptions contains the optional parameters for the VolumesClient.BeginUpdate method. +type VolumesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VolumesClientGetOptions contains the optional parameters for the VolumesClient.Get method. +type VolumesClientGetOptions struct { + // placeholder for future optional parameters +} + +// VolumesClientListByVolumeGroupOptions contains the optional parameters for the VolumesClient.ListByVolumeGroup method. +type VolumesClientListByVolumeGroupOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_models_serde.go b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_models_serde.go new file mode 100644 index 000000000000..5f05627bc8a6 --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_models_serde.go @@ -0,0 +1,256 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armelasticsans + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ElasticSan. +func (e ElasticSan) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", e.ID) + populate(objectMap, "location", e.Location) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ElasticSanList. +func (e ElasticSanList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ElasticSanOperationListResult. +func (e ElasticSanOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ElasticSanProperties. +func (e ElasticSanProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "availabilityZones", e.AvailabilityZones) + populate(objectMap, "baseSizeTiB", e.BaseSizeTiB) + populate(objectMap, "extendedCapacitySizeTiB", e.ExtendedCapacitySizeTiB) + populate(objectMap, "provisionedMBps", e.ProvisionedMBps) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "sku", e.SKU) + populate(objectMap, "totalIops", e.TotalIops) + populate(objectMap, "totalMBps", e.TotalMBps) + populate(objectMap, "totalVolumeSizeGiB", e.TotalVolumeSizeGiB) + populate(objectMap, "volumeGroupCount", e.VolumeGroupCount) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ElasticSanUpdate. +func (e ElasticSanUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkRuleSet. +func (n NetworkRuleSet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "virtualNetworkRules", n.VirtualNetworkRules) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceTypeSKU. +func (r ResourceTypeSKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "locationInfo", r.LocationInfo) + populate(objectMap, "sku", r.SKU) + populate(objectMap, "san", r.San) + populate(objectMap, "volume", r.Volume) + populate(objectMap, "volumeGroup", r.VolumeGroup) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type SKUInformationList. +func (s SKUInformationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type SKULocationInfo. +func (s SKULocationInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", s.Location) + populate(objectMap, "zones", s.Zones) + return json.Marshal(objectMap) +} + +// 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 +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type Volume. +func (v Volume) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", v.ID) + populate(objectMap, "location", v.Location) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "tags", v.Tags) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeGroup. +func (v VolumeGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", v.ID) + populate(objectMap, "location", v.Location) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "tags", v.Tags) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeGroupList. +func (v VolumeGroupList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeGroupUpdate. +func (v VolumeGroupUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "tags", v.Tags) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeList. +func (v VolumeList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeUpdate. +func (v VolumeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "tags", v.Tags) + return json.Marshal(objectMap) +} + +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/elasticsans/armelasticsans/zz_generated_operations_client.go b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_operations_client.go new file mode 100644 index 000000000000..df8da66ef0b1 --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_operations_client.go @@ -0,0 +1,97 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armelasticsans + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + host string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// NewListPager - Gets a list of ElasticSan operations. +// If the operation fails it returns an *azcore.ResponseError type. +// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PageProcessor[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ElasticSan/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ElasticSanOperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_response_types.go b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_response_types.go new file mode 100644 index 000000000000..f1f192ba9c8c --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_response_types.go @@ -0,0 +1,99 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armelasticsans + +// ClientCreateResponse contains the response from method Client.Create. +type ClientCreateResponse struct { + ElasticSan +} + +// ClientDeleteResponse contains the response from method Client.Delete. +type ClientDeleteResponse struct { + // placeholder for future response values +} + +// ClientGetResponse contains the response from method Client.Get. +type ClientGetResponse struct { + ElasticSan +} + +// ClientListByResourceGroupResponse contains the response from method Client.ListByResourceGroup. +type ClientListByResourceGroupResponse struct { + ElasticSanList +} + +// ClientListBySubscriptionResponse contains the response from method Client.ListBySubscription. +type ClientListBySubscriptionResponse struct { + ElasticSanList +} + +// ClientUpdateResponse contains the response from method Client.Update. +type ClientUpdateResponse struct { + ElasticSan +} + +// OperationsClientListResponse contains the response from method OperationsClient.List. +type OperationsClientListResponse struct { + ElasticSanOperationListResult +} + +// SKUsClientListResponse contains the response from method SKUsClient.List. +type SKUsClientListResponse struct { + SKUInformationList +} + +// VolumeGroupsClientCreateResponse contains the response from method VolumeGroupsClient.Create. +type VolumeGroupsClientCreateResponse struct { + VolumeGroup +} + +// VolumeGroupsClientDeleteResponse contains the response from method VolumeGroupsClient.Delete. +type VolumeGroupsClientDeleteResponse struct { + // placeholder for future response values +} + +// VolumeGroupsClientGetResponse contains the response from method VolumeGroupsClient.Get. +type VolumeGroupsClientGetResponse struct { + VolumeGroup +} + +// VolumeGroupsClientListByElasticSanResponse contains the response from method VolumeGroupsClient.ListByElasticSan. +type VolumeGroupsClientListByElasticSanResponse struct { + VolumeGroupList +} + +// VolumeGroupsClientUpdateResponse contains the response from method VolumeGroupsClient.Update. +type VolumeGroupsClientUpdateResponse struct { + VolumeGroup +} + +// VolumesClientCreateResponse contains the response from method VolumesClient.Create. +type VolumesClientCreateResponse struct { + Volume +} + +// VolumesClientDeleteResponse contains the response from method VolumesClient.Delete. +type VolumesClientDeleteResponse struct { + // placeholder for future response values +} + +// VolumesClientGetResponse contains the response from method VolumesClient.Get. +type VolumesClientGetResponse struct { + Volume +} + +// VolumesClientListByVolumeGroupResponse contains the response from method VolumesClient.ListByVolumeGroup. +type VolumesClientListByVolumeGroupResponse struct { + VolumeList +} + +// VolumesClientUpdateResponse contains the response from method VolumesClient.Update. +type VolumesClientUpdateResponse struct { + Volume +} diff --git a/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_skus_client.go b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_skus_client.go new file mode 100644 index 000000000000..92f6c63eb5ad --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_skus_client.go @@ -0,0 +1,100 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armelasticsans + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// SKUsClient contains the methods for the SKUs group. +// Don't use this type directly, use NewSKUsClient() instead. +type SKUsClient struct { + host string + pl runtime.Pipeline +} + +// NewSKUsClient creates a new instance of SKUsClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewSKUsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SKUsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &SKUsClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// NewListPager - List all the available Skus in the region and information related to them +// If the operation fails it returns an *azcore.ResponseError type. +// options - SKUsClientListOptions contains the optional parameters for the SKUsClient.List method. +func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime.Pager[SKUsClientListResponse] { + return runtime.NewPager(runtime.PageProcessor[SKUsClientListResponse]{ + More: func(page SKUsClientListResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *SKUsClientListResponse) (SKUsClientListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return SKUsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SKUsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SKUsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *SKUsClient) listCreateRequest(ctx context.Context, options *SKUsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ElasticSan/skus" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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) (SKUsClientListResponse, error) { + result := SKUsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SKUInformationList); err != nil { + return SKUsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_time_rfc3339.go b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..4dca27bbdef6 --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armelasticsans + +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/elasticsans/armelasticsans/zz_generated_volumegroups_client.go b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_volumegroups_client.go new file mode 100644 index 000000000000..9db0af5b01e5 --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_volumegroups_client.go @@ -0,0 +1,394 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armelasticsans + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// VolumeGroupsClient contains the methods for the VolumeGroups group. +// Don't use this type directly, use NewVolumeGroupsClient() instead. +type VolumeGroupsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewVolumeGroupsClient creates a new instance of VolumeGroupsClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewVolumeGroupsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VolumeGroupsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &VolumeGroupsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreate - Create a Volume Group. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// volumeGroupName - The name of the VolumeGroup. +// parameters - Volume Group object. +// options - VolumeGroupsClientBeginCreateOptions contains the optional parameters for the VolumeGroupsClient.BeginCreate +// method. +func (client *VolumeGroupsClient) BeginCreate(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, parameters VolumeGroup, options *VolumeGroupsClientBeginCreateOptions) (*armruntime.Poller[VolumeGroupsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, elasticSanName, volumeGroupName, parameters, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VolumeGroupsClientCreateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VolumeGroupsClientCreateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Create - Create a Volume Group. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VolumeGroupsClient) create(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, parameters VolumeGroup, options *VolumeGroupsClientBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *VolumeGroupsClient) createCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, parameters VolumeGroup, options *VolumeGroupsClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + if volumeGroupName == "" { + return nil, errors.New("parameter volumeGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// BeginDelete - Delete an VolumeGroup. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// volumeGroupName - The name of the VolumeGroup. +// options - VolumeGroupsClientBeginDeleteOptions contains the optional parameters for the VolumeGroupsClient.BeginDelete +// method. +func (client *VolumeGroupsClient) BeginDelete(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, options *VolumeGroupsClientBeginDeleteOptions) (*armruntime.Poller[VolumeGroupsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, elasticSanName, volumeGroupName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VolumeGroupsClientDeleteResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VolumeGroupsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Delete an VolumeGroup. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VolumeGroupsClient) deleteOperation(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, options *VolumeGroupsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VolumeGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, options *VolumeGroupsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + if volumeGroupName == "" { + return nil, errors.New("parameter volumeGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.ForceDeleteVolumes != nil { + req.Raw().Header.Set("x-ms-delete-volumes", strconv.FormatBool(*options.ForceDeleteVolumes)) + } + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// Get - Get an VolumeGroups. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// volumeGroupName - The name of the VolumeGroup. +// options - VolumeGroupsClientGetOptions contains the optional parameters for the VolumeGroupsClient.Get method. +func (client *VolumeGroupsClient) Get(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, options *VolumeGroupsClientGetOptions) (VolumeGroupsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, options) + if err != nil { + return VolumeGroupsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VolumeGroupsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VolumeGroupsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *VolumeGroupsClient) getCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, options *VolumeGroupsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + if volumeGroupName == "" { + return nil, errors.New("parameter volumeGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VolumeGroupsClient) getHandleResponse(resp *http.Response) (VolumeGroupsClientGetResponse, error) { + result := VolumeGroupsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VolumeGroup); err != nil { + return VolumeGroupsClientGetResponse{}, err + } + return result, nil +} + +// NewListByElasticSanPager - List VolumeGroups. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// options - VolumeGroupsClientListByElasticSanOptions contains the optional parameters for the VolumeGroupsClient.ListByElasticSan +// method. +func (client *VolumeGroupsClient) NewListByElasticSanPager(resourceGroupName string, elasticSanName string, options *VolumeGroupsClientListByElasticSanOptions) *runtime.Pager[VolumeGroupsClientListByElasticSanResponse] { + return runtime.NewPager(runtime.PageProcessor[VolumeGroupsClientListByElasticSanResponse]{ + More: func(page VolumeGroupsClientListByElasticSanResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VolumeGroupsClientListByElasticSanResponse) (VolumeGroupsClientListByElasticSanResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByElasticSanCreateRequest(ctx, resourceGroupName, elasticSanName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VolumeGroupsClientListByElasticSanResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VolumeGroupsClientListByElasticSanResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VolumeGroupsClientListByElasticSanResponse{}, runtime.NewResponseError(resp) + } + return client.listByElasticSanHandleResponse(resp) + }, + }) +} + +// listByElasticSanCreateRequest creates the ListByElasticSan request. +func (client *VolumeGroupsClient) listByElasticSanCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, options *VolumeGroupsClientListByElasticSanOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumeGroups" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByElasticSanHandleResponse handles the ListByElasticSan response. +func (client *VolumeGroupsClient) listByElasticSanHandleResponse(resp *http.Response) (VolumeGroupsClientListByElasticSanResponse, error) { + result := VolumeGroupsClientListByElasticSanResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VolumeGroupList); err != nil { + return VolumeGroupsClientListByElasticSanResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update an VolumeGroup. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// volumeGroupName - The name of the VolumeGroup. +// parameters - Volume Group object. +// options - VolumeGroupsClientBeginUpdateOptions contains the optional parameters for the VolumeGroupsClient.BeginUpdate +// method. +func (client *VolumeGroupsClient) BeginUpdate(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, parameters VolumeGroupUpdate, options *VolumeGroupsClientBeginUpdateOptions) (*armruntime.Poller[VolumeGroupsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, elasticSanName, volumeGroupName, parameters, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VolumeGroupsClientUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VolumeGroupsClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Update an VolumeGroup. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VolumeGroupsClient) update(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, parameters VolumeGroupUpdate, options *VolumeGroupsClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *VolumeGroupsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, parameters VolumeGroupUpdate, options *VolumeGroupsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + if volumeGroupName == "" { + return nil, errors.New("parameter volumeGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} diff --git a/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_volumes_client.go b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_volumes_client.go new file mode 100644 index 000000000000..22c4bb1c79fa --- /dev/null +++ b/sdk/resourcemanager/elasticsans/armelasticsans/zz_generated_volumes_client.go @@ -0,0 +1,412 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armelasticsans + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "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" +) + +// VolumesClient contains the methods for the Volumes group. +// Don't use this type directly, use NewVolumesClient() instead. +type VolumesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewVolumesClient creates a new instance of VolumesClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewVolumesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VolumesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &VolumesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreate - Create a Volume. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// volumeGroupName - The name of the VolumeGroup. +// volumeName - The name of the Volume. +// parameters - Volume object. +// options - VolumesClientBeginCreateOptions contains the optional parameters for the VolumesClient.BeginCreate method. +func (client *VolumesClient) BeginCreate(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, parameters Volume, options *VolumesClientBeginCreateOptions) (*armruntime.Poller[VolumesClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, parameters, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VolumesClientCreateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VolumesClientCreateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Create - Create a Volume. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VolumesClient) create(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, parameters Volume, options *VolumesClientBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *VolumesClient) createCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, parameters Volume, options *VolumesClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + if volumeGroupName == "" { + return nil, errors.New("parameter volumeGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) + if volumeName == "" { + return nil, errors.New("parameter volumeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeName}", url.PathEscape(volumeName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// BeginDelete - Delete an Volume. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// volumeGroupName - The name of the VolumeGroup. +// volumeName - The name of the Volume. +// options - VolumesClientBeginDeleteOptions contains the optional parameters for the VolumesClient.BeginDelete method. +func (client *VolumesClient) BeginDelete(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, options *VolumesClientBeginDeleteOptions) (*armruntime.Poller[VolumesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VolumesClientDeleteResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VolumesClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Delete an Volume. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VolumesClient) deleteOperation(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, options *VolumesClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VolumesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, options *VolumesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + if volumeGroupName == "" { + return nil, errors.New("parameter volumeGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) + if volumeName == "" { + return nil, errors.New("parameter volumeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeName}", url.PathEscape(volumeName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// Get - Get an Volume. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// volumeGroupName - The name of the VolumeGroup. +// volumeName - The name of the Volume. +// options - VolumesClientGetOptions contains the optional parameters for the VolumesClient.Get method. +func (client *VolumesClient) Get(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, options *VolumesClientGetOptions) (VolumesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, options) + if err != nil { + return VolumesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VolumesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VolumesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *VolumesClient) getCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, options *VolumesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + if volumeGroupName == "" { + return nil, errors.New("parameter volumeGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) + if volumeName == "" { + return nil, errors.New("parameter volumeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeName}", url.PathEscape(volumeName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VolumesClient) getHandleResponse(resp *http.Response) (VolumesClientGetResponse, error) { + result := VolumesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Volume); err != nil { + return VolumesClientGetResponse{}, err + } + return result, nil +} + +// NewListByVolumeGroupPager - List Volumes in a VolumeGroup. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// volumeGroupName - The name of the VolumeGroup. +// options - VolumesClientListByVolumeGroupOptions contains the optional parameters for the VolumesClient.ListByVolumeGroup +// method. +func (client *VolumesClient) NewListByVolumeGroupPager(resourceGroupName string, elasticSanName string, volumeGroupName string, options *VolumesClientListByVolumeGroupOptions) *runtime.Pager[VolumesClientListByVolumeGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[VolumesClientListByVolumeGroupResponse]{ + More: func(page VolumesClientListByVolumeGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VolumesClientListByVolumeGroupResponse) (VolumesClientListByVolumeGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByVolumeGroupCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VolumesClientListByVolumeGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VolumesClientListByVolumeGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VolumesClientListByVolumeGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByVolumeGroupHandleResponse(resp) + }, + }) +} + +// listByVolumeGroupCreateRequest creates the ListByVolumeGroup request. +func (client *VolumesClient) listByVolumeGroupCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, options *VolumesClientListByVolumeGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + if volumeGroupName == "" { + return nil, errors.New("parameter volumeGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByVolumeGroupHandleResponse handles the ListByVolumeGroup response. +func (client *VolumesClient) listByVolumeGroupHandleResponse(resp *http.Response) (VolumesClientListByVolumeGroupResponse, error) { + result := VolumesClientListByVolumeGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VolumeList); err != nil { + return VolumesClientListByVolumeGroupResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update an Volume. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// elasticSanName - The name of the ElasticSan. +// volumeGroupName - The name of the VolumeGroup. +// volumeName - The name of the Volume. +// parameters - Volume object. +// options - VolumesClientBeginUpdateOptions contains the optional parameters for the VolumesClient.BeginUpdate method. +func (client *VolumesClient) BeginUpdate(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, parameters VolumeUpdate, options *VolumesClientBeginUpdateOptions) (*armruntime.Poller[VolumesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, parameters, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[VolumesClientUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[VolumesClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Update an Volume. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *VolumesClient) update(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, parameters VolumeUpdate, options *VolumesClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *VolumesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, parameters VolumeUpdate, options *VolumesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if elasticSanName == "" { + return nil, errors.New("parameter elasticSanName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) + if volumeGroupName == "" { + return nil, errors.New("parameter volumeGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) + if volumeName == "" { + return nil, errors.New("parameter volumeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeName}", url.PathEscape(volumeName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +}