// 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
//   - 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
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")
	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
//   - 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
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")
	req.Raw().URL.RawQuery = reqQP.Encode()
	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
//   - 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
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")
	req.Raw().URL.RawQuery = reqQP.Encode()
	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
//   - 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
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")
	req.Raw().URL.RawQuery = reqQP.Encode()
	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
//   - 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
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")
	req.Raw().URL.RawQuery = reqQP.Encode()
	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
//   - 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")
	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
//   - 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")
	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
//   - 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")
	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
//   - 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")
	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
//   - 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")
	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
//   - 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")
	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
//   - 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
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")
	req.Raw().URL.RawQuery = reqQP.Encode()
	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
//   - 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
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")
	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
}
