From 3b32b05e2c5177bdc01c0ed9178fcd05e0d9d421 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 28 Jul 2023 07:26:06 +0000 Subject: [PATCH] CodeGen from PR 25026 in Azure/azure-rest-api-specs Merge 068edffd4531e88deb0bd70b061cf9595c901f0d into fe2113ec4be9d8d52929eee0583d3c841ba3c189 --- .../armcontainerstorage/CHANGELOG.md | 7 + .../armcontainerstorage/LICENSE.txt | 21 + .../armcontainerstorage/README.md | 85 ++ .../armcontainerstorage/autorest.md | 13 + .../armcontainerstorage/build.go | 7 + .../armcontainerstorage/ci.yml | 28 + .../armcontainerstorage/client_factory.go | 58 ++ .../armcontainerstorage/constants.go | 160 +++ .../armcontainerstorage/go.mod | 13 + .../armcontainerstorage/go.sum | 15 + .../armcontainerstorage/models.go | 381 +++++++ .../armcontainerstorage/models_serde.go | 964 ++++++++++++++++++ .../armcontainerstorage/operations_client.go | 93 ++ .../armcontainerstorage/options.go | 106 ++ .../armcontainerstorage/pools_client.go | 445 ++++++++ .../armcontainerstorage/response_types.go | 108 ++ .../armcontainerstorage/time_rfc3339.go | 86 ++ .../armcontainerstorage/volumes_client.go | 409 ++++++++ .../volumesnapshots_client.go | 412 ++++++++ 19 files changed, 3411 insertions(+) create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/CHANGELOG.md create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/LICENSE.txt create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/README.md create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/autorest.md create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/build.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/ci.yml create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/client_factory.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/constants.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/go.mod create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/go.sum create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/models.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/models_serde.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/operations_client.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/options.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/pools_client.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/response_types.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/time_rfc3339.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/volumes_client.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/volumesnapshots_client.go diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/CHANGELOG.md b/sdk/resourcemanager/containerstorage/armcontainerstorage/CHANGELOG.md new file mode 100644 index 000000000000..5b84582a6463 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2023-07-28) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/LICENSE.txt b/sdk/resourcemanager/containerstorage/armcontainerstorage/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/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/containerstorage/armcontainerstorage/README.md b/sdk/resourcemanager/containerstorage/armcontainerstorage/README.md new file mode 100644 index 000000000000..eb35af336fe9 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/README.md @@ -0,0 +1,85 @@ +# Azure Containerstorage Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage) + +The `armcontainerstorage` module provides operations for working with Azure Containerstorage. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/containerstorage/armcontainerstorage) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Containerstorage module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Containerstorage. 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). + +## Client Factory + +Azure Containerstorage module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armcontainerstorage.NewClientFactory(, 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 := armcontainerstorage.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewPoolsClient() +``` + +## 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 `Containerstorage` 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/containerstorage/armcontainerstorage/autorest.md b/sdk/resourcemanager/containerstorage/armcontainerstorage/autorest.md new file mode 100644 index 000000000000..fcb6c5904b9f --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/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/containerstorage/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/containerstorage/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/containerstorage/armcontainerstorage/build.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/build.go new file mode 100644 index 000000000000..910d3d406430 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/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 ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/containerstorage/armcontainerstorage + +package armcontainerstorage diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/ci.yml b/sdk/resourcemanager/containerstorage/armcontainerstorage/ci.yml new file mode 100644 index 000000000000..8162406db2b4 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/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/containerstorage/armcontainerstorage/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/containerstorage/armcontainerstorage/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/containerstorage/armcontainerstorage' diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/client_factory.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/client_factory.go new file mode 100644 index 000000000000..0dcab199296c --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/client_factory.go @@ -0,0 +1,58 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerstorage + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - 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 NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPoolsClient() *PoolsClient { + subClient, _ := NewPoolsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVolumeSnapshotsClient() *VolumeSnapshotsClient { + subClient, _ := NewVolumeSnapshotsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVolumesClient() *VolumesClient { + subClient, _ := NewVolumesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/constants.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/constants.go new file mode 100644 index 000000000000..744cb9fe6725 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/constants.go @@ -0,0 +1,160 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerstorage + +const ( + moduleName = "armcontainerstorage" + moduleVersion = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// 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, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// PoolType - Pool Type +type PoolType float32 + +const ( + // PoolTypeDisk - Disk Pool + PoolTypeDisk PoolType = 2 + // PoolTypeElasticSan - ElasticSan Pool + PoolTypeElasticSan PoolType = 4 + // PoolTypeEphemeral - Ephemeral Pool + PoolTypeEphemeral PoolType = 1 + // PoolTypeManaged - Managed Pool + PoolTypeManaged PoolType = 3 +) + +// PossiblePoolTypeValues returns the possible values for the PoolType const type. +func PossiblePoolTypeValues() []PoolType { + return []PoolType{ + PoolTypeDisk, + PoolTypeElasticSan, + PoolTypeEphemeral, + PoolTypeManaged, + } +} + +// ProvisioningState - Provisioning state of the resource. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted - The resource create request has been accepted + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - The resource is being deleted + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - The resource is being provisioned + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - The resource is updating + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ReclaimPolicy - Reclaim Policy +type ReclaimPolicy string + +const ( + // ReclaimPolicyDelete - Delete resource + ReclaimPolicyDelete ReclaimPolicy = "Delete" + // ReclaimPolicyRetain - Retain resource + ReclaimPolicyRetain ReclaimPolicy = "Retain" +) + +// PossibleReclaimPolicyValues returns the possible values for the ReclaimPolicy const type. +func PossibleReclaimPolicyValues() []ReclaimPolicy { + return []ReclaimPolicy{ + ReclaimPolicyDelete, + ReclaimPolicyRetain, + } +} + +// VolumeMode - Storage volume mode +type VolumeMode string + +const ( + // VolumeModeFilesystem - FileSystem volume mode + VolumeModeFilesystem VolumeMode = "Filesystem" + // VolumeModeRaw - Raw volume mode + VolumeModeRaw VolumeMode = "Raw" +) + +// PossibleVolumeModeValues returns the possible values for the VolumeMode const type. +func PossibleVolumeModeValues() []VolumeMode { + return []VolumeMode{ + VolumeModeFilesystem, + VolumeModeRaw, + } +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/go.mod b/sdk/resourcemanager/containerstorage/armcontainerstorage/go.mod new file mode 100644 index 000000000000..7ddbca8c893c --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/text v0.8.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/go.sum b/sdk/resourcemanager/containerstorage/armcontainerstorage/go.sum new file mode 100644 index 000000000000..5c6bee428364 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/go.sum @@ -0,0 +1,15 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/models.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/models.go new file mode 100644 index 000000000000..f6df0590b5a4 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/models.go @@ -0,0 +1,381 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerstorage + +import "time" + +// DiskPoolProperties - Disk Pool Properties +type DiskPoolProperties struct { + // List of KV pairs to set in StorageClass to configure CSI driver. + CsiParams map[string]*string + + // Only required if individual disk selection is desired. Path to disk, e.g. :/dev/sda or WWN. Supports specifying multiple + // disks (same syntax as tags). + Disks []*string + + // Maximum capacity of the volumes in GiB the user intends to create. Default 512. + MaxVolumeCapacityGiB *int64 +} + +// ElasticSanPoolProperties - Elastic San Pool Properties +type ElasticSanPoolProperties struct { + // REQUIRED; Resource group of an existing SAN. + ResourceGroup *string + + // REQUIRED; Name of an existing SAN. + SanName *string + + // REQUIRED; Volume group of an existing SAN. + VolumeGroup *string +} + +// ElasticSanPoolPropertiesUpdate - Elastic San Pool Properties +type ElasticSanPoolPropertiesUpdate struct { + // Resource group of an existing SAN. + ResourceGroup *string + + // Name of an existing SAN. + SanName *string + + // Volume group of an existing SAN. + VolumeGroup *string +} + +// EphemeralPoolProperties - Ephemeral Pool Properties +type EphemeralPoolProperties struct { + // REQUIRED; Template name or KV pairs containing disk selection criteria, e.g. model="Microsoft NVMe Direct Disk" to match + // all Lsv2 NVMe disks. + DiskSelector []*string + + // REQUIRED; Only required if individual disk selection is desired. Path to disk, e.g. :/dev/sda or WWN. Supports specifying + // multiple disks (same syntax as tags). + Disks []*string + + // Consent to format the local disks. + DiskFormat *bool +} + +// EphemeralPoolPropertiesUpdate - Ephemeral Pool Properties +type EphemeralPoolPropertiesUpdate struct { + // Consent to format the local disks. + DiskFormat *bool + + // Template name or KV pairs containing disk selection criteria, e.g. model="Microsoft NVMe Direct Disk" to match all Lsv2 + // NVMe disks. + DiskSelector []*string + + // Only required if individual disk selection is desired. Path to disk, e.g. :/dev/sda or WWN. Supports specifying multiple + // disks (same syntax as tags). + Disks []*string +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation +} + +// Pool resource +type Pool struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *PoolProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// PoolListResult - The response of a Pool list operation. +type PoolListResult struct { + // REQUIRED; The Pool items on this page + Value []*Pool + + // The link to the next page of items + NextLink *string +} + +// PoolProperties - Pool Properties +type PoolProperties struct { + // REQUIRED; List of resources that should have access to the pool. Typically ARM references to AKS clusters or ACI Container + // Groups. For local and standard this must be a single reference. For portable there can + // be many. + Assignments []*string + + // REQUIRED; Elastic San Pool Properties + ElasticSanPoolProperties *ElasticSanPoolProperties + + // REQUIRED; Initial capacity of the pool in GiB. + PoolCapacityGiB *int64 + + // REQUIRED; Type of the Pool: ephemeral, disk, managed, or elasticsan. + PoolType *PoolType + + // REQUIRED; List of availability zones that resources can be created in. + Zones []*string + + // Disk Pool Properties + DiskPoolProperties *DiskPoolProperties + + // Ephemeral Pool Properties + EphemeralPoolProperties *EphemeralPoolProperties + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// PoolUpdate - The type used for update operations of the Pool. +type PoolUpdate struct { + // The updatable properties of the Pool. + Properties *PoolUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// PoolUpdateProperties - The updatable properties of the Pool. +type PoolUpdateProperties struct { + // List of resources that should have access to the pool. Typically ARM references to AKS clusters or ACI Container Groups. + // For local and standard this must be a single reference. For portable there can + // be many. + Assignments []*string + + // Disk Pool Properties + DiskPoolProperties *DiskPoolProperties + + // Elastic San Pool Properties + ElasticSanPoolProperties *ElasticSanPoolPropertiesUpdate + + // Ephemeral Pool Properties + EphemeralPoolProperties *EphemeralPoolPropertiesUpdate + + // Initial capacity of the pool in GiB. + PoolCapacityGiB *int64 + + // Type of the Pool: ephemeral, disk, managed, or elasticsan. + PoolType *PoolType + + // List of availability zones that resources can be created in. + Zones []*string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// Volume - Concrete proxy resource types can be created by aliasing this type using a specific property type. +type Volume struct { + // The resource-specific properties for this resource. + Properties *VolumeProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// VolumeListResult - The response of a Volume list operation. +type VolumeListResult struct { + // REQUIRED; The Volume items on this page + Value []*Volume + + // The link to the next page of items + NextLink *string +} + +// VolumeProperties - Volume Properties +type VolumeProperties struct { + // REQUIRED; Requested capacity in GiB + CapacityGiB *int64 + + // REQUIRED; String KV pairs indicating labels + Labels map[string]*string + + // REQUIRED; List of string mount options + MountOptions []*string + + // REQUIRED; Reclaim Policy, Delete or Retain + ReclaimPolicy *ReclaimPolicy + + // REQUIRED; Indicates how the volume should be attached + VolumeMode *VolumeMode + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// VolumeSnapshot - Concrete proxy resource types can be created by aliasing this type using a specific property type. +type VolumeSnapshot struct { + // The resource-specific properties for this resource. + Properties *VolumeSnapshotProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// VolumeSnapshotListResult - The response of a VolumeSnapshot list operation. +type VolumeSnapshotListResult struct { + // REQUIRED; The VolumeSnapshot items on this page + Value []*VolumeSnapshot + + // The link to the next page of items + NextLink *string +} + +// VolumeSnapshotProperties - Volume Snapshot Properties +type VolumeSnapshotProperties struct { + // REQUIRED; List of string mount options + MountOptions []*string + + // REQUIRED; Reclaim Policy, Delete or Retain + ReclaimPolicy *ReclaimPolicy + + // REQUIRED; Reference to the source volume + Source *string + + // REQUIRED; Indicates how the volumes created from the snapshot should be attached + VolumeMode *VolumeMode + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// VolumeSnapshotUpdate - The type used for update operations of the VolumeSnapshot. +type VolumeSnapshotUpdate struct { + // The updatable properties of the VolumeSnapshot. + Properties *VolumeSnapshotUpdateProperties +} + +// VolumeSnapshotUpdateProperties - The updatable properties of the VolumeSnapshot. +type VolumeSnapshotUpdateProperties struct { + // List of string mount options + MountOptions []*string + + // Reclaim Policy, Delete or Retain + ReclaimPolicy *ReclaimPolicy + + // Reference to the source volume + Source *string + + // Indicates how the volumes created from the snapshot should be attached + VolumeMode *VolumeMode +} + +// VolumeUpdate - The type used for update operations of the Volume. +type VolumeUpdate struct { + // The updatable properties of the Volume. + Properties *VolumeUpdateProperties +} + +// VolumeUpdateProperties - The updatable properties of the Volume. +type VolumeUpdateProperties struct { + // Requested capacity in GiB + CapacityGiB *int64 + + // String KV pairs indicating labels + Labels map[string]*string + + // List of string mount options + MountOptions []*string + + // Reclaim Policy, Delete or Retain + ReclaimPolicy *ReclaimPolicy + + // Indicates how the volume should be attached + VolumeMode *VolumeMode +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/models_serde.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/models_serde.go new file mode 100644 index 000000000000..af019039dc36 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/models_serde.go @@ -0,0 +1,964 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerstorage + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type DiskPoolProperties. +func (d DiskPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "csiParams", d.CsiParams) + populate(objectMap, "disks", d.Disks) + populate(objectMap, "maxVolumeCapacityGiB", d.MaxVolumeCapacityGiB) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiskPoolProperties. +func (d *DiskPoolProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "csiParams": + err = unpopulate(val, "CsiParams", &d.CsiParams) + delete(rawMsg, key) + case "disks": + err = unpopulate(val, "Disks", &d.Disks) + delete(rawMsg, key) + case "maxVolumeCapacityGiB": + err = unpopulate(val, "MaxVolumeCapacityGiB", &d.MaxVolumeCapacityGiB) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ElasticSanPoolProperties. +func (e ElasticSanPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceGroup", e.ResourceGroup) + populate(objectMap, "sanName", e.SanName) + populate(objectMap, "volumeGroup", e.VolumeGroup) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ElasticSanPoolProperties. +func (e *ElasticSanPoolProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &e.ResourceGroup) + delete(rawMsg, key) + case "sanName": + err = unpopulate(val, "SanName", &e.SanName) + delete(rawMsg, key) + case "volumeGroup": + err = unpopulate(val, "VolumeGroup", &e.VolumeGroup) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ElasticSanPoolPropertiesUpdate. +func (e ElasticSanPoolPropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceGroup", e.ResourceGroup) + populate(objectMap, "sanName", e.SanName) + populate(objectMap, "volumeGroup", e.VolumeGroup) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ElasticSanPoolPropertiesUpdate. +func (e *ElasticSanPoolPropertiesUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &e.ResourceGroup) + delete(rawMsg, key) + case "sanName": + err = unpopulate(val, "SanName", &e.SanName) + delete(rawMsg, key) + case "volumeGroup": + err = unpopulate(val, "VolumeGroup", &e.VolumeGroup) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EphemeralPoolProperties. +func (e EphemeralPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "diskFormat", e.DiskFormat) + populate(objectMap, "diskSelector", e.DiskSelector) + populate(objectMap, "disks", e.Disks) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EphemeralPoolProperties. +func (e *EphemeralPoolProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "diskFormat": + err = unpopulate(val, "DiskFormat", &e.DiskFormat) + delete(rawMsg, key) + case "diskSelector": + err = unpopulate(val, "DiskSelector", &e.DiskSelector) + delete(rawMsg, key) + case "disks": + err = unpopulate(val, "Disks", &e.Disks) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EphemeralPoolPropertiesUpdate. +func (e EphemeralPoolPropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "diskFormat", e.DiskFormat) + populate(objectMap, "diskSelector", e.DiskSelector) + populate(objectMap, "disks", e.Disks) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EphemeralPoolPropertiesUpdate. +func (e *EphemeralPoolPropertiesUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "diskFormat": + err = unpopulate(val, "DiskFormat", &e.DiskFormat) + delete(rawMsg, key) + case "diskSelector": + err = unpopulate(val, "DiskSelector", &e.DiskSelector) + delete(rawMsg, key) + case "disks": + err = unpopulate(val, "Disks", &e.Disks) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Pool. +func (p Pool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Pool. +func (p *Pool) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PoolListResult. +func (p PoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolListResult. +func (p *PoolListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PoolProperties. +func (p PoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignments", p.Assignments) + populate(objectMap, "diskPoolProperties", p.DiskPoolProperties) + populate(objectMap, "elasticSanPoolProperties", p.ElasticSanPoolProperties) + populate(objectMap, "ephemeralPoolProperties", p.EphemeralPoolProperties) + populate(objectMap, "poolCapacityGiB", p.PoolCapacityGiB) + populate(objectMap, "poolType", p.PoolType) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "zones", p.Zones) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolProperties. +func (p *PoolProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assignments": + err = unpopulate(val, "Assignments", &p.Assignments) + delete(rawMsg, key) + case "diskPoolProperties": + err = unpopulate(val, "DiskPoolProperties", &p.DiskPoolProperties) + delete(rawMsg, key) + case "elasticSanPoolProperties": + err = unpopulate(val, "ElasticSanPoolProperties", &p.ElasticSanPoolProperties) + delete(rawMsg, key) + case "ephemeralPoolProperties": + err = unpopulate(val, "EphemeralPoolProperties", &p.EphemeralPoolProperties) + delete(rawMsg, key) + case "poolCapacityGiB": + err = unpopulate(val, "PoolCapacityGiB", &p.PoolCapacityGiB) + delete(rawMsg, key) + case "poolType": + err = unpopulate(val, "PoolType", &p.PoolType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "zones": + err = unpopulate(val, "Zones", &p.Zones) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PoolUpdate. +func (p PoolUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolUpdate. +func (p *PoolUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PoolUpdateProperties. +func (p PoolUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignments", p.Assignments) + populate(objectMap, "diskPoolProperties", p.DiskPoolProperties) + populate(objectMap, "elasticSanPoolProperties", p.ElasticSanPoolProperties) + populate(objectMap, "ephemeralPoolProperties", p.EphemeralPoolProperties) + populate(objectMap, "poolCapacityGiB", p.PoolCapacityGiB) + populate(objectMap, "poolType", p.PoolType) + populate(objectMap, "zones", p.Zones) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolUpdateProperties. +func (p *PoolUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assignments": + err = unpopulate(val, "Assignments", &p.Assignments) + delete(rawMsg, key) + case "diskPoolProperties": + err = unpopulate(val, "DiskPoolProperties", &p.DiskPoolProperties) + delete(rawMsg, key) + case "elasticSanPoolProperties": + err = unpopulate(val, "ElasticSanPoolProperties", &p.ElasticSanPoolProperties) + delete(rawMsg, key) + case "ephemeralPoolProperties": + err = unpopulate(val, "EphemeralPoolProperties", &p.EphemeralPoolProperties) + delete(rawMsg, key) + case "poolCapacityGiB": + err = unpopulate(val, "PoolCapacityGiB", &p.PoolCapacityGiB) + delete(rawMsg, key) + case "poolType": + err = unpopulate(val, "PoolType", &p.PoolType) + delete(rawMsg, key) + case "zones": + err = unpopulate(val, "Zones", &p.Zones) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Volume. +func (v Volume) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", v.ID) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Volume. +func (v *Volume) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &v.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeListResult. +func (v VolumeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeListResult. +func (v *VolumeListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &v.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeProperties. +func (v VolumeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacityGiB", v.CapacityGiB) + populate(objectMap, "labels", v.Labels) + populate(objectMap, "mountOptions", v.MountOptions) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "reclaimPolicy", v.ReclaimPolicy) + populate(objectMap, "volumeMode", v.VolumeMode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeProperties. +func (v *VolumeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "capacityGiB": + err = unpopulate(val, "CapacityGiB", &v.CapacityGiB) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &v.Labels) + delete(rawMsg, key) + case "mountOptions": + err = unpopulate(val, "MountOptions", &v.MountOptions) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + delete(rawMsg, key) + case "reclaimPolicy": + err = unpopulate(val, "ReclaimPolicy", &v.ReclaimPolicy) + delete(rawMsg, key) + case "volumeMode": + err = unpopulate(val, "VolumeMode", &v.VolumeMode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeSnapshot. +func (v VolumeSnapshot) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", v.ID) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeSnapshot. +func (v *VolumeSnapshot) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &v.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeSnapshotListResult. +func (v VolumeSnapshotListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeSnapshotListResult. +func (v *VolumeSnapshotListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &v.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeSnapshotProperties. +func (v VolumeSnapshotProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "mountOptions", v.MountOptions) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "reclaimPolicy", v.ReclaimPolicy) + populate(objectMap, "source", v.Source) + populate(objectMap, "volumeMode", v.VolumeMode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeSnapshotProperties. +func (v *VolumeSnapshotProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "mountOptions": + err = unpopulate(val, "MountOptions", &v.MountOptions) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + delete(rawMsg, key) + case "reclaimPolicy": + err = unpopulate(val, "ReclaimPolicy", &v.ReclaimPolicy) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &v.Source) + delete(rawMsg, key) + case "volumeMode": + err = unpopulate(val, "VolumeMode", &v.VolumeMode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeSnapshotUpdate. +func (v VolumeSnapshotUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", v.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeSnapshotUpdate. +func (v *VolumeSnapshotUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeSnapshotUpdateProperties. +func (v VolumeSnapshotUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "mountOptions", v.MountOptions) + populate(objectMap, "reclaimPolicy", v.ReclaimPolicy) + populate(objectMap, "source", v.Source) + populate(objectMap, "volumeMode", v.VolumeMode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeSnapshotUpdateProperties. +func (v *VolumeSnapshotUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "mountOptions": + err = unpopulate(val, "MountOptions", &v.MountOptions) + delete(rawMsg, key) + case "reclaimPolicy": + err = unpopulate(val, "ReclaimPolicy", &v.ReclaimPolicy) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &v.Source) + delete(rawMsg, key) + case "volumeMode": + err = unpopulate(val, "VolumeMode", &v.VolumeMode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeUpdate. +func (v VolumeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", v.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeUpdate. +func (v *VolumeUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeUpdateProperties. +func (v VolumeUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacityGiB", v.CapacityGiB) + populate(objectMap, "labels", v.Labels) + populate(objectMap, "mountOptions", v.MountOptions) + populate(objectMap, "reclaimPolicy", v.ReclaimPolicy) + populate(objectMap, "volumeMode", v.VolumeMode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeUpdateProperties. +func (v *VolumeUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "capacityGiB": + err = unpopulate(val, "CapacityGiB", &v.CapacityGiB) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &v.Labels) + delete(rawMsg, key) + case "mountOptions": + err = unpopulate(val, "MountOptions", &v.MountOptions) + delete(rawMsg, key) + case "reclaimPolicy": + err = unpopulate(val, "ReclaimPolicy", &v.ReclaimPolicy) + delete(rawMsg, key) + case "volumeMode": + err = unpopulate(val, "VolumeMode", &v.VolumeMode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + 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, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/operations_client.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/operations_client.go new file mode 100644 index 000000000000..0c93983b6b97 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/operations_client.go @@ -0,0 +1,93 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerstorage + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "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 { + internal *arm.Client +} + +// 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) { + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2023-03-01-preview +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().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.ContainerStorage/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"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.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/options.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/options.go new file mode 100644 index 000000000000..5c974dee5dc7 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/options.go @@ -0,0 +1,106 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerstorage + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// PoolsClientBeginCreateOrUpdateOptions contains the optional parameters for the PoolsClient.BeginCreateOrUpdate method. +type PoolsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PoolsClientBeginDeleteOptions contains the optional parameters for the PoolsClient.BeginDelete method. +type PoolsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PoolsClientBeginUpdateOptions contains the optional parameters for the PoolsClient.BeginUpdate method. +type PoolsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PoolsClientGetOptions contains the optional parameters for the PoolsClient.Get method. +type PoolsClientGetOptions struct { + // placeholder for future optional parameters +} + +// PoolsClientListByResourceGroupOptions contains the optional parameters for the PoolsClient.NewListByResourceGroupPager +// method. +type PoolsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// PoolsClientListBySubscriptionOptions contains the optional parameters for the PoolsClient.NewListBySubscriptionPager method. +type PoolsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// VolumeSnapshotsClientBeginCreateOrUpdateOptions contains the optional parameters for the VolumeSnapshotsClient.BeginCreateOrUpdate +// method. +type VolumeSnapshotsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VolumeSnapshotsClientBeginDeleteOptions contains the optional parameters for the VolumeSnapshotsClient.BeginDelete method. +type VolumeSnapshotsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VolumeSnapshotsClientBeginUpdateOptions contains the optional parameters for the VolumeSnapshotsClient.BeginUpdate method. +type VolumeSnapshotsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VolumeSnapshotsClientGetOptions contains the optional parameters for the VolumeSnapshotsClient.Get method. +type VolumeSnapshotsClientGetOptions struct { + // placeholder for future optional parameters +} + +// VolumeSnapshotsClientListByPoolOptions contains the optional parameters for the VolumeSnapshotsClient.NewListByPoolPager +// method. +type VolumeSnapshotsClientListByPoolOptions struct { + // placeholder for future optional parameters +} + +// VolumesClientBeginCreateOrUpdateOptions contains the optional parameters for the VolumesClient.BeginCreateOrUpdate method. +type VolumesClientBeginCreateOrUpdateOptions 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 +} + +// VolumesClientListByPoolOptions contains the optional parameters for the VolumesClient.NewListByPoolPager method. +type VolumesClientListByPoolOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/pools_client.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/pools_client.go new file mode 100644 index 000000000000..f265cc4572e7 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/pools_client.go @@ -0,0 +1,445 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerstorage + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "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" +) + +// PoolsClient contains the methods for the Pools group. +// Don't use this type directly, use NewPoolsClient() instead. +type PoolsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewPoolsClient creates a new instance of PoolsClient 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 NewPoolsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PoolsClient, error) { + cl, err := arm.NewClient(moduleName+".PoolsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PoolsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - resource - Resource create parameters. +// - options - PoolsClientBeginCreateOrUpdateOptions contains the optional parameters for the PoolsClient.BeginCreateOrUpdate +// method. +func (client *PoolsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, poolName string, resource Pool, options *PoolsClientBeginCreateOrUpdateOptions) (*runtime.Poller[PoolsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, poolName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PoolsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PoolsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *PoolsClient) createOrUpdate(ctx context.Context, resourceGroupName string, poolName string, resource Pool, options *PoolsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, poolName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PoolsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, poolName string, resource Pool, options *PoolsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}" + 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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - options - PoolsClientBeginDeleteOptions contains the optional parameters for the PoolsClient.BeginDelete method. +func (client *PoolsClient) BeginDelete(ctx context.Context, resourceGroupName string, poolName string, options *PoolsClientBeginDeleteOptions) (*runtime.Poller[PoolsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, poolName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PoolsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PoolsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *PoolsClient) deleteOperation(ctx context.Context, resourceGroupName string, poolName string, options *PoolsClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, poolName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PoolsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, poolName string, options *PoolsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}" + 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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - options - PoolsClientGetOptions contains the optional parameters for the PoolsClient.Get method. +func (client *PoolsClient) Get(ctx context.Context, resourceGroupName string, poolName string, options *PoolsClientGetOptions) (PoolsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, poolName, options) + if err != nil { + return PoolsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PoolsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PoolsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *PoolsClient) getCreateRequest(ctx context.Context, resourceGroupName string, poolName string, options *PoolsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}" + 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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PoolsClient) getHandleResponse(resp *http.Response) (PoolsClientGetResponse, error) { + result := PoolsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Pool); err != nil { + return PoolsClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List Pool resources by resource group +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - PoolsClientListByResourceGroupOptions contains the optional parameters for the PoolsClient.NewListByResourceGroupPager +// method. +func (client *PoolsClient) NewListByResourceGroupPager(resourceGroupName string, options *PoolsClientListByResourceGroupOptions) *runtime.Pager[PoolsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[PoolsClientListByResourceGroupResponse]{ + More: func(page PoolsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PoolsClientListByResourceGroupResponse) (PoolsClientListByResourceGroupResponse, 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 PoolsClientListByResourceGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PoolsClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PoolsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *PoolsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *PoolsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools" + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *PoolsClient) listByResourceGroupHandleResponse(resp *http.Response) (PoolsClientListByResourceGroupResponse, error) { + result := PoolsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PoolListResult); err != nil { + return PoolsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List Pool resources by subscription ID +// +// Generated from API version 2023-03-01-preview +// - options - PoolsClientListBySubscriptionOptions contains the optional parameters for the PoolsClient.NewListBySubscriptionPager +// method. +func (client *PoolsClient) NewListBySubscriptionPager(options *PoolsClientListBySubscriptionOptions) *runtime.Pager[PoolsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[PoolsClientListBySubscriptionResponse]{ + More: func(page PoolsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PoolsClientListBySubscriptionResponse) (PoolsClientListBySubscriptionResponse, 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 PoolsClientListBySubscriptionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PoolsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PoolsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *PoolsClient) listBySubscriptionCreateRequest(ctx context.Context, options *PoolsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerStorage/pools" + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *PoolsClient) listBySubscriptionHandleResponse(resp *http.Response) (PoolsClientListBySubscriptionResponse, error) { + result := PoolsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PoolListResult); err != nil { + return PoolsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - properties - The resource properties to be updated. +// - options - PoolsClientBeginUpdateOptions contains the optional parameters for the PoolsClient.BeginUpdate method. +func (client *PoolsClient) BeginUpdate(ctx context.Context, resourceGroupName string, poolName string, properties PoolUpdate, options *PoolsClientBeginUpdateOptions) (*runtime.Poller[PoolsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, poolName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PoolsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PoolsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *PoolsClient) update(ctx context.Context, resourceGroupName string, poolName string, properties PoolUpdate, options *PoolsClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, resourceGroupName, poolName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *PoolsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, poolName string, properties PoolUpdate, options *PoolsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}" + 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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/response_types.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/response_types.go new file mode 100644 index 000000000000..3828811bdb47 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/response_types.go @@ -0,0 +1,108 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerstorage + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} + +// PoolsClientCreateOrUpdateResponse contains the response from method PoolsClient.BeginCreateOrUpdate. +type PoolsClientCreateOrUpdateResponse struct { + // Pool resource + Pool +} + +// PoolsClientDeleteResponse contains the response from method PoolsClient.BeginDelete. +type PoolsClientDeleteResponse struct { + // placeholder for future response values +} + +// PoolsClientGetResponse contains the response from method PoolsClient.Get. +type PoolsClientGetResponse struct { + // Pool resource + Pool +} + +// PoolsClientListByResourceGroupResponse contains the response from method PoolsClient.NewListByResourceGroupPager. +type PoolsClientListByResourceGroupResponse struct { + // The response of a Pool list operation. + PoolListResult +} + +// PoolsClientListBySubscriptionResponse contains the response from method PoolsClient.NewListBySubscriptionPager. +type PoolsClientListBySubscriptionResponse struct { + // The response of a Pool list operation. + PoolListResult +} + +// PoolsClientUpdateResponse contains the response from method PoolsClient.BeginUpdate. +type PoolsClientUpdateResponse struct { + // Pool resource + Pool +} + +// VolumeSnapshotsClientCreateOrUpdateResponse contains the response from method VolumeSnapshotsClient.BeginCreateOrUpdate. +type VolumeSnapshotsClientCreateOrUpdateResponse struct { + // Concrete proxy resource types can be created by aliasing this type using a specific property type. + VolumeSnapshot +} + +// VolumeSnapshotsClientDeleteResponse contains the response from method VolumeSnapshotsClient.BeginDelete. +type VolumeSnapshotsClientDeleteResponse struct { + // placeholder for future response values +} + +// VolumeSnapshotsClientGetResponse contains the response from method VolumeSnapshotsClient.Get. +type VolumeSnapshotsClientGetResponse struct { + // Concrete proxy resource types can be created by aliasing this type using a specific property type. + VolumeSnapshot +} + +// VolumeSnapshotsClientListByPoolResponse contains the response from method VolumeSnapshotsClient.NewListByPoolPager. +type VolumeSnapshotsClientListByPoolResponse struct { + // The response of a VolumeSnapshot list operation. + VolumeSnapshotListResult +} + +// VolumeSnapshotsClientUpdateResponse contains the response from method VolumeSnapshotsClient.BeginUpdate. +type VolumeSnapshotsClientUpdateResponse struct { + // Concrete proxy resource types can be created by aliasing this type using a specific property type. + VolumeSnapshot +} + +// VolumesClientCreateOrUpdateResponse contains the response from method VolumesClient.BeginCreateOrUpdate. +type VolumesClientCreateOrUpdateResponse struct { + // Concrete proxy resource types can be created by aliasing this type using a specific property type. + Volume +} + +// VolumesClientDeleteResponse contains the response from method VolumesClient.BeginDelete. +type VolumesClientDeleteResponse struct { + // placeholder for future response values +} + +// VolumesClientGetResponse contains the response from method VolumesClient.Get. +type VolumesClientGetResponse struct { + // Concrete proxy resource types can be created by aliasing this type using a specific property type. + Volume +} + +// VolumesClientListByPoolResponse contains the response from method VolumesClient.NewListByPoolPager. +type VolumesClientListByPoolResponse struct { + // The response of a Volume list operation. + VolumeListResult +} + +// VolumesClientUpdateResponse contains the response from method VolumesClient.BeginUpdate. +type VolumesClientUpdateResponse struct { + // Concrete proxy resource types can be created by aliasing this type using a specific property type. + Volume +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/time_rfc3339.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/time_rfc3339.go new file mode 100644 index 000000000000..b8446025d5ff --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/time_rfc3339.go @@ -0,0 +1,86 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerstorage + +import ( + "encoding/json" + "fmt" + "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]any, 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, fn string, 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 fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/volumes_client.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/volumes_client.go new file mode 100644 index 000000000000..1a5c752362df --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/volumes_client.go @@ -0,0 +1,409 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerstorage + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "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 { + internal *arm.Client + subscriptionID string +} + +// 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) { + cl, err := arm.NewClient(moduleName+".VolumesClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &VolumesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - volumeName - Volume Resource +// - resource - Resource create parameters. +// - options - VolumesClientBeginCreateOrUpdateOptions contains the optional parameters for the VolumesClient.BeginCreateOrUpdate +// method. +func (client *VolumesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, poolName string, volumeName string, resource Volume, options *VolumesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VolumesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, poolName, volumeName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VolumesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VolumesClient) createOrUpdate(ctx context.Context, resourceGroupName string, poolName string, volumeName string, resource Volume, options *VolumesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, poolName, volumeName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VolumesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, poolName string, volumeName string, resource Volume, options *VolumesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - volumeName - Volume Resource +// - options - VolumesClientBeginDeleteOptions contains the optional parameters for the VolumesClient.BeginDelete method. +func (client *VolumesClient) BeginDelete(ctx context.Context, resourceGroupName string, poolName string, volumeName string, options *VolumesClientBeginDeleteOptions) (*runtime.Poller[VolumesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, poolName, volumeName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VolumesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VolumesClient) deleteOperation(ctx context.Context, resourceGroupName string, poolName string, volumeName string, options *VolumesClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, poolName, volumeName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VolumesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, poolName string, volumeName string, options *VolumesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - volumeName - Volume Resource +// - options - VolumesClientGetOptions contains the optional parameters for the VolumesClient.Get method. +func (client *VolumesClient) Get(ctx context.Context, resourceGroupName string, poolName string, volumeName string, options *VolumesClientGetOptions) (VolumesClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, poolName, volumeName, options) + if err != nil { + return VolumesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VolumesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VolumesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *VolumesClient) getCreateRequest(ctx context.Context, resourceGroupName string, poolName string, volumeName string, options *VolumesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"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 +} + +// NewListByPoolPager - List Volume resources by Pool +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - options - VolumesClientListByPoolOptions contains the optional parameters for the VolumesClient.NewListByPoolPager method. +func (client *VolumesClient) NewListByPoolPager(resourceGroupName string, poolName string, options *VolumesClientListByPoolOptions) *runtime.Pager[VolumesClientListByPoolResponse] { + return runtime.NewPager(runtime.PagingHandler[VolumesClientListByPoolResponse]{ + More: func(page VolumesClientListByPoolResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VolumesClientListByPoolResponse) (VolumesClientListByPoolResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByPoolCreateRequest(ctx, resourceGroupName, poolName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VolumesClientListByPoolResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VolumesClientListByPoolResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VolumesClientListByPoolResponse{}, runtime.NewResponseError(resp) + } + return client.listByPoolHandleResponse(resp) + }, + }) +} + +// listByPoolCreateRequest creates the ListByPool request. +func (client *VolumesClient) listByPoolCreateRequest(ctx context.Context, resourceGroupName string, poolName string, options *VolumesClientListByPoolOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByPoolHandleResponse handles the ListByPool response. +func (client *VolumesClient) listByPoolHandleResponse(resp *http.Response) (VolumesClientListByPoolResponse, error) { + result := VolumesClientListByPoolResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VolumeListResult); err != nil { + return VolumesClientListByPoolResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - volumeName - Volume Resource +// - properties - The resource properties to be updated. +// - options - VolumesClientBeginUpdateOptions contains the optional parameters for the VolumesClient.BeginUpdate method. +func (client *VolumesClient) BeginUpdate(ctx context.Context, resourceGroupName string, poolName string, volumeName string, properties VolumeUpdate, options *VolumesClientBeginUpdateOptions) (*runtime.Poller[VolumesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, poolName, volumeName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VolumesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VolumesClient) update(ctx context.Context, resourceGroupName string, poolName string, volumeName string, properties VolumeUpdate, options *VolumesClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, resourceGroupName, poolName, volumeName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *VolumesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, poolName string, volumeName string, properties VolumeUpdate, options *VolumesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/volumesnapshots_client.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/volumesnapshots_client.go new file mode 100644 index 000000000000..71ecadd9025d --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/volumesnapshots_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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerstorage + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "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" +) + +// VolumeSnapshotsClient contains the methods for the VolumeSnapshots group. +// Don't use this type directly, use NewVolumeSnapshotsClient() instead. +type VolumeSnapshotsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewVolumeSnapshotsClient creates a new instance of VolumeSnapshotsClient 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 NewVolumeSnapshotsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VolumeSnapshotsClient, error) { + cl, err := arm.NewClient(moduleName+".VolumeSnapshotsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &VolumeSnapshotsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a VolumeSnapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - volumeSnapshotName - Volume Snapshot Resource +// - resource - Resource create parameters. +// - options - VolumeSnapshotsClientBeginCreateOrUpdateOptions contains the optional parameters for the VolumeSnapshotsClient.BeginCreateOrUpdate +// method. +func (client *VolumeSnapshotsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, poolName string, volumeSnapshotName string, resource VolumeSnapshot, options *VolumeSnapshotsClientBeginCreateOrUpdateOptions) (*runtime.Poller[VolumeSnapshotsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, poolName, volumeSnapshotName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumeSnapshotsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VolumeSnapshotsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a VolumeSnapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VolumeSnapshotsClient) createOrUpdate(ctx context.Context, resourceGroupName string, poolName string, volumeSnapshotName string, resource VolumeSnapshot, options *VolumeSnapshotsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, poolName, volumeSnapshotName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VolumeSnapshotsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, poolName string, volumeSnapshotName string, resource VolumeSnapshot, options *VolumeSnapshotsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/volumeSnapshots/{volumeSnapshotName}" + 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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if volumeSnapshotName == "" { + return nil, errors.New("parameter volumeSnapshotName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeSnapshotName}", url.PathEscape(volumeSnapshotName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a VolumeSnapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - volumeSnapshotName - Volume Snapshot Resource +// - options - VolumeSnapshotsClientBeginDeleteOptions contains the optional parameters for the VolumeSnapshotsClient.BeginDelete +// method. +func (client *VolumeSnapshotsClient) BeginDelete(ctx context.Context, resourceGroupName string, poolName string, volumeSnapshotName string, options *VolumeSnapshotsClientBeginDeleteOptions) (*runtime.Poller[VolumeSnapshotsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, poolName, volumeSnapshotName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumeSnapshotsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VolumeSnapshotsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a VolumeSnapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VolumeSnapshotsClient) deleteOperation(ctx context.Context, resourceGroupName string, poolName string, volumeSnapshotName string, options *VolumeSnapshotsClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, poolName, volumeSnapshotName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VolumeSnapshotsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, poolName string, volumeSnapshotName string, options *VolumeSnapshotsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/volumeSnapshots/{volumeSnapshotName}" + 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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if volumeSnapshotName == "" { + return nil, errors.New("parameter volumeSnapshotName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeSnapshotName}", url.PathEscape(volumeSnapshotName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a VolumeSnapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - volumeSnapshotName - Volume Snapshot Resource +// - options - VolumeSnapshotsClientGetOptions contains the optional parameters for the VolumeSnapshotsClient.Get method. +func (client *VolumeSnapshotsClient) Get(ctx context.Context, resourceGroupName string, poolName string, volumeSnapshotName string, options *VolumeSnapshotsClientGetOptions) (VolumeSnapshotsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, poolName, volumeSnapshotName, options) + if err != nil { + return VolumeSnapshotsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VolumeSnapshotsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VolumeSnapshotsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *VolumeSnapshotsClient) getCreateRequest(ctx context.Context, resourceGroupName string, poolName string, volumeSnapshotName string, options *VolumeSnapshotsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/volumeSnapshots/{volumeSnapshotName}" + 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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if volumeSnapshotName == "" { + return nil, errors.New("parameter volumeSnapshotName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeSnapshotName}", url.PathEscape(volumeSnapshotName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VolumeSnapshotsClient) getHandleResponse(resp *http.Response) (VolumeSnapshotsClientGetResponse, error) { + result := VolumeSnapshotsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VolumeSnapshot); err != nil { + return VolumeSnapshotsClientGetResponse{}, err + } + return result, nil +} + +// NewListByPoolPager - List VolumeSnapshot resources by Pool +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - options - VolumeSnapshotsClientListByPoolOptions contains the optional parameters for the VolumeSnapshotsClient.NewListByPoolPager +// method. +func (client *VolumeSnapshotsClient) NewListByPoolPager(resourceGroupName string, poolName string, options *VolumeSnapshotsClientListByPoolOptions) *runtime.Pager[VolumeSnapshotsClientListByPoolResponse] { + return runtime.NewPager(runtime.PagingHandler[VolumeSnapshotsClientListByPoolResponse]{ + More: func(page VolumeSnapshotsClientListByPoolResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VolumeSnapshotsClientListByPoolResponse) (VolumeSnapshotsClientListByPoolResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByPoolCreateRequest(ctx, resourceGroupName, poolName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VolumeSnapshotsClientListByPoolResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VolumeSnapshotsClientListByPoolResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VolumeSnapshotsClientListByPoolResponse{}, runtime.NewResponseError(resp) + } + return client.listByPoolHandleResponse(resp) + }, + }) +} + +// listByPoolCreateRequest creates the ListByPool request. +func (client *VolumeSnapshotsClient) listByPoolCreateRequest(ctx context.Context, resourceGroupName string, poolName string, options *VolumeSnapshotsClientListByPoolOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/volumeSnapshots" + 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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByPoolHandleResponse handles the ListByPool response. +func (client *VolumeSnapshotsClient) listByPoolHandleResponse(resp *http.Response) (VolumeSnapshotsClientListByPoolResponse, error) { + result := VolumeSnapshotsClientListByPoolResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VolumeSnapshotListResult); err != nil { + return VolumeSnapshotsClientListByPoolResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a VolumeSnapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - volumeSnapshotName - Volume Snapshot Resource +// - properties - The resource properties to be updated. +// - options - VolumeSnapshotsClientBeginUpdateOptions contains the optional parameters for the VolumeSnapshotsClient.BeginUpdate +// method. +func (client *VolumeSnapshotsClient) BeginUpdate(ctx context.Context, resourceGroupName string, poolName string, volumeSnapshotName string, properties VolumeSnapshotUpdate, options *VolumeSnapshotsClientBeginUpdateOptions) (*runtime.Poller[VolumeSnapshotsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, poolName, volumeSnapshotName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumeSnapshotsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VolumeSnapshotsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a VolumeSnapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VolumeSnapshotsClient) update(ctx context.Context, resourceGroupName string, poolName string, volumeSnapshotName string, properties VolumeSnapshotUpdate, options *VolumeSnapshotsClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, resourceGroupName, poolName, volumeSnapshotName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *VolumeSnapshotsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, poolName string, volumeSnapshotName string, properties VolumeSnapshotUpdate, options *VolumeSnapshotsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/volumeSnapshots/{volumeSnapshotName}" + 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 poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if volumeSnapshotName == "" { + return nil, errors.New("parameter volumeSnapshotName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeSnapshotName}", url.PathEscape(volumeSnapshotName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +}