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

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

// ScheduledActionsClient contains the methods for the ScheduledActions group.
// Don't use this type directly, use NewScheduledActionsClient() instead.
type ScheduledActionsClient struct {
	internal       *arm.Client
	subscriptionID string
}

// NewScheduledActionsClient creates a new instance of ScheduledActionsClient 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 NewScheduledActionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ScheduledActionsClient, error) {
	cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
	if err != nil {
		return nil, err
	}
	client := &ScheduledActionsClient{
		subscriptionID: subscriptionID,
		internal:       cl,
	}
	return client, nil
}

// AttachResources - A synchronous resource action.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - scheduledActionName - The name of the ScheduledAction
//   - body - The content of the action request
//   - options - ScheduledActionsClientAttachResourcesOptions contains the optional parameters for the ScheduledActionsClient.AttachResources
//     method.
func (client *ScheduledActionsClient) AttachResources(ctx context.Context, resourceGroupName string, scheduledActionName string, body ResourceAttachRequest, options *ScheduledActionsClientAttachResourcesOptions) (ScheduledActionsClientAttachResourcesResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.AttachResources"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.attachResourcesCreateRequest(ctx, resourceGroupName, scheduledActionName, body, options)
	if err != nil {
		return ScheduledActionsClientAttachResourcesResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientAttachResourcesResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientAttachResourcesResponse{}, err
	}
	resp, err := client.attachResourcesHandleResponse(httpResp)
	return resp, err
}

// attachResourcesCreateRequest creates the AttachResources request.
func (client *ScheduledActionsClient) attachResourcesCreateRequest(ctx context.Context, resourceGroupName string, scheduledActionName string, body ResourceAttachRequest, _ *ScheduledActionsClientAttachResourcesOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions/{scheduledActionName}/attachResources"
	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 scheduledActionName == "" {
		return nil, errors.New("parameter scheduledActionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{scheduledActionName}", url.PathEscape(scheduledActionName))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, body); err != nil {
		return nil, err
	}
	return req, nil
}

// attachResourcesHandleResponse handles the AttachResources response.
func (client *ScheduledActionsClient) attachResourcesHandleResponse(resp *http.Response) (ScheduledActionsClientAttachResourcesResponse, error) {
	result := ScheduledActionsClientAttachResourcesResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.RecurringActionsResourceOperationResult); err != nil {
		return ScheduledActionsClientAttachResourcesResponse{}, err
	}
	return result, nil
}

// CancelNextOccurrence - A synchronous resource action.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - scheduledActionName - The name of the ScheduledAction
//   - body - The content of the action request
//   - options - ScheduledActionsClientCancelNextOccurrenceOptions contains the optional parameters for the ScheduledActionsClient.CancelNextOccurrence
//     method.
func (client *ScheduledActionsClient) CancelNextOccurrence(ctx context.Context, resourceGroupName string, scheduledActionName string, body CancelOccurrenceRequest, options *ScheduledActionsClientCancelNextOccurrenceOptions) (ScheduledActionsClientCancelNextOccurrenceResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.CancelNextOccurrence"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.cancelNextOccurrenceCreateRequest(ctx, resourceGroupName, scheduledActionName, body, options)
	if err != nil {
		return ScheduledActionsClientCancelNextOccurrenceResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientCancelNextOccurrenceResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientCancelNextOccurrenceResponse{}, err
	}
	resp, err := client.cancelNextOccurrenceHandleResponse(httpResp)
	return resp, err
}

// cancelNextOccurrenceCreateRequest creates the CancelNextOccurrence request.
func (client *ScheduledActionsClient) cancelNextOccurrenceCreateRequest(ctx context.Context, resourceGroupName string, scheduledActionName string, body CancelOccurrenceRequest, _ *ScheduledActionsClientCancelNextOccurrenceOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions/{scheduledActionName}/cancelNextOccurrence"
	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 scheduledActionName == "" {
		return nil, errors.New("parameter scheduledActionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{scheduledActionName}", url.PathEscape(scheduledActionName))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, body); err != nil {
		return nil, err
	}
	return req, nil
}

// cancelNextOccurrenceHandleResponse handles the CancelNextOccurrence response.
func (client *ScheduledActionsClient) cancelNextOccurrenceHandleResponse(resp *http.Response) (ScheduledActionsClientCancelNextOccurrenceResponse, error) {
	result := ScheduledActionsClientCancelNextOccurrenceResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.RecurringActionsResourceOperationResult); err != nil {
		return ScheduledActionsClientCancelNextOccurrenceResponse{}, err
	}
	return result, nil
}

// BeginCreateOrUpdate - Create a ScheduledAction
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - scheduledActionName - The name of the ScheduledAction
//   - resource - Resource create parameters.
//   - options - ScheduledActionsClientBeginCreateOrUpdateOptions contains the optional parameters for the ScheduledActionsClient.BeginCreateOrUpdate
//     method.
func (client *ScheduledActionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, scheduledActionName string, resource ScheduledAction, options *ScheduledActionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ScheduledActionsClientCreateOrUpdateResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.createOrUpdate(ctx, resourceGroupName, scheduledActionName, resource, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ScheduledActionsClientCreateOrUpdateResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ScheduledActionsClientCreateOrUpdateResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// CreateOrUpdate - Create a ScheduledAction
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
func (client *ScheduledActionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, scheduledActionName string, resource ScheduledAction, options *ScheduledActionsClientBeginCreateOrUpdateOptions) (*http.Response, error) {
	var err error
	const operationName = "ScheduledActionsClient.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, scheduledActionName, 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 *ScheduledActionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, scheduledActionName string, resource ScheduledAction, _ *ScheduledActionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions/{scheduledActionName}"
	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 scheduledActionName == "" {
		return nil, errors.New("parameter scheduledActionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{scheduledActionName}", url.PathEscape(scheduledActionName))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, resource); err != nil {
		return nil, err
	}
	return req, nil
}

// BeginDelete - Delete a ScheduledAction
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - scheduledActionName - The name of the ScheduledAction
//   - options - ScheduledActionsClientBeginDeleteOptions contains the optional parameters for the ScheduledActionsClient.BeginDelete
//     method.
func (client *ScheduledActionsClient) BeginDelete(ctx context.Context, resourceGroupName string, scheduledActionName string, options *ScheduledActionsClientBeginDeleteOptions) (*runtime.Poller[ScheduledActionsClientDeleteResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.deleteOperation(ctx, resourceGroupName, scheduledActionName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ScheduledActionsClientDeleteResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ScheduledActionsClientDeleteResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Delete - Delete a ScheduledAction
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
func (client *ScheduledActionsClient) deleteOperation(ctx context.Context, resourceGroupName string, scheduledActionName string, options *ScheduledActionsClientBeginDeleteOptions) (*http.Response, error) {
	var err error
	const operationName = "ScheduledActionsClient.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, scheduledActionName, 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 *ScheduledActionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, scheduledActionName string, _ *ScheduledActionsClientBeginDeleteOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions/{scheduledActionName}"
	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 scheduledActionName == "" {
		return nil, errors.New("parameter scheduledActionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{scheduledActionName}", url.PathEscape(scheduledActionName))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// DetachResources - A synchronous resource action.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - scheduledActionName - The name of the ScheduledAction
//   - body - The content of the action request
//   - options - ScheduledActionsClientDetachResourcesOptions contains the optional parameters for the ScheduledActionsClient.DetachResources
//     method.
func (client *ScheduledActionsClient) DetachResources(ctx context.Context, resourceGroupName string, scheduledActionName string, body ResourceDetachRequest, options *ScheduledActionsClientDetachResourcesOptions) (ScheduledActionsClientDetachResourcesResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.DetachResources"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.detachResourcesCreateRequest(ctx, resourceGroupName, scheduledActionName, body, options)
	if err != nil {
		return ScheduledActionsClientDetachResourcesResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientDetachResourcesResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientDetachResourcesResponse{}, err
	}
	resp, err := client.detachResourcesHandleResponse(httpResp)
	return resp, err
}

// detachResourcesCreateRequest creates the DetachResources request.
func (client *ScheduledActionsClient) detachResourcesCreateRequest(ctx context.Context, resourceGroupName string, scheduledActionName string, body ResourceDetachRequest, _ *ScheduledActionsClientDetachResourcesOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions/{scheduledActionName}/detachResources"
	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 scheduledActionName == "" {
		return nil, errors.New("parameter scheduledActionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{scheduledActionName}", url.PathEscape(scheduledActionName))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, body); err != nil {
		return nil, err
	}
	return req, nil
}

// detachResourcesHandleResponse handles the DetachResources response.
func (client *ScheduledActionsClient) detachResourcesHandleResponse(resp *http.Response) (ScheduledActionsClientDetachResourcesResponse, error) {
	result := ScheduledActionsClientDetachResourcesResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.RecurringActionsResourceOperationResult); err != nil {
		return ScheduledActionsClientDetachResourcesResponse{}, err
	}
	return result, nil
}

// Disable - A synchronous resource action.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - scheduledActionName - The name of the ScheduledAction
//   - options - ScheduledActionsClientDisableOptions contains the optional parameters for the ScheduledActionsClient.Disable
//     method.
func (client *ScheduledActionsClient) Disable(ctx context.Context, resourceGroupName string, scheduledActionName string, options *ScheduledActionsClientDisableOptions) (ScheduledActionsClientDisableResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.Disable"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.disableCreateRequest(ctx, resourceGroupName, scheduledActionName, options)
	if err != nil {
		return ScheduledActionsClientDisableResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientDisableResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientDisableResponse{}, err
	}
	return ScheduledActionsClientDisableResponse{}, nil
}

// disableCreateRequest creates the Disable request.
func (client *ScheduledActionsClient) disableCreateRequest(ctx context.Context, resourceGroupName string, scheduledActionName string, _ *ScheduledActionsClientDisableOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions/{scheduledActionName}/disable"
	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 scheduledActionName == "" {
		return nil, errors.New("parameter scheduledActionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{scheduledActionName}", url.PathEscape(scheduledActionName))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// Enable - A synchronous resource action.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - scheduledActionName - The name of the ScheduledAction
//   - options - ScheduledActionsClientEnableOptions contains the optional parameters for the ScheduledActionsClient.Enable method.
func (client *ScheduledActionsClient) Enable(ctx context.Context, resourceGroupName string, scheduledActionName string, options *ScheduledActionsClientEnableOptions) (ScheduledActionsClientEnableResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.Enable"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.enableCreateRequest(ctx, resourceGroupName, scheduledActionName, options)
	if err != nil {
		return ScheduledActionsClientEnableResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientEnableResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientEnableResponse{}, err
	}
	return ScheduledActionsClientEnableResponse{}, nil
}

// enableCreateRequest creates the Enable request.
func (client *ScheduledActionsClient) enableCreateRequest(ctx context.Context, resourceGroupName string, scheduledActionName string, _ *ScheduledActionsClientEnableOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions/{scheduledActionName}/enable"
	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 scheduledActionName == "" {
		return nil, errors.New("parameter scheduledActionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{scheduledActionName}", url.PathEscape(scheduledActionName))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// Get - Get a ScheduledAction
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - scheduledActionName - The name of the ScheduledAction
//   - options - ScheduledActionsClientGetOptions contains the optional parameters for the ScheduledActionsClient.Get method.
func (client *ScheduledActionsClient) Get(ctx context.Context, resourceGroupName string, scheduledActionName string, options *ScheduledActionsClientGetOptions) (ScheduledActionsClientGetResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.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, scheduledActionName, options)
	if err != nil {
		return ScheduledActionsClientGetResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientGetResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientGetResponse{}, err
	}
	resp, err := client.getHandleResponse(httpResp)
	return resp, err
}

// getCreateRequest creates the Get request.
func (client *ScheduledActionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, scheduledActionName string, _ *ScheduledActionsClientGetOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions/{scheduledActionName}"
	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 scheduledActionName == "" {
		return nil, errors.New("parameter scheduledActionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{scheduledActionName}", url.PathEscape(scheduledActionName))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

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

// NewListByResourceGroupPager - List ScheduledAction resources by resource group
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - options - ScheduledActionsClientListByResourceGroupOptions contains the optional parameters for the ScheduledActionsClient.NewListByResourceGroupPager
//     method.
func (client *ScheduledActionsClient) NewListByResourceGroupPager(resourceGroupName string, options *ScheduledActionsClientListByResourceGroupOptions) *runtime.Pager[ScheduledActionsClientListByResourceGroupResponse] {
	return runtime.NewPager(runtime.PagingHandler[ScheduledActionsClientListByResourceGroupResponse]{
		More: func(page ScheduledActionsClientListByResourceGroupResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *ScheduledActionsClientListByResourceGroupResponse) (ScheduledActionsClientListByResourceGroupResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ScheduledActionsClient.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 ScheduledActionsClientListByResourceGroupResponse{}, err
			}
			return client.listByResourceGroupHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listByResourceGroupCreateRequest creates the ListByResourceGroup request.
func (client *ScheduledActionsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *ScheduledActionsClientListByResourceGroupOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions"
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

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

// NewListBySubscriptionPager - List ScheduledAction resources by subscription ID
//
// Generated from API version 2025-04-15-preview
//   - options - ScheduledActionsClientListBySubscriptionOptions contains the optional parameters for the ScheduledActionsClient.NewListBySubscriptionPager
//     method.
func (client *ScheduledActionsClient) NewListBySubscriptionPager(options *ScheduledActionsClientListBySubscriptionOptions) *runtime.Pager[ScheduledActionsClientListBySubscriptionResponse] {
	return runtime.NewPager(runtime.PagingHandler[ScheduledActionsClientListBySubscriptionResponse]{
		More: func(page ScheduledActionsClientListBySubscriptionResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *ScheduledActionsClientListBySubscriptionResponse) (ScheduledActionsClientListBySubscriptionResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ScheduledActionsClient.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 ScheduledActionsClientListBySubscriptionResponse{}, err
			}
			return client.listBySubscriptionHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listBySubscriptionCreateRequest creates the ListBySubscription request.
func (client *ScheduledActionsClient) listBySubscriptionCreateRequest(ctx context.Context, _ *ScheduledActionsClientListBySubscriptionOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/scheduledActions"
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

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

// NewListResourcesPager - List resources attached to Scheduled Actions
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - scheduledActionName - The name of the ScheduledAction
//   - options - ScheduledActionsClientListResourcesOptions contains the optional parameters for the ScheduledActionsClient.NewListResourcesPager
//     method.
func (client *ScheduledActionsClient) NewListResourcesPager(resourceGroupName string, scheduledActionName string, options *ScheduledActionsClientListResourcesOptions) *runtime.Pager[ScheduledActionsClientListResourcesResponse] {
	return runtime.NewPager(runtime.PagingHandler[ScheduledActionsClientListResourcesResponse]{
		More: func(page ScheduledActionsClientListResourcesResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *ScheduledActionsClientListResourcesResponse) (ScheduledActionsClientListResourcesResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ScheduledActionsClient.NewListResourcesPager")
			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.listResourcesCreateRequest(ctx, resourceGroupName, scheduledActionName, options)
			}, nil)
			if err != nil {
				return ScheduledActionsClientListResourcesResponse{}, err
			}
			return client.listResourcesHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listResourcesCreateRequest creates the ListResources request.
func (client *ScheduledActionsClient) listResourcesCreateRequest(ctx context.Context, resourceGroupName string, scheduledActionName string, _ *ScheduledActionsClientListResourcesOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions/{scheduledActionName}/resources"
	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 scheduledActionName == "" {
		return nil, errors.New("parameter scheduledActionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{scheduledActionName}", url.PathEscape(scheduledActionName))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listResourcesHandleResponse handles the ListResources response.
func (client *ScheduledActionsClient) listResourcesHandleResponse(resp *http.Response) (ScheduledActionsClientListResourcesResponse, error) {
	result := ScheduledActionsClientListResourcesResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.ResourceListResponse); err != nil {
		return ScheduledActionsClientListResourcesResponse{}, err
	}
	return result, nil
}

// PatchResources - A synchronous resource action.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - scheduledActionName - The name of the ScheduledAction
//   - body - The content of the action request
//   - options - ScheduledActionsClientPatchResourcesOptions contains the optional parameters for the ScheduledActionsClient.PatchResources
//     method.
func (client *ScheduledActionsClient) PatchResources(ctx context.Context, resourceGroupName string, scheduledActionName string, body ResourcePatchRequest, options *ScheduledActionsClientPatchResourcesOptions) (ScheduledActionsClientPatchResourcesResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.PatchResources"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.patchResourcesCreateRequest(ctx, resourceGroupName, scheduledActionName, body, options)
	if err != nil {
		return ScheduledActionsClientPatchResourcesResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientPatchResourcesResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientPatchResourcesResponse{}, err
	}
	resp, err := client.patchResourcesHandleResponse(httpResp)
	return resp, err
}

// patchResourcesCreateRequest creates the PatchResources request.
func (client *ScheduledActionsClient) patchResourcesCreateRequest(ctx context.Context, resourceGroupName string, scheduledActionName string, body ResourcePatchRequest, _ *ScheduledActionsClientPatchResourcesOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions/{scheduledActionName}/patchResources"
	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 scheduledActionName == "" {
		return nil, errors.New("parameter scheduledActionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{scheduledActionName}", url.PathEscape(scheduledActionName))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, body); err != nil {
		return nil, err
	}
	return req, nil
}

// patchResourcesHandleResponse handles the PatchResources response.
func (client *ScheduledActionsClient) patchResourcesHandleResponse(resp *http.Response) (ScheduledActionsClientPatchResourcesResponse, error) {
	result := ScheduledActionsClientPatchResourcesResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.RecurringActionsResourceOperationResult); err != nil {
		return ScheduledActionsClientPatchResourcesResponse{}, err
	}
	return result, nil
}

// TriggerManualOccurrence - A synchronous resource action.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - scheduledActionName - The name of the ScheduledAction
//   - options - ScheduledActionsClientTriggerManualOccurrenceOptions contains the optional parameters for the ScheduledActionsClient.TriggerManualOccurrence
//     method.
func (client *ScheduledActionsClient) TriggerManualOccurrence(ctx context.Context, resourceGroupName string, scheduledActionName string, options *ScheduledActionsClientTriggerManualOccurrenceOptions) (ScheduledActionsClientTriggerManualOccurrenceResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.TriggerManualOccurrence"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.triggerManualOccurrenceCreateRequest(ctx, resourceGroupName, scheduledActionName, options)
	if err != nil {
		return ScheduledActionsClientTriggerManualOccurrenceResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientTriggerManualOccurrenceResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientTriggerManualOccurrenceResponse{}, err
	}
	resp, err := client.triggerManualOccurrenceHandleResponse(httpResp)
	return resp, err
}

// triggerManualOccurrenceCreateRequest creates the TriggerManualOccurrence request.
func (client *ScheduledActionsClient) triggerManualOccurrenceCreateRequest(ctx context.Context, resourceGroupName string, scheduledActionName string, _ *ScheduledActionsClientTriggerManualOccurrenceOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions/{scheduledActionName}/triggerManualOccurrence"
	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 scheduledActionName == "" {
		return nil, errors.New("parameter scheduledActionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{scheduledActionName}", url.PathEscape(scheduledActionName))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// triggerManualOccurrenceHandleResponse handles the TriggerManualOccurrence response.
func (client *ScheduledActionsClient) triggerManualOccurrenceHandleResponse(resp *http.Response) (ScheduledActionsClientTriggerManualOccurrenceResponse, error) {
	result := ScheduledActionsClientTriggerManualOccurrenceResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.Occurrence); err != nil {
		return ScheduledActionsClientTriggerManualOccurrenceResponse{}, err
	}
	return result, nil
}

// Update - Update a ScheduledAction
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - scheduledActionName - The name of the ScheduledAction
//   - properties - The resource properties to be updated.
//   - options - ScheduledActionsClientUpdateOptions contains the optional parameters for the ScheduledActionsClient.Update method.
func (client *ScheduledActionsClient) Update(ctx context.Context, resourceGroupName string, scheduledActionName string, properties ScheduledActionUpdate, options *ScheduledActionsClientUpdateOptions) (ScheduledActionsClientUpdateResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.Update"
	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, scheduledActionName, properties, options)
	if err != nil {
		return ScheduledActionsClientUpdateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientUpdateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientUpdateResponse{}, err
	}
	resp, err := client.updateHandleResponse(httpResp)
	return resp, err
}

// updateCreateRequest creates the Update request.
func (client *ScheduledActionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, scheduledActionName string, properties ScheduledActionUpdate, _ *ScheduledActionsClientUpdateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ComputeSchedule/scheduledActions/{scheduledActionName}"
	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 scheduledActionName == "" {
		return nil, errors.New("parameter scheduledActionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{scheduledActionName}", url.PathEscape(scheduledActionName))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, properties); err != nil {
		return nil, err
	}
	return req, nil
}

// updateHandleResponse handles the Update response.
func (client *ScheduledActionsClient) updateHandleResponse(resp *http.Response) (ScheduledActionsClientUpdateResponse, error) {
	result := ScheduledActionsClientUpdateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.ScheduledAction); err != nil {
		return ScheduledActionsClientUpdateResponse{}, err
	}
	return result, nil
}

// VirtualMachinesCancelOperations - VirtualMachinesCancelOperations: Cancel a previously submitted (start/deallocate/hibernate)
// request
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - locationparameter - The location name.
//   - requestBody - The request body
//   - options - ScheduledActionsClientVirtualMachinesCancelOperationsOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesCancelOperations
//     method.
func (client *ScheduledActionsClient) VirtualMachinesCancelOperations(ctx context.Context, locationparameter string, requestBody CancelOperationsRequest, options *ScheduledActionsClientVirtualMachinesCancelOperationsOptions) (ScheduledActionsClientVirtualMachinesCancelOperationsResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.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, locationparameter, requestBody, options)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesCancelOperationsResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesCancelOperationsResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientVirtualMachinesCancelOperationsResponse{}, err
	}
	resp, err := client.virtualMachinesCancelOperationsHandleResponse(httpResp)
	return resp, err
}

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

// virtualMachinesCancelOperationsHandleResponse handles the VirtualMachinesCancelOperations response.
func (client *ScheduledActionsClient) virtualMachinesCancelOperationsHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesCancelOperationsResponse, error) {
	result := ScheduledActionsClientVirtualMachinesCancelOperationsResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.CancelOperationsResponse); err != nil {
		return ScheduledActionsClientVirtualMachinesCancelOperationsResponse{}, 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.
//
// Generated from API version 2025-04-15-preview
//   - locationparameter - The location name.
//   - requestBody - The request body
//   - options - ScheduledActionsClientVirtualMachinesExecuteCreateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesExecuteCreate
//     method.
func (client *ScheduledActionsClient) VirtualMachinesExecuteCreate(ctx context.Context, locationparameter string, requestBody ExecuteCreateRequest, options *ScheduledActionsClientVirtualMachinesExecuteCreateOptions) (ScheduledActionsClientVirtualMachinesExecuteCreateResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.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, locationparameter, requestBody, options)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteCreateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteCreateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientVirtualMachinesExecuteCreateResponse{}, err
	}
	resp, err := client.virtualMachinesExecuteCreateHandleResponse(httpResp)
	return resp, err
}

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

// virtualMachinesExecuteCreateHandleResponse handles the VirtualMachinesExecuteCreate response.
func (client *ScheduledActionsClient) virtualMachinesExecuteCreateHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesExecuteCreateResponse, error) {
	result := ScheduledActionsClientVirtualMachinesExecuteCreateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.CreateResourceOperationResponse); err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteCreateResponse{}, 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.
//
// Generated from API version 2025-04-15-preview
//   - locationparameter - The location name.
//   - requestBody - The request body
//   - options - ScheduledActionsClientVirtualMachinesExecuteDeallocateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesExecuteDeallocate
//     method.
func (client *ScheduledActionsClient) VirtualMachinesExecuteDeallocate(ctx context.Context, locationparameter string, requestBody ExecuteDeallocateRequest, options *ScheduledActionsClientVirtualMachinesExecuteDeallocateOptions) (ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.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, locationparameter, requestBody, options)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse{}, err
	}
	resp, err := client.virtualMachinesExecuteDeallocateHandleResponse(httpResp)
	return resp, err
}

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

// virtualMachinesExecuteDeallocateHandleResponse handles the VirtualMachinesExecuteDeallocate response.
func (client *ScheduledActionsClient) virtualMachinesExecuteDeallocateHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse, error) {
	result := ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.DeallocateResourceOperationResponse); err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse{}, 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.
//
// Generated from API version 2025-04-15-preview
//   - locationparameter - The location name.
//   - requestBody - The request body
//   - options - ScheduledActionsClientVirtualMachinesExecuteDeleteOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesExecuteDelete
//     method.
func (client *ScheduledActionsClient) VirtualMachinesExecuteDelete(ctx context.Context, locationparameter string, requestBody ExecuteDeleteRequest, options *ScheduledActionsClientVirtualMachinesExecuteDeleteOptions) (ScheduledActionsClientVirtualMachinesExecuteDeleteResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.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, locationparameter, requestBody, options)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteDeleteResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteDeleteResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientVirtualMachinesExecuteDeleteResponse{}, err
	}
	resp, err := client.virtualMachinesExecuteDeleteHandleResponse(httpResp)
	return resp, err
}

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

// virtualMachinesExecuteDeleteHandleResponse handles the VirtualMachinesExecuteDelete response.
func (client *ScheduledActionsClient) virtualMachinesExecuteDeleteHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesExecuteDeleteResponse, error) {
	result := ScheduledActionsClientVirtualMachinesExecuteDeleteResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.DeleteResourceOperationResponse); err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteDeleteResponse{}, 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.
//
// Generated from API version 2025-04-15-preview
//   - locationparameter - The location name.
//   - requestBody - The request body
//   - options - ScheduledActionsClientVirtualMachinesExecuteHibernateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesExecuteHibernate
//     method.
func (client *ScheduledActionsClient) VirtualMachinesExecuteHibernate(ctx context.Context, locationparameter string, requestBody ExecuteHibernateRequest, options *ScheduledActionsClientVirtualMachinesExecuteHibernateOptions) (ScheduledActionsClientVirtualMachinesExecuteHibernateResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.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, locationparameter, requestBody, options)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteHibernateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteHibernateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientVirtualMachinesExecuteHibernateResponse{}, err
	}
	resp, err := client.virtualMachinesExecuteHibernateHandleResponse(httpResp)
	return resp, err
}

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

// virtualMachinesExecuteHibernateHandleResponse handles the VirtualMachinesExecuteHibernate response.
func (client *ScheduledActionsClient) virtualMachinesExecuteHibernateHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesExecuteHibernateResponse, error) {
	result := ScheduledActionsClientVirtualMachinesExecuteHibernateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.HibernateResourceOperationResponse); err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteHibernateResponse{}, 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.
//
// Generated from API version 2025-04-15-preview
//   - locationparameter - The location name.
//   - requestBody - The request body
//   - options - ScheduledActionsClientVirtualMachinesExecuteStartOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesExecuteStart
//     method.
func (client *ScheduledActionsClient) VirtualMachinesExecuteStart(ctx context.Context, locationparameter string, requestBody ExecuteStartRequest, options *ScheduledActionsClientVirtualMachinesExecuteStartOptions) (ScheduledActionsClientVirtualMachinesExecuteStartResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.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, locationparameter, requestBody, options)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteStartResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesExecuteStartResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientVirtualMachinesExecuteStartResponse{}, err
	}
	resp, err := client.virtualMachinesExecuteStartHandleResponse(httpResp)
	return resp, err
}

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

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

// VirtualMachinesGetOperationErrors - VirtualMachinesGetOperationErrors: Get error details on operation errors (like transient
// errors encountered, additional logs) if they exist.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - locationparameter - The location name.
//   - requestBody - The request body
//   - options - ScheduledActionsClientVirtualMachinesGetOperationErrorsOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesGetOperationErrors
//     method.
func (client *ScheduledActionsClient) VirtualMachinesGetOperationErrors(ctx context.Context, locationparameter string, requestBody GetOperationErrorsRequest, options *ScheduledActionsClientVirtualMachinesGetOperationErrorsOptions) (ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.VirtualMachinesGetOperationErrors"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.virtualMachinesGetOperationErrorsCreateRequest(ctx, locationparameter, requestBody, options)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse{}, err
	}
	resp, err := client.virtualMachinesGetOperationErrorsHandleResponse(httpResp)
	return resp, err
}

// virtualMachinesGetOperationErrorsCreateRequest creates the VirtualMachinesGetOperationErrors request.
func (client *ScheduledActionsClient) virtualMachinesGetOperationErrorsCreateRequest(ctx context.Context, locationparameter string, requestBody GetOperationErrorsRequest, _ *ScheduledActionsClientVirtualMachinesGetOperationErrorsOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesGetOperationErrors"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if locationparameter == "" {
		return nil, errors.New("parameter locationparameter cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, requestBody); err != nil {
		return nil, err
	}
	return req, nil
}

// virtualMachinesGetOperationErrorsHandleResponse handles the VirtualMachinesGetOperationErrors response.
func (client *ScheduledActionsClient) virtualMachinesGetOperationErrorsHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse, error) {
	result := ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.GetOperationErrorsResponse); err != nil {
		return ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse{}, 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.
//
// Generated from API version 2025-04-15-preview
//   - locationparameter - The location name.
//   - requestBody - The request body
//   - options - ScheduledActionsClientVirtualMachinesGetOperationStatusOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesGetOperationStatus
//     method.
func (client *ScheduledActionsClient) VirtualMachinesGetOperationStatus(ctx context.Context, locationparameter string, requestBody GetOperationStatusRequest, options *ScheduledActionsClientVirtualMachinesGetOperationStatusOptions) (ScheduledActionsClientVirtualMachinesGetOperationStatusResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.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, locationparameter, requestBody, options)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesGetOperationStatusResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesGetOperationStatusResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientVirtualMachinesGetOperationStatusResponse{}, err
	}
	resp, err := client.virtualMachinesGetOperationStatusHandleResponse(httpResp)
	return resp, err
}

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

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

// VirtualMachinesSubmitDeallocate - VirtualMachinesSubmitDeallocate: Schedule deallocate operation for a batch of virtual
// machines at datetime in future.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - locationparameter - The location name.
//   - requestBody - The request body
//   - options - ScheduledActionsClientVirtualMachinesSubmitDeallocateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesSubmitDeallocate
//     method.
func (client *ScheduledActionsClient) VirtualMachinesSubmitDeallocate(ctx context.Context, locationparameter string, requestBody SubmitDeallocateRequest, options *ScheduledActionsClientVirtualMachinesSubmitDeallocateOptions) (ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.VirtualMachinesSubmitDeallocate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.virtualMachinesSubmitDeallocateCreateRequest(ctx, locationparameter, requestBody, options)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse{}, err
	}
	resp, err := client.virtualMachinesSubmitDeallocateHandleResponse(httpResp)
	return resp, err
}

// virtualMachinesSubmitDeallocateCreateRequest creates the VirtualMachinesSubmitDeallocate request.
func (client *ScheduledActionsClient) virtualMachinesSubmitDeallocateCreateRequest(ctx context.Context, locationparameter string, requestBody SubmitDeallocateRequest, _ *ScheduledActionsClientVirtualMachinesSubmitDeallocateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitDeallocate"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if locationparameter == "" {
		return nil, errors.New("parameter locationparameter cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, requestBody); err != nil {
		return nil, err
	}
	return req, nil
}

// virtualMachinesSubmitDeallocateHandleResponse handles the VirtualMachinesSubmitDeallocate response.
func (client *ScheduledActionsClient) virtualMachinesSubmitDeallocateHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse, error) {
	result := ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.DeallocateResourceOperationResponse); err != nil {
		return ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse{}, err
	}
	return result, nil
}

// VirtualMachinesSubmitHibernate - VirtualMachinesSubmitHibernate: Schedule hibernate operation for a batch of virtual machines
// at datetime in future.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - locationparameter - The location name.
//   - requestBody - The request body
//   - options - ScheduledActionsClientVirtualMachinesSubmitHibernateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesSubmitHibernate
//     method.
func (client *ScheduledActionsClient) VirtualMachinesSubmitHibernate(ctx context.Context, locationparameter string, requestBody SubmitHibernateRequest, options *ScheduledActionsClientVirtualMachinesSubmitHibernateOptions) (ScheduledActionsClientVirtualMachinesSubmitHibernateResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.VirtualMachinesSubmitHibernate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.virtualMachinesSubmitHibernateCreateRequest(ctx, locationparameter, requestBody, options)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesSubmitHibernateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesSubmitHibernateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientVirtualMachinesSubmitHibernateResponse{}, err
	}
	resp, err := client.virtualMachinesSubmitHibernateHandleResponse(httpResp)
	return resp, err
}

// virtualMachinesSubmitHibernateCreateRequest creates the VirtualMachinesSubmitHibernate request.
func (client *ScheduledActionsClient) virtualMachinesSubmitHibernateCreateRequest(ctx context.Context, locationparameter string, requestBody SubmitHibernateRequest, _ *ScheduledActionsClientVirtualMachinesSubmitHibernateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitHibernate"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if locationparameter == "" {
		return nil, errors.New("parameter locationparameter cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, requestBody); err != nil {
		return nil, err
	}
	return req, nil
}

// virtualMachinesSubmitHibernateHandleResponse handles the VirtualMachinesSubmitHibernate response.
func (client *ScheduledActionsClient) virtualMachinesSubmitHibernateHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesSubmitHibernateResponse, error) {
	result := ScheduledActionsClientVirtualMachinesSubmitHibernateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.HibernateResourceOperationResponse); err != nil {
		return ScheduledActionsClientVirtualMachinesSubmitHibernateResponse{}, err
	}
	return result, nil
}

// VirtualMachinesSubmitStart - VirtualMachinesSubmitStart: Schedule start operation for a batch of virtual machines at datetime
// in future.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-04-15-preview
//   - locationparameter - The location name.
//   - requestBody - The request body
//   - options - ScheduledActionsClientVirtualMachinesSubmitStartOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesSubmitStart
//     method.
func (client *ScheduledActionsClient) VirtualMachinesSubmitStart(ctx context.Context, locationparameter string, requestBody SubmitStartRequest, options *ScheduledActionsClientVirtualMachinesSubmitStartOptions) (ScheduledActionsClientVirtualMachinesSubmitStartResponse, error) {
	var err error
	const operationName = "ScheduledActionsClient.VirtualMachinesSubmitStart"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.virtualMachinesSubmitStartCreateRequest(ctx, locationparameter, requestBody, options)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesSubmitStartResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return ScheduledActionsClientVirtualMachinesSubmitStartResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return ScheduledActionsClientVirtualMachinesSubmitStartResponse{}, err
	}
	resp, err := client.virtualMachinesSubmitStartHandleResponse(httpResp)
	return resp, err
}

// virtualMachinesSubmitStartCreateRequest creates the VirtualMachinesSubmitStart request.
func (client *ScheduledActionsClient) virtualMachinesSubmitStartCreateRequest(ctx context.Context, locationparameter string, requestBody SubmitStartRequest, _ *ScheduledActionsClientVirtualMachinesSubmitStartOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitStart"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if locationparameter == "" {
		return nil, errors.New("parameter locationparameter cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter))
	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", "2025-04-15-preview")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, requestBody); err != nil {
		return nil, err
	}
	return req, nil
}

// virtualMachinesSubmitStartHandleResponse handles the VirtualMachinesSubmitStart response.
func (client *ScheduledActionsClient) virtualMachinesSubmitStartHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesSubmitStartResponse, error) {
	result := ScheduledActionsClientVirtualMachinesSubmitStartResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.StartResourceOperationResponse); err != nil {
		return ScheduledActionsClientVirtualMachinesSubmitStartResponse{}, err
	}
	return result, nil
}
