// 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 armcomputebulkactions

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"
	"strconv"
	"strings"
)

// BulkActionsClient contains the methods for the BulkActions group.
// Don't use this type directly, use NewBulkActionsClient() instead.
//
// Generated from API version 2026-02-01-preview
type BulkActionsClient struct {
	internal       *arm.Client
	subscriptionID string
}

// NewBulkActionsClient creates a new instance of BulkActionsClient 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 - Contains optional client configuration. Pass nil to accept the default values.
func NewBulkActionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BulkActionsClient, error) {
	cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
	if err != nil {
		return nil, err
	}
	client := &BulkActionsClient{
		subscriptionID: subscriptionID,
		internal:       cl,
	}
	return client, nil
}

// BeginCancel - Cancels LaunchBulkInstancesOperation instances that have not yet launched.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - location - The location name.
//   - name - The name of the LaunchBulkInstancesOperation.
//   - options - BulkActionsClientBeginCancelOptions contains the optional parameters for the BulkActionsClient.BeginCancel method.
func (client *BulkActionsClient) BeginCancel(ctx context.Context, resourceGroupName string, location string, name string, options *BulkActionsClientBeginCancelOptions) (*runtime.Poller[BulkActionsClientCancelResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.cancel(ctx, resourceGroupName, location, name, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BulkActionsClientCancelResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BulkActionsClientCancelResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Cancel - Cancels LaunchBulkInstancesOperation instances that have not yet launched.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *BulkActionsClient) cancel(ctx context.Context, resourceGroupName string, location string, name string, options *BulkActionsClientBeginCancelOptions) (*http.Response, error) {
	var err error
	const operationName = "BulkActionsClient.BeginCancel"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.cancelCreateRequest(ctx, resourceGroupName, location, name, 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
}

// cancelCreateRequest creates the Cancel request.
func (client *BulkActionsClient) cancelCreateRequest(ctx context.Context, resourceGroupName string, location string, name string, _ *BulkActionsClientBeginCancelOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeBulkActions/locations/{location}/launchBulkInstancesOperations/{name}/cancel"
	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 location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	if name == "" {
		return nil, errors.New("parameter name cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	return req, nil
}

// BeginCreateOrUpdate - Creates or updates LaunchBulkInstancesOperations.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - location - The location name.
//   - name - The name of the LaunchBulkInstancesOperation.
//   - resource - Resource create parameters.
//   - options - BulkActionsClientBeginCreateOrUpdateOptions contains the optional parameters for the BulkActionsClient.BeginCreateOrUpdate
//     method.
func (client *BulkActionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, location string, name string, resource LocationBasedLaunchBulkInstancesOperation, options *BulkActionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[BulkActionsClientCreateOrUpdateResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.createOrUpdate(ctx, resourceGroupName, location, name, resource, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BulkActionsClientCreateOrUpdateResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BulkActionsClientCreateOrUpdateResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// CreateOrUpdate - Creates or updates LaunchBulkInstancesOperations.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *BulkActionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, location string, name string, resource LocationBasedLaunchBulkInstancesOperation, options *BulkActionsClientBeginCreateOrUpdateOptions) (*http.Response, error) {
	var err error
	const operationName = "BulkActionsClient.BeginCreateOrUpdate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, location, name, resource, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// createOrUpdateCreateRequest creates the CreateOrUpdate request.
func (client *BulkActionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, location string, name string, resource LocationBasedLaunchBulkInstancesOperation, _ *BulkActionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeBulkActions/locations/{location}/launchBulkInstancesOperations/{name}"
	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 location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	if name == "" {
		return nil, errors.New("parameter name cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	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 - Deletes LaunchBulkInstancesOperations.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - location - The location name.
//   - name - The name of the LaunchBulkInstancesOperation.
//   - options - BulkActionsClientBeginDeleteOptions contains the optional parameters for the BulkActionsClient.BeginDelete method.
func (client *BulkActionsClient) BeginDelete(ctx context.Context, resourceGroupName string, location string, name string, options *BulkActionsClientBeginDeleteOptions) (*runtime.Poller[BulkActionsClientDeleteResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.deleteOperation(ctx, resourceGroupName, location, name, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BulkActionsClientDeleteResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BulkActionsClientDeleteResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Delete - Deletes LaunchBulkInstancesOperations.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *BulkActionsClient) deleteOperation(ctx context.Context, resourceGroupName string, location string, name string, options *BulkActionsClientBeginDeleteOptions) (*http.Response, error) {
	var err error
	const operationName = "BulkActionsClient.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, location, name, 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 *BulkActionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, location string, name string, options *BulkActionsClientBeginDeleteOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeBulkActions/locations/{location}/launchBulkInstancesOperations/{name}"
	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 location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	if name == "" {
		return nil, errors.New("parameter name cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name))
	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", version20260201Preview)
	if options != nil && options.DeleteInstances != nil {
		reqQP.Set("deleteInstances", strconv.FormatBool(*options.DeleteInstances))
	}
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	return req, nil
}

// Get - Gets an instance of LaunchBulkInstancesOperations.
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - location - The location name.
//   - name - The name of the LaunchBulkInstancesOperation.
//   - options - BulkActionsClientGetOptions contains the optional parameters for the BulkActionsClient.Get method.
func (client *BulkActionsClient) Get(ctx context.Context, resourceGroupName string, location string, name string, options *BulkActionsClientGetOptions) (BulkActionsClientGetResponse, error) {
	var err error
	const operationName = "BulkActionsClient.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, location, name, options)
	if err != nil {
		return BulkActionsClientGetResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return BulkActionsClientGetResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return BulkActionsClientGetResponse{}, err
	}
	resp, err := client.getHandleResponse(httpResp)
	return resp, err
}

// getCreateRequest creates the Get request.
func (client *BulkActionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, location string, name string, _ *BulkActionsClientGetOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeBulkActions/locations/{location}/launchBulkInstancesOperations/{name}"
	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 location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	if name == "" {
		return nil, errors.New("parameter name cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// getHandleResponse handles the Get response.
func (client *BulkActionsClient) getHandleResponse(resp *http.Response) (BulkActionsClientGetResponse, error) {
	result := BulkActionsClientGetResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.LocationBasedLaunchBulkInstancesOperation); err != nil {
		return BulkActionsClientGetResponse{}, err
	}
	return result, nil
}

// GetOperationStatus - Get the status of a LaunchBulkInstancesOperation.
// If the operation fails it returns an *azcore.ResponseError type.
//   - location - The location name.
//   - id - The async operation id.
//   - options - BulkActionsClientGetOperationStatusOptions contains the optional parameters for the BulkActionsClient.GetOperationStatus
//     method.
func (client *BulkActionsClient) GetOperationStatus(ctx context.Context, location string, id string, options *BulkActionsClientGetOperationStatusOptions) (BulkActionsClientGetOperationStatusResponse, error) {
	var err error
	const operationName = "BulkActionsClient.GetOperationStatus"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.getOperationStatusCreateRequest(ctx, location, id, options)
	if err != nil {
		return BulkActionsClientGetOperationStatusResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return BulkActionsClientGetOperationStatusResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return BulkActionsClientGetOperationStatusResponse{}, err
	}
	resp, err := client.getOperationStatusHandleResponse(httpResp)
	return resp, err
}

// getOperationStatusCreateRequest creates the GetOperationStatus request.
func (client *BulkActionsClient) getOperationStatusCreateRequest(ctx context.Context, location string, id string, _ *BulkActionsClientGetOperationStatusOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeBulkActions/locations/{location}/operations/{id}"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	if id == "" {
		return nil, errors.New("parameter id cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(id))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// getOperationStatusHandleResponse handles the GetOperationStatus response.
func (client *BulkActionsClient) getOperationStatusHandleResponse(resp *http.Response) (BulkActionsClientGetOperationStatusResponse, error) {
	result := BulkActionsClientGetOperationStatusResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatusResult); err != nil {
		return BulkActionsClientGetOperationStatusResponse{}, err
	}
	return result, nil
}

// NewListByResourceGroupPager - List LaunchBulkInstancesOperation resources by resource group.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - location - The location name.
//   - options - BulkActionsClientListByResourceGroupOptions contains the optional parameters for the BulkActionsClient.NewListByResourceGroupPager
//     method.
func (client *BulkActionsClient) NewListByResourceGroupPager(resourceGroupName string, location string, options *BulkActionsClientListByResourceGroupOptions) *runtime.Pager[BulkActionsClientListByResourceGroupResponse] {
	return runtime.NewPager(runtime.PagingHandler[BulkActionsClientListByResourceGroupResponse]{
		More: func(page BulkActionsClientListByResourceGroupResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *BulkActionsClientListByResourceGroupResponse) (BulkActionsClientListByResourceGroupResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BulkActionsClient.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, location, options)
			}, nil)
			if err != nil {
				return BulkActionsClientListByResourceGroupResponse{}, err
			}
			return client.listByResourceGroupHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listByResourceGroupCreateRequest creates the ListByResourceGroup request.
func (client *BulkActionsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, location string, _ *BulkActionsClientListByResourceGroupOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeBulkActions/locations/{location}/launchBulkInstancesOperations"
	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 location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listByResourceGroupHandleResponse handles the ListByResourceGroup response.
func (client *BulkActionsClient) listByResourceGroupHandleResponse(resp *http.Response) (BulkActionsClientListByResourceGroupResponse, error) {
	result := BulkActionsClientListByResourceGroupResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.LaunchBulkInstancesOperationListResult); err != nil {
		return BulkActionsClientListByResourceGroupResponse{}, err
	}
	return result, nil
}

// NewListBySubscriptionPager - List LaunchBulkInstancesOperation resources by subscriptionId.
//   - location - The location name.
//   - options - BulkActionsClientListBySubscriptionOptions contains the optional parameters for the BulkActionsClient.NewListBySubscriptionPager
//     method.
func (client *BulkActionsClient) NewListBySubscriptionPager(location string, options *BulkActionsClientListBySubscriptionOptions) *runtime.Pager[BulkActionsClientListBySubscriptionResponse] {
	return runtime.NewPager(runtime.PagingHandler[BulkActionsClientListBySubscriptionResponse]{
		More: func(page BulkActionsClientListBySubscriptionResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *BulkActionsClientListBySubscriptionResponse) (BulkActionsClientListBySubscriptionResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BulkActionsClient.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, location, options)
			}, nil)
			if err != nil {
				return BulkActionsClientListBySubscriptionResponse{}, err
			}
			return client.listBySubscriptionHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listBySubscriptionCreateRequest creates the ListBySubscription request.
func (client *BulkActionsClient) listBySubscriptionCreateRequest(ctx context.Context, location string, _ *BulkActionsClientListBySubscriptionOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeBulkActions/locations/{location}/launchBulkInstancesOperations"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listBySubscriptionHandleResponse handles the ListBySubscription response.
func (client *BulkActionsClient) listBySubscriptionHandleResponse(resp *http.Response) (BulkActionsClientListBySubscriptionResponse, error) {
	result := BulkActionsClientListBySubscriptionResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.LaunchBulkInstancesOperationListResult); err != nil {
		return BulkActionsClientListBySubscriptionResponse{}, err
	}
	return result, nil
}

// NewListVirtualMachinesPager - List VirtualMachine resources of a LaunchBulkInstancesOperation.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - location - The location name.
//   - name - The name of the LaunchBulkInstancesOperation
//   - options - BulkActionsClientListVirtualMachinesOptions contains the optional parameters for the BulkActionsClient.NewListVirtualMachinesPager
//     method.
func (client *BulkActionsClient) NewListVirtualMachinesPager(resourceGroupName string, location string, name string, options *BulkActionsClientListVirtualMachinesOptions) *runtime.Pager[BulkActionsClientListVirtualMachinesResponse] {
	return runtime.NewPager(runtime.PagingHandler[BulkActionsClientListVirtualMachinesResponse]{
		More: func(page BulkActionsClientListVirtualMachinesResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *BulkActionsClientListVirtualMachinesResponse) (BulkActionsClientListVirtualMachinesResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BulkActionsClient.NewListVirtualMachinesPager")
			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.listVirtualMachinesCreateRequest(ctx, resourceGroupName, location, name, options)
			}, nil)
			if err != nil {
				return BulkActionsClientListVirtualMachinesResponse{}, err
			}
			return client.listVirtualMachinesHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listVirtualMachinesCreateRequest creates the ListVirtualMachines request.
func (client *BulkActionsClient) listVirtualMachinesCreateRequest(ctx context.Context, resourceGroupName string, location string, name string, options *BulkActionsClientListVirtualMachinesOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeBulkActions/locations/{location}/launchBulkInstancesOperations/{name}/virtualMachines"
	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 location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	if name == "" {
		return nil, errors.New("parameter name cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name))
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Filter != nil {
		reqQP.Set("$filter", *options.Filter)
	}
	if options != nil && options.Skiptoken != nil {
		reqQP.Set("$skiptoken", *options.Skiptoken)
	}
	reqQP.Set("api-version", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listVirtualMachinesHandleResponse handles the ListVirtualMachines response.
func (client *BulkActionsClient) listVirtualMachinesHandleResponse(resp *http.Response) (BulkActionsClientListVirtualMachinesResponse, error) {
	result := BulkActionsClientListVirtualMachinesResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineListResult); err != nil {
		return BulkActionsClientListVirtualMachinesResponse{}, err
	}
	return result, nil
}

// VirtualMachinesCancelOperations - VirtualMachinesCancelOperations: Cancel a previously submitted (start/deallocate/hibernate)
// request
// If the operation fails it returns an *azcore.ResponseError type.
//   - location - The location name.
//   - requestBody - The request body
//   - options - BulkActionsClientVirtualMachinesCancelOperationsOptions contains the optional parameters for the BulkActionsClient.VirtualMachinesCancelOperations
//     method.
func (client *BulkActionsClient) VirtualMachinesCancelOperations(ctx context.Context, location string, requestBody CancelOperationsRequest, options *BulkActionsClientVirtualMachinesCancelOperationsOptions) (BulkActionsClientVirtualMachinesCancelOperationsResponse, error) {
	var err error
	const operationName = "BulkActionsClient.VirtualMachinesCancelOperations"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.virtualMachinesCancelOperationsCreateRequest(ctx, location, requestBody, options)
	if err != nil {
		return BulkActionsClientVirtualMachinesCancelOperationsResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return BulkActionsClientVirtualMachinesCancelOperationsResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return BulkActionsClientVirtualMachinesCancelOperationsResponse{}, err
	}
	resp, err := client.virtualMachinesCancelOperationsHandleResponse(httpResp)
	return resp, err
}

// virtualMachinesCancelOperationsCreateRequest creates the VirtualMachinesCancelOperations request.
func (client *BulkActionsClient) virtualMachinesCancelOperationsCreateRequest(ctx context.Context, location string, requestBody CancelOperationsRequest, _ *BulkActionsClientVirtualMachinesCancelOperationsOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeBulkActions/locations/{location}/virtualMachinesCancelOperations"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, requestBody); err != nil {
		return nil, err
	}
	return req, nil
}

// virtualMachinesCancelOperationsHandleResponse handles the VirtualMachinesCancelOperations response.
func (client *BulkActionsClient) virtualMachinesCancelOperationsHandleResponse(resp *http.Response) (BulkActionsClientVirtualMachinesCancelOperationsResponse, error) {
	result := BulkActionsClientVirtualMachinesCancelOperationsResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.CancelOperationsResponse); err != nil {
		return BulkActionsClientVirtualMachinesCancelOperationsResponse{}, err
	}
	return result, nil
}

// VirtualMachinesExecuteCreate - VirtualMachinesExecuteCreate: Execute create operation for a batch of virtual machines,
// this operation is triggered as soon as Computeschedule receives it.
// If the operation fails it returns an *azcore.ResponseError type.
//   - location - The location name.
//   - requestBody - The request body
//   - options - BulkActionsClientVirtualMachinesExecuteCreateOptions contains the optional parameters for the BulkActionsClient.VirtualMachinesExecuteCreate
//     method.
func (client *BulkActionsClient) VirtualMachinesExecuteCreate(ctx context.Context, location string, requestBody ExecuteCreateRequest, options *BulkActionsClientVirtualMachinesExecuteCreateOptions) (BulkActionsClientVirtualMachinesExecuteCreateResponse, error) {
	var err error
	const operationName = "BulkActionsClient.VirtualMachinesExecuteCreate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.virtualMachinesExecuteCreateCreateRequest(ctx, location, requestBody, options)
	if err != nil {
		return BulkActionsClientVirtualMachinesExecuteCreateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return BulkActionsClientVirtualMachinesExecuteCreateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return BulkActionsClientVirtualMachinesExecuteCreateResponse{}, err
	}
	resp, err := client.virtualMachinesExecuteCreateHandleResponse(httpResp)
	return resp, err
}

// virtualMachinesExecuteCreateCreateRequest creates the VirtualMachinesExecuteCreate request.
func (client *BulkActionsClient) virtualMachinesExecuteCreateCreateRequest(ctx context.Context, location string, requestBody ExecuteCreateRequest, _ *BulkActionsClientVirtualMachinesExecuteCreateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeBulkActions/locations/{location}/virtualMachinesExecuteCreate"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, requestBody); err != nil {
		return nil, err
	}
	return req, nil
}

// virtualMachinesExecuteCreateHandleResponse handles the VirtualMachinesExecuteCreate response.
func (client *BulkActionsClient) virtualMachinesExecuteCreateHandleResponse(resp *http.Response) (BulkActionsClientVirtualMachinesExecuteCreateResponse, error) {
	result := BulkActionsClientVirtualMachinesExecuteCreateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.CreateResourceOperationResponse); err != nil {
		return BulkActionsClientVirtualMachinesExecuteCreateResponse{}, err
	}
	return result, nil
}

// VirtualMachinesExecuteDeallocate - VirtualMachinesExecuteDeallocate: Execute deallocate operation for a batch of virtual
// machines, this operation is triggered as soon as Computeschedule receives it.
// If the operation fails it returns an *azcore.ResponseError type.
//   - location - The location name.
//   - requestBody - The request body
//   - options - BulkActionsClientVirtualMachinesExecuteDeallocateOptions contains the optional parameters for the BulkActionsClient.VirtualMachinesExecuteDeallocate
//     method.
func (client *BulkActionsClient) VirtualMachinesExecuteDeallocate(ctx context.Context, location string, requestBody ExecuteDeallocateRequest, options *BulkActionsClientVirtualMachinesExecuteDeallocateOptions) (BulkActionsClientVirtualMachinesExecuteDeallocateResponse, error) {
	var err error
	const operationName = "BulkActionsClient.VirtualMachinesExecuteDeallocate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.virtualMachinesExecuteDeallocateCreateRequest(ctx, location, requestBody, options)
	if err != nil {
		return BulkActionsClientVirtualMachinesExecuteDeallocateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return BulkActionsClientVirtualMachinesExecuteDeallocateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return BulkActionsClientVirtualMachinesExecuteDeallocateResponse{}, err
	}
	resp, err := client.virtualMachinesExecuteDeallocateHandleResponse(httpResp)
	return resp, err
}

// virtualMachinesExecuteDeallocateCreateRequest creates the VirtualMachinesExecuteDeallocate request.
func (client *BulkActionsClient) virtualMachinesExecuteDeallocateCreateRequest(ctx context.Context, location string, requestBody ExecuteDeallocateRequest, _ *BulkActionsClientVirtualMachinesExecuteDeallocateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeBulkActions/locations/{location}/virtualMachinesExecuteDeallocate"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, requestBody); err != nil {
		return nil, err
	}
	return req, nil
}

// virtualMachinesExecuteDeallocateHandleResponse handles the VirtualMachinesExecuteDeallocate response.
func (client *BulkActionsClient) virtualMachinesExecuteDeallocateHandleResponse(resp *http.Response) (BulkActionsClientVirtualMachinesExecuteDeallocateResponse, error) {
	result := BulkActionsClientVirtualMachinesExecuteDeallocateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.DeallocateResourceOperationResponse); err != nil {
		return BulkActionsClientVirtualMachinesExecuteDeallocateResponse{}, err
	}
	return result, nil
}

// VirtualMachinesExecuteDelete - VirtualMachinesExecuteDelete: Execute delete operation for a batch of virtual machines,
// this operation is triggered as soon as Computeschedule receives it.
// If the operation fails it returns an *azcore.ResponseError type.
//   - location - The location name.
//   - requestBody - The request body
//   - options - BulkActionsClientVirtualMachinesExecuteDeleteOptions contains the optional parameters for the BulkActionsClient.VirtualMachinesExecuteDelete
//     method.
func (client *BulkActionsClient) VirtualMachinesExecuteDelete(ctx context.Context, location string, requestBody ExecuteDeleteRequest, options *BulkActionsClientVirtualMachinesExecuteDeleteOptions) (BulkActionsClientVirtualMachinesExecuteDeleteResponse, error) {
	var err error
	const operationName = "BulkActionsClient.VirtualMachinesExecuteDelete"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.virtualMachinesExecuteDeleteCreateRequest(ctx, location, requestBody, options)
	if err != nil {
		return BulkActionsClientVirtualMachinesExecuteDeleteResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return BulkActionsClientVirtualMachinesExecuteDeleteResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return BulkActionsClientVirtualMachinesExecuteDeleteResponse{}, err
	}
	resp, err := client.virtualMachinesExecuteDeleteHandleResponse(httpResp)
	return resp, err
}

// virtualMachinesExecuteDeleteCreateRequest creates the VirtualMachinesExecuteDelete request.
func (client *BulkActionsClient) virtualMachinesExecuteDeleteCreateRequest(ctx context.Context, location string, requestBody ExecuteDeleteRequest, _ *BulkActionsClientVirtualMachinesExecuteDeleteOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeBulkActions/locations/{location}/virtualMachinesExecuteDelete"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, requestBody); err != nil {
		return nil, err
	}
	return req, nil
}

// virtualMachinesExecuteDeleteHandleResponse handles the VirtualMachinesExecuteDelete response.
func (client *BulkActionsClient) virtualMachinesExecuteDeleteHandleResponse(resp *http.Response) (BulkActionsClientVirtualMachinesExecuteDeleteResponse, error) {
	result := BulkActionsClientVirtualMachinesExecuteDeleteResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.DeleteResourceOperationResponse); err != nil {
		return BulkActionsClientVirtualMachinesExecuteDeleteResponse{}, err
	}
	return result, nil
}

// VirtualMachinesExecuteHibernate - VirtualMachinesExecuteHibernate: Execute hibernate operation for a batch of virtual machines,
// this operation is triggered as soon as Computeschedule receives it.
// If the operation fails it returns an *azcore.ResponseError type.
//   - location - The location name.
//   - requestBody - The request body
//   - options - BulkActionsClientVirtualMachinesExecuteHibernateOptions contains the optional parameters for the BulkActionsClient.VirtualMachinesExecuteHibernate
//     method.
func (client *BulkActionsClient) VirtualMachinesExecuteHibernate(ctx context.Context, location string, requestBody ExecuteHibernateRequest, options *BulkActionsClientVirtualMachinesExecuteHibernateOptions) (BulkActionsClientVirtualMachinesExecuteHibernateResponse, error) {
	var err error
	const operationName = "BulkActionsClient.VirtualMachinesExecuteHibernate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.virtualMachinesExecuteHibernateCreateRequest(ctx, location, requestBody, options)
	if err != nil {
		return BulkActionsClientVirtualMachinesExecuteHibernateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return BulkActionsClientVirtualMachinesExecuteHibernateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return BulkActionsClientVirtualMachinesExecuteHibernateResponse{}, err
	}
	resp, err := client.virtualMachinesExecuteHibernateHandleResponse(httpResp)
	return resp, err
}

// virtualMachinesExecuteHibernateCreateRequest creates the VirtualMachinesExecuteHibernate request.
func (client *BulkActionsClient) virtualMachinesExecuteHibernateCreateRequest(ctx context.Context, location string, requestBody ExecuteHibernateRequest, _ *BulkActionsClientVirtualMachinesExecuteHibernateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeBulkActions/locations/{location}/virtualMachinesExecuteHibernate"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, requestBody); err != nil {
		return nil, err
	}
	return req, nil
}

// virtualMachinesExecuteHibernateHandleResponse handles the VirtualMachinesExecuteHibernate response.
func (client *BulkActionsClient) virtualMachinesExecuteHibernateHandleResponse(resp *http.Response) (BulkActionsClientVirtualMachinesExecuteHibernateResponse, error) {
	result := BulkActionsClientVirtualMachinesExecuteHibernateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.HibernateResourceOperationResponse); err != nil {
		return BulkActionsClientVirtualMachinesExecuteHibernateResponse{}, err
	}
	return result, nil
}

// VirtualMachinesExecuteStart - VirtualMachinesExecuteStart: Execute start operation for a batch of virtual machines, this
// operation is triggered as soon as Computeschedule receives it.
// If the operation fails it returns an *azcore.ResponseError type.
//   - location - The location name.
//   - requestBody - The request body
//   - options - BulkActionsClientVirtualMachinesExecuteStartOptions contains the optional parameters for the BulkActionsClient.VirtualMachinesExecuteStart
//     method.
func (client *BulkActionsClient) VirtualMachinesExecuteStart(ctx context.Context, location string, requestBody ExecuteStartRequest, options *BulkActionsClientVirtualMachinesExecuteStartOptions) (BulkActionsClientVirtualMachinesExecuteStartResponse, error) {
	var err error
	const operationName = "BulkActionsClient.VirtualMachinesExecuteStart"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.virtualMachinesExecuteStartCreateRequest(ctx, location, requestBody, options)
	if err != nil {
		return BulkActionsClientVirtualMachinesExecuteStartResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return BulkActionsClientVirtualMachinesExecuteStartResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return BulkActionsClientVirtualMachinesExecuteStartResponse{}, err
	}
	resp, err := client.virtualMachinesExecuteStartHandleResponse(httpResp)
	return resp, err
}

// virtualMachinesExecuteStartCreateRequest creates the VirtualMachinesExecuteStart request.
func (client *BulkActionsClient) virtualMachinesExecuteStartCreateRequest(ctx context.Context, location string, requestBody ExecuteStartRequest, _ *BulkActionsClientVirtualMachinesExecuteStartOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeBulkActions/locations/{location}/virtualMachinesExecuteStart"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, requestBody); err != nil {
		return nil, err
	}
	return req, nil
}

// virtualMachinesExecuteStartHandleResponse handles the VirtualMachinesExecuteStart response.
func (client *BulkActionsClient) virtualMachinesExecuteStartHandleResponse(resp *http.Response) (BulkActionsClientVirtualMachinesExecuteStartResponse, error) {
	result := BulkActionsClientVirtualMachinesExecuteStartResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.StartResourceOperationResponse); err != nil {
		return BulkActionsClientVirtualMachinesExecuteStartResponse{}, err
	}
	return result, nil
}

// VirtualMachinesGetOperationStatus - VirtualMachinesGetOperationStatus: Polling endpoint to read status of operations performed
// on virtual machines
// If the operation fails it returns an *azcore.ResponseError type.
//   - location - The location name.
//   - requestBody - The request body
//   - options - BulkActionsClientVirtualMachinesGetOperationStatusOptions contains the optional parameters for the BulkActionsClient.VirtualMachinesGetOperationStatus
//     method.
func (client *BulkActionsClient) VirtualMachinesGetOperationStatus(ctx context.Context, location string, requestBody GetOperationStatusRequest, options *BulkActionsClientVirtualMachinesGetOperationStatusOptions) (BulkActionsClientVirtualMachinesGetOperationStatusResponse, error) {
	var err error
	const operationName = "BulkActionsClient.VirtualMachinesGetOperationStatus"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.virtualMachinesGetOperationStatusCreateRequest(ctx, location, requestBody, options)
	if err != nil {
		return BulkActionsClientVirtualMachinesGetOperationStatusResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return BulkActionsClientVirtualMachinesGetOperationStatusResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return BulkActionsClientVirtualMachinesGetOperationStatusResponse{}, err
	}
	resp, err := client.virtualMachinesGetOperationStatusHandleResponse(httpResp)
	return resp, err
}

// virtualMachinesGetOperationStatusCreateRequest creates the VirtualMachinesGetOperationStatus request.
func (client *BulkActionsClient) virtualMachinesGetOperationStatusCreateRequest(ctx context.Context, location string, requestBody GetOperationStatusRequest, _ *BulkActionsClientVirtualMachinesGetOperationStatusOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeBulkActions/locations/{location}/virtualMachinesGetOperationStatus"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if location == "" {
		return nil, errors.New("parameter location cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location))
	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", version20260201Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, requestBody); err != nil {
		return nil, err
	}
	return req, nil
}

// virtualMachinesGetOperationStatusHandleResponse handles the VirtualMachinesGetOperationStatus response.
func (client *BulkActionsClient) virtualMachinesGetOperationStatusHandleResponse(resp *http.Response) (BulkActionsClientVirtualMachinesGetOperationStatusResponse, error) {
	result := BulkActionsClientVirtualMachinesGetOperationStatusResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.GetOperationStatusResponse); err != nil {
		return BulkActionsClientVirtualMachinesGetOperationStatusResponse{}, err
	}
	return result, nil
}
