diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/CHANGELOG.md b/sdk/resourcemanager/purestorageblock/armpurestorageblock/CHANGELOG.md new file mode 100644 index 000000000000..9655c93e8602 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-05-12) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock` 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/purestorageblock/armpurestorageblock/LICENSE.txt b/sdk/resourcemanager/purestorageblock/armpurestorageblock/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/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/purestorageblock/armpurestorageblock/README.md b/sdk/resourcemanager/purestorageblock/armpurestorageblock/README.md new file mode 100644 index 000000000000..9bfe5f64eff4 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/README.md @@ -0,0 +1,90 @@ +# Azure Purestorageblock Module for Go + +The `armpurestorageblock` module provides operations for working with Azure Purestorageblock. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/purestorageblock/armpurestorageblock) + +# 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 Purestorageblock module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Purestorageblock. 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 Purestorageblock 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 := armpurestorageblock.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, + }, +} +clientFactory, err := armpurestorageblock.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.NewAvsStorageContainerVolumesClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## 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 `Purestorageblock` 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/purestorageblock/armpurestorageblock/avsstoragecontainers_client.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsstoragecontainers_client.go new file mode 100644 index 000000000000..200167b1bc51 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsstoragecontainers_client.go @@ -0,0 +1,256 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +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" +) + +// AvsStorageContainersClient contains the methods for the AvsStorageContainers group. +// Don't use this type directly, use NewAvsStorageContainersClient() instead. +type AvsStorageContainersClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAvsStorageContainersClient creates a new instance of AvsStorageContainersClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAvsStorageContainersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AvsStorageContainersClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AvsStorageContainersClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginDelete - Delete an AVS storage container +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - storageContainerName - Name of the storage container +// - options - AvsStorageContainersClientBeginDeleteOptions contains the optional parameters for the AvsStorageContainersClient.BeginDelete +// method. +func (client *AvsStorageContainersClient) BeginDelete(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, options *AvsStorageContainersClientBeginDeleteOptions) (*runtime.Poller[AvsStorageContainersClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, storagePoolName, storageContainerName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AvsStorageContainersClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AvsStorageContainersClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete an AVS storage container +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *AvsStorageContainersClient) deleteOperation(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, options *AvsStorageContainersClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "AvsStorageContainersClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, storagePoolName, storageContainerName, 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.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AvsStorageContainersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, _ *AvsStorageContainersClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsStorageContainers/{storageContainerName}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if storageContainerName == "" { + return nil, errors.New("parameter storageContainerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageContainerName}", url.PathEscape(storageContainerName)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get an AVS storage container +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - storageContainerName - Name of the storage container +// - options - AvsStorageContainersClientGetOptions contains the optional parameters for the AvsStorageContainersClient.Get +// method. +func (client *AvsStorageContainersClient) Get(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, options *AvsStorageContainersClientGetOptions) (AvsStorageContainersClientGetResponse, error) { + var err error + const operationName = "AvsStorageContainersClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, storagePoolName, storageContainerName, options) + if err != nil { + return AvsStorageContainersClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AvsStorageContainersClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AvsStorageContainersClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *AvsStorageContainersClient) getCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, _ *AvsStorageContainersClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsStorageContainers/{storageContainerName}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if storageContainerName == "" { + return nil, errors.New("parameter storageContainerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageContainerName}", url.PathEscape(storageContainerName)) + 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", "2024-11-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 *AvsStorageContainersClient) getHandleResponse(resp *http.Response) (AvsStorageContainersClientGetResponse, error) { + result := AvsStorageContainersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvsStorageContainer); err != nil { + return AvsStorageContainersClientGetResponse{}, err + } + return result, nil +} + +// NewListByStoragePoolPager - List AVS storage containers by storage pool +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - options - AvsStorageContainersClientListByStoragePoolOptions contains the optional parameters for the AvsStorageContainersClient.NewListByStoragePoolPager +// method. +func (client *AvsStorageContainersClient) NewListByStoragePoolPager(resourceGroupName string, storagePoolName string, options *AvsStorageContainersClientListByStoragePoolOptions) *runtime.Pager[AvsStorageContainersClientListByStoragePoolResponse] { + return runtime.NewPager(runtime.PagingHandler[AvsStorageContainersClientListByStoragePoolResponse]{ + More: func(page AvsStorageContainersClientListByStoragePoolResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AvsStorageContainersClientListByStoragePoolResponse) (AvsStorageContainersClientListByStoragePoolResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AvsStorageContainersClient.NewListByStoragePoolPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByStoragePoolCreateRequest(ctx, resourceGroupName, storagePoolName, options) + }, nil) + if err != nil { + return AvsStorageContainersClientListByStoragePoolResponse{}, err + } + return client.listByStoragePoolHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByStoragePoolCreateRequest creates the ListByStoragePool request. +func (client *AvsStorageContainersClient) listByStoragePoolCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, _ *AvsStorageContainersClientListByStoragePoolOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsStorageContainers" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByStoragePoolHandleResponse handles the ListByStoragePool response. +func (client *AvsStorageContainersClient) listByStoragePoolHandleResponse(resp *http.Response) (AvsStorageContainersClientListByStoragePoolResponse, error) { + result := AvsStorageContainersClientListByStoragePoolResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvsStorageContainerListResult); err != nil { + return AvsStorageContainersClientListByStoragePoolResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsstoragecontainers_client_example_test.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsstoragecontainers_client_example_test.go new file mode 100644 index 000000000000..19d3bfa720a0 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsstoragecontainers_client_example_test.go @@ -0,0 +1,137 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "log" +) + +// Generated from example definition: 2024-11-01-preview/AvsStorageContainers_Delete_MaximumSet_Gen.json +func ExampleAvsStorageContainersClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAvsStorageContainersClient().BeginDelete(ctx, "rgpurestorage", "storagePoolName", "storageContainerName", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-11-01-preview/AvsStorageContainers_Get_MaximumSet_Gen.json +func ExampleAvsStorageContainersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAvsStorageContainersClient().Get(ctx, "rgpurestorage", "storagePoolName", "storageContainerName", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.AvsStorageContainersClientGetResponse{ + // AvsStorageContainer: &armpurestorageblock.AvsStorageContainer{ + // Properties: &armpurestorageblock.AvsStorageContainerProperties{ + // Space: &armpurestorageblock.Space{ + // TotalUsed: to.Ptr[int64](28), + // Unique: to.Ptr[int64](4), + // Snapshots: to.Ptr[int64](5), + // Shared: to.Ptr[int64](9), + // }, + // ResourceName: to.Ptr("name"), + // ProvisionedLimit: to.Ptr[int64](24), + // Datastore: to.Ptr("name"), + // Mounted: to.Ptr(true), + // }, + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("acezain"), + // Type: to.Ptr("rhdmvrbnpxcydalkvtfsb"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-11-01-preview/AvsStorageContainers_ListByStoragePool_MaximumSet_Gen.json +func ExampleAvsStorageContainersClient_NewListByStoragePoolPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAvsStorageContainersClient().NewListByStoragePoolPager("rgpurestorage", "spName", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armpurestorageblock.AvsStorageContainersClientListByStoragePoolResponse{ + // AvsStorageContainerListResult: armpurestorageblock.AvsStorageContainerListResult{ + // Value: []*armpurestorageblock.AvsStorageContainer{ + // { + // Properties: &armpurestorageblock.AvsStorageContainerProperties{ + // Space: &armpurestorageblock.Space{ + // TotalUsed: to.Ptr[int64](28), + // Unique: to.Ptr[int64](4), + // Snapshots: to.Ptr[int64](5), + // Shared: to.Ptr[int64](9), + // }, + // ResourceName: to.Ptr("name"), + // ProvisionedLimit: to.Ptr[int64](24), + // Datastore: to.Ptr("name"), + // Mounted: to.Ptr(true), + // }, + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("acezain"), + // Type: to.Ptr("rhdmvrbnpxcydalkvtfsb"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsstoragecontainervolumes_client.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsstoragecontainervolumes_client.go new file mode 100644 index 000000000000..18d26b4cb4b5 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsstoragecontainervolumes_client.go @@ -0,0 +1,362 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +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" +) + +// AvsStorageContainerVolumesClient contains the methods for the AvsStorageContainerVolumes group. +// Don't use this type directly, use NewAvsStorageContainerVolumesClient() instead. +type AvsStorageContainerVolumesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAvsStorageContainerVolumesClient creates a new instance of AvsStorageContainerVolumesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAvsStorageContainerVolumesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AvsStorageContainerVolumesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AvsStorageContainerVolumesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginDelete - Delete a volume in an AVS storage container +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - storageContainerName - Name of the storage container +// - volumeID - ID of the volume in the storage container +// - options - AvsStorageContainerVolumesClientBeginDeleteOptions contains the optional parameters for the AvsStorageContainerVolumesClient.BeginDelete +// method. +func (client *AvsStorageContainerVolumesClient) BeginDelete(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, volumeID string, options *AvsStorageContainerVolumesClientBeginDeleteOptions) (*runtime.Poller[AvsStorageContainerVolumesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, storagePoolName, storageContainerName, volumeID, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AvsStorageContainerVolumesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AvsStorageContainerVolumesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a volume in an AVS storage container +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *AvsStorageContainerVolumesClient) deleteOperation(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, volumeID string, options *AvsStorageContainerVolumesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "AvsStorageContainerVolumesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, storagePoolName, storageContainerName, volumeID, 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.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AvsStorageContainerVolumesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, volumeID string, _ *AvsStorageContainerVolumesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsStorageContainers/{storageContainerName}/volumes/{volumeId}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if storageContainerName == "" { + return nil, errors.New("parameter storageContainerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageContainerName}", url.PathEscape(storageContainerName)) + if volumeID == "" { + return nil, errors.New("parameter volumeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeId}", url.PathEscape(volumeID)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a volume in an AVS storage container +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - storageContainerName - Name of the storage container +// - volumeID - ID of the volume in the storage container +// - options - AvsStorageContainerVolumesClientGetOptions contains the optional parameters for the AvsStorageContainerVolumesClient.Get +// method. +func (client *AvsStorageContainerVolumesClient) Get(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, volumeID string, options *AvsStorageContainerVolumesClientGetOptions) (AvsStorageContainerVolumesClientGetResponse, error) { + var err error + const operationName = "AvsStorageContainerVolumesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, storagePoolName, storageContainerName, volumeID, options) + if err != nil { + return AvsStorageContainerVolumesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AvsStorageContainerVolumesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AvsStorageContainerVolumesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *AvsStorageContainerVolumesClient) getCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, volumeID string, _ *AvsStorageContainerVolumesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsStorageContainers/{storageContainerName}/volumes/{volumeId}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if storageContainerName == "" { + return nil, errors.New("parameter storageContainerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageContainerName}", url.PathEscape(storageContainerName)) + if volumeID == "" { + return nil, errors.New("parameter volumeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeId}", url.PathEscape(volumeID)) + 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", "2024-11-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 *AvsStorageContainerVolumesClient) getHandleResponse(resp *http.Response) (AvsStorageContainerVolumesClientGetResponse, error) { + result := AvsStorageContainerVolumesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvsStorageContainerVolume); err != nil { + return AvsStorageContainerVolumesClientGetResponse{}, err + } + return result, nil +} + +// NewListByAvsStorageContainerPager - List volumes in an AVS storage container +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - storageContainerName - Name of the storage container +// - options - AvsStorageContainerVolumesClientListByAvsStorageContainerOptions contains the optional parameters for the AvsStorageContainerVolumesClient.NewListByAvsStorageContainerPager +// method. +func (client *AvsStorageContainerVolumesClient) NewListByAvsStorageContainerPager(resourceGroupName string, storagePoolName string, storageContainerName string, options *AvsStorageContainerVolumesClientListByAvsStorageContainerOptions) *runtime.Pager[AvsStorageContainerVolumesClientListByAvsStorageContainerResponse] { + return runtime.NewPager(runtime.PagingHandler[AvsStorageContainerVolumesClientListByAvsStorageContainerResponse]{ + More: func(page AvsStorageContainerVolumesClientListByAvsStorageContainerResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AvsStorageContainerVolumesClientListByAvsStorageContainerResponse) (AvsStorageContainerVolumesClientListByAvsStorageContainerResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AvsStorageContainerVolumesClient.NewListByAvsStorageContainerPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByAvsStorageContainerCreateRequest(ctx, resourceGroupName, storagePoolName, storageContainerName, options) + }, nil) + if err != nil { + return AvsStorageContainerVolumesClientListByAvsStorageContainerResponse{}, err + } + return client.listByAvsStorageContainerHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByAvsStorageContainerCreateRequest creates the ListByAvsStorageContainer request. +func (client *AvsStorageContainerVolumesClient) listByAvsStorageContainerCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, _ *AvsStorageContainerVolumesClientListByAvsStorageContainerOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsStorageContainers/{storageContainerName}/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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if storageContainerName == "" { + return nil, errors.New("parameter storageContainerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageContainerName}", url.PathEscape(storageContainerName)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByAvsStorageContainerHandleResponse handles the ListByAvsStorageContainer response. +func (client *AvsStorageContainerVolumesClient) listByAvsStorageContainerHandleResponse(resp *http.Response) (AvsStorageContainerVolumesClientListByAvsStorageContainerResponse, error) { + result := AvsStorageContainerVolumesClientListByAvsStorageContainerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvsStorageContainerVolumeListResult); err != nil { + return AvsStorageContainerVolumesClientListByAvsStorageContainerResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a volume in an AVS storage container +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - storageContainerName - Name of the storage container +// - volumeID - ID of the volume in the storage container +// - properties - The resource properties to be updated. +// - options - AvsStorageContainerVolumesClientBeginUpdateOptions contains the optional parameters for the AvsStorageContainerVolumesClient.BeginUpdate +// method. +func (client *AvsStorageContainerVolumesClient) BeginUpdate(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, volumeID string, properties AvsStorageContainerVolumeUpdate, options *AvsStorageContainerVolumesClientBeginUpdateOptions) (*runtime.Poller[AvsStorageContainerVolumesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, storagePoolName, storageContainerName, volumeID, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AvsStorageContainerVolumesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AvsStorageContainerVolumesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a volume in an AVS storage container +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *AvsStorageContainerVolumesClient) update(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, volumeID string, properties AvsStorageContainerVolumeUpdate, options *AvsStorageContainerVolumesClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "AvsStorageContainerVolumesClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, storagePoolName, storageContainerName, volumeID, 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 *AvsStorageContainerVolumesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, volumeID string, properties AvsStorageContainerVolumeUpdate, _ *AvsStorageContainerVolumesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsStorageContainers/{storageContainerName}/volumes/{volumeId}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if storageContainerName == "" { + return nil, errors.New("parameter storageContainerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageContainerName}", url.PathEscape(storageContainerName)) + if volumeID == "" { + return nil, errors.New("parameter volumeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeId}", url.PathEscape(volumeID)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsstoragecontainervolumes_client_example_test.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsstoragecontainervolumes_client_example_test.go new file mode 100644 index 000000000000..425cc1f7b905 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsstoragecontainervolumes_client_example_test.go @@ -0,0 +1,246 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "log" +) + +// Generated from example definition: 2024-11-01-preview/AvsStorageContainerVolumes_Delete_MaximumSet_Gen.json +func ExampleAvsStorageContainerVolumesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAvsStorageContainerVolumesClient().BeginDelete(ctx, "rgpurestorage", "storagePoolname", "name", "cbdec-ddbb", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-11-01-preview/AvsStorageContainerVolumes_Get_MaximumSet_Gen.json +func ExampleAvsStorageContainerVolumesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAvsStorageContainerVolumesClient().Get(ctx, "rgpurestorage", "storagePoolname", "name", "cbdec-ddbb", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.AvsStorageContainerVolumesClientGetResponse{ + // AvsStorageContainerVolume: &armpurestorageblock.AvsStorageContainerVolume{ + // Properties: &armpurestorageblock.VolumeProperties{ + // StoragePoolInternalID: to.Ptr("xkcbzbtfhftbnowayannq"), + // StoragePoolResourceID: to.Ptr("mrnioblkjhwry"), + // VolumeInternalID: to.Ptr("ivdmuth"), + // DisplayName: to.Ptr("mcdetkfvt"), + // Space: &armpurestorageblock.Space{ + // TotalUsed: to.Ptr[int64](28), + // Unique: to.Ptr[int64](4), + // Snapshots: to.Ptr[int64](5), + // Shared: to.Ptr[int64](9), + // }, + // SoftDeletion: &armpurestorageblock.SoftDeletion{ + // Destroyed: to.Ptr(true), + // EradicationTimestamp: to.Ptr("kaxjtehra"), + // }, + // CreatedTimestamp: to.Ptr("pwhsjhrcszrhsmzc"), + // ProvisionedSize: to.Ptr[int64](14), + // VolumeType: to.Ptr(armpurestorageblock.VolumeTypeAVS), + // Avs: &armpurestorageblock.AvsDiskDetails{ + // DiskID: to.Ptr("egehzvidnjgevc"), + // DiskName: to.Ptr("gqpqpkxjyj"), + // Folder: to.Ptr("oxdbbh"), + // AvsVMInternalID: to.Ptr("xoiliugbcvkhdl"), + // AvsVMResourceID: to.Ptr("jblyybyfhtikdhwx"), + // AvsVMName: to.Ptr("gaeydwwisfuonbuwtnkdk"), + // AvsStorageContainerResourceID: to.Ptr("svwilhkpx"), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("eyomi"), + // Type: to.Ptr("kaapjwvnvm"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-11-01-preview/AvsStorageContainerVolumes_ListByAvsStorageContainer_MaximumSet_Gen.json +func ExampleAvsStorageContainerVolumesClient_NewListByAvsStorageContainerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAvsStorageContainerVolumesClient().NewListByAvsStorageContainerPager("rgpurestorage", "storagePoolname", "name", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armpurestorageblock.AvsStorageContainerVolumesClientListByAvsStorageContainerResponse{ + // AvsStorageContainerVolumeListResult: armpurestorageblock.AvsStorageContainerVolumeListResult{ + // Value: []*armpurestorageblock.AvsStorageContainerVolume{ + // { + // Properties: &armpurestorageblock.VolumeProperties{ + // StoragePoolInternalID: to.Ptr("xkcbzbtfhftbnowayannq"), + // StoragePoolResourceID: to.Ptr("mrnioblkjhwry"), + // VolumeInternalID: to.Ptr("ivdmuth"), + // DisplayName: to.Ptr("mcdetkfvt"), + // Space: &armpurestorageblock.Space{ + // TotalUsed: to.Ptr[int64](28), + // Unique: to.Ptr[int64](4), + // Snapshots: to.Ptr[int64](5), + // Shared: to.Ptr[int64](9), + // }, + // SoftDeletion: &armpurestorageblock.SoftDeletion{ + // Destroyed: to.Ptr(true), + // EradicationTimestamp: to.Ptr("kaxjtehra"), + // }, + // CreatedTimestamp: to.Ptr("pwhsjhrcszrhsmzc"), + // ProvisionedSize: to.Ptr[int64](14), + // VolumeType: to.Ptr(armpurestorageblock.VolumeTypeAVS), + // Avs: &armpurestorageblock.AvsDiskDetails{ + // DiskID: to.Ptr("egehzvidnjgevc"), + // DiskName: to.Ptr("gqpqpkxjyj"), + // Folder: to.Ptr("oxdbbh"), + // AvsVMInternalID: to.Ptr("xoiliugbcvkhdl"), + // AvsVMResourceID: to.Ptr("jblyybyfhtikdhwx"), + // AvsVMName: to.Ptr("gaeydwwisfuonbuwtnkdk"), + // AvsStorageContainerResourceID: to.Ptr("svwilhkpx"), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("eyomi"), + // Type: to.Ptr("kaapjwvnvm"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-11-01-preview/AvsStorageContainerVolumes_Update_MaximumSet_Gen.json +func ExampleAvsStorageContainerVolumesClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAvsStorageContainerVolumesClient().BeginUpdate(ctx, "rgpurestorage", "storagePoolname", "name", "cbdec-ddbb", armpurestorageblock.AvsStorageContainerVolumeUpdate{ + Properties: &armpurestorageblock.AvsStorageContainerVolumeUpdateProperties{ + SoftDeletion: &armpurestorageblock.SoftDeletion{ + Destroyed: to.Ptr(true), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.AvsStorageContainerVolumesClientUpdateResponse{ + // AvsStorageContainerVolume: &armpurestorageblock.AvsStorageContainerVolume{ + // Properties: &armpurestorageblock.VolumeProperties{ + // StoragePoolInternalID: to.Ptr("xkcbzbtfhftbnowayannq"), + // StoragePoolResourceID: to.Ptr("mrnioblkjhwry"), + // VolumeInternalID: to.Ptr("ivdmuth"), + // DisplayName: to.Ptr("mcdetkfvt"), + // Space: &armpurestorageblock.Space{ + // TotalUsed: to.Ptr[int64](28), + // Unique: to.Ptr[int64](4), + // Snapshots: to.Ptr[int64](5), + // Shared: to.Ptr[int64](9), + // }, + // SoftDeletion: &armpurestorageblock.SoftDeletion{ + // Destroyed: to.Ptr(true), + // EradicationTimestamp: to.Ptr("kaxjtehra"), + // }, + // CreatedTimestamp: to.Ptr("pwhsjhrcszrhsmzc"), + // ProvisionedSize: to.Ptr[int64](14), + // VolumeType: to.Ptr(armpurestorageblock.VolumeTypeAVS), + // Avs: &armpurestorageblock.AvsDiskDetails{ + // DiskID: to.Ptr("egehzvidnjgevc"), + // DiskName: to.Ptr("gqpqpkxjyj"), + // Folder: to.Ptr("oxdbbh"), + // AvsVMInternalID: to.Ptr("xoiliugbcvkhdl"), + // AvsVMResourceID: to.Ptr("jblyybyfhtikdhwx"), + // AvsVMName: to.Ptr("gaeydwwisfuonbuwtnkdk"), + // AvsStorageContainerResourceID: to.Ptr("svwilhkpx"), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("eyomi"), + // Type: to.Ptr("kaapjwvnvm"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsvms_client.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsvms_client.go new file mode 100644 index 000000000000..daf6c3338ebb --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsvms_client.go @@ -0,0 +1,339 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +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" +) + +// AvsVMsClient contains the methods for the AvsVMs group. +// Don't use this type directly, use NewAvsVMsClient() instead. +type AvsVMsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAvsVMsClient creates a new instance of AvsVMsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAvsVMsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AvsVMsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AvsVMsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginDelete - Delete an AVS VM +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - avsVMID - ID of the AVS VM +// - options - AvsVMsClientBeginDeleteOptions contains the optional parameters for the AvsVMsClient.BeginDelete method. +func (client *AvsVMsClient) BeginDelete(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, options *AvsVMsClientBeginDeleteOptions) (*runtime.Poller[AvsVMsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, storagePoolName, avsVMID, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AvsVMsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AvsVMsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete an AVS VM +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *AvsVMsClient) deleteOperation(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, options *AvsVMsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "AvsVMsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, storagePoolName, avsVMID, 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.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AvsVMsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, _ *AvsVMsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsVms/{avsVmId}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if avsVMID == "" { + return nil, errors.New("parameter avsVMID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{avsVmId}", url.PathEscape(avsVMID)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get an AVS VM +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - avsVMID - ID of the AVS VM +// - options - AvsVMsClientGetOptions contains the optional parameters for the AvsVMsClient.Get method. +func (client *AvsVMsClient) Get(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, options *AvsVMsClientGetOptions) (AvsVMsClientGetResponse, error) { + var err error + const operationName = "AvsVMsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, storagePoolName, avsVMID, options) + if err != nil { + return AvsVMsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AvsVMsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AvsVMsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *AvsVMsClient) getCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, _ *AvsVMsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsVms/{avsVmId}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if avsVMID == "" { + return nil, errors.New("parameter avsVMID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{avsVmId}", url.PathEscape(avsVMID)) + 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", "2024-11-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 *AvsVMsClient) getHandleResponse(resp *http.Response) (AvsVMsClientGetResponse, error) { + result := AvsVMsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvsVM); err != nil { + return AvsVMsClientGetResponse{}, err + } + return result, nil +} + +// NewListByStoragePoolPager - List AVS VMs by storage pool +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - options - AvsVMsClientListByStoragePoolOptions contains the optional parameters for the AvsVMsClient.NewListByStoragePoolPager +// method. +func (client *AvsVMsClient) NewListByStoragePoolPager(resourceGroupName string, storagePoolName string, options *AvsVMsClientListByStoragePoolOptions) *runtime.Pager[AvsVMsClientListByStoragePoolResponse] { + return runtime.NewPager(runtime.PagingHandler[AvsVMsClientListByStoragePoolResponse]{ + More: func(page AvsVMsClientListByStoragePoolResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AvsVMsClientListByStoragePoolResponse) (AvsVMsClientListByStoragePoolResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AvsVMsClient.NewListByStoragePoolPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByStoragePoolCreateRequest(ctx, resourceGroupName, storagePoolName, options) + }, nil) + if err != nil { + return AvsVMsClientListByStoragePoolResponse{}, err + } + return client.listByStoragePoolHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByStoragePoolCreateRequest creates the ListByStoragePool request. +func (client *AvsVMsClient) listByStoragePoolCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, _ *AvsVMsClientListByStoragePoolOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsVms" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByStoragePoolHandleResponse handles the ListByStoragePool response. +func (client *AvsVMsClient) listByStoragePoolHandleResponse(resp *http.Response) (AvsVMsClientListByStoragePoolResponse, error) { + result := AvsVMsClientListByStoragePoolResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvsVMListResult); err != nil { + return AvsVMsClientListByStoragePoolResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update an AVS VM +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - avsVMID - ID of the AVS VM +// - properties - The resource properties to be updated. +// - options - AvsVMsClientBeginUpdateOptions contains the optional parameters for the AvsVMsClient.BeginUpdate method. +func (client *AvsVMsClient) BeginUpdate(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, properties AvsVMUpdate, options *AvsVMsClientBeginUpdateOptions) (*runtime.Poller[AvsVMsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, storagePoolName, avsVMID, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AvsVMsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AvsVMsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update an AVS VM +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *AvsVMsClient) update(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, properties AvsVMUpdate, options *AvsVMsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "AvsVMsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, storagePoolName, avsVMID, 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 *AvsVMsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, properties AvsVMUpdate, _ *AvsVMsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsVms/{avsVmId}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if avsVMID == "" { + return nil, errors.New("parameter avsVMID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{avsVmId}", url.PathEscape(avsVMID)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsvms_client_example_test.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsvms_client_example_test.go new file mode 100644 index 000000000000..ed5364ed0f9e --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsvms_client_example_test.go @@ -0,0 +1,231 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "log" +) + +// Generated from example definition: 2024-11-01-preview/AvsVms_Delete_MaximumSet_Gen.json +func ExampleAvsVMsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAvsVMsClient().BeginDelete(ctx, "rgpurestorage", "storagePoolname", "cbdec-ddbb", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-11-01-preview/AvsVms_Get_MaximumSet_Gen.json +func ExampleAvsVMsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAvsVMsClient().Get(ctx, "rgpurestorage", "storagePoolname", "cbdec-ddbb", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.AvsVMsClientGetResponse{ + // AvsVM: &armpurestorageblock.AvsVM{ + // Properties: &armpurestorageblock.AvsVMProperties{ + // StoragePoolInternalID: to.Ptr("zpchlbmnmgympdfqeuchp"), + // StoragePoolResourceID: to.Ptr("refrmhvh"), + // DisplayName: to.Ptr("zcpusnyyozsxptnvia"), + // CreatedTimestamp: to.Ptr("eeczpavimq"), + // SoftDeletion: &armpurestorageblock.SoftDeletion{ + // Destroyed: to.Ptr(true), + // EradicationTimestamp: to.Ptr("kaxjtehra"), + // }, + // VolumeContainerType: to.Ptr(armpurestorageblock.VolumeContainerTypeAVS), + // Avs: &armpurestorageblock.AvsVMDetails{ + // VMID: to.Ptr("ljsdq"), + // VMName: to.Ptr("hskuenhnxpscuqikeohkyjfebgzapx"), + // VMType: to.Ptr(armpurestorageblock.VMTypeVVol), + // AvsVMInternalID: to.Ptr("wnamcozqs"), + // }, + // Space: &armpurestorageblock.Space{ + // TotalUsed: to.Ptr[int64](28), + // Unique: to.Ptr[int64](4), + // Snapshots: to.Ptr[int64](5), + // Shared: to.Ptr[int64](9), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("ifvdmtawvkzz"), + // Type: to.Ptr("qsfuizcaje"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-11-01-preview/AvsVms_ListByStoragePool_MaximumSet_Gen.json +func ExampleAvsVMsClient_NewListByStoragePoolPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAvsVMsClient().NewListByStoragePoolPager("rgpurestorage", "storagePoolname", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armpurestorageblock.AvsVMsClientListByStoragePoolResponse{ + // AvsVMListResult: armpurestorageblock.AvsVMListResult{ + // Value: []*armpurestorageblock.AvsVM{ + // { + // Properties: &armpurestorageblock.AvsVMProperties{ + // StoragePoolInternalID: to.Ptr("zpchlbmnmgympdfqeuchp"), + // StoragePoolResourceID: to.Ptr("refrmhvh"), + // DisplayName: to.Ptr("zcpusnyyozsxptnvia"), + // CreatedTimestamp: to.Ptr("eeczpavimq"), + // SoftDeletion: &armpurestorageblock.SoftDeletion{ + // Destroyed: to.Ptr(true), + // EradicationTimestamp: to.Ptr("kaxjtehra"), + // }, + // VolumeContainerType: to.Ptr(armpurestorageblock.VolumeContainerTypeAVS), + // Avs: &armpurestorageblock.AvsVMDetails{ + // VMID: to.Ptr("ljsdq"), + // VMName: to.Ptr("hskuenhnxpscuqikeohkyjfebgzapx"), + // VMType: to.Ptr(armpurestorageblock.VMTypeVVol), + // AvsVMInternalID: to.Ptr("wnamcozqs"), + // }, + // Space: &armpurestorageblock.Space{ + // TotalUsed: to.Ptr[int64](28), + // Unique: to.Ptr[int64](4), + // Snapshots: to.Ptr[int64](5), + // Shared: to.Ptr[int64](9), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("ifvdmtawvkzz"), + // Type: to.Ptr("qsfuizcaje"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/annrdra"), + // }, + // } + } +} + +// Generated from example definition: 2024-11-01-preview/AvsVms_Update_MaximumSet_Gen.json +func ExampleAvsVMsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAvsVMsClient().BeginUpdate(ctx, "rgpurestorage", "storagePoolname", "cbdec-ddbb", armpurestorageblock.AvsVMUpdate{ + Properties: &armpurestorageblock.AvsVMUpdateProperties{ + SoftDeletion: &armpurestorageblock.SoftDeletion{ + Destroyed: to.Ptr(true), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.AvsVMsClientUpdateResponse{ + // AvsVM: &armpurestorageblock.AvsVM{ + // Properties: &armpurestorageblock.AvsVMProperties{ + // StoragePoolInternalID: to.Ptr("zpchlbmnmgympdfqeuchp"), + // StoragePoolResourceID: to.Ptr("refrmhvh"), + // DisplayName: to.Ptr("zcpusnyyozsxptnvia"), + // CreatedTimestamp: to.Ptr("eeczpavimq"), + // SoftDeletion: &armpurestorageblock.SoftDeletion{ + // Destroyed: to.Ptr(true), + // EradicationTimestamp: to.Ptr("kaxjtehra"), + // }, + // VolumeContainerType: to.Ptr(armpurestorageblock.VolumeContainerTypeAVS), + // Avs: &armpurestorageblock.AvsVMDetails{ + // VMID: to.Ptr("ljsdq"), + // VMName: to.Ptr("hskuenhnxpscuqikeohkyjfebgzapx"), + // VMType: to.Ptr(armpurestorageblock.VMTypeVVol), + // AvsVMInternalID: to.Ptr("wnamcozqs"), + // }, + // Space: &armpurestorageblock.Space{ + // TotalUsed: to.Ptr[int64](28), + // Unique: to.Ptr[int64](4), + // Snapshots: to.Ptr[int64](5), + // Shared: to.Ptr[int64](9), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("ifvdmtawvkzz"), + // Type: to.Ptr("qsfuizcaje"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsvmvolumes_client.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsvmvolumes_client.go new file mode 100644 index 000000000000..687eb99320f8 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsvmvolumes_client.go @@ -0,0 +1,361 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +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" +) + +// AvsVMVolumesClient contains the methods for the AvsVMVolumes group. +// Don't use this type directly, use NewAvsVMVolumesClient() instead. +type AvsVMVolumesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAvsVMVolumesClient creates a new instance of AvsVMVolumesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAvsVMVolumesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AvsVMVolumesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AvsVMVolumesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginDelete - Delete a volume in an AVS VM +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - avsVMID - ID of the AVS VM +// - volumeID - ID of the volume in the AVS VM +// - options - AvsVMVolumesClientBeginDeleteOptions contains the optional parameters for the AvsVMVolumesClient.BeginDelete +// method. +func (client *AvsVMVolumesClient) BeginDelete(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, volumeID string, options *AvsVMVolumesClientBeginDeleteOptions) (*runtime.Poller[AvsVMVolumesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, storagePoolName, avsVMID, volumeID, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AvsVMVolumesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AvsVMVolumesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a volume in an AVS VM +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *AvsVMVolumesClient) deleteOperation(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, volumeID string, options *AvsVMVolumesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "AvsVMVolumesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, storagePoolName, avsVMID, volumeID, 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.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AvsVMVolumesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, volumeID string, _ *AvsVMVolumesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsVms/{avsVmId}/avsVmVolumes/{volumeId}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if avsVMID == "" { + return nil, errors.New("parameter avsVMID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{avsVmId}", url.PathEscape(avsVMID)) + if volumeID == "" { + return nil, errors.New("parameter volumeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeId}", url.PathEscape(volumeID)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a volume in an AVS VM +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - avsVMID - ID of the AVS VM +// - volumeID - ID of the volume in the AVS VM +// - options - AvsVMVolumesClientGetOptions contains the optional parameters for the AvsVMVolumesClient.Get method. +func (client *AvsVMVolumesClient) Get(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, volumeID string, options *AvsVMVolumesClientGetOptions) (AvsVMVolumesClientGetResponse, error) { + var err error + const operationName = "AvsVMVolumesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, storagePoolName, avsVMID, volumeID, options) + if err != nil { + return AvsVMVolumesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AvsVMVolumesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AvsVMVolumesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *AvsVMVolumesClient) getCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, volumeID string, _ *AvsVMVolumesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsVms/{avsVmId}/avsVmVolumes/{volumeId}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if avsVMID == "" { + return nil, errors.New("parameter avsVMID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{avsVmId}", url.PathEscape(avsVMID)) + if volumeID == "" { + return nil, errors.New("parameter volumeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeId}", url.PathEscape(volumeID)) + 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", "2024-11-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 *AvsVMVolumesClient) getHandleResponse(resp *http.Response) (AvsVMVolumesClientGetResponse, error) { + result := AvsVMVolumesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvsVMVolume); err != nil { + return AvsVMVolumesClientGetResponse{}, err + } + return result, nil +} + +// NewListByAvsVMPager - List volumes in an AVS VM +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - avsVMID - ID of the AVS VM +// - options - AvsVMVolumesClientListByAvsVMOptions contains the optional parameters for the AvsVMVolumesClient.NewListByAvsVMPager +// method. +func (client *AvsVMVolumesClient) NewListByAvsVMPager(resourceGroupName string, storagePoolName string, avsVMID string, options *AvsVMVolumesClientListByAvsVMOptions) *runtime.Pager[AvsVMVolumesClientListByAvsVMResponse] { + return runtime.NewPager(runtime.PagingHandler[AvsVMVolumesClientListByAvsVMResponse]{ + More: func(page AvsVMVolumesClientListByAvsVMResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AvsVMVolumesClientListByAvsVMResponse) (AvsVMVolumesClientListByAvsVMResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AvsVMVolumesClient.NewListByAvsVMPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByAvsVMCreateRequest(ctx, resourceGroupName, storagePoolName, avsVMID, options) + }, nil) + if err != nil { + return AvsVMVolumesClientListByAvsVMResponse{}, err + } + return client.listByAvsVMHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByAvsVMCreateRequest creates the ListByAvsVM request. +func (client *AvsVMVolumesClient) listByAvsVMCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, _ *AvsVMVolumesClientListByAvsVMOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsVms/{avsVmId}/avsVmVolumes" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if avsVMID == "" { + return nil, errors.New("parameter avsVMID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{avsVmId}", url.PathEscape(avsVMID)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByAvsVMHandleResponse handles the ListByAvsVM response. +func (client *AvsVMVolumesClient) listByAvsVMHandleResponse(resp *http.Response) (AvsVMVolumesClientListByAvsVMResponse, error) { + result := AvsVMVolumesClientListByAvsVMResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvsVMVolumeListResult); err != nil { + return AvsVMVolumesClientListByAvsVMResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a volume in an AVS VM +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - avsVMID - ID of the AVS VM +// - volumeID - ID of the volume in the AVS VM +// - properties - The resource properties to be updated. +// - options - AvsVMVolumesClientBeginUpdateOptions contains the optional parameters for the AvsVMVolumesClient.BeginUpdate +// method. +func (client *AvsVMVolumesClient) BeginUpdate(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, volumeID string, properties AvsVMVolumeUpdate, options *AvsVMVolumesClientBeginUpdateOptions) (*runtime.Poller[AvsVMVolumesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, storagePoolName, avsVMID, volumeID, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AvsVMVolumesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AvsVMVolumesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a volume in an AVS VM +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *AvsVMVolumesClient) update(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, volumeID string, properties AvsVMVolumeUpdate, options *AvsVMVolumesClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "AvsVMVolumesClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, storagePoolName, avsVMID, volumeID, 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 *AvsVMVolumesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, volumeID string, properties AvsVMVolumeUpdate, _ *AvsVMVolumesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/avsVms/{avsVmId}/avsVmVolumes/{volumeId}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + if avsVMID == "" { + return nil, errors.New("parameter avsVMID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{avsVmId}", url.PathEscape(avsVMID)) + if volumeID == "" { + return nil, errors.New("parameter volumeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeId}", url.PathEscape(volumeID)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsvmvolumes_client_example_test.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsvmvolumes_client_example_test.go new file mode 100644 index 000000000000..c1fcf23bd3bb --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/avsvmvolumes_client_example_test.go @@ -0,0 +1,246 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "log" +) + +// Generated from example definition: 2024-11-01-preview/AvsVmVolumes_Delete_MaximumSet_Gen.json +func ExampleAvsVMVolumesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAvsVMVolumesClient().BeginDelete(ctx, "rgpurestorage", "storagePoolname", "cbdec-ddbb", "cbdec-ddbb", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-11-01-preview/AvsVmVolumes_Get_MaximumSet_Gen.json +func ExampleAvsVMVolumesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAvsVMVolumesClient().Get(ctx, "rgpurestorage", "storagePoolname", "cbdec-ddbb", "cbdec-ddbb", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.AvsVMVolumesClientGetResponse{ + // AvsVMVolume: &armpurestorageblock.AvsVMVolume{ + // Properties: &armpurestorageblock.VolumeProperties{ + // StoragePoolInternalID: to.Ptr("xkcbzbtfhftbnowayannq"), + // StoragePoolResourceID: to.Ptr("mrnioblkjhwry"), + // VolumeInternalID: to.Ptr("ivdmuth"), + // DisplayName: to.Ptr("mcdetkfvt"), + // Space: &armpurestorageblock.Space{ + // TotalUsed: to.Ptr[int64](28), + // Unique: to.Ptr[int64](4), + // Snapshots: to.Ptr[int64](5), + // Shared: to.Ptr[int64](9), + // }, + // SoftDeletion: &armpurestorageblock.SoftDeletion{ + // Destroyed: to.Ptr(true), + // EradicationTimestamp: to.Ptr("kaxjtehra"), + // }, + // CreatedTimestamp: to.Ptr("pwhsjhrcszrhsmzc"), + // ProvisionedSize: to.Ptr[int64](14), + // VolumeType: to.Ptr(armpurestorageblock.VolumeTypeAVS), + // Avs: &armpurestorageblock.AvsDiskDetails{ + // DiskID: to.Ptr("egehzvidnjgevc"), + // DiskName: to.Ptr("gqpqpkxjyj"), + // Folder: to.Ptr("oxdbbh"), + // AvsVMInternalID: to.Ptr("xoiliugbcvkhdl"), + // AvsVMResourceID: to.Ptr("jblyybyfhtikdhwx"), + // AvsVMName: to.Ptr("gaeydwwisfuonbuwtnkdk"), + // AvsStorageContainerResourceID: to.Ptr("svwilhkpx"), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("hnglbdwyocdmggwii"), + // Type: to.Ptr("jprfxakifyliuzougfctzpfhozq"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-11-01-preview/AvsVmVolumes_ListByAvsVm_MaximumSet_Gen.json +func ExampleAvsVMVolumesClient_NewListByAvsVMPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAvsVMVolumesClient().NewListByAvsVMPager("rgpurestorage", "storagePoolname", "cbdec-ddbb", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armpurestorageblock.AvsVMVolumesClientListByAvsVMResponse{ + // AvsVMVolumeListResult: armpurestorageblock.AvsVMVolumeListResult{ + // Value: []*armpurestorageblock.AvsVMVolume{ + // { + // Properties: &armpurestorageblock.VolumeProperties{ + // StoragePoolInternalID: to.Ptr("xkcbzbtfhftbnowayannq"), + // StoragePoolResourceID: to.Ptr("mrnioblkjhwry"), + // VolumeInternalID: to.Ptr("ivdmuth"), + // DisplayName: to.Ptr("mcdetkfvt"), + // Space: &armpurestorageblock.Space{ + // TotalUsed: to.Ptr[int64](28), + // Unique: to.Ptr[int64](4), + // Snapshots: to.Ptr[int64](5), + // Shared: to.Ptr[int64](9), + // }, + // SoftDeletion: &armpurestorageblock.SoftDeletion{ + // Destroyed: to.Ptr(true), + // EradicationTimestamp: to.Ptr("kaxjtehra"), + // }, + // CreatedTimestamp: to.Ptr("pwhsjhrcszrhsmzc"), + // ProvisionedSize: to.Ptr[int64](14), + // VolumeType: to.Ptr(armpurestorageblock.VolumeTypeAVS), + // Avs: &armpurestorageblock.AvsDiskDetails{ + // DiskID: to.Ptr("egehzvidnjgevc"), + // DiskName: to.Ptr("gqpqpkxjyj"), + // Folder: to.Ptr("oxdbbh"), + // AvsVMInternalID: to.Ptr("xoiliugbcvkhdl"), + // AvsVMResourceID: to.Ptr("jblyybyfhtikdhwx"), + // AvsVMName: to.Ptr("gaeydwwisfuonbuwtnkdk"), + // AvsStorageContainerResourceID: to.Ptr("svwilhkpx"), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("hnglbdwyocdmggwii"), + // Type: to.Ptr("jprfxakifyliuzougfctzpfhozq"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/aqekkjck"), + // }, + // } + } +} + +// Generated from example definition: 2024-11-01-preview/AvsVmVolumes_Update_MaximumSet_Gen.json +func ExampleAvsVMVolumesClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAvsVMVolumesClient().BeginUpdate(ctx, "rgpurestorage", "storagePoolname", "cbdec-ddbb", "cbdec-ddbb", armpurestorageblock.AvsVMVolumeUpdate{ + Properties: &armpurestorageblock.AvsVMVolumeUpdateProperties{ + SoftDeletion: &armpurestorageblock.SoftDeletion{ + Destroyed: to.Ptr(true), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.AvsVMVolumesClientUpdateResponse{ + // AvsVMVolume: &armpurestorageblock.AvsVMVolume{ + // Properties: &armpurestorageblock.VolumeProperties{ + // StoragePoolInternalID: to.Ptr("xkcbzbtfhftbnowayannq"), + // StoragePoolResourceID: to.Ptr("mrnioblkjhwry"), + // VolumeInternalID: to.Ptr("ivdmuth"), + // DisplayName: to.Ptr("mcdetkfvt"), + // Space: &armpurestorageblock.Space{ + // TotalUsed: to.Ptr[int64](28), + // Unique: to.Ptr[int64](4), + // Snapshots: to.Ptr[int64](5), + // Shared: to.Ptr[int64](9), + // }, + // SoftDeletion: &armpurestorageblock.SoftDeletion{ + // Destroyed: to.Ptr(true), + // EradicationTimestamp: to.Ptr("kaxjtehra"), + // }, + // CreatedTimestamp: to.Ptr("pwhsjhrcszrhsmzc"), + // ProvisionedSize: to.Ptr[int64](14), + // VolumeType: to.Ptr(armpurestorageblock.VolumeTypeAVS), + // Avs: &armpurestorageblock.AvsDiskDetails{ + // DiskID: to.Ptr("egehzvidnjgevc"), + // DiskName: to.Ptr("gqpqpkxjyj"), + // Folder: to.Ptr("oxdbbh"), + // AvsVMInternalID: to.Ptr("xoiliugbcvkhdl"), + // AvsVMResourceID: to.Ptr("jblyybyfhtikdhwx"), + // AvsVMName: to.Ptr("gaeydwwisfuonbuwtnkdk"), + // AvsStorageContainerResourceID: to.Ptr("svwilhkpx"), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("hnglbdwyocdmggwii"), + // Type: to.Ptr("jprfxakifyliuzougfctzpfhozq"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/ci.yml b/sdk/resourcemanager/purestorageblock/armpurestorageblock/ci.yml new file mode 100644 index 000000000000..a534696d5ead --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/purestorageblock/armpurestorageblock/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/purestorageblock/armpurestorageblock/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/purestorageblock/armpurestorageblock' diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/client_factory.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/client_factory.go new file mode 100644 index 000000000000..598c72dc9cce --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/client_factory.go @@ -0,0 +1,88 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +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 + internal *arm.Client +} + +// 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. The value must be an UUID. +// - 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) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewAvsStorageContainerVolumesClient creates a new instance of AvsStorageContainerVolumesClient. +func (c *ClientFactory) NewAvsStorageContainerVolumesClient() *AvsStorageContainerVolumesClient { + return &AvsStorageContainerVolumesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewAvsStorageContainersClient creates a new instance of AvsStorageContainersClient. +func (c *ClientFactory) NewAvsStorageContainersClient() *AvsStorageContainersClient { + return &AvsStorageContainersClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewAvsVMVolumesClient creates a new instance of AvsVMVolumesClient. +func (c *ClientFactory) NewAvsVMVolumesClient() *AvsVMVolumesClient { + return &AvsVMVolumesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewAvsVMsClient creates a new instance of AvsVMsClient. +func (c *ClientFactory) NewAvsVMsClient() *AvsVMsClient { + return &AvsVMsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} + +// NewReservationsClient creates a new instance of ReservationsClient. +func (c *ClientFactory) NewReservationsClient() *ReservationsClient { + return &ReservationsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewStoragePoolsClient creates a new instance of StoragePoolsClient. +func (c *ClientFactory) NewStoragePoolsClient() *StoragePoolsClient { + return &StoragePoolsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/constants.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/constants.go new file mode 100644 index 000000000000..d7e67b0a8d54 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/constants.go @@ -0,0 +1,257 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + moduleVersion = "v0.1.0" +) + +// ActionType - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + // ActionTypeInternal - Actions are for internal-only APIs. + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// AlertLevel - Severity level of the alert +type AlertLevel string + +const ( + // AlertLevelError - Error level + AlertLevelError AlertLevel = "error" + // AlertLevelInfo - Information level + AlertLevelInfo AlertLevel = "info" + // AlertLevelWarning - Warning level + AlertLevelWarning AlertLevel = "warning" +) + +// PossibleAlertLevelValues returns the possible values for the AlertLevel const type. +func PossibleAlertLevelValues() []AlertLevel { + return []AlertLevel{ + AlertLevelError, + AlertLevelInfo, + AlertLevelWarning, + } +} + +// CreatedByType - The kind of entity that created the resource. +type CreatedByType string + +const ( + // CreatedByTypeApplication - The entity was created by an application. + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey - The entity was created by a key. + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity - The entity was created by a managed identity. + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser - The entity was created by a user. + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// ManagedServiceIdentityType - Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). +type ManagedServiceIdentityType string + +const ( + // ManagedServiceIdentityTypeNone - No managed identity. + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + // ManagedServiceIdentityTypeSystemAssigned - System assigned managed identity. + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + // ManagedServiceIdentityTypeSystemAssignedUserAssigned - System and user assigned managed identity. + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" + // ManagedServiceIdentityTypeUserAssigned - User assigned managed identity. + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ + ManagedServiceIdentityTypeNone, + ManagedServiceIdentityTypeSystemAssigned, + ManagedServiceIdentityTypeSystemAssignedUserAssigned, + ManagedServiceIdentityTypeUserAssigned, + } +} + +// MarketplaceSubscriptionStatus - Marketplace subscription status +type MarketplaceSubscriptionStatus string + +const ( + // MarketplaceSubscriptionStatusPendingFulfillmentStart - Marketplace subscription purchased but not yet activated + MarketplaceSubscriptionStatusPendingFulfillmentStart MarketplaceSubscriptionStatus = "PendingFulfillmentStart" + // MarketplaceSubscriptionStatusSubscribed - Marketplace subscription activated + MarketplaceSubscriptionStatusSubscribed MarketplaceSubscriptionStatus = "Subscribed" + // MarketplaceSubscriptionStatusSuspended - Marketplace subscription suspended due to missing customer payment + MarketplaceSubscriptionStatusSuspended MarketplaceSubscriptionStatus = "Suspended" + // MarketplaceSubscriptionStatusUnsubscribed - Marketplace subscription cancelled + MarketplaceSubscriptionStatusUnsubscribed MarketplaceSubscriptionStatus = "Unsubscribed" +) + +// PossibleMarketplaceSubscriptionStatusValues returns the possible values for the MarketplaceSubscriptionStatus const type. +func PossibleMarketplaceSubscriptionStatusValues() []MarketplaceSubscriptionStatus { + return []MarketplaceSubscriptionStatus{ + MarketplaceSubscriptionStatusPendingFulfillmentStart, + MarketplaceSubscriptionStatusSubscribed, + MarketplaceSubscriptionStatusSuspended, + MarketplaceSubscriptionStatusUnsubscribed, + } +} + +// 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 - Indicates the operation is initiated by a system. + OriginSystem Origin = "system" + // OriginUser - Indicates the operation is initiated by a user. + OriginUser Origin = "user" + // OriginUserSystem - Indicates the operation is initiated by a user or system. + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ProvisioningState - The status of the current operation. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted - Change accepted for processing + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - Deletion in progress + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateSucceeded - Resource has been created. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + } +} + +// ResourceProvisioningState - The provisioning state of a resource type. +type ResourceProvisioningState string + +const ( + // ResourceProvisioningStateCanceled - Resource creation was canceled. + ResourceProvisioningStateCanceled ResourceProvisioningState = "Canceled" + // ResourceProvisioningStateFailed - Resource creation failed. + ResourceProvisioningStateFailed ResourceProvisioningState = "Failed" + // ResourceProvisioningStateSucceeded - Resource has been created. + ResourceProvisioningStateSucceeded ResourceProvisioningState = "Succeeded" +) + +// PossibleResourceProvisioningStateValues returns the possible values for the ResourceProvisioningState const type. +func PossibleResourceProvisioningStateValues() []ResourceProvisioningState { + return []ResourceProvisioningState{ + ResourceProvisioningStateCanceled, + ResourceProvisioningStateFailed, + ResourceProvisioningStateSucceeded, + } +} + +// UsageSeverity - Severity levels for billing usage properties +type UsageSeverity string + +const ( + // UsageSeverityALERT - Indicates an alert condition + UsageSeverityALERT UsageSeverity = "alert" + // UsageSeverityINFORMATION - Provides informational details + UsageSeverityINFORMATION UsageSeverity = "information" + // UsageSeverityNONE - Indicates no severity + UsageSeverityNONE UsageSeverity = "none" + // UsageSeverityWARNING - Indicates a warning condition + UsageSeverityWARNING UsageSeverity = "warning" +) + +// PossibleUsageSeverityValues returns the possible values for the UsageSeverity const type. +func PossibleUsageSeverityValues() []UsageSeverity { + return []UsageSeverity{ + UsageSeverityALERT, + UsageSeverityINFORMATION, + UsageSeverityNONE, + UsageSeverityWARNING, + } +} + +// VMType - AVS VM storage types +type VMType string + +const ( + // VMTypeVVol - VM using vVols as underlying storage + VMTypeVVol VMType = "vvol" +) + +// PossibleVMTypeValues returns the possible values for the VMType const type. +func PossibleVMTypeValues() []VMType { + return []VMType{ + VMTypeVVol, + } +} + +// VolumeContainerType - Specify which control plane handles the lifecycle of the volume container +type VolumeContainerType string + +const ( + // VolumeContainerTypeAVS - AVS/VMware + VolumeContainerTypeAVS VolumeContainerType = "avs" +) + +// PossibleVolumeContainerTypeValues returns the possible values for the VolumeContainerType const type. +func PossibleVolumeContainerTypeValues() []VolumeContainerType { + return []VolumeContainerType{ + VolumeContainerTypeAVS, + } +} + +// VolumeType - Specify which control plane handles the lifecycle of the volume +type VolumeType string + +const ( + // VolumeTypeAVS - AVS/VMware + VolumeTypeAVS VolumeType = "avs" +) + +// PossibleVolumeTypeValues returns the possible values for the VolumeType const type. +func PossibleVolumeTypeValues() []VolumeType { + return []VolumeType{ + VolumeTypeAVS, + } +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/avsstoragecontainers_server.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/avsstoragecontainers_server.go new file mode 100644 index 000000000000..46351060244a --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/avsstoragecontainers_server.go @@ -0,0 +1,233 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "net/http" + "net/url" + "regexp" +) + +// AvsStorageContainersServer is a fake server for instances of the armpurestorageblock.AvsStorageContainersClient type. +type AvsStorageContainersServer struct { + // BeginDelete is the fake for method AvsStorageContainersClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, options *armpurestorageblock.AvsStorageContainersClientBeginDeleteOptions) (resp azfake.PollerResponder[armpurestorageblock.AvsStorageContainersClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method AvsStorageContainersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, options *armpurestorageblock.AvsStorageContainersClientGetOptions) (resp azfake.Responder[armpurestorageblock.AvsStorageContainersClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByStoragePoolPager is the fake for method AvsStorageContainersClient.NewListByStoragePoolPager + // HTTP status codes to indicate success: http.StatusOK + NewListByStoragePoolPager func(resourceGroupName string, storagePoolName string, options *armpurestorageblock.AvsStorageContainersClientListByStoragePoolOptions) (resp azfake.PagerResponder[armpurestorageblock.AvsStorageContainersClientListByStoragePoolResponse]) +} + +// NewAvsStorageContainersServerTransport creates a new instance of AvsStorageContainersServerTransport with the provided implementation. +// The returned AvsStorageContainersServerTransport instance is connected to an instance of armpurestorageblock.AvsStorageContainersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAvsStorageContainersServerTransport(srv *AvsStorageContainersServer) *AvsStorageContainersServerTransport { + return &AvsStorageContainersServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armpurestorageblock.AvsStorageContainersClientDeleteResponse]](), + newListByStoragePoolPager: newTracker[azfake.PagerResponder[armpurestorageblock.AvsStorageContainersClientListByStoragePoolResponse]](), + } +} + +// AvsStorageContainersServerTransport connects instances of armpurestorageblock.AvsStorageContainersClient to instances of AvsStorageContainersServer. +// Don't use this type directly, use NewAvsStorageContainersServerTransport instead. +type AvsStorageContainersServerTransport struct { + srv *AvsStorageContainersServer + beginDelete *tracker[azfake.PollerResponder[armpurestorageblock.AvsStorageContainersClientDeleteResponse]] + newListByStoragePoolPager *tracker[azfake.PagerResponder[armpurestorageblock.AvsStorageContainersClientListByStoragePoolResponse]] +} + +// Do implements the policy.Transporter interface for AvsStorageContainersServerTransport. +func (a *AvsStorageContainersServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return a.dispatchToMethodFake(req, method) +} + +func (a *AvsStorageContainersServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if avsStorageContainersServerTransportInterceptor != nil { + res.resp, res.err, intercepted = avsStorageContainersServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AvsStorageContainersClient.BeginDelete": + res.resp, res.err = a.dispatchBeginDelete(req) + case "AvsStorageContainersClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "AvsStorageContainersClient.NewListByStoragePoolPager": + res.resp, res.err = a.dispatchNewListByStoragePoolPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (a *AvsStorageContainersServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if a.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := a.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsStorageContainers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + storageContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storageContainerName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameParam, storagePoolNameParam, storageContainerNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + a.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + a.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + a.beginDelete.remove(req) + } + + return resp, nil +} + +func (a *AvsStorageContainersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsStorageContainers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + storageContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storageContainerName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, storagePoolNameParam, storageContainerNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AvsStorageContainer, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AvsStorageContainersServerTransport) dispatchNewListByStoragePoolPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByStoragePoolPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByStoragePoolPager not implemented")} + } + newListByStoragePoolPager := a.newListByStoragePoolPager.get(req) + if newListByStoragePoolPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsStorageContainers` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByStoragePoolPager(resourceGroupNameParam, storagePoolNameParam, nil) + newListByStoragePoolPager = &resp + a.newListByStoragePoolPager.add(req, newListByStoragePoolPager) + server.PagerResponderInjectNextLinks(newListByStoragePoolPager, req, func(page *armpurestorageblock.AvsStorageContainersClientListByStoragePoolResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByStoragePoolPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByStoragePoolPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByStoragePoolPager) { + a.newListByStoragePoolPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to AvsStorageContainersServerTransport +var avsStorageContainersServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/avsstoragecontainervolumes_server.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/avsstoragecontainervolumes_server.go new file mode 100644 index 000000000000..21b71b2b902f --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/avsstoragecontainervolumes_server.go @@ -0,0 +1,309 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "net/http" + "net/url" + "regexp" +) + +// AvsStorageContainerVolumesServer is a fake server for instances of the armpurestorageblock.AvsStorageContainerVolumesClient type. +type AvsStorageContainerVolumesServer struct { + // BeginDelete is the fake for method AvsStorageContainerVolumesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, volumeID string, options *armpurestorageblock.AvsStorageContainerVolumesClientBeginDeleteOptions) (resp azfake.PollerResponder[armpurestorageblock.AvsStorageContainerVolumesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method AvsStorageContainerVolumesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, volumeID string, options *armpurestorageblock.AvsStorageContainerVolumesClientGetOptions) (resp azfake.Responder[armpurestorageblock.AvsStorageContainerVolumesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByAvsStorageContainerPager is the fake for method AvsStorageContainerVolumesClient.NewListByAvsStorageContainerPager + // HTTP status codes to indicate success: http.StatusOK + NewListByAvsStorageContainerPager func(resourceGroupName string, storagePoolName string, storageContainerName string, options *armpurestorageblock.AvsStorageContainerVolumesClientListByAvsStorageContainerOptions) (resp azfake.PagerResponder[armpurestorageblock.AvsStorageContainerVolumesClientListByAvsStorageContainerResponse]) + + // BeginUpdate is the fake for method AvsStorageContainerVolumesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, storagePoolName string, storageContainerName string, volumeID string, properties armpurestorageblock.AvsStorageContainerVolumeUpdate, options *armpurestorageblock.AvsStorageContainerVolumesClientBeginUpdateOptions) (resp azfake.PollerResponder[armpurestorageblock.AvsStorageContainerVolumesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewAvsStorageContainerVolumesServerTransport creates a new instance of AvsStorageContainerVolumesServerTransport with the provided implementation. +// The returned AvsStorageContainerVolumesServerTransport instance is connected to an instance of armpurestorageblock.AvsStorageContainerVolumesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAvsStorageContainerVolumesServerTransport(srv *AvsStorageContainerVolumesServer) *AvsStorageContainerVolumesServerTransport { + return &AvsStorageContainerVolumesServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armpurestorageblock.AvsStorageContainerVolumesClientDeleteResponse]](), + newListByAvsStorageContainerPager: newTracker[azfake.PagerResponder[armpurestorageblock.AvsStorageContainerVolumesClientListByAvsStorageContainerResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armpurestorageblock.AvsStorageContainerVolumesClientUpdateResponse]](), + } +} + +// AvsStorageContainerVolumesServerTransport connects instances of armpurestorageblock.AvsStorageContainerVolumesClient to instances of AvsStorageContainerVolumesServer. +// Don't use this type directly, use NewAvsStorageContainerVolumesServerTransport instead. +type AvsStorageContainerVolumesServerTransport struct { + srv *AvsStorageContainerVolumesServer + beginDelete *tracker[azfake.PollerResponder[armpurestorageblock.AvsStorageContainerVolumesClientDeleteResponse]] + newListByAvsStorageContainerPager *tracker[azfake.PagerResponder[armpurestorageblock.AvsStorageContainerVolumesClientListByAvsStorageContainerResponse]] + beginUpdate *tracker[azfake.PollerResponder[armpurestorageblock.AvsStorageContainerVolumesClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for AvsStorageContainerVolumesServerTransport. +func (a *AvsStorageContainerVolumesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return a.dispatchToMethodFake(req, method) +} + +func (a *AvsStorageContainerVolumesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if avsStorageContainerVolumesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = avsStorageContainerVolumesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AvsStorageContainerVolumesClient.BeginDelete": + res.resp, res.err = a.dispatchBeginDelete(req) + case "AvsStorageContainerVolumesClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "AvsStorageContainerVolumesClient.NewListByAvsStorageContainerPager": + res.resp, res.err = a.dispatchNewListByAvsStorageContainerPager(req) + case "AvsStorageContainerVolumesClient.BeginUpdate": + res.resp, res.err = a.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (a *AvsStorageContainerVolumesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if a.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := a.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsStorageContainers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/volumes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + storageContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storageContainerName")]) + if err != nil { + return nil, err + } + volumeIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("volumeId")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameParam, storagePoolNameParam, storageContainerNameParam, volumeIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + a.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + a.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + a.beginDelete.remove(req) + } + + return resp, nil +} + +func (a *AvsStorageContainerVolumesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsStorageContainers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/volumes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + storageContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storageContainerName")]) + if err != nil { + return nil, err + } + volumeIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("volumeId")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, storagePoolNameParam, storageContainerNameParam, volumeIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AvsStorageContainerVolume, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AvsStorageContainerVolumesServerTransport) dispatchNewListByAvsStorageContainerPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByAvsStorageContainerPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByAvsStorageContainerPager not implemented")} + } + newListByAvsStorageContainerPager := a.newListByAvsStorageContainerPager.get(req) + if newListByAvsStorageContainerPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsStorageContainers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/volumes` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + storageContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storageContainerName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByAvsStorageContainerPager(resourceGroupNameParam, storagePoolNameParam, storageContainerNameParam, nil) + newListByAvsStorageContainerPager = &resp + a.newListByAvsStorageContainerPager.add(req, newListByAvsStorageContainerPager) + server.PagerResponderInjectNextLinks(newListByAvsStorageContainerPager, req, func(page *armpurestorageblock.AvsStorageContainerVolumesClientListByAvsStorageContainerResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByAvsStorageContainerPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByAvsStorageContainerPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByAvsStorageContainerPager) { + a.newListByAvsStorageContainerPager.remove(req) + } + return resp, nil +} + +func (a *AvsStorageContainerVolumesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if a.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := a.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsStorageContainers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/volumes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpurestorageblock.AvsStorageContainerVolumeUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + storageContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storageContainerName")]) + if err != nil { + return nil, err + } + volumeIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("volumeId")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginUpdate(req.Context(), resourceGroupNameParam, storagePoolNameParam, storageContainerNameParam, volumeIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + a.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + a.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + a.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to AvsStorageContainerVolumesServerTransport +var avsStorageContainerVolumesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/avsvms_server.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/avsvms_server.go new file mode 100644 index 000000000000..c58a461b6879 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/avsvms_server.go @@ -0,0 +1,293 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "net/http" + "net/url" + "regexp" +) + +// AvsVMsServer is a fake server for instances of the armpurestorageblock.AvsVMsClient type. +type AvsVMsServer struct { + // BeginDelete is the fake for method AvsVMsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, options *armpurestorageblock.AvsVMsClientBeginDeleteOptions) (resp azfake.PollerResponder[armpurestorageblock.AvsVMsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method AvsVMsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, options *armpurestorageblock.AvsVMsClientGetOptions) (resp azfake.Responder[armpurestorageblock.AvsVMsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByStoragePoolPager is the fake for method AvsVMsClient.NewListByStoragePoolPager + // HTTP status codes to indicate success: http.StatusOK + NewListByStoragePoolPager func(resourceGroupName string, storagePoolName string, options *armpurestorageblock.AvsVMsClientListByStoragePoolOptions) (resp azfake.PagerResponder[armpurestorageblock.AvsVMsClientListByStoragePoolResponse]) + + // BeginUpdate is the fake for method AvsVMsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, properties armpurestorageblock.AvsVMUpdate, options *armpurestorageblock.AvsVMsClientBeginUpdateOptions) (resp azfake.PollerResponder[armpurestorageblock.AvsVMsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewAvsVMsServerTransport creates a new instance of AvsVMsServerTransport with the provided implementation. +// The returned AvsVMsServerTransport instance is connected to an instance of armpurestorageblock.AvsVMsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAvsVMsServerTransport(srv *AvsVMsServer) *AvsVMsServerTransport { + return &AvsVMsServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armpurestorageblock.AvsVMsClientDeleteResponse]](), + newListByStoragePoolPager: newTracker[azfake.PagerResponder[armpurestorageblock.AvsVMsClientListByStoragePoolResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armpurestorageblock.AvsVMsClientUpdateResponse]](), + } +} + +// AvsVMsServerTransport connects instances of armpurestorageblock.AvsVMsClient to instances of AvsVMsServer. +// Don't use this type directly, use NewAvsVMsServerTransport instead. +type AvsVMsServerTransport struct { + srv *AvsVMsServer + beginDelete *tracker[azfake.PollerResponder[armpurestorageblock.AvsVMsClientDeleteResponse]] + newListByStoragePoolPager *tracker[azfake.PagerResponder[armpurestorageblock.AvsVMsClientListByStoragePoolResponse]] + beginUpdate *tracker[azfake.PollerResponder[armpurestorageblock.AvsVMsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for AvsVMsServerTransport. +func (a *AvsVMsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return a.dispatchToMethodFake(req, method) +} + +func (a *AvsVMsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if avsVMSServerTransportInterceptor != nil { + res.resp, res.err, intercepted = avsVMSServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AvsVMsClient.BeginDelete": + res.resp, res.err = a.dispatchBeginDelete(req) + case "AvsVMsClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "AvsVMsClient.NewListByStoragePoolPager": + res.resp, res.err = a.dispatchNewListByStoragePoolPager(req) + case "AvsVMsClient.BeginUpdate": + res.resp, res.err = a.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (a *AvsVMsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if a.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := a.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsVms/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + avsVMIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("avsVmId")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameParam, storagePoolNameParam, avsVMIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + a.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + a.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + a.beginDelete.remove(req) + } + + return resp, nil +} + +func (a *AvsVMsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsVms/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + avsVMIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("avsVmId")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, storagePoolNameParam, avsVMIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AvsVM, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AvsVMsServerTransport) dispatchNewListByStoragePoolPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByStoragePoolPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByStoragePoolPager not implemented")} + } + newListByStoragePoolPager := a.newListByStoragePoolPager.get(req) + if newListByStoragePoolPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsVms` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByStoragePoolPager(resourceGroupNameParam, storagePoolNameParam, nil) + newListByStoragePoolPager = &resp + a.newListByStoragePoolPager.add(req, newListByStoragePoolPager) + server.PagerResponderInjectNextLinks(newListByStoragePoolPager, req, func(page *armpurestorageblock.AvsVMsClientListByStoragePoolResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByStoragePoolPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByStoragePoolPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByStoragePoolPager) { + a.newListByStoragePoolPager.remove(req) + } + return resp, nil +} + +func (a *AvsVMsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if a.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := a.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsVms/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpurestorageblock.AvsVMUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + avsVMIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("avsVmId")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginUpdate(req.Context(), resourceGroupNameParam, storagePoolNameParam, avsVMIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + a.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + a.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + a.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to AvsVMsServerTransport +var avsVMSServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/avsvmvolumes_server.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/avsvmvolumes_server.go new file mode 100644 index 000000000000..8f566536197b --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/avsvmvolumes_server.go @@ -0,0 +1,309 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "net/http" + "net/url" + "regexp" +) + +// AvsVMVolumesServer is a fake server for instances of the armpurestorageblock.AvsVMVolumesClient type. +type AvsVMVolumesServer struct { + // BeginDelete is the fake for method AvsVMVolumesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, volumeID string, options *armpurestorageblock.AvsVMVolumesClientBeginDeleteOptions) (resp azfake.PollerResponder[armpurestorageblock.AvsVMVolumesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method AvsVMVolumesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, volumeID string, options *armpurestorageblock.AvsVMVolumesClientGetOptions) (resp azfake.Responder[armpurestorageblock.AvsVMVolumesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByAvsVMPager is the fake for method AvsVMVolumesClient.NewListByAvsVMPager + // HTTP status codes to indicate success: http.StatusOK + NewListByAvsVMPager func(resourceGroupName string, storagePoolName string, avsVMID string, options *armpurestorageblock.AvsVMVolumesClientListByAvsVMOptions) (resp azfake.PagerResponder[armpurestorageblock.AvsVMVolumesClientListByAvsVMResponse]) + + // BeginUpdate is the fake for method AvsVMVolumesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, storagePoolName string, avsVMID string, volumeID string, properties armpurestorageblock.AvsVMVolumeUpdate, options *armpurestorageblock.AvsVMVolumesClientBeginUpdateOptions) (resp azfake.PollerResponder[armpurestorageblock.AvsVMVolumesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewAvsVMVolumesServerTransport creates a new instance of AvsVMVolumesServerTransport with the provided implementation. +// The returned AvsVMVolumesServerTransport instance is connected to an instance of armpurestorageblock.AvsVMVolumesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAvsVMVolumesServerTransport(srv *AvsVMVolumesServer) *AvsVMVolumesServerTransport { + return &AvsVMVolumesServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armpurestorageblock.AvsVMVolumesClientDeleteResponse]](), + newListByAvsVMPager: newTracker[azfake.PagerResponder[armpurestorageblock.AvsVMVolumesClientListByAvsVMResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armpurestorageblock.AvsVMVolumesClientUpdateResponse]](), + } +} + +// AvsVMVolumesServerTransport connects instances of armpurestorageblock.AvsVMVolumesClient to instances of AvsVMVolumesServer. +// Don't use this type directly, use NewAvsVMVolumesServerTransport instead. +type AvsVMVolumesServerTransport struct { + srv *AvsVMVolumesServer + beginDelete *tracker[azfake.PollerResponder[armpurestorageblock.AvsVMVolumesClientDeleteResponse]] + newListByAvsVMPager *tracker[azfake.PagerResponder[armpurestorageblock.AvsVMVolumesClientListByAvsVMResponse]] + beginUpdate *tracker[azfake.PollerResponder[armpurestorageblock.AvsVMVolumesClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for AvsVMVolumesServerTransport. +func (a *AvsVMVolumesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return a.dispatchToMethodFake(req, method) +} + +func (a *AvsVMVolumesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if avsVMVolumesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = avsVMVolumesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AvsVMVolumesClient.BeginDelete": + res.resp, res.err = a.dispatchBeginDelete(req) + case "AvsVMVolumesClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "AvsVMVolumesClient.NewListByAvsVMPager": + res.resp, res.err = a.dispatchNewListByAvsVMPager(req) + case "AvsVMVolumesClient.BeginUpdate": + res.resp, res.err = a.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (a *AvsVMVolumesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if a.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := a.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsVms/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsVmVolumes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + avsVMIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("avsVmId")]) + if err != nil { + return nil, err + } + volumeIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("volumeId")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameParam, storagePoolNameParam, avsVMIDParam, volumeIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + a.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + a.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + a.beginDelete.remove(req) + } + + return resp, nil +} + +func (a *AvsVMVolumesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsVms/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsVmVolumes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + avsVMIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("avsVmId")]) + if err != nil { + return nil, err + } + volumeIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("volumeId")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, storagePoolNameParam, avsVMIDParam, volumeIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AvsVMVolume, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AvsVMVolumesServerTransport) dispatchNewListByAvsVMPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByAvsVMPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByAvsVMPager not implemented")} + } + newListByAvsVMPager := a.newListByAvsVMPager.get(req) + if newListByAvsVMPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsVms/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsVmVolumes` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + avsVMIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("avsVmId")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByAvsVMPager(resourceGroupNameParam, storagePoolNameParam, avsVMIDParam, nil) + newListByAvsVMPager = &resp + a.newListByAvsVMPager.add(req, newListByAvsVMPager) + server.PagerResponderInjectNextLinks(newListByAvsVMPager, req, func(page *armpurestorageblock.AvsVMVolumesClientListByAvsVMResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByAvsVMPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByAvsVMPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByAvsVMPager) { + a.newListByAvsVMPager.remove(req) + } + return resp, nil +} + +func (a *AvsVMVolumesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if a.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := a.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsVms/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/avsVmVolumes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpurestorageblock.AvsVMVolumeUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + avsVMIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("avsVmId")]) + if err != nil { + return nil, err + } + volumeIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("volumeId")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginUpdate(req.Context(), resourceGroupNameParam, storagePoolNameParam, avsVMIDParam, volumeIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + a.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + a.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + a.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to AvsVMVolumesServerTransport +var avsVMVolumesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/internal.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/internal.go new file mode 100644 index 000000000000..7425b6a669e2 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/internal.go @@ -0,0 +1,65 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +type result struct { + resp *http.Response + err error +} + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/operations_server.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/operations_server.go new file mode 100644 index 000000000000..bc10261f70b6 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/operations_server.go @@ -0,0 +1,117 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "net/http" +) + +// OperationsServer is a fake server for instances of the armpurestorageblock.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armpurestorageblock.OperationsClientListOptions) (resp azfake.PagerResponder[armpurestorageblock.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armpurestorageblock.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armpurestorageblock.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armpurestorageblock.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armpurestorageblock.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return o.dispatchToMethodFake(req, method) +} + +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpurestorageblock.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/reservations_server.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/reservations_server.go new file mode 100644 index 000000000000..3c62d1779217 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/reservations_server.go @@ -0,0 +1,491 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "net/http" + "net/url" + "regexp" +) + +// ReservationsServer is a fake server for instances of the armpurestorageblock.ReservationsClient type. +type ReservationsServer struct { + // BeginCreate is the fake for method ReservationsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, reservationName string, resource armpurestorageblock.Reservation, options *armpurestorageblock.ReservationsClientBeginCreateOptions) (resp azfake.PollerResponder[armpurestorageblock.ReservationsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ReservationsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, reservationName string, options *armpurestorageblock.ReservationsClientBeginDeleteOptions) (resp azfake.PollerResponder[armpurestorageblock.ReservationsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ReservationsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, reservationName string, options *armpurestorageblock.ReservationsClientGetOptions) (resp azfake.Responder[armpurestorageblock.ReservationsClientGetResponse], errResp azfake.ErrorResponder) + + // GetBillingReport is the fake for method ReservationsClient.GetBillingReport + // HTTP status codes to indicate success: http.StatusOK + GetBillingReport func(ctx context.Context, resourceGroupName string, reservationName string, options *armpurestorageblock.ReservationsClientGetBillingReportOptions) (resp azfake.Responder[armpurestorageblock.ReservationsClientGetBillingReportResponse], errResp azfake.ErrorResponder) + + // GetBillingStatus is the fake for method ReservationsClient.GetBillingStatus + // HTTP status codes to indicate success: http.StatusOK + GetBillingStatus func(ctx context.Context, resourceGroupName string, reservationName string, options *armpurestorageblock.ReservationsClientGetBillingStatusOptions) (resp azfake.Responder[armpurestorageblock.ReservationsClientGetBillingStatusResponse], errResp azfake.ErrorResponder) + + // GetResourceLimits is the fake for method ReservationsClient.GetResourceLimits + // HTTP status codes to indicate success: http.StatusOK + GetResourceLimits func(ctx context.Context, resourceGroupName string, reservationName string, options *armpurestorageblock.ReservationsClientGetResourceLimitsOptions) (resp azfake.Responder[armpurestorageblock.ReservationsClientGetResourceLimitsResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method ReservationsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armpurestorageblock.ReservationsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armpurestorageblock.ReservationsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method ReservationsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armpurestorageblock.ReservationsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armpurestorageblock.ReservationsClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method ReservationsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, reservationName string, properties armpurestorageblock.ReservationUpdate, options *armpurestorageblock.ReservationsClientBeginUpdateOptions) (resp azfake.PollerResponder[armpurestorageblock.ReservationsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewReservationsServerTransport creates a new instance of ReservationsServerTransport with the provided implementation. +// The returned ReservationsServerTransport instance is connected to an instance of armpurestorageblock.ReservationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewReservationsServerTransport(srv *ReservationsServer) *ReservationsServerTransport { + return &ReservationsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armpurestorageblock.ReservationsClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armpurestorageblock.ReservationsClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armpurestorageblock.ReservationsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armpurestorageblock.ReservationsClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armpurestorageblock.ReservationsClientUpdateResponse]](), + } +} + +// ReservationsServerTransport connects instances of armpurestorageblock.ReservationsClient to instances of ReservationsServer. +// Don't use this type directly, use NewReservationsServerTransport instead. +type ReservationsServerTransport struct { + srv *ReservationsServer + beginCreate *tracker[azfake.PollerResponder[armpurestorageblock.ReservationsClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armpurestorageblock.ReservationsClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armpurestorageblock.ReservationsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armpurestorageblock.ReservationsClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armpurestorageblock.ReservationsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for ReservationsServerTransport. +func (r *ReservationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return r.dispatchToMethodFake(req, method) +} + +func (r *ReservationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if reservationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = reservationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ReservationsClient.BeginCreate": + res.resp, res.err = r.dispatchBeginCreate(req) + case "ReservationsClient.BeginDelete": + res.resp, res.err = r.dispatchBeginDelete(req) + case "ReservationsClient.Get": + res.resp, res.err = r.dispatchGet(req) + case "ReservationsClient.GetBillingReport": + res.resp, res.err = r.dispatchGetBillingReport(req) + case "ReservationsClient.GetBillingStatus": + res.resp, res.err = r.dispatchGetBillingStatus(req) + case "ReservationsClient.GetResourceLimits": + res.resp, res.err = r.dispatchGetResourceLimits(req) + case "ReservationsClient.NewListByResourceGroupPager": + res.resp, res.err = r.dispatchNewListByResourceGroupPager(req) + case "ReservationsClient.NewListBySubscriptionPager": + res.resp, res.err = r.dispatchNewListBySubscriptionPager(req) + case "ReservationsClient.BeginUpdate": + res.resp, res.err = r.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (r *ReservationsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := r.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpurestorageblock.Reservation](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreate(req.Context(), resourceGroupNameParam, reservationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + r.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + r.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + r.beginCreate.remove(req) + } + + return resp, nil +} + +func (r *ReservationsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if r.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := r.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginDelete(req.Context(), resourceGroupNameParam, reservationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + r.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + r.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + r.beginDelete.remove(req) + } + + return resp, nil +} + +func (r *ReservationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameParam, reservationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Reservation, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ReservationsServerTransport) dispatchGetBillingReport(req *http.Request) (*http.Response, error) { + if r.srv.GetBillingReport == nil { + return nil, &nonRetriableError{errors.New("fake for method GetBillingReport not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getBillingReport` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetBillingReport(req.Context(), resourceGroupNameParam, reservationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ReservationBillingUsageReport, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ReservationsServerTransport) dispatchGetBillingStatus(req *http.Request) (*http.Response, error) { + if r.srv.GetBillingStatus == nil { + return nil, &nonRetriableError{errors.New("fake for method GetBillingStatus not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getBillingStatus` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetBillingStatus(req.Context(), resourceGroupNameParam, reservationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ReservationBillingStatus, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ReservationsServerTransport) dispatchGetResourceLimits(req *http.Request) (*http.Response, error) { + if r.srv.GetResourceLimits == nil { + return nil, &nonRetriableError{errors.New("fake for method GetResourceLimits not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getResourceLimits` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetResourceLimits(req.Context(), resourceGroupNameParam, reservationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LimitDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ReservationsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := r.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + r.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armpurestorageblock.ReservationsClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + r.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (r *ReservationsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := r.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := r.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + r.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armpurestorageblock.ReservationsClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + r.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (r *ReservationsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if r.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := r.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/reservations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpurestorageblock.ReservationUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + reservationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginUpdate(req.Context(), resourceGroupNameParam, reservationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + r.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + r.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + r.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to ReservationsServerTransport +var reservationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/server_factory.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/server_factory.go new file mode 100644 index 000000000000..4f962fcb995c --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/server_factory.go @@ -0,0 +1,118 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armpurestorageblock.ClientFactory type. +type ServerFactory struct { + // AvsStorageContainerVolumesServer contains the fakes for client AvsStorageContainerVolumesClient + AvsStorageContainerVolumesServer AvsStorageContainerVolumesServer + + // AvsStorageContainersServer contains the fakes for client AvsStorageContainersClient + AvsStorageContainersServer AvsStorageContainersServer + + // AvsVMVolumesServer contains the fakes for client AvsVMVolumesClient + AvsVMVolumesServer AvsVMVolumesServer + + // AvsVMsServer contains the fakes for client AvsVMsClient + AvsVMsServer AvsVMsServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // ReservationsServer contains the fakes for client ReservationsClient + ReservationsServer ReservationsServer + + // StoragePoolsServer contains the fakes for client StoragePoolsClient + StoragePoolsServer StoragePoolsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armpurestorageblock.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armpurestorageblock.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trAvsStorageContainerVolumesServer *AvsStorageContainerVolumesServerTransport + trAvsStorageContainersServer *AvsStorageContainersServerTransport + trAvsVMVolumesServer *AvsVMVolumesServerTransport + trAvsVMsServer *AvsVMsServerTransport + trOperationsServer *OperationsServerTransport + trReservationsServer *ReservationsServerTransport + trStoragePoolsServer *StoragePoolsServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "AvsStorageContainerVolumesClient": + initServer(s, &s.trAvsStorageContainerVolumesServer, func() *AvsStorageContainerVolumesServerTransport { + return NewAvsStorageContainerVolumesServerTransport(&s.srv.AvsStorageContainerVolumesServer) + }) + resp, err = s.trAvsStorageContainerVolumesServer.Do(req) + case "AvsStorageContainersClient": + initServer(s, &s.trAvsStorageContainersServer, func() *AvsStorageContainersServerTransport { + return NewAvsStorageContainersServerTransport(&s.srv.AvsStorageContainersServer) + }) + resp, err = s.trAvsStorageContainersServer.Do(req) + case "AvsVMVolumesClient": + initServer(s, &s.trAvsVMVolumesServer, func() *AvsVMVolumesServerTransport { return NewAvsVMVolumesServerTransport(&s.srv.AvsVMVolumesServer) }) + resp, err = s.trAvsVMVolumesServer.Do(req) + case "AvsVMsClient": + initServer(s, &s.trAvsVMsServer, func() *AvsVMsServerTransport { return NewAvsVMsServerTransport(&s.srv.AvsVMsServer) }) + resp, err = s.trAvsVMsServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "ReservationsClient": + initServer(s, &s.trReservationsServer, func() *ReservationsServerTransport { return NewReservationsServerTransport(&s.srv.ReservationsServer) }) + resp, err = s.trReservationsServer.Do(req) + case "StoragePoolsClient": + initServer(s, &s.trStoragePoolsServer, func() *StoragePoolsServerTransport { return NewStoragePoolsServerTransport(&s.srv.StoragePoolsServer) }) + resp, err = s.trStoragePoolsServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/storagepools_server.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/storagepools_server.go new file mode 100644 index 000000000000..ec27b4c38b60 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/fake/storagepools_server.go @@ -0,0 +1,707 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "net/http" + "net/url" + "regexp" +) + +// StoragePoolsServer is a fake server for instances of the armpurestorageblock.StoragePoolsClient type. +type StoragePoolsServer struct { + // BeginCreate is the fake for method StoragePoolsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, storagePoolName string, resource armpurestorageblock.StoragePool, options *armpurestorageblock.StoragePoolsClientBeginCreateOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method StoragePoolsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, storagePoolName string, options *armpurestorageblock.StoragePoolsClientBeginDeleteOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientDeleteResponse], errResp azfake.ErrorResponder) + + // BeginDisableAvsConnection is the fake for method StoragePoolsClient.BeginDisableAvsConnection + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDisableAvsConnection func(ctx context.Context, resourceGroupName string, storagePoolName string, options *armpurestorageblock.StoragePoolsClientBeginDisableAvsConnectionOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientDisableAvsConnectionResponse], errResp azfake.ErrorResponder) + + // BeginEnableAvsConnection is the fake for method StoragePoolsClient.BeginEnableAvsConnection + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginEnableAvsConnection func(ctx context.Context, resourceGroupName string, storagePoolName string, properties armpurestorageblock.StoragePoolEnableAvsConnectionPost, options *armpurestorageblock.StoragePoolsClientBeginEnableAvsConnectionOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientEnableAvsConnectionResponse], errResp azfake.ErrorResponder) + + // BeginFinalizeAvsConnection is the fake for method StoragePoolsClient.BeginFinalizeAvsConnection + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginFinalizeAvsConnection func(ctx context.Context, resourceGroupName string, storagePoolName string, properties armpurestorageblock.StoragePoolFinalizeAvsConnectionPost, options *armpurestorageblock.StoragePoolsClientBeginFinalizeAvsConnectionOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientFinalizeAvsConnectionResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method StoragePoolsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, storagePoolName string, options *armpurestorageblock.StoragePoolsClientGetOptions) (resp azfake.Responder[armpurestorageblock.StoragePoolsClientGetResponse], errResp azfake.ErrorResponder) + + // GetAvsConnection is the fake for method StoragePoolsClient.GetAvsConnection + // HTTP status codes to indicate success: http.StatusOK + GetAvsConnection func(ctx context.Context, resourceGroupName string, storagePoolName string, options *armpurestorageblock.StoragePoolsClientGetAvsConnectionOptions) (resp azfake.Responder[armpurestorageblock.StoragePoolsClientGetAvsConnectionResponse], errResp azfake.ErrorResponder) + + // GetAvsStatus is the fake for method StoragePoolsClient.GetAvsStatus + // HTTP status codes to indicate success: http.StatusOK + GetAvsStatus func(ctx context.Context, resourceGroupName string, storagePoolName string, options *armpurestorageblock.StoragePoolsClientGetAvsStatusOptions) (resp azfake.Responder[armpurestorageblock.StoragePoolsClientGetAvsStatusResponse], errResp azfake.ErrorResponder) + + // GetHealthStatus is the fake for method StoragePoolsClient.GetHealthStatus + // HTTP status codes to indicate success: http.StatusOK + GetHealthStatus func(ctx context.Context, resourceGroupName string, storagePoolName string, options *armpurestorageblock.StoragePoolsClientGetHealthStatusOptions) (resp azfake.Responder[armpurestorageblock.StoragePoolsClientGetHealthStatusResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method StoragePoolsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armpurestorageblock.StoragePoolsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armpurestorageblock.StoragePoolsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method StoragePoolsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armpurestorageblock.StoragePoolsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armpurestorageblock.StoragePoolsClientListBySubscriptionResponse]) + + // BeginRepairAvsConnection is the fake for method StoragePoolsClient.BeginRepairAvsConnection + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginRepairAvsConnection func(ctx context.Context, resourceGroupName string, storagePoolName string, options *armpurestorageblock.StoragePoolsClientBeginRepairAvsConnectionOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientRepairAvsConnectionResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method StoragePoolsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, storagePoolName string, properties armpurestorageblock.StoragePoolUpdate, options *armpurestorageblock.StoragePoolsClientBeginUpdateOptions) (resp azfake.PollerResponder[armpurestorageblock.StoragePoolsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewStoragePoolsServerTransport creates a new instance of StoragePoolsServerTransport with the provided implementation. +// The returned StoragePoolsServerTransport instance is connected to an instance of armpurestorageblock.StoragePoolsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewStoragePoolsServerTransport(srv *StoragePoolsServer) *StoragePoolsServerTransport { + return &StoragePoolsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientDeleteResponse]](), + beginDisableAvsConnection: newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientDisableAvsConnectionResponse]](), + beginEnableAvsConnection: newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientEnableAvsConnectionResponse]](), + beginFinalizeAvsConnection: newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientFinalizeAvsConnectionResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armpurestorageblock.StoragePoolsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armpurestorageblock.StoragePoolsClientListBySubscriptionResponse]](), + beginRepairAvsConnection: newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientRepairAvsConnectionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientUpdateResponse]](), + } +} + +// StoragePoolsServerTransport connects instances of armpurestorageblock.StoragePoolsClient to instances of StoragePoolsServer. +// Don't use this type directly, use NewStoragePoolsServerTransport instead. +type StoragePoolsServerTransport struct { + srv *StoragePoolsServer + beginCreate *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientDeleteResponse]] + beginDisableAvsConnection *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientDisableAvsConnectionResponse]] + beginEnableAvsConnection *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientEnableAvsConnectionResponse]] + beginFinalizeAvsConnection *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientFinalizeAvsConnectionResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armpurestorageblock.StoragePoolsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armpurestorageblock.StoragePoolsClientListBySubscriptionResponse]] + beginRepairAvsConnection *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientRepairAvsConnectionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armpurestorageblock.StoragePoolsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for StoragePoolsServerTransport. +func (s *StoragePoolsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return s.dispatchToMethodFake(req, method) +} + +func (s *StoragePoolsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if storagePoolsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = storagePoolsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "StoragePoolsClient.BeginCreate": + res.resp, res.err = s.dispatchBeginCreate(req) + case "StoragePoolsClient.BeginDelete": + res.resp, res.err = s.dispatchBeginDelete(req) + case "StoragePoolsClient.BeginDisableAvsConnection": + res.resp, res.err = s.dispatchBeginDisableAvsConnection(req) + case "StoragePoolsClient.BeginEnableAvsConnection": + res.resp, res.err = s.dispatchBeginEnableAvsConnection(req) + case "StoragePoolsClient.BeginFinalizeAvsConnection": + res.resp, res.err = s.dispatchBeginFinalizeAvsConnection(req) + case "StoragePoolsClient.Get": + res.resp, res.err = s.dispatchGet(req) + case "StoragePoolsClient.GetAvsConnection": + res.resp, res.err = s.dispatchGetAvsConnection(req) + case "StoragePoolsClient.GetAvsStatus": + res.resp, res.err = s.dispatchGetAvsStatus(req) + case "StoragePoolsClient.GetHealthStatus": + res.resp, res.err = s.dispatchGetHealthStatus(req) + case "StoragePoolsClient.NewListByResourceGroupPager": + res.resp, res.err = s.dispatchNewListByResourceGroupPager(req) + case "StoragePoolsClient.NewListBySubscriptionPager": + res.resp, res.err = s.dispatchNewListBySubscriptionPager(req) + case "StoragePoolsClient.BeginRepairAvsConnection": + res.resp, res.err = s.dispatchBeginRepairAvsConnection(req) + case "StoragePoolsClient.BeginUpdate": + res.resp, res.err = s.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (s *StoragePoolsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := s.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpurestorageblock.StoragePool](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreate(req.Context(), resourceGroupNameParam, storagePoolNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + s.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + s.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + s.beginCreate.remove(req) + } + + return resp, nil +} + +func (s *StoragePoolsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, storagePoolNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + s.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + s.beginDelete.remove(req) + } + + return resp, nil +} + +func (s *StoragePoolsServerTransport) dispatchBeginDisableAvsConnection(req *http.Request) (*http.Response, error) { + if s.srv.BeginDisableAvsConnection == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDisableAvsConnection not implemented")} + } + beginDisableAvsConnection := s.beginDisableAvsConnection.get(req) + if beginDisableAvsConnection == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/disableAvsConnection` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDisableAvsConnection(req.Context(), resourceGroupNameParam, storagePoolNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDisableAvsConnection = &respr + s.beginDisableAvsConnection.add(req, beginDisableAvsConnection) + } + + resp, err := server.PollerResponderNext(beginDisableAvsConnection, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDisableAvsConnection.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDisableAvsConnection) { + s.beginDisableAvsConnection.remove(req) + } + + return resp, nil +} + +func (s *StoragePoolsServerTransport) dispatchBeginEnableAvsConnection(req *http.Request) (*http.Response, error) { + if s.srv.BeginEnableAvsConnection == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginEnableAvsConnection not implemented")} + } + beginEnableAvsConnection := s.beginEnableAvsConnection.get(req) + if beginEnableAvsConnection == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enableAvsConnection` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpurestorageblock.StoragePoolEnableAvsConnectionPost](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginEnableAvsConnection(req.Context(), resourceGroupNameParam, storagePoolNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginEnableAvsConnection = &respr + s.beginEnableAvsConnection.add(req, beginEnableAvsConnection) + } + + resp, err := server.PollerResponderNext(beginEnableAvsConnection, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginEnableAvsConnection.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginEnableAvsConnection) { + s.beginEnableAvsConnection.remove(req) + } + + return resp, nil +} + +func (s *StoragePoolsServerTransport) dispatchBeginFinalizeAvsConnection(req *http.Request) (*http.Response, error) { + if s.srv.BeginFinalizeAvsConnection == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginFinalizeAvsConnection not implemented")} + } + beginFinalizeAvsConnection := s.beginFinalizeAvsConnection.get(req) + if beginFinalizeAvsConnection == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/finalizeAvsConnection` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpurestorageblock.StoragePoolFinalizeAvsConnectionPost](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginFinalizeAvsConnection(req.Context(), resourceGroupNameParam, storagePoolNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginFinalizeAvsConnection = &respr + s.beginFinalizeAvsConnection.add(req, beginFinalizeAvsConnection) + } + + resp, err := server.PollerResponderNext(beginFinalizeAvsConnection, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginFinalizeAvsConnection.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginFinalizeAvsConnection) { + s.beginFinalizeAvsConnection.remove(req) + } + + return resp, nil +} + +func (s *StoragePoolsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, storagePoolNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).StoragePool, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *StoragePoolsServerTransport) dispatchGetAvsConnection(req *http.Request) (*http.Response, error) { + if s.srv.GetAvsConnection == nil { + return nil, &nonRetriableError{errors.New("fake for method GetAvsConnection not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getAvsConnection` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.GetAvsConnection(req.Context(), resourceGroupNameParam, storagePoolNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AvsConnection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *StoragePoolsServerTransport) dispatchGetAvsStatus(req *http.Request) (*http.Response, error) { + if s.srv.GetAvsStatus == nil { + return nil, &nonRetriableError{errors.New("fake for method GetAvsStatus not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getAvsStatus` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.GetAvsStatus(req.Context(), resourceGroupNameParam, storagePoolNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AvsStatus, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *StoragePoolsServerTransport) dispatchGetHealthStatus(req *http.Request) (*http.Response, error) { + if s.srv.GetHealthStatus == nil { + return nil, &nonRetriableError{errors.New("fake for method GetHealthStatus not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getHealthStatus` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.GetHealthStatus(req.Context(), resourceGroupNameParam, storagePoolNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).StoragePoolHealthInfo, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *StoragePoolsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := s.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + s.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armpurestorageblock.StoragePoolsClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + s.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (s *StoragePoolsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := s.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := s.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + s.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armpurestorageblock.StoragePoolsClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + s.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (s *StoragePoolsServerTransport) dispatchBeginRepairAvsConnection(req *http.Request) (*http.Response, error) { + if s.srv.BeginRepairAvsConnection == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginRepairAvsConnection not implemented")} + } + beginRepairAvsConnection := s.beginRepairAvsConnection.get(req) + if beginRepairAvsConnection == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/repairAvsConnection` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginRepairAvsConnection(req.Context(), resourceGroupNameParam, storagePoolNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginRepairAvsConnection = &respr + s.beginRepairAvsConnection.add(req, beginRepairAvsConnection) + } + + resp, err := server.PollerResponderNext(beginRepairAvsConnection, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginRepairAvsConnection.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginRepairAvsConnection) { + s.beginRepairAvsConnection.remove(req) + } + + return resp, nil +} + +func (s *StoragePoolsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := s.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/PureStorage\.Block/storagePools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpurestorageblock.StoragePoolUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + storagePoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("storagePoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginUpdate(req.Context(), resourceGroupNameParam, storagePoolNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + s.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + s.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + s.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to StoragePoolsServerTransport +var storagePoolsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/go.mod b/sdk/resourcemanager/purestorageblock/armpurestorageblock/go.mod new file mode 100644 index 000000000000..035807ed0315 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/go.mod @@ -0,0 +1,23 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock + +go 1.23.0 + +toolchain go1.23.8 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.36.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/sys v0.31.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/go.sum b/sdk/resourcemanager/purestorageblock/armpurestorageblock/go.sum new file mode 100644 index 000000000000..1f92486fbbcf --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/go.sum @@ -0,0 +1,33 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +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/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/models.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/models.go new file mode 100644 index 000000000000..a265c97d2bac --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/models.go @@ -0,0 +1,920 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +import "time" + +// Address details +type Address struct { + // REQUIRED; Address line 1 + AddressLine1 *string + + // REQUIRED; Name of the city + City *string + + // REQUIRED; Name of the country + Country *string + + // REQUIRED; Postal code + PostalCode *string + + // REQUIRED; State (if any) + State *string + + // Address line 2 + AddressLine2 *string +} + +// Alert - Health alerts +type Alert struct { + // REQUIRED; Severity level + Level *AlertLevel + + // REQUIRED; A short description of the alert + Message *string +} + +// AvsConnection - Transient information about an on-going connection to an AVS instance +type AvsConnection struct { + // REQUIRED; Indicates whether service initialization is complete + ServiceInitializationCompleted *bool + + // Explicit service account credentials + ServiceInitializationHandle *ServiceInitializationHandle + + // Encoded service account credentials alongside connection information + ServiceInitializationHandleEnc *string +} + +// AvsDiskDetails - AVS disk/volume information +type AvsDiskDetails struct { + // REQUIRED; Azure resource ID of the AVS storage container containing this disk/volume + AvsStorageContainerResourceID *string + + // REQUIRED; VMware ID assigned to the disk/volume + AvsVMInternalID *string + + // REQUIRED; Name of the AVS VM connected to this disk/volume + AvsVMName *string + + // REQUIRED; Azure resource ID of the AVS VM connected to this disk/volume + AvsVMResourceID *string + + // REQUIRED; VMware ID of the disk/volume + DiskID *string + + // REQUIRED; VMware name of the disk/volume + DiskName *string + + // REQUIRED; Name of the top-level folder in the datastore that contains the disk/volume + Folder *string +} + +// AvsStatus - Status of storage pool / AVS connection +type AvsStatus struct { + // REQUIRED; If true, an AVS connection has been successfully completed + AvsEnabled *bool + + // REQUIRED; Human-readable current AVS connection status + CurrentConnectionStatus *string + + // Azure resource ID of the AVS SDDC the pool is connected to + ClusterResourceID *string +} + +// AvsStorageContainer - AVS storage container resource type, representing a VMware storage container in a storage pool, which +// can be associated to and mounted as a datastore +type AvsStorageContainer struct { + // The resource-specific properties for this resource. + Properties *AvsStorageContainerProperties + + // READ-ONLY; Name of the storage container + Name *string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *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 +} + +// AvsStorageContainerListResult - The response of a AvsStorageContainer list operation. +type AvsStorageContainerListResult struct { + // REQUIRED; The AvsStorageContainer items on this page + Value []*AvsStorageContainer + + // The link to the next page of items + NextLink *string +} + +// AvsStorageContainerProperties - AVS storage container properties +type AvsStorageContainerProperties struct { + // READ-ONLY; Name of the storage container + ResourceName *string + + // Maximum amount of bytes that can be provisioned in this storage container; it must be a multiple of 512; each time a volume + // is provisioned in this container, its provisionedSize will be counted against the provisionLimit and the provisioning will + // fail if it goes over (minimum: 1048576 (1MiB), maximum: 4503599627370496 (4PiB)); by default it is unrestricted + ProvisionedLimit *int64 + + // READ-ONLY; VMware datastore associated with this storage container (if any) + Datastore *string + + // READ-ONLY; Whether the datastore is mounted in VMware or not + Mounted *bool + + // READ-ONLY; Storage space usage + Space *Space +} + +// AvsStorageContainerVolume - A volume contained in an AVS storage container +type AvsStorageContainerVolume struct { + // The resource-specific properties for this resource. + Properties *VolumeProperties + + // READ-ONLY; ID of the volume in the storage container + Name *string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *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 +} + +// AvsStorageContainerVolumeListResult - The response of a AvsStorageContainerVolume list operation. +type AvsStorageContainerVolumeListResult struct { + // REQUIRED; The AvsStorageContainerVolume items on this page + Value []*AvsStorageContainerVolume + + // The link to the next page of items + NextLink *string +} + +// AvsStorageContainerVolumeUpdate - The type used for update operations of the AvsStorageContainerVolume. +type AvsStorageContainerVolumeUpdate struct { + // The resource-specific properties for this resource. + Properties *AvsStorageContainerVolumeUpdateProperties +} + +// AvsStorageContainerVolumeUpdateProperties - The updatable properties of the AvsStorageContainerVolume. +type AvsStorageContainerVolumeUpdateProperties struct { + // Volume's soft-deletion state + SoftDeletion *SoftDeletion +} + +// AvsVM - AVS VM resource type, representing all the volumes associated to an AVS VM as defined by VMware +type AvsVM struct { + // The resource-specific properties for this resource. + Properties *AvsVMProperties + + // READ-ONLY; ID of the AVS VM + Name *string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *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 +} + +// AvsVMDetails - AVS VM details +type AvsVMDetails struct { + // REQUIRED; Pure Storage's internal ID for this AVS VM + AvsVMInternalID *string + + // REQUIRED; ID of the AVS VM using this set of volumes + VMID *string + + // REQUIRED; Name of the VMware VM using this set of volumes + VMName *string + + // REQUIRED; Type of the VMware VM using this set of volumes + VMType *VMType +} + +// AvsVMListResult - The response of a AvsVm list operation. +type AvsVMListResult struct { + // REQUIRED; The AvsVm items on this page + Value []*AvsVM + + // The link to the next page of items + NextLink *string +} + +// AvsVMProperties - AVS VM properties +type AvsVMProperties struct { + // AVS VM's soft-deletion state + SoftDeletion *SoftDeletion + + // READ-ONLY; AVS VM details + Avs *AvsVMDetails + + // READ-ONLY; Date at which the AVS VM was created, as an RFC 3339 timestamp + CreatedTimestamp *string + + // READ-ONLY; Human-readable name of the AVS VM + DisplayName *string + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ResourceProvisioningState + + // READ-ONLY; Contains properties related to used Flash space + Space *Space + + // READ-ONLY; Pure Storage's internal ID for the storage pool + StoragePoolInternalID *string + + // READ-ONLY; Azure resource ID of the storage pool + StoragePoolResourceID *string + + // READ-ONLY; Specify which control plane handles the lifecycle of the volume container + VolumeContainerType *VolumeContainerType +} + +// AvsVMUpdate - The type used for update operations of the AvsVm. +type AvsVMUpdate struct { + // The resource-specific properties for this resource. + Properties *AvsVMUpdateProperties +} + +// AvsVMUpdateProperties - The updatable properties of the AvsVm. +type AvsVMUpdateProperties struct { + // AVS VM's soft-deletion state + SoftDeletion *SoftDeletion +} + +// AvsVMVolume - Any volume associated to a particular AVS VM +type AvsVMVolume struct { + // The resource-specific properties for this resource. + Properties *VolumeProperties + + // READ-ONLY; ID of the volume in the AVS VM + Name *string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *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 +} + +// AvsVMVolumeListResult - The response of a AvsVmVolume list operation. +type AvsVMVolumeListResult struct { + // REQUIRED; The AvsVmVolume items on this page + Value []*AvsVMVolume + + // The link to the next page of items + NextLink *string +} + +// AvsVMVolumeUpdate - The type used for update operations of the AvsVmVolume. +type AvsVMVolumeUpdate struct { + // The resource-specific properties for this resource. + Properties *AvsVMVolumeUpdateProperties +} + +// AvsVMVolumeUpdateProperties - The updatable properties of the AvsVmVolume. +type AvsVMVolumeUpdateProperties struct { + // Volume's soft-deletion state + SoftDeletion *SoftDeletion +} + +// AzureVmwareService - Connected AVS status +type AzureVmwareService struct { + // REQUIRED; If true, an AVS SDDC is successfully connected to the storage pool + AvsEnabled *bool + + // Azure resource ID of the AVS SDDC the storage pool is connected to + ClusterResourceID *string +} + +// BandwidthUsage - Bandwidth usage metrics +type BandwidthUsage struct { + // REQUIRED; Number of bytes written and read per second (maximum value over the last 10 minutes) + Current *int64 + + // REQUIRED; Maximum bandwidth value that can be provisioned for the storage pool + Max *int64 + + // REQUIRED; Bandwidth value currently provisioned for the storage pool, in MB/s + Provisioned *int64 +} + +// BillingUsageProperty - Represents an individual billing usage property +type BillingUsageProperty struct { + // REQUIRED; Current value of the billing usage property + CurrentValue *string + + // REQUIRED; Unique identifier for the billing usage property + PropertyID *string + + // REQUIRED; Name of the billing usage property + PropertyName *string + + // REQUIRED; Severity level of the usage + Severity *UsageSeverity + + // Previous value of the billing usage property + PreviousValue *string + + // Status message for the billing usage against a property + StatusMessage *string + + // Optional list of sub-properties providing additional details + SubProperties []*BillingUsageProperty +} + +// CompanyDetails - Company details +type CompanyDetails struct { + // REQUIRED; Company name + CompanyName *string + + // Company address + Address *Address +} + +// HealthDetails - Health metrics for a storage pool +type HealthDetails struct { + // REQUIRED; Bandwidth usage metrics + BandwidthUsage *BandwidthUsage + + // REQUIRED; Data reduction ratio achieved on this pool + DataReductionRatio *float64 + + // REQUIRED; Estimated maximum capacity of the pool, in bytes, based on current usage and data reduction ratio + EstimatedMaxCapacity *int64 + + // REQUIRED; IOPS usage metrics + IopsUsage *IopsUsage + + // REQUIRED; Storage space usage + Space *Space + + // REQUIRED; How full the pool is right now, in %, compared to the maximum size it can grow to; estimated based on current + // usage and data reduction ratio + UsedCapacityPercentage *float64 +} + +// IopsUsage - IOPS usage metrics +type IopsUsage struct { + // REQUIRED; Current number of IOPS (maximum value over the last 10 minutes) + Current *int64 + + // REQUIRED; Maximum IOPS value that can be provisioned for the storage pool + Max *int64 + + // REQUIRED; IOPS value currently provisioned for the storage pool + Provisioned *int64 +} + +// LimitDetails - Limits constraining certain resource properties +type LimitDetails struct { + // REQUIRED; internal + PerformancePolicy *PerformancePolicyLimits + + // REQUIRED; internal + ProtectionPolicy *ProtectionPolicyLimits + + // REQUIRED; Limits used for storage pool resources + StoragePool *StoragePoolLimits + + // REQUIRED; Limits used for volume resources + Volume *VolumeLimits +} + +// ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) +type ManagedServiceIdentity struct { + // REQUIRED; The type of managed identity assigned to this resource. + Type *ManagedServiceIdentityType + + // The identities assigned to this resource by the user. + UserAssignedIdentities map[string]*UserAssignedIdentity + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string +} + +// MarketplaceDetails - Marketplace details +type MarketplaceDetails struct { + // REQUIRED; Offer details of the marketplace subscription + OfferDetails *OfferDetails + + // Marketplace subscription status + SubscriptionStatus *MarketplaceSubscriptionStatus + + // READ-ONLY; Marketplace subscription ID + SubscriptionID *string +} + +// OfferDetails - Offer details for the marketplace that is selected by the user +type OfferDetails struct { + // REQUIRED; Offer ID for the marketplace offer + OfferID *string + + // REQUIRED; Plan ID for the marketplace offer + PlanID *string + + // REQUIRED; Publisher ID for the marketplace offer + PublisherID *string + + // Plan Name for the marketplace offer + PlanName *string + + // Term ID for the marketplace offer + TermID *string + + // Term Unit for the marketplace offer + TermUnit *string +} + +// Operation - REST API 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; Extensible 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 Azure + // Resource Manager/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 and 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 { + // REQUIRED; The Operation items on this page + Value []*Operation + + // The link to the next page of items + NextLink *string +} + +// PerformancePolicyLimits - internal +type PerformancePolicyLimits struct { + // REQUIRED; internal + BandwidthLimit *RangeLimits + + // REQUIRED; internal + IopsLimit *RangeLimits +} + +// ProtectionPolicyLimits - internal +type ProtectionPolicyLimits struct { + // REQUIRED; internal + Frequency *RangeLimits + + // REQUIRED; internal + Retention *RangeLimits +} + +// RangeLimits - Minimum and maximum values for a property +type RangeLimits struct { + // REQUIRED; Maximum value of the property + Max *int64 + + // REQUIRED; Minimum value of the property + Min *int64 +} + +// Reservation - Pure Storage cloud service resource type, also called reservation +type Reservation struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *ReservationPropertiesBaseResourceProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Name of the reservation. + Name *string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *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 +} + +// ReservationBillingStatus - Latest billing status for this reservation +type ReservationBillingStatus struct { + // REQUIRED; Weighted average of the data-reduction ratio for all associated pools + DrrWeightedAverage *float64 + + // REQUIRED; Extra capacity added when rounding up low-usage pools to 30TiB. In bytes + ExtraUsedCapacityLowUsageRounding *int64 + + // REQUIRED; Extra capacity added because of low DRR storage pools; In bytes + ExtraUsedCapacityNonReducible *int64 + + // REQUIRED; Extra capacity discounted due to plan forgiving some low-DRR usage. In bytes + ExtraUsedCapacityNonReduciblePlanDiscount *int64 + + // REQUIRED; How many associated storage pools reported low data reduction ratio (DRR) + LowDrrPoolCount *int32 + + // REQUIRED; Timestamp for the latest update of this billing status, in RFC 3339 format + Timestamp *string + + // REQUIRED; The sum of total used capacity for all pools with low DRR, if the DRR penalty applies. In bytes + TotalNonReducibleReported *int64 + + // REQUIRED; Total performance amount included in plan. In bytes per second + TotalPerformanceIncludedPlan *int64 + + // REQUIRED; Total performance amount reported at on-demand price. In MB per second + TotalPerformanceOverage *int64 + + // REQUIRED; The sum of all performance settings across the pools under this reservation. In MB per second + TotalPerformanceReported *int64 + + // REQUIRED; Total used capacity actually billed. In bytes + TotalUsedCapacityBilled *int64 + + // REQUIRED; Total used capacity included in plan. In bytes + TotalUsedCapacityIncludedPlan *int64 + + // REQUIRED; Total used capacity reported at on-demand price. In bytes + TotalUsedCapacityOverage *int64 + + // REQUIRED; Total used capacity as reported by associated storage pools. In bytes + TotalUsedCapacityReported *int64 +} + +// ReservationBillingUsageReport - Represents a billing usage report, including overall status and detailed properties +type ReservationBillingUsageReport struct { + // REQUIRED; A list of detailed billing usage properties + BillingUsageProperties []*BillingUsageProperty + + // REQUIRED; Overall status message of the billing usage report + OverallStatusMessage *string + + // REQUIRED; Latest formatted billing report for this reservation + Timestamp *string +} + +// ReservationListResult - The response of a Reservation list operation. +type ReservationListResult struct { + // REQUIRED; The Reservation items on this page + Value []*Reservation + + // The link to the next page of items + NextLink *string +} + +// ReservationPropertiesBaseResourceProperties - Properties of a Reservation resource. +type ReservationPropertiesBaseResourceProperties struct { + // REQUIRED; Marketplace details + Marketplace *MarketplaceDetails + + // REQUIRED; User details + User *UserDetails + + // READ-ONLY; Provisioning state of the resource + ProvisioningState *ProvisioningState + + // READ-ONLY; Pure Storage's internal ID for the reservation + ReservationInternalID *string +} + +// ReservationUpdate - The type used for update operations of the Reservation. +type ReservationUpdate struct { + // The resource-specific properties for this resource. + Properties *ReservationUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// ReservationUpdateProperties - The updatable properties of the Reservation. +type ReservationUpdateProperties struct { + // User details + User *UserDetails +} + +// ServiceInitializationHandle - Initialization handle used to configure the AVS SDDC to communicate with the storage pool +type ServiceInitializationHandle struct { + // Azure resource ID of the AVS SDDC the pool is connecting to + ClusterResourceID *string + + // Requested service account username + ServiceAccountUsername *string +} + +// ServiceInitializationInfo - Explicit service initialization data +type ServiceInitializationInfo struct { + // Service account password + ServiceAccountPassword *string + + // Service account username + ServiceAccountUsername *string + + // AVS instance's vSphere certificate + VSphereCertificate *string + + // AVS instance's vSphere IP address + VSphereIP *string +} + +// SoftDeletion - Soft-deletion state +type SoftDeletion struct { + // REQUIRED; If false, the resource is active; if true, the resource has been destroyed; resources can be soft-deleted by + // setting destroyed to true, and recovered by setting it to false + Destroyed *bool + + // READ-ONLY; Date at which the resource will be eradicated and impossible to recover, as an RFC 3339 timestamp; invalid if + // destroyed is false; + EradicationTimestamp *string +} + +// Space - Storage space usage +type Space struct { + // REQUIRED; Space occupied by duplicated data, meaning data shared with other volumes and snapshots as a result of data deduplication, + // in bytes + Shared *int64 + + // REQUIRED; Space occupied by data unique to one or more snapshots, in bytes + Snapshots *int64 + + // REQUIRED; Total space occupied by customer data (i.e., being billed for), in bytes + TotalUsed *int64 + + // REQUIRED; Unique space occupied by customer data, in bytes; for a volume, this is the amount of storage that would be freed + // by deleting the volume, since snapshot and shared data would be kept + Unique *int64 +} + +// StoragePool - Storage pool resource +type StoragePool struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // READ-ONLY; Name of the storage pool + Name *string + + // The managed service identities assigned to this resource. + Identity *ManagedServiceIdentity + + // The resource-specific properties for this resource. + Properties *StoragePoolProperties + + // 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; 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 +} + +// StoragePoolEnableAvsConnectionPost - EnableAvsConnection payload information +type StoragePoolEnableAvsConnectionPost struct { + // REQUIRED; Azure resource ID of the AVS SDDC to connect to + ClusterResourceID *string +} + +// StoragePoolFinalizeAvsConnectionPost - FinalizeAvsConnection payload information, either encoded or explicit +type StoragePoolFinalizeAvsConnectionPost struct { + // Explicit AVS connection information + ServiceInitializationData *ServiceInitializationInfo + + // Encoded AVS connection information + ServiceInitializationDataEnc *string +} + +// StoragePoolHealthInfo - Health information for a storage pool +type StoragePoolHealthInfo struct { + // REQUIRED; List of health alerts + Alerts []*Alert + + // REQUIRED; Health metrics + Health *HealthDetails +} + +// StoragePoolLimits - Limits used for storage pool creation +type StoragePoolLimits struct { + // REQUIRED; List of physical availability zones in the region in which storage pools can be deployed; some Azure regions + // do not support the necessary resources in all availability zones + PhysicalAvailabilityZones []*string + + // REQUIRED; Allowed provisioned bandwidth range for a storage pool, in MB/s + ProvisionedBandwidthMbPerSec *RangeLimits + + // REQUIRED; Allowed provisioned IOPS range for a storage pool, as a number of operations + ProvisionedIops *RangeLimits +} + +// StoragePoolListResult - The response of a StoragePool list operation. +type StoragePoolListResult struct { + // REQUIRED; The StoragePool items on this page + Value []*StoragePool + + // The link to the next page of items + NextLink *string +} + +// StoragePoolProperties - Properties of a storage pool +type StoragePoolProperties struct { + // REQUIRED; Azure Availability Zone the Pool is located in + AvailabilityZone *string + + // REQUIRED; Total bandwidth provisioned for the pool, in MB/s + ProvisionedBandwidthMbPerSec *int64 + + // REQUIRED; Azure resource ID of the Pure Storage Cloud service (reservation resource) this storage pool belongs to + ReservationResourceID *string + + // REQUIRED; Network properties of the storage pool + VnetInjection *VnetInjection + + // READ-ONLY; AVS connection state summary + Avs *AzureVmwareService + + // READ-ONLY; How long a destroyed object is kept before being eradicated, in seconds + DataRetentionPeriod *int64 + + // READ-ONLY; Total I/O operations per second (IOPS) provisioned for the pool + ProvisionedIops *int64 + + // READ-ONLY; Provisioning state of the resource + ProvisioningState *ProvisioningState + + // READ-ONLY; Pure Storage's internal ID of the storage pool + StoragePoolInternalID *string +} + +// StoragePoolUpdate - The type used for update operations of the StoragePool. +type StoragePoolUpdate struct { + // The managed service identities assigned to this resource. + Identity *ManagedServiceIdentity + + // The resource-specific properties for this resource. + Properties *StoragePoolUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// StoragePoolUpdateProperties - The updatable properties of the StoragePool. +type StoragePoolUpdateProperties struct { + // Total bandwidth provisioned for the pool, in MB/s + ProvisionedBandwidthMbPerSec *int64 +} + +// 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 +} + +// UserAssignedIdentity - User assigned identity properties +type UserAssignedIdentity struct { + // READ-ONLY; The client ID of the assigned identity. + ClientID *string + + // READ-ONLY; The principal ID of the assigned identity. + PrincipalID *string +} + +// UserDetails - User details +type UserDetails struct { + // REQUIRED; Email address + EmailAddress *string + + // REQUIRED; First name + FirstName *string + + // REQUIRED; Last name + LastName *string + + // Company details + CompanyDetails *CompanyDetails + + // Phone number + PhoneNumber *string + + // Principal name + Upn *string +} + +// VnetInjection - Network in which the storage pool will be made available +type VnetInjection struct { + // REQUIRED; Azure resource ID of the Virtual Network subnet where the storage pool will be connected + SubnetID *string + + // REQUIRED; Azure resource ID of the Virtual Network in which the subnet is located + VnetID *string +} + +// VolumeLimits - Limits used for volumes +type VolumeLimits struct { + // REQUIRED; Provisioned size limits for a volume, in bytes + ProvisionedSize *RangeLimits +} + +// VolumeProperties - Volume properties +type VolumeProperties struct { + // REQUIRED; Volume's soft-deletion state + SoftDeletion *SoftDeletion + + // READ-ONLY; AVS-specific volume information + Avs *AvsDiskDetails + + // READ-ONLY; Volume creation date, as an RFC 3339 timestamp + CreatedTimestamp *string + + // READ-ONLY; Human-readable name of the volume + DisplayName *string + + // READ-ONLY; Currently provisioned size of the volume, in bytes + ProvisionedSize *int64 + + // READ-ONLY; Provisioning state of the resource + ProvisioningState *ResourceProvisioningState + + // READ-ONLY; Storage space usage + Space *Space + + // READ-ONLY; Pure Storage's internal ID for the storage pool containing the volume + StoragePoolInternalID *string + + // READ-ONLY; Azure Resource ID of the storage pool containing this volume + StoragePoolResourceID *string + + // READ-ONLY; Pure Storage's internal ID for the volume + VolumeInternalID *string + + // READ-ONLY; Specify which control plane handles the lifecycle of the volume + VolumeType *VolumeType +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/models_serde.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/models_serde.go new file mode 100644 index 000000000000..b630ee21b7e8 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/models_serde.go @@ -0,0 +1,2440 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Address. +func (a Address) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addressLine1", a.AddressLine1) + populate(objectMap, "addressLine2", a.AddressLine2) + populate(objectMap, "city", a.City) + populate(objectMap, "country", a.Country) + populate(objectMap, "postalCode", a.PostalCode) + populate(objectMap, "state", a.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Address. +func (a *Address) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addressLine1": + err = unpopulate(val, "AddressLine1", &a.AddressLine1) + delete(rawMsg, key) + case "addressLine2": + err = unpopulate(val, "AddressLine2", &a.AddressLine2) + delete(rawMsg, key) + case "city": + err = unpopulate(val, "City", &a.City) + delete(rawMsg, key) + case "country": + err = unpopulate(val, "Country", &a.Country) + delete(rawMsg, key) + case "postalCode": + err = unpopulate(val, "PostalCode", &a.PostalCode) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &a.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Alert. +func (a Alert) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "level", a.Level) + populate(objectMap, "message", a.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Alert. +func (a *Alert) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "level": + err = unpopulate(val, "Level", &a.Level) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &a.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsConnection. +func (a AvsConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "serviceInitializationCompleted", a.ServiceInitializationCompleted) + populate(objectMap, "serviceInitializationHandle", a.ServiceInitializationHandle) + populate(objectMap, "serviceInitializationHandleEnc", a.ServiceInitializationHandleEnc) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsConnection. +func (a *AvsConnection) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "serviceInitializationCompleted": + err = unpopulate(val, "ServiceInitializationCompleted", &a.ServiceInitializationCompleted) + delete(rawMsg, key) + case "serviceInitializationHandle": + err = unpopulate(val, "ServiceInitializationHandle", &a.ServiceInitializationHandle) + delete(rawMsg, key) + case "serviceInitializationHandleEnc": + err = unpopulate(val, "ServiceInitializationHandleEnc", &a.ServiceInitializationHandleEnc) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsDiskDetails. +func (a AvsDiskDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "avsStorageContainerResourceId", a.AvsStorageContainerResourceID) + populate(objectMap, "avsVmInternalId", a.AvsVMInternalID) + populate(objectMap, "avsVmName", a.AvsVMName) + populate(objectMap, "avsVmResourceId", a.AvsVMResourceID) + populate(objectMap, "diskId", a.DiskID) + populate(objectMap, "diskName", a.DiskName) + populate(objectMap, "folder", a.Folder) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsDiskDetails. +func (a *AvsDiskDetails) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "avsStorageContainerResourceId": + err = unpopulate(val, "AvsStorageContainerResourceID", &a.AvsStorageContainerResourceID) + delete(rawMsg, key) + case "avsVmInternalId": + err = unpopulate(val, "AvsVMInternalID", &a.AvsVMInternalID) + delete(rawMsg, key) + case "avsVmName": + err = unpopulate(val, "AvsVMName", &a.AvsVMName) + delete(rawMsg, key) + case "avsVmResourceId": + err = unpopulate(val, "AvsVMResourceID", &a.AvsVMResourceID) + delete(rawMsg, key) + case "diskId": + err = unpopulate(val, "DiskID", &a.DiskID) + delete(rawMsg, key) + case "diskName": + err = unpopulate(val, "DiskName", &a.DiskName) + delete(rawMsg, key) + case "folder": + err = unpopulate(val, "Folder", &a.Folder) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsStatus. +func (a AvsStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "avsEnabled", a.AvsEnabled) + populate(objectMap, "sddcResourceId", a.ClusterResourceID) + populate(objectMap, "currentConnectionStatus", a.CurrentConnectionStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsStatus. +func (a *AvsStatus) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "avsEnabled": + err = unpopulate(val, "AvsEnabled", &a.AvsEnabled) + delete(rawMsg, key) + case "sddcResourceId": + err = unpopulate(val, "ClusterResourceID", &a.ClusterResourceID) + delete(rawMsg, key) + case "currentConnectionStatus": + err = unpopulate(val, "CurrentConnectionStatus", &a.CurrentConnectionStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsStorageContainer. +func (a AvsStorageContainer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsStorageContainer. +func (a *AvsStorageContainer) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsStorageContainerListResult. +func (a AvsStorageContainerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsStorageContainerListResult. +func (a *AvsStorageContainerListResult) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsStorageContainerProperties. +func (a AvsStorageContainerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "datastore", a.Datastore) + populate(objectMap, "mounted", a.Mounted) + populate(objectMap, "provisionedLimit", a.ProvisionedLimit) + populate(objectMap, "resourceName", a.ResourceName) + populate(objectMap, "space", a.Space) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsStorageContainerProperties. +func (a *AvsStorageContainerProperties) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "datastore": + err = unpopulate(val, "Datastore", &a.Datastore) + delete(rawMsg, key) + case "mounted": + err = unpopulate(val, "Mounted", &a.Mounted) + delete(rawMsg, key) + case "provisionedLimit": + err = unpopulate(val, "ProvisionedLimit", &a.ProvisionedLimit) + delete(rawMsg, key) + case "resourceName": + err = unpopulate(val, "ResourceName", &a.ResourceName) + delete(rawMsg, key) + case "space": + err = unpopulate(val, "Space", &a.Space) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsStorageContainerVolume. +func (a AvsStorageContainerVolume) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsStorageContainerVolume. +func (a *AvsStorageContainerVolume) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsStorageContainerVolumeListResult. +func (a AvsStorageContainerVolumeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsStorageContainerVolumeListResult. +func (a *AvsStorageContainerVolumeListResult) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsStorageContainerVolumeUpdate. +func (a AvsStorageContainerVolumeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsStorageContainerVolumeUpdate. +func (a *AvsStorageContainerVolumeUpdate) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsStorageContainerVolumeUpdateProperties. +func (a AvsStorageContainerVolumeUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "softDeletion", a.SoftDeletion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsStorageContainerVolumeUpdateProperties. +func (a *AvsStorageContainerVolumeUpdateProperties) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "softDeletion": + err = unpopulate(val, "SoftDeletion", &a.SoftDeletion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsVM. +func (a AvsVM) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsVM. +func (a *AvsVM) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsVMDetails. +func (a AvsVMDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "avsVmInternalId", a.AvsVMInternalID) + populate(objectMap, "vmId", a.VMID) + populate(objectMap, "vmName", a.VMName) + populate(objectMap, "vmType", a.VMType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsVMDetails. +func (a *AvsVMDetails) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "avsVmInternalId": + err = unpopulate(val, "AvsVMInternalID", &a.AvsVMInternalID) + delete(rawMsg, key) + case "vmId": + err = unpopulate(val, "VMID", &a.VMID) + delete(rawMsg, key) + case "vmName": + err = unpopulate(val, "VMName", &a.VMName) + delete(rawMsg, key) + case "vmType": + err = unpopulate(val, "VMType", &a.VMType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsVMListResult. +func (a AvsVMListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsVMListResult. +func (a *AvsVMListResult) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsVMProperties. +func (a AvsVMProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "avs", a.Avs) + populate(objectMap, "createdTimestamp", a.CreatedTimestamp) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "softDeletion", a.SoftDeletion) + populate(objectMap, "space", a.Space) + populate(objectMap, "storagePoolInternalId", a.StoragePoolInternalID) + populate(objectMap, "storagePoolResourceId", a.StoragePoolResourceID) + populate(objectMap, "volumeContainerType", a.VolumeContainerType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsVMProperties. +func (a *AvsVMProperties) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "avs": + err = unpopulate(val, "Avs", &a.Avs) + delete(rawMsg, key) + case "createdTimestamp": + err = unpopulate(val, "CreatedTimestamp", &a.CreatedTimestamp) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "softDeletion": + err = unpopulate(val, "SoftDeletion", &a.SoftDeletion) + delete(rawMsg, key) + case "space": + err = unpopulate(val, "Space", &a.Space) + delete(rawMsg, key) + case "storagePoolInternalId": + err = unpopulate(val, "StoragePoolInternalID", &a.StoragePoolInternalID) + delete(rawMsg, key) + case "storagePoolResourceId": + err = unpopulate(val, "StoragePoolResourceID", &a.StoragePoolResourceID) + delete(rawMsg, key) + case "volumeContainerType": + err = unpopulate(val, "VolumeContainerType", &a.VolumeContainerType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsVMUpdate. +func (a AvsVMUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsVMUpdate. +func (a *AvsVMUpdate) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsVMUpdateProperties. +func (a AvsVMUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "softDeletion", a.SoftDeletion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsVMUpdateProperties. +func (a *AvsVMUpdateProperties) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "softDeletion": + err = unpopulate(val, "SoftDeletion", &a.SoftDeletion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsVMVolume. +func (a AvsVMVolume) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsVMVolume. +func (a *AvsVMVolume) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsVMVolumeListResult. +func (a AvsVMVolumeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsVMVolumeListResult. +func (a *AvsVMVolumeListResult) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsVMVolumeUpdate. +func (a AvsVMVolumeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsVMVolumeUpdate. +func (a *AvsVMVolumeUpdate) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvsVMVolumeUpdateProperties. +func (a AvsVMVolumeUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "softDeletion", a.SoftDeletion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvsVMVolumeUpdateProperties. +func (a *AvsVMVolumeUpdateProperties) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "softDeletion": + err = unpopulate(val, "SoftDeletion", &a.SoftDeletion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AzureVmwareService. +func (a AzureVmwareService) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "avsEnabled", a.AvsEnabled) + populate(objectMap, "sddcResourceId", a.ClusterResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureVmwareService. +func (a *AzureVmwareService) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "avsEnabled": + err = unpopulate(val, "AvsEnabled", &a.AvsEnabled) + delete(rawMsg, key) + case "sddcResourceId": + err = unpopulate(val, "ClusterResourceID", &a.ClusterResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BandwidthUsage. +func (b BandwidthUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "current", b.Current) + populate(objectMap, "max", b.Max) + populate(objectMap, "provisioned", b.Provisioned) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BandwidthUsage. +func (b *BandwidthUsage) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "current": + err = unpopulate(val, "Current", &b.Current) + delete(rawMsg, key) + case "max": + err = unpopulate(val, "Max", &b.Max) + delete(rawMsg, key) + case "provisioned": + err = unpopulate(val, "Provisioned", &b.Provisioned) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BillingUsageProperty. +func (b BillingUsageProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currentValue", b.CurrentValue) + populate(objectMap, "previousValue", b.PreviousValue) + populate(objectMap, "propertyId", b.PropertyID) + populate(objectMap, "propertyName", b.PropertyName) + populate(objectMap, "severity", b.Severity) + populate(objectMap, "statusMessage", b.StatusMessage) + populate(objectMap, "subProperties", b.SubProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BillingUsageProperty. +func (b *BillingUsageProperty) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "currentValue": + err = unpopulate(val, "CurrentValue", &b.CurrentValue) + delete(rawMsg, key) + case "previousValue": + err = unpopulate(val, "PreviousValue", &b.PreviousValue) + delete(rawMsg, key) + case "propertyId": + err = unpopulate(val, "PropertyID", &b.PropertyID) + delete(rawMsg, key) + case "propertyName": + err = unpopulate(val, "PropertyName", &b.PropertyName) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &b.Severity) + delete(rawMsg, key) + case "statusMessage": + err = unpopulate(val, "StatusMessage", &b.StatusMessage) + delete(rawMsg, key) + case "subProperties": + err = unpopulate(val, "SubProperties", &b.SubProperties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CompanyDetails. +func (c CompanyDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", c.Address) + populate(objectMap, "companyName", c.CompanyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CompanyDetails. +func (c *CompanyDetails) 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", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &c.Address) + delete(rawMsg, key) + case "companyName": + err = unpopulate(val, "CompanyName", &c.CompanyName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthDetails. +func (h HealthDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bandwidthUsage", h.BandwidthUsage) + populate(objectMap, "dataReductionRatio", h.DataReductionRatio) + populate(objectMap, "estimatedMaxCapacity", h.EstimatedMaxCapacity) + populate(objectMap, "iopsUsage", h.IopsUsage) + populate(objectMap, "space", h.Space) + populate(objectMap, "usedCapacityPercentage", h.UsedCapacityPercentage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthDetails. +func (h *HealthDetails) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "bandwidthUsage": + err = unpopulate(val, "BandwidthUsage", &h.BandwidthUsage) + delete(rawMsg, key) + case "dataReductionRatio": + err = unpopulate(val, "DataReductionRatio", &h.DataReductionRatio) + delete(rawMsg, key) + case "estimatedMaxCapacity": + err = unpopulate(val, "EstimatedMaxCapacity", &h.EstimatedMaxCapacity) + delete(rawMsg, key) + case "iopsUsage": + err = unpopulate(val, "IopsUsage", &h.IopsUsage) + delete(rawMsg, key) + case "space": + err = unpopulate(val, "Space", &h.Space) + delete(rawMsg, key) + case "usedCapacityPercentage": + err = unpopulate(val, "UsedCapacityPercentage", &h.UsedCapacityPercentage) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IopsUsage. +func (i IopsUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "current", i.Current) + populate(objectMap, "max", i.Max) + populate(objectMap, "provisioned", i.Provisioned) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IopsUsage. +func (i *IopsUsage) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "current": + err = unpopulate(val, "Current", &i.Current) + delete(rawMsg, key) + case "max": + err = unpopulate(val, "Max", &i.Max) + delete(rawMsg, key) + case "provisioned": + err = unpopulate(val, "Provisioned", &i.Provisioned) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LimitDetails. +func (l LimitDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "performancePolicy", l.PerformancePolicy) + populate(objectMap, "protectionPolicy", l.ProtectionPolicy) + populate(objectMap, "storagePool", l.StoragePool) + populate(objectMap, "volume", l.Volume) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LimitDetails. +func (l *LimitDetails) 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", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "performancePolicy": + err = unpopulate(val, "PerformancePolicy", &l.PerformancePolicy) + delete(rawMsg, key) + case "protectionPolicy": + err = unpopulate(val, "ProtectionPolicy", &l.ProtectionPolicy) + delete(rawMsg, key) + case "storagePool": + err = unpopulate(val, "StoragePool", &l.StoragePool) + delete(rawMsg, key) + case "volume": + err = unpopulate(val, "Volume", &l.Volume) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity. +func (m *ManagedServiceIdentity) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &m.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MarketplaceDetails. +func (m MarketplaceDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "offerDetails", m.OfferDetails) + populate(objectMap, "subscriptionId", m.SubscriptionID) + populate(objectMap, "subscriptionStatus", m.SubscriptionStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MarketplaceDetails. +func (m *MarketplaceDetails) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "offerDetails": + err = unpopulate(val, "OfferDetails", &m.OfferDetails) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &m.SubscriptionID) + delete(rawMsg, key) + case "subscriptionStatus": + err = unpopulate(val, "SubscriptionStatus", &m.SubscriptionStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OfferDetails. +func (o OfferDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "offerId", o.OfferID) + populate(objectMap, "planId", o.PlanID) + populate(objectMap, "planName", o.PlanName) + populate(objectMap, "publisherId", o.PublisherID) + populate(objectMap, "termId", o.TermID) + populate(objectMap, "termUnit", o.TermUnit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OfferDetails. +func (o *OfferDetails) 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 "offerId": + err = unpopulate(val, "OfferID", &o.OfferID) + delete(rawMsg, key) + case "planId": + err = unpopulate(val, "PlanID", &o.PlanID) + delete(rawMsg, key) + case "planName": + err = unpopulate(val, "PlanName", &o.PlanName) + delete(rawMsg, key) + case "publisherId": + err = unpopulate(val, "PublisherID", &o.PublisherID) + delete(rawMsg, key) + case "termId": + err = unpopulate(val, "TermID", &o.TermID) + delete(rawMsg, key) + case "termUnit": + err = unpopulate(val, "TermUnit", &o.TermUnit) + 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 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 PerformancePolicyLimits. +func (p PerformancePolicyLimits) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bandwidthLimit", p.BandwidthLimit) + populate(objectMap, "iopsLimit", p.IopsLimit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PerformancePolicyLimits. +func (p *PerformancePolicyLimits) 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 "bandwidthLimit": + err = unpopulate(val, "BandwidthLimit", &p.BandwidthLimit) + delete(rawMsg, key) + case "iopsLimit": + err = unpopulate(val, "IopsLimit", &p.IopsLimit) + 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 ProtectionPolicyLimits. +func (p ProtectionPolicyLimits) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "frequency", p.Frequency) + populate(objectMap, "retention", p.Retention) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProtectionPolicyLimits. +func (p *ProtectionPolicyLimits) 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 "frequency": + err = unpopulate(val, "Frequency", &p.Frequency) + delete(rawMsg, key) + case "retention": + err = unpopulate(val, "Retention", &p.Retention) + 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 RangeLimits. +func (r RangeLimits) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "max", r.Max) + populate(objectMap, "min", r.Min) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RangeLimits. +func (r *RangeLimits) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "max": + err = unpopulate(val, "Max", &r.Max) + delete(rawMsg, key) + case "min": + err = unpopulate(val, "Min", &r.Min) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Reservation. +func (r Reservation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Reservation. +func (r *Reservation) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationBillingStatus. +func (r ReservationBillingStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "drrWeightedAverage", r.DrrWeightedAverage) + populate(objectMap, "extraUsedCapacityLowUsageRounding", r.ExtraUsedCapacityLowUsageRounding) + populate(objectMap, "extraUsedCapacityNonReducible", r.ExtraUsedCapacityNonReducible) + populate(objectMap, "extraUsedCapacityNonReduciblePlanDiscount", r.ExtraUsedCapacityNonReduciblePlanDiscount) + populate(objectMap, "lowDrrPoolCount", r.LowDrrPoolCount) + populate(objectMap, "timestamp", r.Timestamp) + populate(objectMap, "totalNonReducibleReported", r.TotalNonReducibleReported) + populate(objectMap, "totalPerformanceIncludedPlan", r.TotalPerformanceIncludedPlan) + populate(objectMap, "totalPerformanceOverage", r.TotalPerformanceOverage) + populate(objectMap, "totalPerformanceReported", r.TotalPerformanceReported) + populate(objectMap, "totalUsedCapacityBilled", r.TotalUsedCapacityBilled) + populate(objectMap, "totalUsedCapacityIncludedPlan", r.TotalUsedCapacityIncludedPlan) + populate(objectMap, "totalUsedCapacityOverage", r.TotalUsedCapacityOverage) + populate(objectMap, "totalUsedCapacityReported", r.TotalUsedCapacityReported) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationBillingStatus. +func (r *ReservationBillingStatus) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "drrWeightedAverage": + err = unpopulate(val, "DrrWeightedAverage", &r.DrrWeightedAverage) + delete(rawMsg, key) + case "extraUsedCapacityLowUsageRounding": + err = unpopulate(val, "ExtraUsedCapacityLowUsageRounding", &r.ExtraUsedCapacityLowUsageRounding) + delete(rawMsg, key) + case "extraUsedCapacityNonReducible": + err = unpopulate(val, "ExtraUsedCapacityNonReducible", &r.ExtraUsedCapacityNonReducible) + delete(rawMsg, key) + case "extraUsedCapacityNonReduciblePlanDiscount": + err = unpopulate(val, "ExtraUsedCapacityNonReduciblePlanDiscount", &r.ExtraUsedCapacityNonReduciblePlanDiscount) + delete(rawMsg, key) + case "lowDrrPoolCount": + err = unpopulate(val, "LowDrrPoolCount", &r.LowDrrPoolCount) + delete(rawMsg, key) + case "timestamp": + err = unpopulate(val, "Timestamp", &r.Timestamp) + delete(rawMsg, key) + case "totalNonReducibleReported": + err = unpopulate(val, "TotalNonReducibleReported", &r.TotalNonReducibleReported) + delete(rawMsg, key) + case "totalPerformanceIncludedPlan": + err = unpopulate(val, "TotalPerformanceIncludedPlan", &r.TotalPerformanceIncludedPlan) + delete(rawMsg, key) + case "totalPerformanceOverage": + err = unpopulate(val, "TotalPerformanceOverage", &r.TotalPerformanceOverage) + delete(rawMsg, key) + case "totalPerformanceReported": + err = unpopulate(val, "TotalPerformanceReported", &r.TotalPerformanceReported) + delete(rawMsg, key) + case "totalUsedCapacityBilled": + err = unpopulate(val, "TotalUsedCapacityBilled", &r.TotalUsedCapacityBilled) + delete(rawMsg, key) + case "totalUsedCapacityIncludedPlan": + err = unpopulate(val, "TotalUsedCapacityIncludedPlan", &r.TotalUsedCapacityIncludedPlan) + delete(rawMsg, key) + case "totalUsedCapacityOverage": + err = unpopulate(val, "TotalUsedCapacityOverage", &r.TotalUsedCapacityOverage) + delete(rawMsg, key) + case "totalUsedCapacityReported": + err = unpopulate(val, "TotalUsedCapacityReported", &r.TotalUsedCapacityReported) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationBillingUsageReport. +func (r ReservationBillingUsageReport) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingUsageProperties", r.BillingUsageProperties) + populate(objectMap, "overallStatusMessage", r.OverallStatusMessage) + populate(objectMap, "timestamp", r.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationBillingUsageReport. +func (r *ReservationBillingUsageReport) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingUsageProperties": + err = unpopulate(val, "BillingUsageProperties", &r.BillingUsageProperties) + delete(rawMsg, key) + case "overallStatusMessage": + err = unpopulate(val, "OverallStatusMessage", &r.OverallStatusMessage) + delete(rawMsg, key) + case "timestamp": + err = unpopulate(val, "Timestamp", &r.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationListResult. +func (r ReservationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationListResult. +func (r *ReservationListResult) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationPropertiesBaseResourceProperties. +func (r ReservationPropertiesBaseResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "marketplace", r.Marketplace) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "reservationInternalId", r.ReservationInternalID) + populate(objectMap, "user", r.User) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationPropertiesBaseResourceProperties. +func (r *ReservationPropertiesBaseResourceProperties) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "marketplace": + err = unpopulate(val, "Marketplace", &r.Marketplace) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) + case "reservationInternalId": + err = unpopulate(val, "ReservationInternalID", &r.ReservationInternalID) + delete(rawMsg, key) + case "user": + err = unpopulate(val, "User", &r.User) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationUpdate. +func (r ReservationUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationUpdate. +func (r *ReservationUpdate) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationUpdateProperties. +func (r ReservationUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "user", r.User) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationUpdateProperties. +func (r *ReservationUpdateProperties) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "user": + err = unpopulate(val, "User", &r.User) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceInitializationHandle. +func (s ServiceInitializationHandle) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sddcResourceId", s.ClusterResourceID) + populate(objectMap, "serviceAccountUsername", s.ServiceAccountUsername) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceInitializationHandle. +func (s *ServiceInitializationHandle) 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 "sddcResourceId": + err = unpopulate(val, "ClusterResourceID", &s.ClusterResourceID) + delete(rawMsg, key) + case "serviceAccountUsername": + err = unpopulate(val, "ServiceAccountUsername", &s.ServiceAccountUsername) + 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 ServiceInitializationInfo. +func (s ServiceInitializationInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "serviceAccountPassword", s.ServiceAccountPassword) + populate(objectMap, "serviceAccountUsername", s.ServiceAccountUsername) + populate(objectMap, "vSphereCertificate", s.VSphereCertificate) + populate(objectMap, "vSphereIp", s.VSphereIP) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceInitializationInfo. +func (s *ServiceInitializationInfo) 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 "serviceAccountPassword": + err = unpopulate(val, "ServiceAccountPassword", &s.ServiceAccountPassword) + delete(rawMsg, key) + case "serviceAccountUsername": + err = unpopulate(val, "ServiceAccountUsername", &s.ServiceAccountUsername) + delete(rawMsg, key) + case "vSphereCertificate": + err = unpopulate(val, "VSphereCertificate", &s.VSphereCertificate) + delete(rawMsg, key) + case "vSphereIp": + err = unpopulate(val, "VSphereIP", &s.VSphereIP) + 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 SoftDeletion. +func (s SoftDeletion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "destroyed", s.Destroyed) + populate(objectMap, "eradicationTimestamp", s.EradicationTimestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SoftDeletion. +func (s *SoftDeletion) 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 "destroyed": + err = unpopulate(val, "Destroyed", &s.Destroyed) + delete(rawMsg, key) + case "eradicationTimestamp": + err = unpopulate(val, "EradicationTimestamp", &s.EradicationTimestamp) + 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 Space. +func (s Space) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "shared", s.Shared) + populate(objectMap, "snapshots", s.Snapshots) + populate(objectMap, "totalUsed", s.TotalUsed) + populate(objectMap, "unique", s.Unique) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Space. +func (s *Space) 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 "shared": + err = unpopulate(val, "Shared", &s.Shared) + delete(rawMsg, key) + case "snapshots": + err = unpopulate(val, "Snapshots", &s.Snapshots) + delete(rawMsg, key) + case "totalUsed": + err = unpopulate(val, "TotalUsed", &s.TotalUsed) + delete(rawMsg, key) + case "unique": + err = unpopulate(val, "Unique", &s.Unique) + 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 StoragePool. +func (s StoragePool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "location", s.Location) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StoragePool. +func (s *StoragePool) 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 "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + 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 StoragePoolEnableAvsConnectionPost. +func (s StoragePoolEnableAvsConnectionPost) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sddcResourceId", s.ClusterResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StoragePoolEnableAvsConnectionPost. +func (s *StoragePoolEnableAvsConnectionPost) 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 "sddcResourceId": + err = unpopulate(val, "ClusterResourceID", &s.ClusterResourceID) + 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 StoragePoolFinalizeAvsConnectionPost. +func (s StoragePoolFinalizeAvsConnectionPost) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "serviceInitializationData", s.ServiceInitializationData) + populate(objectMap, "serviceInitializationDataEnc", s.ServiceInitializationDataEnc) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StoragePoolFinalizeAvsConnectionPost. +func (s *StoragePoolFinalizeAvsConnectionPost) 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 "serviceInitializationData": + err = unpopulate(val, "ServiceInitializationData", &s.ServiceInitializationData) + delete(rawMsg, key) + case "serviceInitializationDataEnc": + err = unpopulate(val, "ServiceInitializationDataEnc", &s.ServiceInitializationDataEnc) + 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 StoragePoolHealthInfo. +func (s StoragePoolHealthInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "alerts", s.Alerts) + populate(objectMap, "health", s.Health) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StoragePoolHealthInfo. +func (s *StoragePoolHealthInfo) 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 "alerts": + err = unpopulate(val, "Alerts", &s.Alerts) + delete(rawMsg, key) + case "health": + err = unpopulate(val, "Health", &s.Health) + 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 StoragePoolLimits. +func (s StoragePoolLimits) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "physicalAvailabilityZones", s.PhysicalAvailabilityZones) + populate(objectMap, "provisionedBandwidthMbPerSec", s.ProvisionedBandwidthMbPerSec) + populate(objectMap, "provisionedIops", s.ProvisionedIops) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StoragePoolLimits. +func (s *StoragePoolLimits) 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 "physicalAvailabilityZones": + err = unpopulate(val, "PhysicalAvailabilityZones", &s.PhysicalAvailabilityZones) + delete(rawMsg, key) + case "provisionedBandwidthMbPerSec": + err = unpopulate(val, "ProvisionedBandwidthMbPerSec", &s.ProvisionedBandwidthMbPerSec) + delete(rawMsg, key) + case "provisionedIops": + err = unpopulate(val, "ProvisionedIops", &s.ProvisionedIops) + 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 StoragePoolListResult. +func (s StoragePoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StoragePoolListResult. +func (s *StoragePoolListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + 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 StoragePoolProperties. +func (s StoragePoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "availabilityZone", s.AvailabilityZone) + populate(objectMap, "avs", s.Avs) + populate(objectMap, "dataRetentionPeriod", s.DataRetentionPeriod) + populate(objectMap, "provisionedBandwidthMbPerSec", s.ProvisionedBandwidthMbPerSec) + populate(objectMap, "provisionedIops", s.ProvisionedIops) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "reservationResourceId", s.ReservationResourceID) + populate(objectMap, "storagePoolInternalId", s.StoragePoolInternalID) + populate(objectMap, "vnetInjection", s.VnetInjection) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StoragePoolProperties. +func (s *StoragePoolProperties) 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 "availabilityZone": + err = unpopulate(val, "AvailabilityZone", &s.AvailabilityZone) + delete(rawMsg, key) + case "avs": + err = unpopulate(val, "Avs", &s.Avs) + delete(rawMsg, key) + case "dataRetentionPeriod": + err = unpopulate(val, "DataRetentionPeriod", &s.DataRetentionPeriod) + delete(rawMsg, key) + case "provisionedBandwidthMbPerSec": + err = unpopulate(val, "ProvisionedBandwidthMbPerSec", &s.ProvisionedBandwidthMbPerSec) + delete(rawMsg, key) + case "provisionedIops": + err = unpopulate(val, "ProvisionedIops", &s.ProvisionedIops) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "reservationResourceId": + err = unpopulate(val, "ReservationResourceID", &s.ReservationResourceID) + delete(rawMsg, key) + case "storagePoolInternalId": + err = unpopulate(val, "StoragePoolInternalID", &s.StoragePoolInternalID) + delete(rawMsg, key) + case "vnetInjection": + err = unpopulate(val, "VnetInjection", &s.VnetInjection) + 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 StoragePoolUpdate. +func (s StoragePoolUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StoragePoolUpdate. +func (s *StoragePoolUpdate) 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 "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + 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 StoragePoolUpdateProperties. +func (s StoragePoolUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisionedBandwidthMbPerSec", s.ProvisionedBandwidthMbPerSec) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StoragePoolUpdateProperties. +func (s *StoragePoolUpdateProperties) 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 "provisionedBandwidthMbPerSec": + err = unpopulate(val, "ProvisionedBandwidthMbPerSec", &s.ProvisionedBandwidthMbPerSec) + 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 SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(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 = unpopulateDateTimeRFC3339(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 = unpopulateDateTimeRFC3339(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 UserAssignedIdentity. +func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentity. +func (u *UserAssignedIdentity) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserDetails. +func (u UserDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "companyDetails", u.CompanyDetails) + populate(objectMap, "emailAddress", u.EmailAddress) + populate(objectMap, "firstName", u.FirstName) + populate(objectMap, "lastName", u.LastName) + populate(objectMap, "phoneNumber", u.PhoneNumber) + populate(objectMap, "upn", u.Upn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserDetails. +func (u *UserDetails) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "companyDetails": + err = unpopulate(val, "CompanyDetails", &u.CompanyDetails) + delete(rawMsg, key) + case "emailAddress": + err = unpopulate(val, "EmailAddress", &u.EmailAddress) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, "FirstName", &u.FirstName) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, "LastName", &u.LastName) + delete(rawMsg, key) + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &u.PhoneNumber) + delete(rawMsg, key) + case "upn": + err = unpopulate(val, "Upn", &u.Upn) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VnetInjection. +func (v VnetInjection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "subnetId", v.SubnetID) + populate(objectMap, "vnetId", v.VnetID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VnetInjection. +func (v *VnetInjection) 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 "subnetId": + err = unpopulate(val, "SubnetID", &v.SubnetID) + delete(rawMsg, key) + case "vnetId": + err = unpopulate(val, "VnetID", &v.VnetID) + 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 VolumeLimits. +func (v VolumeLimits) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisionedSize", v.ProvisionedSize) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeLimits. +func (v *VolumeLimits) 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 "provisionedSize": + err = unpopulate(val, "ProvisionedSize", &v.ProvisionedSize) + 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, "avs", v.Avs) + populate(objectMap, "createdTimestamp", v.CreatedTimestamp) + populate(objectMap, "displayName", v.DisplayName) + populate(objectMap, "provisionedSize", v.ProvisionedSize) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "softDeletion", v.SoftDeletion) + populate(objectMap, "space", v.Space) + populate(objectMap, "storagePoolInternalId", v.StoragePoolInternalID) + populate(objectMap, "storagePoolResourceId", v.StoragePoolResourceID) + populate(objectMap, "volumeInternalId", v.VolumeInternalID) + populate(objectMap, "volumeType", v.VolumeType) + 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 "avs": + err = unpopulate(val, "Avs", &v.Avs) + delete(rawMsg, key) + case "createdTimestamp": + err = unpopulate(val, "CreatedTimestamp", &v.CreatedTimestamp) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &v.DisplayName) + delete(rawMsg, key) + case "provisionedSize": + err = unpopulate(val, "ProvisionedSize", &v.ProvisionedSize) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + delete(rawMsg, key) + case "softDeletion": + err = unpopulate(val, "SoftDeletion", &v.SoftDeletion) + delete(rawMsg, key) + case "space": + err = unpopulate(val, "Space", &v.Space) + delete(rawMsg, key) + case "storagePoolInternalId": + err = unpopulate(val, "StoragePoolInternalID", &v.StoragePoolInternalID) + delete(rawMsg, key) + case "storagePoolResourceId": + err = unpopulate(val, "StoragePoolResourceID", &v.StoragePoolResourceID) + delete(rawMsg, key) + case "volumeInternalId": + err = unpopulate(val, "VolumeInternalID", &v.VolumeInternalID) + delete(rawMsg, key) + case "volumeType": + err = unpopulate(val, "VolumeType", &v.VolumeType) + 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 || string(data) == "null" { + 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/purestorageblock/armpurestorageblock/operations_client.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/operations_client.go new file mode 100644 index 000000000000..b1350ba30bd0 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/operations_client.go @@ -0,0 +1,84 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +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, 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 2024-11-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) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/PureStorage.Block/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", "2024-11-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/purestorageblock/armpurestorageblock/operations_client_example_test.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/operations_client_example_test.go new file mode 100644 index 000000000000..110e990495fd --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/operations_client_example_test.go @@ -0,0 +1,85 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "log" +) + +// Generated from example definition: 2024-11-01-preview/Operations_List_MaximumSet_Gen.json +func ExampleOperationsClient_NewListPager_operationsList() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armpurestorageblock.OperationsClientListResponse{ + // OperationListResult: armpurestorageblock.OperationListResult{ + // Value: []*armpurestorageblock.Operation{ + // { + // Name: to.Ptr("wikaab"), + // IsDataAction: to.Ptr(true), + // Display: &armpurestorageblock.OperationDisplay{ + // Provider: to.Ptr("oqlfyrrvbitoadnqagqkgxylxkow"), + // Resource: to.Ptr("dxeqyes"), + // Operation: to.Ptr("mk"), + // Description: to.Ptr("zcgnhznothktczdlyovbbjwnxep"), + // }, + // Origin: to.Ptr(armpurestorageblock.OriginUser), + // ActionType: to.Ptr(armpurestorageblock.ActionTypeInternal), + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-11-01-preview/Operations_List_MinimumSet_Gen.json +func ExampleOperationsClient_NewListPager_operationsListMinimumGenSet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armpurestorageblock.OperationsClientListResponse{ + // OperationListResult: armpurestorageblock.OperationListResult{ + // }, + // } + } +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/options.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/options.go new file mode 100644 index 000000000000..384c1eb05063 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/options.go @@ -0,0 +1,230 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +// AvsStorageContainerVolumesClientBeginDeleteOptions contains the optional parameters for the AvsStorageContainerVolumesClient.BeginDelete +// method. +type AvsStorageContainerVolumesClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// AvsStorageContainerVolumesClientBeginUpdateOptions contains the optional parameters for the AvsStorageContainerVolumesClient.BeginUpdate +// method. +type AvsStorageContainerVolumesClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// AvsStorageContainerVolumesClientGetOptions contains the optional parameters for the AvsStorageContainerVolumesClient.Get +// method. +type AvsStorageContainerVolumesClientGetOptions struct { + // placeholder for future optional parameters +} + +// AvsStorageContainerVolumesClientListByAvsStorageContainerOptions contains the optional parameters for the AvsStorageContainerVolumesClient.NewListByAvsStorageContainerPager +// method. +type AvsStorageContainerVolumesClientListByAvsStorageContainerOptions struct { + // placeholder for future optional parameters +} + +// AvsStorageContainersClientBeginDeleteOptions contains the optional parameters for the AvsStorageContainersClient.BeginDelete +// method. +type AvsStorageContainersClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// AvsStorageContainersClientGetOptions contains the optional parameters for the AvsStorageContainersClient.Get method. +type AvsStorageContainersClientGetOptions struct { + // placeholder for future optional parameters +} + +// AvsStorageContainersClientListByStoragePoolOptions contains the optional parameters for the AvsStorageContainersClient.NewListByStoragePoolPager +// method. +type AvsStorageContainersClientListByStoragePoolOptions struct { + // placeholder for future optional parameters +} + +// AvsVMVolumesClientBeginDeleteOptions contains the optional parameters for the AvsVMVolumesClient.BeginDelete method. +type AvsVMVolumesClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// AvsVMVolumesClientBeginUpdateOptions contains the optional parameters for the AvsVMVolumesClient.BeginUpdate method. +type AvsVMVolumesClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// AvsVMVolumesClientGetOptions contains the optional parameters for the AvsVMVolumesClient.Get method. +type AvsVMVolumesClientGetOptions struct { + // placeholder for future optional parameters +} + +// AvsVMVolumesClientListByAvsVMOptions contains the optional parameters for the AvsVMVolumesClient.NewListByAvsVMPager method. +type AvsVMVolumesClientListByAvsVMOptions struct { + // placeholder for future optional parameters +} + +// AvsVMsClientBeginDeleteOptions contains the optional parameters for the AvsVMsClient.BeginDelete method. +type AvsVMsClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// AvsVMsClientBeginUpdateOptions contains the optional parameters for the AvsVMsClient.BeginUpdate method. +type AvsVMsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// AvsVMsClientGetOptions contains the optional parameters for the AvsVMsClient.Get method. +type AvsVMsClientGetOptions struct { + // placeholder for future optional parameters +} + +// AvsVMsClientListByStoragePoolOptions contains the optional parameters for the AvsVMsClient.NewListByStoragePoolPager method. +type AvsVMsClientListByStoragePoolOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// ReservationsClientBeginCreateOptions contains the optional parameters for the ReservationsClient.BeginCreate method. +type ReservationsClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ReservationsClientBeginDeleteOptions contains the optional parameters for the ReservationsClient.BeginDelete method. +type ReservationsClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ReservationsClientBeginUpdateOptions contains the optional parameters for the ReservationsClient.BeginUpdate method. +type ReservationsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ReservationsClientGetBillingReportOptions contains the optional parameters for the ReservationsClient.GetBillingReport +// method. +type ReservationsClientGetBillingReportOptions struct { + // placeholder for future optional parameters +} + +// ReservationsClientGetBillingStatusOptions contains the optional parameters for the ReservationsClient.GetBillingStatus +// method. +type ReservationsClientGetBillingStatusOptions struct { + // placeholder for future optional parameters +} + +// ReservationsClientGetOptions contains the optional parameters for the ReservationsClient.Get method. +type ReservationsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ReservationsClientGetResourceLimitsOptions contains the optional parameters for the ReservationsClient.GetResourceLimits +// method. +type ReservationsClientGetResourceLimitsOptions struct { + // placeholder for future optional parameters +} + +// ReservationsClientListByResourceGroupOptions contains the optional parameters for the ReservationsClient.NewListByResourceGroupPager +// method. +type ReservationsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ReservationsClientListBySubscriptionOptions contains the optional parameters for the ReservationsClient.NewListBySubscriptionPager +// method. +type ReservationsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// StoragePoolsClientBeginCreateOptions contains the optional parameters for the StoragePoolsClient.BeginCreate method. +type StoragePoolsClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// StoragePoolsClientBeginDeleteOptions contains the optional parameters for the StoragePoolsClient.BeginDelete method. +type StoragePoolsClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// StoragePoolsClientBeginDisableAvsConnectionOptions contains the optional parameters for the StoragePoolsClient.BeginDisableAvsConnection +// method. +type StoragePoolsClientBeginDisableAvsConnectionOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// StoragePoolsClientBeginEnableAvsConnectionOptions contains the optional parameters for the StoragePoolsClient.BeginEnableAvsConnection +// method. +type StoragePoolsClientBeginEnableAvsConnectionOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// StoragePoolsClientBeginFinalizeAvsConnectionOptions contains the optional parameters for the StoragePoolsClient.BeginFinalizeAvsConnection +// method. +type StoragePoolsClientBeginFinalizeAvsConnectionOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// StoragePoolsClientBeginRepairAvsConnectionOptions contains the optional parameters for the StoragePoolsClient.BeginRepairAvsConnection +// method. +type StoragePoolsClientBeginRepairAvsConnectionOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// StoragePoolsClientBeginUpdateOptions contains the optional parameters for the StoragePoolsClient.BeginUpdate method. +type StoragePoolsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// StoragePoolsClientGetAvsConnectionOptions contains the optional parameters for the StoragePoolsClient.GetAvsConnection +// method. +type StoragePoolsClientGetAvsConnectionOptions struct { + // placeholder for future optional parameters +} + +// StoragePoolsClientGetAvsStatusOptions contains the optional parameters for the StoragePoolsClient.GetAvsStatus method. +type StoragePoolsClientGetAvsStatusOptions struct { + // placeholder for future optional parameters +} + +// StoragePoolsClientGetHealthStatusOptions contains the optional parameters for the StoragePoolsClient.GetHealthStatus method. +type StoragePoolsClientGetHealthStatusOptions struct { + // placeholder for future optional parameters +} + +// StoragePoolsClientGetOptions contains the optional parameters for the StoragePoolsClient.Get method. +type StoragePoolsClientGetOptions struct { + // placeholder for future optional parameters +} + +// StoragePoolsClientListByResourceGroupOptions contains the optional parameters for the StoragePoolsClient.NewListByResourceGroupPager +// method. +type StoragePoolsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// StoragePoolsClientListBySubscriptionOptions contains the optional parameters for the StoragePoolsClient.NewListBySubscriptionPager +// method. +type StoragePoolsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/reservations_client.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/reservations_client.go new file mode 100644 index 000000000000..bbd9734a0c67 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/reservations_client.go @@ -0,0 +1,652 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +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" +) + +// ReservationsClient contains the methods for the Reservations group. +// Don't use this type directly, use NewReservationsClient() instead. +type ReservationsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewReservationsClient creates a new instance of ReservationsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewReservationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ReservationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ReservationsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Create a reservation +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - reservationName - Name of the reservation. +// - resource - Resource create parameters. +// - options - ReservationsClientBeginCreateOptions contains the optional parameters for the ReservationsClient.BeginCreate +// method. +func (client *ReservationsClient) BeginCreate(ctx context.Context, resourceGroupName string, reservationName string, resource Reservation, options *ReservationsClientBeginCreateOptions) (*runtime.Poller[ReservationsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, reservationName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReservationsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReservationsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create a reservation +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *ReservationsClient) create(ctx context.Context, resourceGroupName string, reservationName string, resource Reservation, options *ReservationsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "ReservationsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, reservationName, 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 +} + +// createCreateRequest creates the Create request. +func (client *ReservationsClient) createCreateRequest(ctx context.Context, resourceGroupName string, reservationName string, resource Reservation, _ *ReservationsClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/reservations/{reservationName}" + 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 reservationName == "" { + return nil, errors.New("parameter reservationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationName}", url.PathEscape(reservationName)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a reservation +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - reservationName - Name of the reservation. +// - options - ReservationsClientBeginDeleteOptions contains the optional parameters for the ReservationsClient.BeginDelete +// method. +func (client *ReservationsClient) BeginDelete(ctx context.Context, resourceGroupName string, reservationName string, options *ReservationsClientBeginDeleteOptions) (*runtime.Poller[ReservationsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, reservationName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReservationsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReservationsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a reservation +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *ReservationsClient) deleteOperation(ctx context.Context, resourceGroupName string, reservationName string, options *ReservationsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "ReservationsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, reservationName, 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.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ReservationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, reservationName string, _ *ReservationsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/reservations/{reservationName}" + 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 reservationName == "" { + return nil, errors.New("parameter reservationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationName}", url.PathEscape(reservationName)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a reservation +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - reservationName - Name of the reservation. +// - options - ReservationsClientGetOptions contains the optional parameters for the ReservationsClient.Get method. +func (client *ReservationsClient) Get(ctx context.Context, resourceGroupName string, reservationName string, options *ReservationsClientGetOptions) (ReservationsClientGetResponse, error) { + var err error + const operationName = "ReservationsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, reservationName, options) + if err != nil { + return ReservationsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReservationsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReservationsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ReservationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, reservationName string, _ *ReservationsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/reservations/{reservationName}" + 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 reservationName == "" { + return nil, errors.New("parameter reservationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationName}", url.PathEscape(reservationName)) + 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", "2024-11-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 *ReservationsClient) getHandleResponse(resp *http.Response) (ReservationsClientGetResponse, error) { + result := ReservationsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Reservation); err != nil { + return ReservationsClientGetResponse{}, err + } + return result, nil +} + +// GetBillingReport - Provides a summarized report along with actions for resources billed via given reservation +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - reservationName - Name of the reservation. +// - options - ReservationsClientGetBillingReportOptions contains the optional parameters for the ReservationsClient.GetBillingReport +// method. +func (client *ReservationsClient) GetBillingReport(ctx context.Context, resourceGroupName string, reservationName string, options *ReservationsClientGetBillingReportOptions) (ReservationsClientGetBillingReportResponse, error) { + var err error + const operationName = "ReservationsClient.GetBillingReport" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getBillingReportCreateRequest(ctx, resourceGroupName, reservationName, options) + if err != nil { + return ReservationsClientGetBillingReportResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReservationsClientGetBillingReportResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReservationsClientGetBillingReportResponse{}, err + } + resp, err := client.getBillingReportHandleResponse(httpResp) + return resp, err +} + +// getBillingReportCreateRequest creates the GetBillingReport request. +func (client *ReservationsClient) getBillingReportCreateRequest(ctx context.Context, resourceGroupName string, reservationName string, _ *ReservationsClientGetBillingReportOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/reservations/{reservationName}/getBillingReport" + 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 reservationName == "" { + return nil, errors.New("parameter reservationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationName}", url.PathEscape(reservationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getBillingReportHandleResponse handles the GetBillingReport response. +func (client *ReservationsClient) getBillingReportHandleResponse(resp *http.Response) (ReservationsClientGetBillingReportResponse, error) { + result := ReservationsClientGetBillingReportResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationBillingUsageReport); err != nil { + return ReservationsClientGetBillingReportResponse{}, err + } + return result, nil +} + +// GetBillingStatus - Provides various statistics about resources billed via given reservation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - reservationName - Name of the reservation. +// - options - ReservationsClientGetBillingStatusOptions contains the optional parameters for the ReservationsClient.GetBillingStatus +// method. +func (client *ReservationsClient) GetBillingStatus(ctx context.Context, resourceGroupName string, reservationName string, options *ReservationsClientGetBillingStatusOptions) (ReservationsClientGetBillingStatusResponse, error) { + var err error + const operationName = "ReservationsClient.GetBillingStatus" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getBillingStatusCreateRequest(ctx, resourceGroupName, reservationName, options) + if err != nil { + return ReservationsClientGetBillingStatusResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReservationsClientGetBillingStatusResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReservationsClientGetBillingStatusResponse{}, err + } + resp, err := client.getBillingStatusHandleResponse(httpResp) + return resp, err +} + +// getBillingStatusCreateRequest creates the GetBillingStatus request. +func (client *ReservationsClient) getBillingStatusCreateRequest(ctx context.Context, resourceGroupName string, reservationName string, _ *ReservationsClientGetBillingStatusOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/reservations/{reservationName}/getBillingStatus" + 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 reservationName == "" { + return nil, errors.New("parameter reservationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationName}", url.PathEscape(reservationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getBillingStatusHandleResponse handles the GetBillingStatus response. +func (client *ReservationsClient) getBillingStatusHandleResponse(resp *http.Response) (ReservationsClientGetBillingStatusResponse, error) { + result := ReservationsClientGetBillingStatusResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationBillingStatus); err != nil { + return ReservationsClientGetBillingStatusResponse{}, err + } + return result, nil +} + +// GetResourceLimits - Limits constraining certain resource properties. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - reservationName - Name of the reservation. +// - options - ReservationsClientGetResourceLimitsOptions contains the optional parameters for the ReservationsClient.GetResourceLimits +// method. +func (client *ReservationsClient) GetResourceLimits(ctx context.Context, resourceGroupName string, reservationName string, options *ReservationsClientGetResourceLimitsOptions) (ReservationsClientGetResourceLimitsResponse, error) { + var err error + const operationName = "ReservationsClient.GetResourceLimits" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getResourceLimitsCreateRequest(ctx, resourceGroupName, reservationName, options) + if err != nil { + return ReservationsClientGetResourceLimitsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReservationsClientGetResourceLimitsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReservationsClientGetResourceLimitsResponse{}, err + } + resp, err := client.getResourceLimitsHandleResponse(httpResp) + return resp, err +} + +// getResourceLimitsCreateRequest creates the GetResourceLimits request. +func (client *ReservationsClient) getResourceLimitsCreateRequest(ctx context.Context, resourceGroupName string, reservationName string, _ *ReservationsClientGetResourceLimitsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/reservations/{reservationName}/getResourceLimits" + 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 reservationName == "" { + return nil, errors.New("parameter reservationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationName}", url.PathEscape(reservationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getResourceLimitsHandleResponse handles the GetResourceLimits response. +func (client *ReservationsClient) getResourceLimitsHandleResponse(resp *http.Response) (ReservationsClientGetResourceLimitsResponse, error) { + result := ReservationsClientGetResourceLimitsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LimitDetails); err != nil { + return ReservationsClientGetResourceLimitsResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List reservations by resource group +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ReservationsClientListByResourceGroupOptions contains the optional parameters for the ReservationsClient.NewListByResourceGroupPager +// method. +func (client *ReservationsClient) NewListByResourceGroupPager(resourceGroupName string, options *ReservationsClientListByResourceGroupOptions) *runtime.Pager[ReservationsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ReservationsClientListByResourceGroupResponse]{ + More: func(page ReservationsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ReservationsClientListByResourceGroupResponse) (ReservationsClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ReservationsClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return ReservationsClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ReservationsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *ReservationsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/reservations" + 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", "2024-11-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 *ReservationsClient) listByResourceGroupHandleResponse(resp *http.Response) (ReservationsClientListByResourceGroupResponse, error) { + result := ReservationsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationListResult); err != nil { + return ReservationsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List reservations by Azure subscription ID +// +// Generated from API version 2024-11-01-preview +// - options - ReservationsClientListBySubscriptionOptions contains the optional parameters for the ReservationsClient.NewListBySubscriptionPager +// method. +func (client *ReservationsClient) NewListBySubscriptionPager(options *ReservationsClientListBySubscriptionOptions) *runtime.Pager[ReservationsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[ReservationsClientListBySubscriptionResponse]{ + More: func(page ReservationsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ReservationsClientListBySubscriptionResponse) (ReservationsClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ReservationsClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return ReservationsClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ReservationsClient) listBySubscriptionCreateRequest(ctx context.Context, _ *ReservationsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/PureStorage.Block/reservations" + 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", "2024-11-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 *ReservationsClient) listBySubscriptionHandleResponse(resp *http.Response) (ReservationsClientListBySubscriptionResponse, error) { + result := ReservationsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReservationListResult); err != nil { + return ReservationsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a reservation +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - reservationName - Name of the reservation. +// - properties - The resource properties to be updated. +// - options - ReservationsClientBeginUpdateOptions contains the optional parameters for the ReservationsClient.BeginUpdate +// method. +func (client *ReservationsClient) BeginUpdate(ctx context.Context, resourceGroupName string, reservationName string, properties ReservationUpdate, options *ReservationsClientBeginUpdateOptions) (*runtime.Poller[ReservationsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, reservationName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReservationsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReservationsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a reservation +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *ReservationsClient) update(ctx context.Context, resourceGroupName string, reservationName string, properties ReservationUpdate, options *ReservationsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "ReservationsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, reservationName, 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 *ReservationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, reservationName string, properties ReservationUpdate, _ *ReservationsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/reservations/{reservationName}" + 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 reservationName == "" { + return nil, errors.New("parameter reservationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationName}", url.PathEscape(reservationName)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/reservations_client_example_test.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/reservations_client_example_test.go new file mode 100644 index 000000000000..3204a2e2ddf5 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/reservations_client_example_test.go @@ -0,0 +1,151 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "log" +) + +// Generated from example definition: 2024-11-01-preview/Reservations_GetBillingReport_MaximumSet_Gen.json +func ExampleReservationsClient_GetBillingReport() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReservationsClient().GetBillingReport(ctx, "rgpurestorage", "reservationname", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.ReservationsClientGetBillingReportResponse{ + // ReservationBillingUsageReport: &armpurestorageblock.ReservationBillingUsageReport{ + // Timestamp: to.Ptr("2024-10-04T05:29:25.345Z"), + // BillingUsageProperties: []*armpurestorageblock.BillingUsageProperty{ + // { + // PropertyID: to.Ptr("fknpxmzbrocjevhnuxohiwl"), + // PropertyName: to.Ptr("rznqcuwmulhtvp"), + // CurrentValue: to.Ptr("ndiuedcwtwpedirqdq"), + // PreviousValue: to.Ptr("fqnvq"), + // Severity: to.Ptr(armpurestorageblock.UsageSeverityALERT), + // StatusMessage: to.Ptr("vkce"), + // SubProperties: []*armpurestorageblock.BillingUsageProperty{ + // }, + // }, + // }, + // OverallStatusMessage: to.Ptr("aurwogtwwsxjoocpsobslpv"), + // }, + // } +} + +// Generated from example definition: 2024-11-01-preview/Reservations_GetBillingStatus_MaximumSet_Gen.json +func ExampleReservationsClient_GetBillingStatus() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReservationsClient().GetBillingStatus(ctx, "rgpurestorage", "reservationname", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.ReservationsClientGetBillingStatusResponse{ + // ReservationBillingStatus: &armpurestorageblock.ReservationBillingStatus{ + // Timestamp: to.Ptr("2024-10-04T05:29:25.345Z"), + // TotalUsedCapacityReported: to.Ptr[int64](8), + // LowDrrPoolCount: to.Ptr[int32](5), + // DrrWeightedAverage: to.Ptr[float64](15), + // TotalNonReducibleReported: to.Ptr[int64](9), + // ExtraUsedCapacityNonReducible: to.Ptr[int64](12), + // ExtraUsedCapacityLowUsageRounding: to.Ptr[int64](9), + // ExtraUsedCapacityNonReduciblePlanDiscount: to.Ptr[int64](19), + // TotalUsedCapacityBilled: to.Ptr[int64](7), + // TotalUsedCapacityIncludedPlan: to.Ptr[int64](18), + // TotalUsedCapacityOverage: to.Ptr[int64](28), + // TotalPerformanceReported: to.Ptr[int64](29), + // TotalPerformanceIncludedPlan: to.Ptr[int64](23), + // TotalPerformanceOverage: to.Ptr[int64](16), + // }, + // } +} + +// Generated from example definition: 2024-11-01-preview/Reservations_GetResourceLimits_MaximumSet_Gen.json +func ExampleReservationsClient_GetResourceLimits() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReservationsClient().GetResourceLimits(ctx, "rgpurestorage", "storagePoolname", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.ReservationsClientGetResourceLimitsResponse{ + // LimitDetails: &armpurestorageblock.LimitDetails{ + // StoragePool: &armpurestorageblock.StoragePoolLimits{ + // ProvisionedBandwidthMbPerSec: &armpurestorageblock.RangeLimits{ + // Min: to.Ptr[int64](26), + // Max: to.Ptr[int64](2), + // }, + // ProvisionedIops: &armpurestorageblock.RangeLimits{ + // Min: to.Ptr[int64](26), + // Max: to.Ptr[int64](2), + // }, + // PhysicalAvailabilityZones: []*string{ + // to.Ptr("bhcreafgubemvymffktiojnkblw"), + // }, + // }, + // Volume: &armpurestorageblock.VolumeLimits{ + // ProvisionedSize: &armpurestorageblock.RangeLimits{ + // Min: to.Ptr[int64](26), + // Max: to.Ptr[int64](2), + // }, + // }, + // ProtectionPolicy: &armpurestorageblock.ProtectionPolicyLimits{ + // Frequency: &armpurestorageblock.RangeLimits{ + // Min: to.Ptr[int64](26), + // Max: to.Ptr[int64](2), + // }, + // Retention: &armpurestorageblock.RangeLimits{ + // Min: to.Ptr[int64](26), + // Max: to.Ptr[int64](2), + // }, + // }, + // PerformancePolicy: &armpurestorageblock.PerformancePolicyLimits{ + // IopsLimit: &armpurestorageblock.RangeLimits{ + // Min: to.Ptr[int64](26), + // Max: to.Ptr[int64](2), + // }, + // BandwidthLimit: &armpurestorageblock.RangeLimits{ + // Min: to.Ptr[int64](26), + // Max: to.Ptr[int64](2), + // }, + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/responses.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/responses.go new file mode 100644 index 000000000000..e62eca8623e3 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/responses.go @@ -0,0 +1,224 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +// AvsStorageContainerVolumesClientDeleteResponse contains the response from method AvsStorageContainerVolumesClient.BeginDelete. +type AvsStorageContainerVolumesClientDeleteResponse struct { + // placeholder for future response values +} + +// AvsStorageContainerVolumesClientGetResponse contains the response from method AvsStorageContainerVolumesClient.Get. +type AvsStorageContainerVolumesClientGetResponse struct { + // A volume contained in an AVS storage container + AvsStorageContainerVolume +} + +// AvsStorageContainerVolumesClientListByAvsStorageContainerResponse contains the response from method AvsStorageContainerVolumesClient.NewListByAvsStorageContainerPager. +type AvsStorageContainerVolumesClientListByAvsStorageContainerResponse struct { + // The response of a AvsStorageContainerVolume list operation. + AvsStorageContainerVolumeListResult +} + +// AvsStorageContainerVolumesClientUpdateResponse contains the response from method AvsStorageContainerVolumesClient.BeginUpdate. +type AvsStorageContainerVolumesClientUpdateResponse struct { + // A volume contained in an AVS storage container + AvsStorageContainerVolume +} + +// AvsStorageContainersClientDeleteResponse contains the response from method AvsStorageContainersClient.BeginDelete. +type AvsStorageContainersClientDeleteResponse struct { + // placeholder for future response values +} + +// AvsStorageContainersClientGetResponse contains the response from method AvsStorageContainersClient.Get. +type AvsStorageContainersClientGetResponse struct { + // AVS storage container resource type, representing a VMware storage container in a storage pool, which can be associated + // to and mounted as a datastore + AvsStorageContainer +} + +// AvsStorageContainersClientListByStoragePoolResponse contains the response from method AvsStorageContainersClient.NewListByStoragePoolPager. +type AvsStorageContainersClientListByStoragePoolResponse struct { + // The response of a AvsStorageContainer list operation. + AvsStorageContainerListResult +} + +// AvsVMVolumesClientDeleteResponse contains the response from method AvsVMVolumesClient.BeginDelete. +type AvsVMVolumesClientDeleteResponse struct { + // placeholder for future response values +} + +// AvsVMVolumesClientGetResponse contains the response from method AvsVMVolumesClient.Get. +type AvsVMVolumesClientGetResponse struct { + // Any volume associated to a particular AVS VM + AvsVMVolume +} + +// AvsVMVolumesClientListByAvsVMResponse contains the response from method AvsVMVolumesClient.NewListByAvsVMPager. +type AvsVMVolumesClientListByAvsVMResponse struct { + // The response of a AvsVmVolume list operation. + AvsVMVolumeListResult +} + +// AvsVMVolumesClientUpdateResponse contains the response from method AvsVMVolumesClient.BeginUpdate. +type AvsVMVolumesClientUpdateResponse struct { + // Any volume associated to a particular AVS VM + AvsVMVolume +} + +// AvsVMsClientDeleteResponse contains the response from method AvsVMsClient.BeginDelete. +type AvsVMsClientDeleteResponse struct { + // placeholder for future response values +} + +// AvsVMsClientGetResponse contains the response from method AvsVMsClient.Get. +type AvsVMsClientGetResponse struct { + // AVS VM resource type, representing all the volumes associated to an AVS VM as defined by VMware + AvsVM +} + +// AvsVMsClientListByStoragePoolResponse contains the response from method AvsVMsClient.NewListByStoragePoolPager. +type AvsVMsClientListByStoragePoolResponse struct { + // The response of a AvsVm list operation. + AvsVMListResult +} + +// AvsVMsClientUpdateResponse contains the response from method AvsVMsClient.BeginUpdate. +type AvsVMsClientUpdateResponse struct { + // AVS VM resource type, representing all the volumes associated to an AVS VM as defined by VMware + AvsVM +} + +// 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 +} + +// ReservationsClientCreateResponse contains the response from method ReservationsClient.BeginCreate. +type ReservationsClientCreateResponse struct { + // Pure Storage cloud service resource type, also called reservation + Reservation +} + +// ReservationsClientDeleteResponse contains the response from method ReservationsClient.BeginDelete. +type ReservationsClientDeleteResponse struct { + // placeholder for future response values +} + +// ReservationsClientGetBillingReportResponse contains the response from method ReservationsClient.GetBillingReport. +type ReservationsClientGetBillingReportResponse struct { + // Represents a billing usage report, including overall status and detailed properties + ReservationBillingUsageReport +} + +// ReservationsClientGetBillingStatusResponse contains the response from method ReservationsClient.GetBillingStatus. +type ReservationsClientGetBillingStatusResponse struct { + // Latest billing status for this reservation + ReservationBillingStatus +} + +// ReservationsClientGetResourceLimitsResponse contains the response from method ReservationsClient.GetResourceLimits. +type ReservationsClientGetResourceLimitsResponse struct { + // Limits constraining certain resource properties + LimitDetails +} + +// ReservationsClientGetResponse contains the response from method ReservationsClient.Get. +type ReservationsClientGetResponse struct { + // Pure Storage cloud service resource type, also called reservation + Reservation +} + +// ReservationsClientListByResourceGroupResponse contains the response from method ReservationsClient.NewListByResourceGroupPager. +type ReservationsClientListByResourceGroupResponse struct { + // The response of a Reservation list operation. + ReservationListResult +} + +// ReservationsClientListBySubscriptionResponse contains the response from method ReservationsClient.NewListBySubscriptionPager. +type ReservationsClientListBySubscriptionResponse struct { + // The response of a Reservation list operation. + ReservationListResult +} + +// ReservationsClientUpdateResponse contains the response from method ReservationsClient.BeginUpdate. +type ReservationsClientUpdateResponse struct { + // Pure Storage cloud service resource type, also called reservation + Reservation +} + +// StoragePoolsClientCreateResponse contains the response from method StoragePoolsClient.BeginCreate. +type StoragePoolsClientCreateResponse struct { + // Storage pool resource + StoragePool +} + +// StoragePoolsClientDeleteResponse contains the response from method StoragePoolsClient.BeginDelete. +type StoragePoolsClientDeleteResponse struct { + // placeholder for future response values +} + +// StoragePoolsClientDisableAvsConnectionResponse contains the response from method StoragePoolsClient.BeginDisableAvsConnection. +type StoragePoolsClientDisableAvsConnectionResponse struct { + // placeholder for future response values +} + +// StoragePoolsClientEnableAvsConnectionResponse contains the response from method StoragePoolsClient.BeginEnableAvsConnection. +type StoragePoolsClientEnableAvsConnectionResponse struct { + // placeholder for future response values +} + +// StoragePoolsClientFinalizeAvsConnectionResponse contains the response from method StoragePoolsClient.BeginFinalizeAvsConnection. +type StoragePoolsClientFinalizeAvsConnectionResponse struct { + // placeholder for future response values +} + +// StoragePoolsClientGetAvsConnectionResponse contains the response from method StoragePoolsClient.GetAvsConnection. +type StoragePoolsClientGetAvsConnectionResponse struct { + // Transient information about an on-going connection to an AVS instance + AvsConnection +} + +// StoragePoolsClientGetAvsStatusResponse contains the response from method StoragePoolsClient.GetAvsStatus. +type StoragePoolsClientGetAvsStatusResponse struct { + // Status of storage pool / AVS connection + AvsStatus +} + +// StoragePoolsClientGetHealthStatusResponse contains the response from method StoragePoolsClient.GetHealthStatus. +type StoragePoolsClientGetHealthStatusResponse struct { + // Health information for a storage pool + StoragePoolHealthInfo +} + +// StoragePoolsClientGetResponse contains the response from method StoragePoolsClient.Get. +type StoragePoolsClientGetResponse struct { + // Storage pool resource + StoragePool +} + +// StoragePoolsClientListByResourceGroupResponse contains the response from method StoragePoolsClient.NewListByResourceGroupPager. +type StoragePoolsClientListByResourceGroupResponse struct { + // The response of a StoragePool list operation. + StoragePoolListResult +} + +// StoragePoolsClientListBySubscriptionResponse contains the response from method StoragePoolsClient.NewListBySubscriptionPager. +type StoragePoolsClientListBySubscriptionResponse struct { + // The response of a StoragePool list operation. + StoragePoolListResult +} + +// StoragePoolsClientRepairAvsConnectionResponse contains the response from method StoragePoolsClient.BeginRepairAvsConnection. +type StoragePoolsClientRepairAvsConnectionResponse struct { + // placeholder for future response values +} + +// StoragePoolsClientUpdateResponse contains the response from method StoragePoolsClient.BeginUpdate. +type StoragePoolsClientUpdateResponse struct { + // Storage pool resource + StoragePool +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/storagepools_client.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/storagepools_client.go new file mode 100644 index 000000000000..1eb393e91445 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/storagepools_client.go @@ -0,0 +1,968 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +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" +) + +// StoragePoolsClient contains the methods for the StoragePools group. +// Don't use this type directly, use NewStoragePoolsClient() instead. +type StoragePoolsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewStoragePoolsClient creates a new instance of StoragePoolsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewStoragePoolsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*StoragePoolsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &StoragePoolsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Create a storage pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - resource - Resource create parameters. +// - options - StoragePoolsClientBeginCreateOptions contains the optional parameters for the StoragePoolsClient.BeginCreate +// method. +func (client *StoragePoolsClient) BeginCreate(ctx context.Context, resourceGroupName string, storagePoolName string, resource StoragePool, options *StoragePoolsClientBeginCreateOptions) (*runtime.Poller[StoragePoolsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, storagePoolName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StoragePoolsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[StoragePoolsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create a storage pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *StoragePoolsClient) create(ctx context.Context, resourceGroupName string, storagePoolName string, resource StoragePool, options *StoragePoolsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "StoragePoolsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, storagePoolName, 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 +} + +// createCreateRequest creates the Create request. +func (client *StoragePoolsClient) createCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, resource StoragePool, _ *StoragePoolsClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a storage pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - options - StoragePoolsClientBeginDeleteOptions contains the optional parameters for the StoragePoolsClient.BeginDelete +// method. +func (client *StoragePoolsClient) BeginDelete(ctx context.Context, resourceGroupName string, storagePoolName string, options *StoragePoolsClientBeginDeleteOptions) (*runtime.Poller[StoragePoolsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, storagePoolName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StoragePoolsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[StoragePoolsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a storage pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *StoragePoolsClient) deleteOperation(ctx context.Context, resourceGroupName string, storagePoolName string, options *StoragePoolsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "StoragePoolsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, storagePoolName, 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.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *StoragePoolsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, _ *StoragePoolsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginDisableAvsConnection - Disable the existing AVS connection +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - options - StoragePoolsClientBeginDisableAvsConnectionOptions contains the optional parameters for the StoragePoolsClient.BeginDisableAvsConnection +// method. +func (client *StoragePoolsClient) BeginDisableAvsConnection(ctx context.Context, resourceGroupName string, storagePoolName string, options *StoragePoolsClientBeginDisableAvsConnectionOptions) (*runtime.Poller[StoragePoolsClientDisableAvsConnectionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.disableAvsConnection(ctx, resourceGroupName, storagePoolName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StoragePoolsClientDisableAvsConnectionResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[StoragePoolsClientDisableAvsConnectionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DisableAvsConnection - Disable the existing AVS connection +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *StoragePoolsClient) disableAvsConnection(ctx context.Context, resourceGroupName string, storagePoolName string, options *StoragePoolsClientBeginDisableAvsConnectionOptions) (*http.Response, error) { + var err error + const operationName = "StoragePoolsClient.BeginDisableAvsConnection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.disableAvsConnectionCreateRequest(ctx, resourceGroupName, storagePoolName, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// disableAvsConnectionCreateRequest creates the DisableAvsConnection request. +func (client *StoragePoolsClient) disableAvsConnectionCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, _ *StoragePoolsClientBeginDisableAvsConnectionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/disableAvsConnection" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginEnableAvsConnection - Initiate a connection between the storage pool and a specified AVS SDDC resource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - properties - Storage pool EnableAvsConnection properties +// - options - StoragePoolsClientBeginEnableAvsConnectionOptions contains the optional parameters for the StoragePoolsClient.BeginEnableAvsConnection +// method. +func (client *StoragePoolsClient) BeginEnableAvsConnection(ctx context.Context, resourceGroupName string, storagePoolName string, properties StoragePoolEnableAvsConnectionPost, options *StoragePoolsClientBeginEnableAvsConnectionOptions) (*runtime.Poller[StoragePoolsClientEnableAvsConnectionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.enableAvsConnection(ctx, resourceGroupName, storagePoolName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StoragePoolsClientEnableAvsConnectionResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[StoragePoolsClientEnableAvsConnectionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// EnableAvsConnection - Initiate a connection between the storage pool and a specified AVS SDDC resource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *StoragePoolsClient) enableAvsConnection(ctx context.Context, resourceGroupName string, storagePoolName string, properties StoragePoolEnableAvsConnectionPost, options *StoragePoolsClientBeginEnableAvsConnectionOptions) (*http.Response, error) { + var err error + const operationName = "StoragePoolsClient.BeginEnableAvsConnection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.enableAvsConnectionCreateRequest(ctx, resourceGroupName, storagePoolName, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// enableAvsConnectionCreateRequest creates the EnableAvsConnection request. +func (client *StoragePoolsClient) enableAvsConnectionCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, properties StoragePoolEnableAvsConnectionPost, _ *StoragePoolsClientBeginEnableAvsConnectionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/enableAvsConnection" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// BeginFinalizeAvsConnection - Finalize an already started AVS connection to a specific AVS SDDC +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - properties - Storage pool FinalizeAvsConnection properties +// - options - StoragePoolsClientBeginFinalizeAvsConnectionOptions contains the optional parameters for the StoragePoolsClient.BeginFinalizeAvsConnection +// method. +func (client *StoragePoolsClient) BeginFinalizeAvsConnection(ctx context.Context, resourceGroupName string, storagePoolName string, properties StoragePoolFinalizeAvsConnectionPost, options *StoragePoolsClientBeginFinalizeAvsConnectionOptions) (*runtime.Poller[StoragePoolsClientFinalizeAvsConnectionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.finalizeAvsConnection(ctx, resourceGroupName, storagePoolName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StoragePoolsClientFinalizeAvsConnectionResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[StoragePoolsClientFinalizeAvsConnectionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// FinalizeAvsConnection - Finalize an already started AVS connection to a specific AVS SDDC +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *StoragePoolsClient) finalizeAvsConnection(ctx context.Context, resourceGroupName string, storagePoolName string, properties StoragePoolFinalizeAvsConnectionPost, options *StoragePoolsClientBeginFinalizeAvsConnectionOptions) (*http.Response, error) { + var err error + const operationName = "StoragePoolsClient.BeginFinalizeAvsConnection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.finalizeAvsConnectionCreateRequest(ctx, resourceGroupName, storagePoolName, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// finalizeAvsConnectionCreateRequest creates the FinalizeAvsConnection request. +func (client *StoragePoolsClient) finalizeAvsConnectionCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, properties StoragePoolFinalizeAvsConnectionPost, _ *StoragePoolsClientBeginFinalizeAvsConnectionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/finalizeAvsConnection" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// Get - Get a storage pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - options - StoragePoolsClientGetOptions contains the optional parameters for the StoragePoolsClient.Get method. +func (client *StoragePoolsClient) Get(ctx context.Context, resourceGroupName string, storagePoolName string, options *StoragePoolsClientGetOptions) (StoragePoolsClientGetResponse, error) { + var err error + const operationName = "StoragePoolsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, storagePoolName, options) + if err != nil { + return StoragePoolsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return StoragePoolsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return StoragePoolsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *StoragePoolsClient) getCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, _ *StoragePoolsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + 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", "2024-11-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 *StoragePoolsClient) getHandleResponse(resp *http.Response) (StoragePoolsClientGetResponse, error) { + result := StoragePoolsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StoragePool); err != nil { + return StoragePoolsClientGetResponse{}, err + } + return result, nil +} + +// GetAvsConnection - Returns current information about an on-going connection to an AVS instance +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - options - StoragePoolsClientGetAvsConnectionOptions contains the optional parameters for the StoragePoolsClient.GetAvsConnection +// method. +func (client *StoragePoolsClient) GetAvsConnection(ctx context.Context, resourceGroupName string, storagePoolName string, options *StoragePoolsClientGetAvsConnectionOptions) (StoragePoolsClientGetAvsConnectionResponse, error) { + var err error + const operationName = "StoragePoolsClient.GetAvsConnection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getAvsConnectionCreateRequest(ctx, resourceGroupName, storagePoolName, options) + if err != nil { + return StoragePoolsClientGetAvsConnectionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return StoragePoolsClientGetAvsConnectionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return StoragePoolsClientGetAvsConnectionResponse{}, err + } + resp, err := client.getAvsConnectionHandleResponse(httpResp) + return resp, err +} + +// getAvsConnectionCreateRequest creates the GetAvsConnection request. +func (client *StoragePoolsClient) getAvsConnectionCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, _ *StoragePoolsClientGetAvsConnectionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/getAvsConnection" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getAvsConnectionHandleResponse handles the GetAvsConnection response. +func (client *StoragePoolsClient) getAvsConnectionHandleResponse(resp *http.Response) (StoragePoolsClientGetAvsConnectionResponse, error) { + result := StoragePoolsClientGetAvsConnectionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvsConnection); err != nil { + return StoragePoolsClientGetAvsConnectionResponse{}, err + } + return result, nil +} + +// GetAvsStatus - Returns the status of the storage pool connection to AVS +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - options - StoragePoolsClientGetAvsStatusOptions contains the optional parameters for the StoragePoolsClient.GetAvsStatus +// method. +func (client *StoragePoolsClient) GetAvsStatus(ctx context.Context, resourceGroupName string, storagePoolName string, options *StoragePoolsClientGetAvsStatusOptions) (StoragePoolsClientGetAvsStatusResponse, error) { + var err error + const operationName = "StoragePoolsClient.GetAvsStatus" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getAvsStatusCreateRequest(ctx, resourceGroupName, storagePoolName, options) + if err != nil { + return StoragePoolsClientGetAvsStatusResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return StoragePoolsClientGetAvsStatusResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return StoragePoolsClientGetAvsStatusResponse{}, err + } + resp, err := client.getAvsStatusHandleResponse(httpResp) + return resp, err +} + +// getAvsStatusCreateRequest creates the GetAvsStatus request. +func (client *StoragePoolsClient) getAvsStatusCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, _ *StoragePoolsClientGetAvsStatusOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/getAvsStatus" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getAvsStatusHandleResponse handles the GetAvsStatus response. +func (client *StoragePoolsClient) getAvsStatusHandleResponse(resp *http.Response) (StoragePoolsClientGetAvsStatusResponse, error) { + result := StoragePoolsClientGetAvsStatusResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AvsStatus); err != nil { + return StoragePoolsClientGetAvsStatusResponse{}, err + } + return result, nil +} + +// GetHealthStatus - Retrieve health metrics of a storage pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - options - StoragePoolsClientGetHealthStatusOptions contains the optional parameters for the StoragePoolsClient.GetHealthStatus +// method. +func (client *StoragePoolsClient) GetHealthStatus(ctx context.Context, resourceGroupName string, storagePoolName string, options *StoragePoolsClientGetHealthStatusOptions) (StoragePoolsClientGetHealthStatusResponse, error) { + var err error + const operationName = "StoragePoolsClient.GetHealthStatus" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getHealthStatusCreateRequest(ctx, resourceGroupName, storagePoolName, options) + if err != nil { + return StoragePoolsClientGetHealthStatusResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return StoragePoolsClientGetHealthStatusResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return StoragePoolsClientGetHealthStatusResponse{}, err + } + resp, err := client.getHealthStatusHandleResponse(httpResp) + return resp, err +} + +// getHealthStatusCreateRequest creates the GetHealthStatus request. +func (client *StoragePoolsClient) getHealthStatusCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, _ *StoragePoolsClientGetHealthStatusOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/getHealthStatus" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHealthStatusHandleResponse handles the GetHealthStatus response. +func (client *StoragePoolsClient) getHealthStatusHandleResponse(resp *http.Response) (StoragePoolsClientGetHealthStatusResponse, error) { + result := StoragePoolsClientGetHealthStatusResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StoragePoolHealthInfo); err != nil { + return StoragePoolsClientGetHealthStatusResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List storage pools by resource group +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - StoragePoolsClientListByResourceGroupOptions contains the optional parameters for the StoragePoolsClient.NewListByResourceGroupPager +// method. +func (client *StoragePoolsClient) NewListByResourceGroupPager(resourceGroupName string, options *StoragePoolsClientListByResourceGroupOptions) *runtime.Pager[StoragePoolsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[StoragePoolsClientListByResourceGroupResponse]{ + More: func(page StoragePoolsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *StoragePoolsClientListByResourceGroupResponse) (StoragePoolsClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "StoragePoolsClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return StoragePoolsClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *StoragePoolsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *StoragePoolsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools" + 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", "2024-11-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 *StoragePoolsClient) listByResourceGroupHandleResponse(resp *http.Response) (StoragePoolsClientListByResourceGroupResponse, error) { + result := StoragePoolsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StoragePoolListResult); err != nil { + return StoragePoolsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List storage pools by Azure subscription ID +// +// Generated from API version 2024-11-01-preview +// - options - StoragePoolsClientListBySubscriptionOptions contains the optional parameters for the StoragePoolsClient.NewListBySubscriptionPager +// method. +func (client *StoragePoolsClient) NewListBySubscriptionPager(options *StoragePoolsClientListBySubscriptionOptions) *runtime.Pager[StoragePoolsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[StoragePoolsClientListBySubscriptionResponse]{ + More: func(page StoragePoolsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *StoragePoolsClientListBySubscriptionResponse) (StoragePoolsClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "StoragePoolsClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return StoragePoolsClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *StoragePoolsClient) listBySubscriptionCreateRequest(ctx context.Context, _ *StoragePoolsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/PureStorage.Block/storagePools" + 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", "2024-11-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 *StoragePoolsClient) listBySubscriptionHandleResponse(resp *http.Response) (StoragePoolsClientListBySubscriptionResponse, error) { + result := StoragePoolsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StoragePoolListResult); err != nil { + return StoragePoolsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginRepairAvsConnection - Test and repair, if needed, all configuration elements of the storage pool connection to the +// AVS instance +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - options - StoragePoolsClientBeginRepairAvsConnectionOptions contains the optional parameters for the StoragePoolsClient.BeginRepairAvsConnection +// method. +func (client *StoragePoolsClient) BeginRepairAvsConnection(ctx context.Context, resourceGroupName string, storagePoolName string, options *StoragePoolsClientBeginRepairAvsConnectionOptions) (*runtime.Poller[StoragePoolsClientRepairAvsConnectionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.repairAvsConnection(ctx, resourceGroupName, storagePoolName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StoragePoolsClientRepairAvsConnectionResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[StoragePoolsClientRepairAvsConnectionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// RepairAvsConnection - Test and repair, if needed, all configuration elements of the storage pool connection to the AVS +// instance +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *StoragePoolsClient) repairAvsConnection(ctx context.Context, resourceGroupName string, storagePoolName string, options *StoragePoolsClientBeginRepairAvsConnectionOptions) (*http.Response, error) { + var err error + const operationName = "StoragePoolsClient.BeginRepairAvsConnection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.repairAvsConnectionCreateRequest(ctx, resourceGroupName, storagePoolName, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// repairAvsConnectionCreateRequest creates the RepairAvsConnection request. +func (client *StoragePoolsClient) repairAvsConnectionCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, _ *StoragePoolsClientBeginRepairAvsConnectionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}/repairAvsConnection" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginUpdate - Update a storage pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - storagePoolName - Name of the storage pool +// - properties - The resource properties to be updated. +// - options - StoragePoolsClientBeginUpdateOptions contains the optional parameters for the StoragePoolsClient.BeginUpdate +// method. +func (client *StoragePoolsClient) BeginUpdate(ctx context.Context, resourceGroupName string, storagePoolName string, properties StoragePoolUpdate, options *StoragePoolsClientBeginUpdateOptions) (*runtime.Poller[StoragePoolsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, storagePoolName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StoragePoolsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[StoragePoolsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a storage pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *StoragePoolsClient) update(ctx context.Context, resourceGroupName string, storagePoolName string, properties StoragePoolUpdate, options *StoragePoolsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "StoragePoolsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, storagePoolName, 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 *StoragePoolsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, storagePoolName string, properties StoragePoolUpdate, _ *StoragePoolsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PureStorage.Block/storagePools/{storagePoolName}" + 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 storagePoolName == "" { + return nil, errors.New("parameter storagePoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storagePoolName}", url.PathEscape(storagePoolName)) + 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", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/storagepools_client_example_test.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/storagepools_client_example_test.go new file mode 100644 index 000000000000..9f112227b505 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/storagepools_client_example_test.go @@ -0,0 +1,636 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purestorageblock/armpurestorageblock" + "log" +) + +// Generated from example definition: 2024-11-01-preview/StoragePools_Create_MaximumSet_Gen.json +func ExampleStoragePoolsClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewStoragePoolsClient().BeginCreate(ctx, "rgpurestorage", "storagePoolname", armpurestorageblock.StoragePool{ + Properties: &armpurestorageblock.StoragePoolProperties{ + AvailabilityZone: to.Ptr("vknyl"), + VnetInjection: &armpurestorageblock.VnetInjection{ + SubnetID: to.Ptr("tnlctolrxdvnkjiphlrdxq"), + VnetID: to.Ptr("zbumtytyqwewjcyckwqchiypshv"), + }, + ProvisionedBandwidthMbPerSec: to.Ptr[int64](17), + Avs: &armpurestorageblock.AzureVmwareService{ + AvsEnabled: to.Ptr(true), + ClusterResourceID: to.Ptr("zekrdsarbkwcbvpzhmuwoazogziwms"), + }, + ReservationResourceID: to.Ptr("xiowoxnbtcotutcmmrofvgdi"), + }, + Identity: &armpurestorageblock.ManagedServiceIdentity{ + Type: to.Ptr(armpurestorageblock.ManagedServiceIdentityTypeNone), + UserAssignedIdentities: map[string]*armpurestorageblock.UserAssignedIdentity{ + "key4211": {}, + }, + }, + Tags: map[string]*string{ + "key7593": to.Ptr("vsyiygyurvwlfaezpuqu"), + }, + Location: to.Ptr("lonlc"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.StoragePoolsClientCreateResponse{ + // StoragePool: &armpurestorageblock.StoragePool{ + // Properties: &armpurestorageblock.StoragePoolProperties{ + // StoragePoolInternalID: to.Ptr("zcvzukcmphctpzrebsgtcr"), + // AvailabilityZone: to.Ptr("vknyl"), + // VnetInjection: &armpurestorageblock.VnetInjection{ + // SubnetID: to.Ptr("tnlctolrxdvnkjiphlrdxq"), + // VnetID: to.Ptr("zbumtytyqwewjcyckwqchiypshv"), + // }, + // DataRetentionPeriod: to.Ptr[int64](23), + // ProvisionedBandwidthMbPerSec: to.Ptr[int64](17), + // ProvisionedIops: to.Ptr[int64](3), + // Avs: &armpurestorageblock.AzureVmwareService{ + // AvsEnabled: to.Ptr(true), + // ClusterResourceID: to.Ptr("zekrdsarbkwcbvpzhmuwoazogziwms"), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ProvisioningStateSucceeded), + // ReservationResourceID: to.Ptr("xiowoxnbtcotutcmmrofvgdi"), + // }, + // Identity: &armpurestorageblock.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // TenantID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // Type: to.Ptr(armpurestorageblock.ManagedServiceIdentityTypeNone), + // UserAssignedIdentities: map[string]*armpurestorageblock.UserAssignedIdentity{ + // "key4211": &armpurestorageblock.UserAssignedIdentity{ + // PrincipalID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // ClientID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key7593": to.Ptr("vsyiygyurvwlfaezpuqu"), + // }, + // Location: to.Ptr("lonlc"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("imnjvmnlsmalufopyw"), + // Type: to.Ptr("hjztnpxxisrllusazxy"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-11-01-preview/StoragePools_Delete_MaximumSet_Gen.json +func ExampleStoragePoolsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewStoragePoolsClient().BeginDelete(ctx, "rgpurestorage", "storagePoolname", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-11-01-preview/StoragePools_DisableAvsConnection_MaximumSet_Gen.json +func ExampleStoragePoolsClient_BeginDisableAvsConnection() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewStoragePoolsClient().BeginDisableAvsConnection(ctx, "rgpurestorage", "storagePoolname", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-11-01-preview/StoragePools_EnableAvsConnection_MaximumSet_Gen.json +func ExampleStoragePoolsClient_BeginEnableAvsConnection() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewStoragePoolsClient().BeginEnableAvsConnection(ctx, "rgpurestorage", "storagePoolname", armpurestorageblock.StoragePoolEnableAvsConnectionPost{ + ClusterResourceID: to.Ptr("tghkgktlddwlszbeh"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-11-01-preview/StoragePools_FinalizeAvsConnection_MaximumSet_Gen.json +func ExampleStoragePoolsClient_BeginFinalizeAvsConnection() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewStoragePoolsClient().BeginFinalizeAvsConnection(ctx, "rgpurestorage", "storagePoolname", armpurestorageblock.StoragePoolFinalizeAvsConnectionPost{ + ServiceInitializationDataEnc: to.Ptr("hlgzaxrohv"), + ServiceInitializationData: &armpurestorageblock.ServiceInitializationInfo{ + ServiceAccountUsername: to.Ptr("axchgm"), + ServiceAccountPassword: to.Ptr("i"), + VSphereIP: to.Ptr("lhbajnykbznxnxpxozyfdjaciennks"), + VSphereCertificate: to.Ptr("s"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-11-01-preview/StoragePools_Get_MaximumSet_Gen.json +func ExampleStoragePoolsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewStoragePoolsClient().Get(ctx, "rgpurestorage", "storagePoolname", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.StoragePoolsClientGetResponse{ + // StoragePool: &armpurestorageblock.StoragePool{ + // Properties: &armpurestorageblock.StoragePoolProperties{ + // StoragePoolInternalID: to.Ptr("zcvzukcmphctpzrebsgtcr"), + // AvailabilityZone: to.Ptr("vknyl"), + // VnetInjection: &armpurestorageblock.VnetInjection{ + // SubnetID: to.Ptr("tnlctolrxdvnkjiphlrdxq"), + // VnetID: to.Ptr("zbumtytyqwewjcyckwqchiypshv"), + // }, + // DataRetentionPeriod: to.Ptr[int64](23), + // ProvisionedBandwidthMbPerSec: to.Ptr[int64](17), + // ProvisionedIops: to.Ptr[int64](3), + // Avs: &armpurestorageblock.AzureVmwareService{ + // AvsEnabled: to.Ptr(true), + // ClusterResourceID: to.Ptr("zekrdsarbkwcbvpzhmuwoazogziwms"), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ProvisioningStateSucceeded), + // ReservationResourceID: to.Ptr("xiowoxnbtcotutcmmrofvgdi"), + // }, + // Identity: &armpurestorageblock.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // TenantID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // Type: to.Ptr(armpurestorageblock.ManagedServiceIdentityTypeNone), + // UserAssignedIdentities: map[string]*armpurestorageblock.UserAssignedIdentity{ + // "key4211": &armpurestorageblock.UserAssignedIdentity{ + // PrincipalID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // ClientID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key7593": to.Ptr("vsyiygyurvwlfaezpuqu"), + // }, + // Location: to.Ptr("lonlc"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("imnjvmnlsmalufopyw"), + // Type: to.Ptr("hjztnpxxisrllusazxy"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-11-01-preview/StoragePools_GetAvsConnection_MaximumSet_Gen.json +func ExampleStoragePoolsClient_GetAvsConnection() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewStoragePoolsClient().GetAvsConnection(ctx, "rgpurestorage", "storagePoolname", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.StoragePoolsClientGetAvsConnectionResponse{ + // AvsConnection: &armpurestorageblock.AvsConnection{ + // ServiceInitializationCompleted: to.Ptr(true), + // ServiceInitializationHandleEnc: to.Ptr("kvidtocmjciflvtwql"), + // ServiceInitializationHandle: &armpurestorageblock.ServiceInitializationHandle{ + // ClusterResourceID: to.Ptr("aqgnpie"), + // ServiceAccountUsername: to.Ptr("xcu"), + // }, + // }, + // } +} + +// Generated from example definition: 2024-11-01-preview/StoragePools_GetAvsStatus_MaximumSet_Gen.json +func ExampleStoragePoolsClient_GetAvsStatus() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewStoragePoolsClient().GetAvsStatus(ctx, "rgpurestorage", "storagePoolname", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.StoragePoolsClientGetAvsStatusResponse{ + // AvsStatus: &armpurestorageblock.AvsStatus{ + // AvsEnabled: to.Ptr(true), + // CurrentConnectionStatus: to.Ptr("vfirgp"), + // ClusterResourceID: to.Ptr("zxkvzrdjzwpk"), + // }, + // } +} + +// Generated from example definition: 2024-11-01-preview/StoragePools_GetHealthStatus_MaximumSet_Gen.json +func ExampleStoragePoolsClient_GetHealthStatus() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewStoragePoolsClient().GetHealthStatus(ctx, "rgpurestorage", "storagePoolname", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.StoragePoolsClientGetHealthStatusResponse{ + // StoragePoolHealthInfo: &armpurestorageblock.StoragePoolHealthInfo{ + // Health: &armpurestorageblock.HealthDetails{ + // UsedCapacityPercentage: to.Ptr[float64](21), + // BandwidthUsage: &armpurestorageblock.BandwidthUsage{ + // Current: to.Ptr[int64](15), + // Provisioned: to.Ptr[int64](23), + // Max: to.Ptr[int64](21), + // }, + // IopsUsage: &armpurestorageblock.IopsUsage{ + // Current: to.Ptr[int64](5), + // Provisioned: to.Ptr[int64](19), + // Max: to.Ptr[int64](15), + // }, + // Space: &armpurestorageblock.Space{ + // TotalUsed: to.Ptr[int64](28), + // Unique: to.Ptr[int64](4), + // Snapshots: to.Ptr[int64](5), + // Shared: to.Ptr[int64](9), + // }, + // DataReductionRatio: to.Ptr[float64](28), + // EstimatedMaxCapacity: to.Ptr[int64](1), + // }, + // Alerts: []*armpurestorageblock.Alert{ + // { + // Level: to.Ptr(armpurestorageblock.AlertLevelInfo), + // Message: to.Ptr("uasvakccxihgmdz"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-11-01-preview/StoragePools_ListByResourceGroup_MaximumSet_Gen.json +func ExampleStoragePoolsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewStoragePoolsClient().NewListByResourceGroupPager("rgpurestorage", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armpurestorageblock.StoragePoolsClientListByResourceGroupResponse{ + // StoragePoolListResult: armpurestorageblock.StoragePoolListResult{ + // Value: []*armpurestorageblock.StoragePool{ + // { + // Properties: &armpurestorageblock.StoragePoolProperties{ + // StoragePoolInternalID: to.Ptr("zcvzukcmphctpzrebsgtcr"), + // AvailabilityZone: to.Ptr("vknyl"), + // VnetInjection: &armpurestorageblock.VnetInjection{ + // SubnetID: to.Ptr("tnlctolrxdvnkjiphlrdxq"), + // VnetID: to.Ptr("zbumtytyqwewjcyckwqchiypshv"), + // }, + // DataRetentionPeriod: to.Ptr[int64](23), + // ProvisionedBandwidthMbPerSec: to.Ptr[int64](17), + // ProvisionedIops: to.Ptr[int64](3), + // Avs: &armpurestorageblock.AzureVmwareService{ + // AvsEnabled: to.Ptr(true), + // ClusterResourceID: to.Ptr("zekrdsarbkwcbvpzhmuwoazogziwms"), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ProvisioningStateSucceeded), + // ReservationResourceID: to.Ptr("xiowoxnbtcotutcmmrofvgdi"), + // }, + // Identity: &armpurestorageblock.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // TenantID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // Type: to.Ptr(armpurestorageblock.ManagedServiceIdentityTypeNone), + // UserAssignedIdentities: map[string]*armpurestorageblock.UserAssignedIdentity{ + // "key4211": &armpurestorageblock.UserAssignedIdentity{ + // PrincipalID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // ClientID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key7593": to.Ptr("vsyiygyurvwlfaezpuqu"), + // }, + // Location: to.Ptr("lonlc"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("imnjvmnlsmalufopyw"), + // Type: to.Ptr("hjztnpxxisrllusazxy"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/ahd"), + // }, + // } + } +} + +// Generated from example definition: 2024-11-01-preview/StoragePools_ListBySubscription_MaximumSet_Gen.json +func ExampleStoragePoolsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewStoragePoolsClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armpurestorageblock.StoragePoolsClientListBySubscriptionResponse{ + // StoragePoolListResult: armpurestorageblock.StoragePoolListResult{ + // Value: []*armpurestorageblock.StoragePool{ + // { + // Properties: &armpurestorageblock.StoragePoolProperties{ + // StoragePoolInternalID: to.Ptr("zcvzukcmphctpzrebsgtcr"), + // AvailabilityZone: to.Ptr("vknyl"), + // VnetInjection: &armpurestorageblock.VnetInjection{ + // SubnetID: to.Ptr("tnlctolrxdvnkjiphlrdxq"), + // VnetID: to.Ptr("zbumtytyqwewjcyckwqchiypshv"), + // }, + // DataRetentionPeriod: to.Ptr[int64](23), + // ProvisionedBandwidthMbPerSec: to.Ptr[int64](17), + // ProvisionedIops: to.Ptr[int64](3), + // Avs: &armpurestorageblock.AzureVmwareService{ + // AvsEnabled: to.Ptr(true), + // ClusterResourceID: to.Ptr("zekrdsarbkwcbvpzhmuwoazogziwms"), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ProvisioningStateSucceeded), + // ReservationResourceID: to.Ptr("xiowoxnbtcotutcmmrofvgdi"), + // }, + // Identity: &armpurestorageblock.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // TenantID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // Type: to.Ptr(armpurestorageblock.ManagedServiceIdentityTypeNone), + // UserAssignedIdentities: map[string]*armpurestorageblock.UserAssignedIdentity{ + // "key4211": &armpurestorageblock.UserAssignedIdentity{ + // PrincipalID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // ClientID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key7593": to.Ptr("vsyiygyurvwlfaezpuqu"), + // }, + // Location: to.Ptr("lonlc"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("imnjvmnlsmalufopyw"), + // Type: to.Ptr("hjztnpxxisrllusazxy"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/ahd"), + // }, + // } + } +} + +// Generated from example definition: 2024-11-01-preview/StoragePools_RepairAvsConnection_MaximumSet_Gen.json +func ExampleStoragePoolsClient_BeginRepairAvsConnection() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewStoragePoolsClient().BeginRepairAvsConnection(ctx, "rgpurestorage", "storagePoolname", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-11-01-preview/StoragePools_Update_MaximumSet_Gen.json +func ExampleStoragePoolsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armpurestorageblock.NewClientFactory("BC47D6CC-AA80-4374-86F8-19D94EC70666", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewStoragePoolsClient().BeginUpdate(ctx, "rgpurestorage", "storagePoolname", armpurestorageblock.StoragePoolUpdate{ + Identity: &armpurestorageblock.ManagedServiceIdentity{ + Type: to.Ptr(armpurestorageblock.ManagedServiceIdentityTypeNone), + UserAssignedIdentities: map[string]*armpurestorageblock.UserAssignedIdentity{ + "key4211": {}, + }, + }, + Tags: map[string]*string{ + "key9065": to.Ptr("ebgmkwxqewe"), + }, + Properties: &armpurestorageblock.StoragePoolUpdateProperties{ + ProvisionedBandwidthMbPerSec: to.Ptr[int64](23), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armpurestorageblock.StoragePoolsClientUpdateResponse{ + // StoragePool: &armpurestorageblock.StoragePool{ + // Properties: &armpurestorageblock.StoragePoolProperties{ + // StoragePoolInternalID: to.Ptr("zcvzukcmphctpzrebsgtcr"), + // AvailabilityZone: to.Ptr("vknyl"), + // VnetInjection: &armpurestorageblock.VnetInjection{ + // SubnetID: to.Ptr("tnlctolrxdvnkjiphlrdxq"), + // VnetID: to.Ptr("zbumtytyqwewjcyckwqchiypshv"), + // }, + // DataRetentionPeriod: to.Ptr[int64](23), + // ProvisionedBandwidthMbPerSec: to.Ptr[int64](17), + // ProvisionedIops: to.Ptr[int64](3), + // Avs: &armpurestorageblock.AzureVmwareService{ + // AvsEnabled: to.Ptr(true), + // ClusterResourceID: to.Ptr("zekrdsarbkwcbvpzhmuwoazogziwms"), + // }, + // ProvisioningState: to.Ptr(armpurestorageblock.ProvisioningStateSucceeded), + // ReservationResourceID: to.Ptr("xiowoxnbtcotutcmmrofvgdi"), + // }, + // Identity: &armpurestorageblock.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // TenantID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // Type: to.Ptr(armpurestorageblock.ManagedServiceIdentityTypeNone), + // UserAssignedIdentities: map[string]*armpurestorageblock.UserAssignedIdentity{ + // "key4211": &armpurestorageblock.UserAssignedIdentity{ + // PrincipalID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // ClientID: to.Ptr("550e8400-e29b-41d4-a716-446655440000"), + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key7593": to.Ptr("vsyiygyurvwlfaezpuqu"), + // }, + // Location: to.Ptr("lonlc"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"), + // Name: to.Ptr("imnjvmnlsmalufopyw"), + // Type: to.Ptr("hjztnpxxisrllusazxy"), + // SystemData: &armpurestorageblock.SystemData{ + // CreatedBy: to.Ptr("ruoitchmuomrbscg"), + // CreatedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.341Z"); return t}()), + // LastModifiedBy: to.Ptr("thfyhokbrldzmghuylqbwpbublj"), + // LastModifiedByType: to.Ptr(armpurestorageblock.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-04T05:29:25.345Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/purestorageblock/armpurestorageblock/time_rfc3339.go b/sdk/resourcemanager/purestorageblock/armpurestorageblock/time_rfc3339.go new file mode 100644 index 000000000000..26e6aa3f2f7d --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/time_rfc3339.go @@ -0,0 +1,109 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armpurestorageblock + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// 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+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(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] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + 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/purestorageblock/armpurestorageblock/tsp-location.yaml b/sdk/resourcemanager/purestorageblock/armpurestorageblock/tsp-location.yaml new file mode 100644 index 000000000000..5ee14e64fe65 --- /dev/null +++ b/sdk/resourcemanager/purestorageblock/armpurestorageblock/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/purestorage/PureStorage.Block.Management +commit: 6dd5b7903dcd7eee4517ede8a2032a657f384397 +repo: Azure/azure-rest-api-specs +additionalDirectories: