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

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

// RecoveryPlanActionsClient - Actions for managing Recovery Orchestration Plans.
// Don't use this type directly, use NewRecoveryPlanActionsClient() instead.
//
// Generated from API version 2026-04-01-preview
type RecoveryPlanActionsClient struct {
	internal *arm.Client
}

// NewRecoveryPlanActionsClient creates a new instance of RecoveryPlanActionsClient with the specified values.
//   - credential - used to authorize requests. Usually a credential from azidentity.
//   - options - Contains optional client configuration. Pass nil to accept the default values.
func NewRecoveryPlanActionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*RecoveryPlanActionsClient, error) {
	cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
	if err != nil {
		return nil, err
	}
	client := &RecoveryPlanActionsClient{
		internal: cl,
	}
	return client, nil
}

// BeginCheckReadiness - This action performs the necessary readiness check on the recovery orchestration plan to ensure it
// is in the desired state and eligible for all recovery actions, including all protected resources.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - options - RecoveryPlanActionsClientBeginCheckReadinessOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginCheckReadiness
//     method.
func (client *RecoveryPlanActionsClient) BeginCheckReadiness(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginCheckReadinessOptions) (*runtime.Poller[RecoveryPlanActionsClientCheckReadinessResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.checkReadiness(ctx, serviceGroupName, operationID, recoveryPlanName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientCheckReadinessResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientCheckReadinessResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// CheckReadiness - This action performs the necessary readiness check on the recovery orchestration plan to ensure it is
// in the desired state and eligible for all recovery actions, including all protected resources.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) checkReadiness(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginCheckReadinessOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginCheckReadiness"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.checkReadinessCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// checkReadinessCreateRequest creates the CheckReadiness request.
func (client *RecoveryPlanActionsClient) checkReadinessCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, _ *RecoveryPlanActionsClientBeginCheckReadinessOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/checkReadiness"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["operation-id"] = []string{operationID}
	return req, nil
}

// BeginFailover - This action triggers the failover operation on the recovery orchestration plan for the qualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - body - The content of the action request
//   - options - RecoveryPlanActionsClientBeginFailoverOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginFailover
//     method.
func (client *RecoveryPlanActionsClient) BeginFailover(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body FailoverRequest, options *RecoveryPlanActionsClientBeginFailoverOptions) (*runtime.Poller[RecoveryPlanActionsClientFailoverResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.failover(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientFailoverResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientFailoverResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Failover - This action triggers the failover operation on the recovery orchestration plan for the qualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) failover(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body FailoverRequest, options *RecoveryPlanActionsClientBeginFailoverOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginFailover"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.failoverCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// failoverCreateRequest creates the Failover request.
func (client *RecoveryPlanActionsClient) failoverCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body FailoverRequest, _ *RecoveryPlanActionsClientBeginFailoverOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/failover"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["operation-id"] = []string{operationID}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, body); err != nil {
		return nil, err
	}
	return req, nil
}

// BeginFailoverCommit - This action triggers the failover commit operation on the recovery orchestration plan for the qualified
// resources.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - options - RecoveryPlanActionsClientBeginFailoverCommitOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginFailoverCommit
//     method.
func (client *RecoveryPlanActionsClient) BeginFailoverCommit(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginFailoverCommitOptions) (*runtime.Poller[RecoveryPlanActionsClientFailoverCommitResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.failoverCommit(ctx, serviceGroupName, operationID, recoveryPlanName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientFailoverCommitResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientFailoverCommitResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// FailoverCommit - This action triggers the failover commit operation on the recovery orchestration plan for the qualified
// resources.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) failoverCommit(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginFailoverCommitOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginFailoverCommit"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.failoverCommitCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// failoverCommitCreateRequest creates the FailoverCommit request.
func (client *RecoveryPlanActionsClient) failoverCommitCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, _ *RecoveryPlanActionsClientBeginFailoverCommitOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/failoverCommit"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["operation-id"] = []string{operationID}
	return req, nil
}

// BeginFinalize - This action finalizes the recovery orchestration plan, ensuring all necessary configurations are in place.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - options - RecoveryPlanActionsClientBeginFinalizeOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginFinalize
//     method.
func (client *RecoveryPlanActionsClient) BeginFinalize(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginFinalizeOptions) (*runtime.Poller[RecoveryPlanActionsClientFinalizeResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.finalize(ctx, serviceGroupName, operationID, recoveryPlanName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientFinalizeResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientFinalizeResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Finalize - This action finalizes the recovery orchestration plan, ensuring all necessary configurations are in place.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) finalize(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginFinalizeOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginFinalize"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.finalizeCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, 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
}

// finalizeCreateRequest creates the Finalize request.
func (client *RecoveryPlanActionsClient) finalizeCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, _ *RecoveryPlanActionsClientBeginFinalizeOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/finalize"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["operation-id"] = []string{operationID}
	return req, nil
}

// BeginReprotect - This action triggers the reprotect operation on the recovery orchestration plan for the qualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - options - RecoveryPlanActionsClientBeginReprotectOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginReprotect
//     method.
func (client *RecoveryPlanActionsClient) BeginReprotect(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginReprotectOptions) (*runtime.Poller[RecoveryPlanActionsClientReprotectResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.reprotect(ctx, serviceGroupName, operationID, recoveryPlanName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientReprotectResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientReprotectResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Reprotect - This action triggers the reprotect operation on the recovery orchestration plan for the qualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) reprotect(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginReprotectOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginReprotect"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.reprotectCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// reprotectCreateRequest creates the Reprotect request.
func (client *RecoveryPlanActionsClient) reprotectCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginReprotectOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/reprotect"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["operation-id"] = []string{operationID}
	if options != nil && options.Body != nil {
		req.Raw().Header["Content-Type"] = []string{"application/json"}
		if err := runtime.MarshalAsJSON(req, *options.Body); err != nil {
			return nil, err
		}
		return req, nil
	}
	return req, nil
}

// BeginTestFailover - This action triggers the test failover operation on the recovery orchestration plan for the qualified
// resources.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - body - The content of the action request
//   - options - RecoveryPlanActionsClientBeginTestFailoverOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginTestFailover
//     method.
func (client *RecoveryPlanActionsClient) BeginTestFailover(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body FailoverRequest, options *RecoveryPlanActionsClientBeginTestFailoverOptions) (*runtime.Poller[RecoveryPlanActionsClientTestFailoverResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.testFailover(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientTestFailoverResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientTestFailoverResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// TestFailover - This action triggers the test failover operation on the recovery orchestration plan for the qualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) testFailover(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body FailoverRequest, options *RecoveryPlanActionsClientBeginTestFailoverOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginTestFailover"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.testFailoverCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// testFailoverCreateRequest creates the TestFailover request.
func (client *RecoveryPlanActionsClient) testFailoverCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body FailoverRequest, _ *RecoveryPlanActionsClientBeginTestFailoverOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/testFailover"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["operation-id"] = []string{operationID}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, body); err != nil {
		return nil, err
	}
	return req, nil
}

// BeginTestFailoverCleanup - This action triggers the test failover cleanup operation on the recovery orchestration plan
// for the qualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - body - The content of the action request
//   - options - RecoveryPlanActionsClientBeginTestFailoverCleanupOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginTestFailoverCleanup
//     method.
func (client *RecoveryPlanActionsClient) BeginTestFailoverCleanup(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body TestFailoverCleanupRequest, options *RecoveryPlanActionsClientBeginTestFailoverCleanupOptions) (*runtime.Poller[RecoveryPlanActionsClientTestFailoverCleanupResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.testFailoverCleanup(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientTestFailoverCleanupResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientTestFailoverCleanupResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// TestFailoverCleanup - This action triggers the test failover cleanup operation on the recovery orchestration plan for the
// qualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) testFailoverCleanup(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body TestFailoverCleanupRequest, options *RecoveryPlanActionsClientBeginTestFailoverCleanupOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginTestFailoverCleanup"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.testFailoverCleanupCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// testFailoverCleanupCreateRequest creates the TestFailoverCleanup request.
func (client *RecoveryPlanActionsClient) testFailoverCleanupCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body TestFailoverCleanupRequest, _ *RecoveryPlanActionsClientBeginTestFailoverCleanupOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/testFailoverCleanup"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["operation-id"] = []string{operationID}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, body); err != nil {
		return nil, err
	}
	return req, nil
}

// BeginUpdateResources - This action adds or updates the resources to be included in the recovery orchestration plan.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - body - The content of the action request
//   - options - RecoveryPlanActionsClientBeginUpdateResourcesOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginUpdateResources
//     method.
func (client *RecoveryPlanActionsClient) BeginUpdateResources(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body UpdateRecoveryResourcesRequest, options *RecoveryPlanActionsClientBeginUpdateResourcesOptions) (*runtime.Poller[RecoveryPlanActionsClientUpdateResourcesResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.updateResources(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientUpdateResourcesResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientUpdateResourcesResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// UpdateResources - This action adds or updates the resources to be included in the recovery orchestration plan.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) updateResources(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body UpdateRecoveryResourcesRequest, options *RecoveryPlanActionsClientBeginUpdateResourcesOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginUpdateResources"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.updateResourcesCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// updateResourcesCreateRequest creates the UpdateResources request.
func (client *RecoveryPlanActionsClient) updateResourcesCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body UpdateRecoveryResourcesRequest, _ *RecoveryPlanActionsClientBeginUpdateResourcesOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/updateResources"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["operation-id"] = []string{operationID}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, body); err != nil {
		return nil, err
	}
	return req, nil
}

// BeginValidateForFailover - This action checks if the recovery orchestration plan is eligible for failover operation, ensuring
// it meets the necessary criteria and provides a list of qualified and unqualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - body - The content of the action request
//   - options - RecoveryPlanActionsClientBeginValidateForFailoverOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginValidateForFailover
//     method.
func (client *RecoveryPlanActionsClient) BeginValidateForFailover(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body FailoverRequest, options *RecoveryPlanActionsClientBeginValidateForFailoverOptions) (*runtime.Poller[RecoveryPlanActionsClientValidateForFailoverResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.validateForFailover(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientValidateForFailoverResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientValidateForFailoverResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// ValidateForFailover - This action checks if the recovery orchestration plan is eligible for failover operation, ensuring
// it meets the necessary criteria and provides a list of qualified and unqualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) validateForFailover(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body FailoverRequest, options *RecoveryPlanActionsClientBeginValidateForFailoverOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginValidateForFailover"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.validateForFailoverCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// validateForFailoverCreateRequest creates the ValidateForFailover request.
func (client *RecoveryPlanActionsClient) validateForFailoverCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body FailoverRequest, _ *RecoveryPlanActionsClientBeginValidateForFailoverOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/validateForFailover"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["operation-id"] = []string{operationID}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, body); err != nil {
		return nil, err
	}
	return req, nil
}

// BeginValidateForFailoverCommit - This action checks if the recovery orchestration plan is eligible for failover commit
// operation, ensuring it meets the necessary criteria and provides a list of qualified and unqualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - options - RecoveryPlanActionsClientBeginValidateForFailoverCommitOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginValidateForFailoverCommit
//     method.
func (client *RecoveryPlanActionsClient) BeginValidateForFailoverCommit(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginValidateForFailoverCommitOptions) (*runtime.Poller[RecoveryPlanActionsClientValidateForFailoverCommitResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.validateForFailoverCommit(ctx, serviceGroupName, operationID, recoveryPlanName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientValidateForFailoverCommitResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientValidateForFailoverCommitResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// ValidateForFailoverCommit - This action checks if the recovery orchestration plan is eligible for failover commit operation,
// ensuring it meets the necessary criteria and provides a list of qualified and unqualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) validateForFailoverCommit(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginValidateForFailoverCommitOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginValidateForFailoverCommit"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.validateForFailoverCommitCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// validateForFailoverCommitCreateRequest creates the ValidateForFailoverCommit request.
func (client *RecoveryPlanActionsClient) validateForFailoverCommitCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, _ *RecoveryPlanActionsClientBeginValidateForFailoverCommitOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/validateForFailoverCommit"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["operation-id"] = []string{operationID}
	return req, nil
}

// BeginValidateForOperation - This action checks if the recovery orchestration plan is eligible for operations like failover
// and reprotect, ensuring it meets the necessary criteria.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - body - The content of the action request
//   - options - RecoveryPlanActionsClientBeginValidateForOperationOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginValidateForOperation
//     method.
func (client *RecoveryPlanActionsClient) BeginValidateForOperation(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body ValidateForOperationRequest, options *RecoveryPlanActionsClientBeginValidateForOperationOptions) (*runtime.Poller[RecoveryPlanActionsClientValidateForOperationResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.validateForOperation(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientValidateForOperationResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientValidateForOperationResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// ValidateForOperation - This action checks if the recovery orchestration plan is eligible for operations like failover and
// reprotect, ensuring it meets the necessary criteria.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) validateForOperation(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body ValidateForOperationRequest, options *RecoveryPlanActionsClientBeginValidateForOperationOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginValidateForOperation"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.validateForOperationCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, body, 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
}

// validateForOperationCreateRequest creates the ValidateForOperation request.
func (client *RecoveryPlanActionsClient) validateForOperationCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body ValidateForOperationRequest, _ *RecoveryPlanActionsClientBeginValidateForOperationOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/validateForOperation"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["operation-id"] = []string{operationID}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, body); err != nil {
		return nil, err
	}
	return req, nil
}

// BeginValidateForReprotect - This action checks if the recovery orchestration plan is eligible for reprotect operation,
// ensuring it meets the necessary criteria and provides a list of qualified and unqualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - options - RecoveryPlanActionsClientBeginValidateForReprotectOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginValidateForReprotect
//     method.
func (client *RecoveryPlanActionsClient) BeginValidateForReprotect(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginValidateForReprotectOptions) (*runtime.Poller[RecoveryPlanActionsClientValidateForReprotectResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.validateForReprotect(ctx, serviceGroupName, operationID, recoveryPlanName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientValidateForReprotectResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientValidateForReprotectResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// ValidateForReprotect - This action checks if the recovery orchestration plan is eligible for reprotect operation, ensuring
// it meets the necessary criteria and provides a list of qualified and unqualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) validateForReprotect(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginValidateForReprotectOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginValidateForReprotect"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.validateForReprotectCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// validateForReprotectCreateRequest creates the ValidateForReprotect request.
func (client *RecoveryPlanActionsClient) validateForReprotectCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginValidateForReprotectOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/validateForReprotect"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["operation-id"] = []string{operationID}
	if options != nil && options.Body != nil {
		req.Raw().Header["Content-Type"] = []string{"application/json"}
		if err := runtime.MarshalAsJSON(req, *options.Body); err != nil {
			return nil, err
		}
		return req, nil
	}
	return req, nil
}

// BeginValidateForTestFailover - This action checks if the recovery orchestration plan is eligible for test failover operation,
// ensuring it meets the necessary criteria and provides a list of qualified and unqualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - body - The content of the action request
//   - options - RecoveryPlanActionsClientBeginValidateForTestFailoverOptions contains the optional parameters for the RecoveryPlanActionsClient.BeginValidateForTestFailover
//     method.
func (client *RecoveryPlanActionsClient) BeginValidateForTestFailover(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body FailoverRequest, options *RecoveryPlanActionsClientBeginValidateForTestFailoverOptions) (*runtime.Poller[RecoveryPlanActionsClientValidateForTestFailoverResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.validateForTestFailover(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientValidateForTestFailoverResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientValidateForTestFailoverResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// ValidateForTestFailover - This action checks if the recovery orchestration plan is eligible for test failover operation,
// ensuring it meets the necessary criteria and provides a list of qualified and unqualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) validateForTestFailover(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body FailoverRequest, options *RecoveryPlanActionsClientBeginValidateForTestFailoverOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginValidateForTestFailover"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.validateForTestFailoverCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, body, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// validateForTestFailoverCreateRequest creates the ValidateForTestFailover request.
func (client *RecoveryPlanActionsClient) validateForTestFailoverCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, body FailoverRequest, _ *RecoveryPlanActionsClientBeginValidateForTestFailoverOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/validateForTestFailover"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["operation-id"] = []string{operationID}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, body); err != nil {
		return nil, err
	}
	return req, nil
}

// BeginValidateForTestFailoverCleanup - This action checks if the recovery orchestration plan is eligible for test failover
// cleanup operation, ensuring it meets the necessary criteria and provides a list of qualified and unqualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
//   - serviceGroupName - The name of the service group.
//   - operationID - A GUID that represents the Long Running OperationId.
//   - recoveryPlanName - The name of the recovery orchestration plan.
//   - options - RecoveryPlanActionsClientBeginValidateForTestFailoverCleanupOptions contains the optional parameters for the
//     RecoveryPlanActionsClient.BeginValidateForTestFailoverCleanup method.
func (client *RecoveryPlanActionsClient) BeginValidateForTestFailoverCleanup(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginValidateForTestFailoverCleanupOptions) (*runtime.Poller[RecoveryPlanActionsClientValidateForTestFailoverCleanupResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.validateForTestFailoverCleanup(ctx, serviceGroupName, operationID, recoveryPlanName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RecoveryPlanActionsClientValidateForTestFailoverCleanupResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RecoveryPlanActionsClientValidateForTestFailoverCleanupResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// ValidateForTestFailoverCleanup - This action checks if the recovery orchestration plan is eligible for test failover cleanup
// operation, ensuring it meets the necessary criteria and provides a list of qualified and unqualified resources.
// If the operation fails it returns an *azcore.ResponseError type.
func (client *RecoveryPlanActionsClient) validateForTestFailoverCleanup(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, options *RecoveryPlanActionsClientBeginValidateForTestFailoverCleanupOptions) (*http.Response, error) {
	var err error
	const operationName = "RecoveryPlanActionsClient.BeginValidateForTestFailoverCleanup"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.validateForTestFailoverCleanupCreateRequest(ctx, serviceGroupName, operationID, recoveryPlanName, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// validateForTestFailoverCleanupCreateRequest creates the ValidateForTestFailoverCleanup request.
func (client *RecoveryPlanActionsClient) validateForTestFailoverCleanupCreateRequest(ctx context.Context, serviceGroupName string, operationID string, recoveryPlanName string, _ *RecoveryPlanActionsClientBeginValidateForTestFailoverCleanupOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.AzureResilienceManagement/recoveryPlans/{recoveryPlanName}/validateForTestFailoverCleanup"
	if serviceGroupName == "" {
		return nil, errors.New("parameter serviceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{serviceGroupName}", url.PathEscape(serviceGroupName))
	if recoveryPlanName == "" {
		return nil, errors.New("parameter recoveryPlanName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{recoveryPlanName}", url.PathEscape(recoveryPlanName))
	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", version20260401Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["operation-id"] = []string{operationID}
	return req, nil
}
