sdk/resourcemanager/recoveryservices/armrecoveryservicessiterecovery/replicationprotectionclusters_client.go (877 lines of code) (raw):
// 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) AutoRest Code Generator. DO NOT EDIT.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
package armrecoveryservicessiterecovery
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"
)
// ReplicationProtectionClustersClient contains the methods for the ReplicationProtectionClusters group.
// Don't use this type directly, use NewReplicationProtectionClustersClient() instead.
type ReplicationProtectionClustersClient struct {
internal *arm.Client
subscriptionID string
}
// NewReplicationProtectionClustersClient creates a new instance of ReplicationProtectionClustersClient with the specified values.
// - subscriptionID - The subscription Id.
// - credential - used to authorize requests. Usually a credential from azidentity.
// - options - pass nil to accept the default values.
func NewReplicationProtectionClustersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ReplicationProtectionClustersClient, error) {
cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
if err != nil {
return nil, err
}
client := &ReplicationProtectionClustersClient{
subscriptionID: subscriptionID,
internal: cl,
}
return client, nil
}
// BeginApplyRecoveryPoint - Operation to apply a new cluster recovery point on the Protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
// - resourceGroupName - The name of the resource group where the recovery services vault is present.
// - resourceName - The name of the recovery services vault.
// - fabricName - Fabric name.
// - protectionContainerName - Protection container name.
// - replicationProtectionClusterName - Replication protection cluster name.
// - applyClusterRecoveryPointInput - Apply recovery point input.
// - options - ReplicationProtectionClustersClientBeginApplyRecoveryPointOptions contains the optional parameters for the ReplicationProtectionClustersClient.BeginApplyRecoveryPoint
// method.
func (client *ReplicationProtectionClustersClient) BeginApplyRecoveryPoint(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, applyClusterRecoveryPointInput ApplyClusterRecoveryPointInput, options *ReplicationProtectionClustersClientBeginApplyRecoveryPointOptions) (*runtime.Poller[ReplicationProtectionClustersClientApplyRecoveryPointResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.applyRecoveryPoint(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, applyClusterRecoveryPointInput, options)
if err != nil {
return nil, err
}
poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationProtectionClustersClientApplyRecoveryPointResponse]{
FinalStateVia: runtime.FinalStateViaLocation,
Tracer: client.internal.Tracer(),
})
return poller, err
} else {
return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReplicationProtectionClustersClientApplyRecoveryPointResponse]{
Tracer: client.internal.Tracer(),
})
}
}
// ApplyRecoveryPoint - Operation to apply a new cluster recovery point on the Protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
func (client *ReplicationProtectionClustersClient) applyRecoveryPoint(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, applyClusterRecoveryPointInput ApplyClusterRecoveryPointInput, options *ReplicationProtectionClustersClientBeginApplyRecoveryPointOptions) (*http.Response, error) {
var err error
const operationName = "ReplicationProtectionClustersClient.BeginApplyRecoveryPoint"
ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
defer func() { endSpan(err) }()
req, err := client.applyRecoveryPointCreateRequest(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, applyClusterRecoveryPointInput, 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
}
// applyRecoveryPointCreateRequest creates the ApplyRecoveryPoint request.
func (client *ReplicationProtectionClustersClient) applyRecoveryPointCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, applyClusterRecoveryPointInput ApplyClusterRecoveryPointInput, _ *ReplicationProtectionClustersClientBeginApplyRecoveryPointOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionClusters/{replicationProtectionClusterName}/applyRecoveryPoint"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if resourceName == "" {
return nil, errors.New("parameter resourceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if fabricName == "" {
return nil, errors.New("parameter fabricName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName))
if protectionContainerName == "" {
return nil, errors.New("parameter protectionContainerName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{protectionContainerName}", url.PathEscape(protectionContainerName))
if replicationProtectionClusterName == "" {
return nil, errors.New("parameter replicationProtectionClusterName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{replicationProtectionClusterName}", url.PathEscape(replicationProtectionClusterName))
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-01-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
if err := runtime.MarshalAsJSON(req, applyClusterRecoveryPointInput); err != nil {
return nil, err
}
return req, nil
}
// BeginCreate - The operation to create an ASR replication protection cluster item.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
// - resourceGroupName - The name of the resource group where the recovery services vault is present.
// - resourceName - The name of the recovery services vault.
// - fabricName - Fabric name.
// - protectionContainerName - Protection container name.
// - replicationProtectionClusterName - Replication protection cluster name.
// - replicationProtectionCluster - Create replication protection cluster Input.
// - options - ReplicationProtectionClustersClientBeginCreateOptions contains the optional parameters for the ReplicationProtectionClustersClient.BeginCreate
// method.
func (client *ReplicationProtectionClustersClient) BeginCreate(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, replicationProtectionCluster ReplicationProtectionCluster, options *ReplicationProtectionClustersClientBeginCreateOptions) (*runtime.Poller[ReplicationProtectionClustersClientCreateResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.create(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, replicationProtectionCluster, options)
if err != nil {
return nil, err
}
poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationProtectionClustersClientCreateResponse]{
Tracer: client.internal.Tracer(),
})
return poller, err
} else {
return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReplicationProtectionClustersClientCreateResponse]{
Tracer: client.internal.Tracer(),
})
}
}
// Create - The operation to create an ASR replication protection cluster item.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
func (client *ReplicationProtectionClustersClient) create(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, replicationProtectionCluster ReplicationProtectionCluster, options *ReplicationProtectionClustersClientBeginCreateOptions) (*http.Response, error) {
var err error
const operationName = "ReplicationProtectionClustersClient.BeginCreate"
ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
defer func() { endSpan(err) }()
req, err := client.createCreateRequest(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, replicationProtectionCluster, 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
}
// createCreateRequest creates the Create request.
func (client *ReplicationProtectionClustersClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, replicationProtectionCluster ReplicationProtectionCluster, _ *ReplicationProtectionClustersClientBeginCreateOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionClusters/{replicationProtectionClusterName}"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if resourceName == "" {
return nil, errors.New("parameter resourceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if fabricName == "" {
return nil, errors.New("parameter fabricName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName))
if protectionContainerName == "" {
return nil, errors.New("parameter protectionContainerName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{protectionContainerName}", url.PathEscape(protectionContainerName))
if replicationProtectionClusterName == "" {
return nil, errors.New("parameter replicationProtectionClusterName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{replicationProtectionClusterName}", url.PathEscape(replicationProtectionClusterName))
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-01-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
if err := runtime.MarshalAsJSON(req, replicationProtectionCluster); err != nil {
return nil, err
}
return req, nil
}
// BeginFailoverCommit - Operation to initiate commit failover of the replication protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
// - resourceGroupName - The name of the resource group where the recovery services vault is present.
// - resourceName - The name of the recovery services vault.
// - fabricName - Fabric name.
// - protectionContainerName - Protection container name.
// - replicationProtectionClusterName - Replication protection cluster name.
// - options - ReplicationProtectionClustersClientBeginFailoverCommitOptions contains the optional parameters for the ReplicationProtectionClustersClient.BeginFailoverCommit
// method.
func (client *ReplicationProtectionClustersClient) BeginFailoverCommit(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, options *ReplicationProtectionClustersClientBeginFailoverCommitOptions) (*runtime.Poller[ReplicationProtectionClustersClientFailoverCommitResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.failoverCommit(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, options)
if err != nil {
return nil, err
}
poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationProtectionClustersClientFailoverCommitResponse]{
FinalStateVia: runtime.FinalStateViaLocation,
Tracer: client.internal.Tracer(),
})
return poller, err
} else {
return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReplicationProtectionClustersClientFailoverCommitResponse]{
Tracer: client.internal.Tracer(),
})
}
}
// FailoverCommit - Operation to initiate commit failover of the replication protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
func (client *ReplicationProtectionClustersClient) failoverCommit(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, options *ReplicationProtectionClustersClientBeginFailoverCommitOptions) (*http.Response, error) {
var err error
const operationName = "ReplicationProtectionClustersClient.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, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, 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 *ReplicationProtectionClustersClient) failoverCommitCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, _ *ReplicationProtectionClustersClientBeginFailoverCommitOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionClusters/{replicationProtectionClusterName}/failoverCommit"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if resourceName == "" {
return nil, errors.New("parameter resourceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if fabricName == "" {
return nil, errors.New("parameter fabricName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName))
if protectionContainerName == "" {
return nil, errors.New("parameter protectionContainerName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{protectionContainerName}", url.PathEscape(protectionContainerName))
if replicationProtectionClusterName == "" {
return nil, errors.New("parameter replicationProtectionClusterName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{replicationProtectionClusterName}", url.PathEscape(replicationProtectionClusterName))
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-01-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// Get - Gets the details of an ASR replication protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
// - resourceGroupName - The name of the resource group where the recovery services vault is present.
// - resourceName - The name of the recovery services vault.
// - fabricName - Fabric name.
// - protectionContainerName - Protection container name.
// - replicationProtectionClusterName - Replication protection cluster name.
// - options - ReplicationProtectionClustersClientGetOptions contains the optional parameters for the ReplicationProtectionClustersClient.Get
// method.
func (client *ReplicationProtectionClustersClient) Get(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, options *ReplicationProtectionClustersClientGetOptions) (ReplicationProtectionClustersClientGetResponse, error) {
var err error
const operationName = "ReplicationProtectionClustersClient.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, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, options)
if err != nil {
return ReplicationProtectionClustersClientGetResponse{}, err
}
httpResp, err := client.internal.Pipeline().Do(req)
if err != nil {
return ReplicationProtectionClustersClientGetResponse{}, err
}
if !runtime.HasStatusCode(httpResp, http.StatusOK) {
err = runtime.NewResponseError(httpResp)
return ReplicationProtectionClustersClientGetResponse{}, err
}
resp, err := client.getHandleResponse(httpResp)
return resp, err
}
// getCreateRequest creates the Get request.
func (client *ReplicationProtectionClustersClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, _ *ReplicationProtectionClustersClientGetOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionClusters/{replicationProtectionClusterName}"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if resourceName == "" {
return nil, errors.New("parameter resourceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if fabricName == "" {
return nil, errors.New("parameter fabricName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName))
if protectionContainerName == "" {
return nil, errors.New("parameter protectionContainerName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{protectionContainerName}", url.PathEscape(protectionContainerName))
if replicationProtectionClusterName == "" {
return nil, errors.New("parameter replicationProtectionClusterName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{replicationProtectionClusterName}", url.PathEscape(replicationProtectionClusterName))
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-01-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// getHandleResponse handles the Get response.
func (client *ReplicationProtectionClustersClient) getHandleResponse(resp *http.Response) (ReplicationProtectionClustersClientGetResponse, error) {
result := ReplicationProtectionClustersClientGetResponse{}
if err := runtime.UnmarshalAsJSON(resp, &result.ReplicationProtectionCluster); err != nil {
return ReplicationProtectionClustersClientGetResponse{}, err
}
return result, nil
}
// GetOperationResults - Track the results of an asynchronous operation on the replication protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
// - resourceGroupName - The name of the resource group where the recovery services vault is present.
// - resourceName - The name of the recovery services vault.
// - fabricName - Fabric name.
// - protectionContainerName - Protection container name.
// - replicationProtectionClusterName - Replication protection cluster name.
// - jobID - job id to track.
// - options - ReplicationProtectionClustersClientGetOperationResultsOptions contains the optional parameters for the ReplicationProtectionClustersClient.GetOperationResults
// method.
func (client *ReplicationProtectionClustersClient) GetOperationResults(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, jobID string, options *ReplicationProtectionClustersClientGetOperationResultsOptions) (ReplicationProtectionClustersClientGetOperationResultsResponse, error) {
var err error
const operationName = "ReplicationProtectionClustersClient.GetOperationResults"
ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
defer func() { endSpan(err) }()
req, err := client.getOperationResultsCreateRequest(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, jobID, options)
if err != nil {
return ReplicationProtectionClustersClientGetOperationResultsResponse{}, err
}
httpResp, err := client.internal.Pipeline().Do(req)
if err != nil {
return ReplicationProtectionClustersClientGetOperationResultsResponse{}, err
}
if !runtime.HasStatusCode(httpResp, http.StatusOK) {
err = runtime.NewResponseError(httpResp)
return ReplicationProtectionClustersClientGetOperationResultsResponse{}, err
}
resp, err := client.getOperationResultsHandleResponse(httpResp)
return resp, err
}
// getOperationResultsCreateRequest creates the GetOperationResults request.
func (client *ReplicationProtectionClustersClient) getOperationResultsCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, jobID string, _ *ReplicationProtectionClustersClientGetOperationResultsOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionClusters/{replicationProtectionClusterName}/operationResults/{jobId}"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if resourceName == "" {
return nil, errors.New("parameter resourceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if fabricName == "" {
return nil, errors.New("parameter fabricName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName))
if protectionContainerName == "" {
return nil, errors.New("parameter protectionContainerName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{protectionContainerName}", url.PathEscape(protectionContainerName))
if replicationProtectionClusterName == "" {
return nil, errors.New("parameter replicationProtectionClusterName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{replicationProtectionClusterName}", url.PathEscape(replicationProtectionClusterName))
if jobID == "" {
return nil, errors.New("parameter jobID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{jobId}", url.PathEscape(jobID))
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-01-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// getOperationResultsHandleResponse handles the GetOperationResults response.
func (client *ReplicationProtectionClustersClient) getOperationResultsHandleResponse(resp *http.Response) (ReplicationProtectionClustersClientGetOperationResultsResponse, error) {
result := ReplicationProtectionClustersClientGetOperationResultsResponse{}
if err := runtime.UnmarshalAsJSON(resp, &result.ReplicationProtectionCluster); err != nil {
return ReplicationProtectionClustersClientGetOperationResultsResponse{}, err
}
return result, nil
}
// NewListPager - Gets the list of ASR replication protected clusters in the vault.
//
// Generated from API version 2025-01-01
// - resourceGroupName - The name of the resource group where the recovery services vault is present.
// - resourceName - The name of the recovery services vault.
// - options - ReplicationProtectionClustersClientListOptions contains the optional parameters for the ReplicationProtectionClustersClient.NewListPager
// method.
func (client *ReplicationProtectionClustersClient) NewListPager(resourceGroupName string, resourceName string, options *ReplicationProtectionClustersClientListOptions) *runtime.Pager[ReplicationProtectionClustersClientListResponse] {
return runtime.NewPager(runtime.PagingHandler[ReplicationProtectionClustersClientListResponse]{
More: func(page ReplicationProtectionClustersClientListResponse) bool {
return page.NextLink != nil && len(*page.NextLink) > 0
},
Fetcher: func(ctx context.Context, page *ReplicationProtectionClustersClientListResponse) (ReplicationProtectionClustersClientListResponse, error) {
ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ReplicationProtectionClustersClient.NewListPager")
nextLink := ""
if page != nil {
nextLink = *page.NextLink
}
resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
return client.listCreateRequest(ctx, resourceGroupName, resourceName, options)
}, nil)
if err != nil {
return ReplicationProtectionClustersClientListResponse{}, err
}
return client.listHandleResponse(resp)
},
Tracer: client.internal.Tracer(),
})
}
// listCreateRequest creates the List request.
func (client *ReplicationProtectionClustersClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *ReplicationProtectionClustersClientListOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationProtectionClusters"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if resourceName == "" {
return nil, errors.New("parameter resourceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
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()
if options != nil && options.Filter != nil {
reqQP.Set("$filter", *options.Filter)
}
reqQP.Set("api-version", "2025-01-01")
if options != nil && options.SkipToken != nil {
reqQP.Set("skipToken", *options.SkipToken)
}
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// listHandleResponse handles the List response.
func (client *ReplicationProtectionClustersClient) listHandleResponse(resp *http.Response) (ReplicationProtectionClustersClientListResponse, error) {
result := ReplicationProtectionClustersClientListResponse{}
if err := runtime.UnmarshalAsJSON(resp, &result.ReplicationProtectionClusterCollection); err != nil {
return ReplicationProtectionClustersClientListResponse{}, err
}
return result, nil
}
// NewListByReplicationProtectionContainersPager - Gets the list of ASR replication protected clusters in the protection container.
//
// Generated from API version 2025-01-01
// - resourceGroupName - The name of the resource group where the recovery services vault is present.
// - resourceName - The name of the recovery services vault.
// - fabricName - Fabric name.
// - protectionContainerName - Protection container name.
// - options - ReplicationProtectionClustersClientListByReplicationProtectionContainersOptions contains the optional parameters
// for the ReplicationProtectionClustersClient.NewListByReplicationProtectionContainersPager method.
func (client *ReplicationProtectionClustersClient) NewListByReplicationProtectionContainersPager(resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, options *ReplicationProtectionClustersClientListByReplicationProtectionContainersOptions) *runtime.Pager[ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse] {
return runtime.NewPager(runtime.PagingHandler[ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse]{
More: func(page ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse) bool {
return page.NextLink != nil && len(*page.NextLink) > 0
},
Fetcher: func(ctx context.Context, page *ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse) (ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse, error) {
ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ReplicationProtectionClustersClient.NewListByReplicationProtectionContainersPager")
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.listByReplicationProtectionContainersCreateRequest(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, options)
}, nil)
if err != nil {
return ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse{}, err
}
return client.listByReplicationProtectionContainersHandleResponse(resp)
},
Tracer: client.internal.Tracer(),
})
}
// listByReplicationProtectionContainersCreateRequest creates the ListByReplicationProtectionContainers request.
func (client *ReplicationProtectionClustersClient) listByReplicationProtectionContainersCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, _ *ReplicationProtectionClustersClientListByReplicationProtectionContainersOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionClusters"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if resourceName == "" {
return nil, errors.New("parameter resourceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if fabricName == "" {
return nil, errors.New("parameter fabricName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName))
if protectionContainerName == "" {
return nil, errors.New("parameter protectionContainerName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{protectionContainerName}", url.PathEscape(protectionContainerName))
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-01-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// listByReplicationProtectionContainersHandleResponse handles the ListByReplicationProtectionContainers response.
func (client *ReplicationProtectionClustersClient) listByReplicationProtectionContainersHandleResponse(resp *http.Response) (ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse, error) {
result := ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse{}
if err := runtime.UnmarshalAsJSON(resp, &result.ReplicationProtectionClusterCollection); err != nil {
return ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse{}, err
}
return result, nil
}
// BeginPurge - The operation to purge the replication protection cluster. This operation will force delete the replication
// protection cluster. Use the remove operation on replication protection cluster to perform a
// clean disable replication protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
// - resourceGroupName - The name of the resource group where the recovery services vault is present.
// - resourceName - The name of the recovery services vault.
// - fabricName - Fabric name.
// - protectionContainerName - Protection container name.
// - replicationProtectionClusterName - Replication protection cluster name.
// - options - ReplicationProtectionClustersClientBeginPurgeOptions contains the optional parameters for the ReplicationProtectionClustersClient.BeginPurge
// method.
func (client *ReplicationProtectionClustersClient) BeginPurge(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, options *ReplicationProtectionClustersClientBeginPurgeOptions) (*runtime.Poller[ReplicationProtectionClustersClientPurgeResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.purge(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, options)
if err != nil {
return nil, err
}
poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationProtectionClustersClientPurgeResponse]{
FinalStateVia: runtime.FinalStateViaLocation,
Tracer: client.internal.Tracer(),
})
return poller, err
} else {
return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReplicationProtectionClustersClientPurgeResponse]{
Tracer: client.internal.Tracer(),
})
}
}
// Purge - The operation to purge the replication protection cluster. This operation will force delete the replication protection
// cluster. Use the remove operation on replication protection cluster to perform a
// clean disable replication protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
func (client *ReplicationProtectionClustersClient) purge(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, options *ReplicationProtectionClustersClientBeginPurgeOptions) (*http.Response, error) {
var err error
const operationName = "ReplicationProtectionClustersClient.BeginPurge"
ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
defer func() { endSpan(err) }()
req, err := client.purgeCreateRequest(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, 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
}
// purgeCreateRequest creates the Purge request.
func (client *ReplicationProtectionClustersClient) purgeCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, _ *ReplicationProtectionClustersClientBeginPurgeOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionClusters/{replicationProtectionClusterName}"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if resourceName == "" {
return nil, errors.New("parameter resourceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if fabricName == "" {
return nil, errors.New("parameter fabricName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName))
if protectionContainerName == "" {
return nil, errors.New("parameter protectionContainerName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{protectionContainerName}", url.PathEscape(protectionContainerName))
if replicationProtectionClusterName == "" {
return nil, errors.New("parameter replicationProtectionClusterName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{replicationProtectionClusterName}", url.PathEscape(replicationProtectionClusterName))
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-01-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// BeginRepairReplication - The operation to repair replication protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
// - resourceGroupName - The name of the resource group where the recovery services vault is present.
// - resourceName - The name of the recovery services vault.
// - fabricName - Fabric name.
// - protectionContainerName - Protection container name.
// - replicationProtectionClusterName - Replication protection cluster name.
// - options - ReplicationProtectionClustersClientBeginRepairReplicationOptions contains the optional parameters for the ReplicationProtectionClustersClient.BeginRepairReplication
// method.
func (client *ReplicationProtectionClustersClient) BeginRepairReplication(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, options *ReplicationProtectionClustersClientBeginRepairReplicationOptions) (*runtime.Poller[ReplicationProtectionClustersClientRepairReplicationResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.repairReplication(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, options)
if err != nil {
return nil, err
}
poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationProtectionClustersClientRepairReplicationResponse]{
FinalStateVia: runtime.FinalStateViaLocation,
Tracer: client.internal.Tracer(),
})
return poller, err
} else {
return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReplicationProtectionClustersClientRepairReplicationResponse]{
Tracer: client.internal.Tracer(),
})
}
}
// RepairReplication - The operation to repair replication protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
func (client *ReplicationProtectionClustersClient) repairReplication(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, options *ReplicationProtectionClustersClientBeginRepairReplicationOptions) (*http.Response, error) {
var err error
const operationName = "ReplicationProtectionClustersClient.BeginRepairReplication"
ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
defer func() { endSpan(err) }()
req, err := client.repairReplicationCreateRequest(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, 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
}
// repairReplicationCreateRequest creates the RepairReplication request.
func (client *ReplicationProtectionClustersClient) repairReplicationCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, _ *ReplicationProtectionClustersClientBeginRepairReplicationOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionClusters/{replicationProtectionClusterName}/repairReplication"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if resourceName == "" {
return nil, errors.New("parameter resourceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if fabricName == "" {
return nil, errors.New("parameter fabricName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName))
if protectionContainerName == "" {
return nil, errors.New("parameter protectionContainerName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{protectionContainerName}", url.PathEscape(protectionContainerName))
if replicationProtectionClusterName == "" {
return nil, errors.New("parameter replicationProtectionClusterName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{replicationProtectionClusterName}", url.PathEscape(replicationProtectionClusterName))
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-01-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// BeginTestFailover - Operation to initiate a failover of the replication protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
// - resourceGroupName - The name of the resource group where the recovery services vault is present.
// - resourceName - The name of the recovery services vault.
// - fabricName - Fabric name.
// - protectionContainerName - Protection container name.
// - replicationProtectionClusterName - Replication protection cluster name.
// - failoverInput - Cluster test failover input body.
// - options - ReplicationProtectionClustersClientBeginTestFailoverOptions contains the optional parameters for the ReplicationProtectionClustersClient.BeginTestFailover
// method.
func (client *ReplicationProtectionClustersClient) BeginTestFailover(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, failoverInput ClusterTestFailoverInput, options *ReplicationProtectionClustersClientBeginTestFailoverOptions) (*runtime.Poller[ReplicationProtectionClustersClientTestFailoverResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.testFailover(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, failoverInput, options)
if err != nil {
return nil, err
}
poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationProtectionClustersClientTestFailoverResponse]{
FinalStateVia: runtime.FinalStateViaLocation,
Tracer: client.internal.Tracer(),
})
return poller, err
} else {
return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReplicationProtectionClustersClientTestFailoverResponse]{
Tracer: client.internal.Tracer(),
})
}
}
// TestFailover - Operation to initiate a failover of the replication protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
func (client *ReplicationProtectionClustersClient) testFailover(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, failoverInput ClusterTestFailoverInput, options *ReplicationProtectionClustersClientBeginTestFailoverOptions) (*http.Response, error) {
var err error
const operationName = "ReplicationProtectionClustersClient.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, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, failoverInput, 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 *ReplicationProtectionClustersClient) testFailoverCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, failoverInput ClusterTestFailoverInput, _ *ReplicationProtectionClustersClientBeginTestFailoverOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionClusters/{replicationProtectionClusterName}/testFailover"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if resourceName == "" {
return nil, errors.New("parameter resourceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if fabricName == "" {
return nil, errors.New("parameter fabricName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName))
if protectionContainerName == "" {
return nil, errors.New("parameter protectionContainerName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{protectionContainerName}", url.PathEscape(protectionContainerName))
if replicationProtectionClusterName == "" {
return nil, errors.New("parameter replicationProtectionClusterName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{replicationProtectionClusterName}", url.PathEscape(replicationProtectionClusterName))
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-01-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
if err := runtime.MarshalAsJSON(req, failoverInput); err != nil {
return nil, err
}
return req, nil
}
// BeginTestFailoverCleanup - Operation to clean up the test failover of a replication protected cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
// - resourceGroupName - The name of the resource group where the recovery services vault is present.
// - resourceName - The name of the recovery services vault.
// - fabricName - Fabric name.
// - protectionContainerName - Protection container name.
// - replicationProtectionClusterName - Replication protection cluster name.
// - cleanupInput - Test failover cleanup input.
// - options - ReplicationProtectionClustersClientBeginTestFailoverCleanupOptions contains the optional parameters for the ReplicationProtectionClustersClient.BeginTestFailoverCleanup
// method.
func (client *ReplicationProtectionClustersClient) BeginTestFailoverCleanup(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, cleanupInput ClusterTestFailoverCleanupInput, options *ReplicationProtectionClustersClientBeginTestFailoverCleanupOptions) (*runtime.Poller[ReplicationProtectionClustersClientTestFailoverCleanupResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.testFailoverCleanup(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, cleanupInput, options)
if err != nil {
return nil, err
}
poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationProtectionClustersClientTestFailoverCleanupResponse]{
FinalStateVia: runtime.FinalStateViaLocation,
Tracer: client.internal.Tracer(),
})
return poller, err
} else {
return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReplicationProtectionClustersClientTestFailoverCleanupResponse]{
Tracer: client.internal.Tracer(),
})
}
}
// TestFailoverCleanup - Operation to clean up the test failover of a replication protected cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
func (client *ReplicationProtectionClustersClient) testFailoverCleanup(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, cleanupInput ClusterTestFailoverCleanupInput, options *ReplicationProtectionClustersClientBeginTestFailoverCleanupOptions) (*http.Response, error) {
var err error
const operationName = "ReplicationProtectionClustersClient.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, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, cleanupInput, 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 *ReplicationProtectionClustersClient) testFailoverCleanupCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, cleanupInput ClusterTestFailoverCleanupInput, _ *ReplicationProtectionClustersClientBeginTestFailoverCleanupOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionClusters/{replicationProtectionClusterName}/testFailoverCleanup"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if resourceName == "" {
return nil, errors.New("parameter resourceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if fabricName == "" {
return nil, errors.New("parameter fabricName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName))
if protectionContainerName == "" {
return nil, errors.New("parameter protectionContainerName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{protectionContainerName}", url.PathEscape(protectionContainerName))
if replicationProtectionClusterName == "" {
return nil, errors.New("parameter replicationProtectionClusterName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{replicationProtectionClusterName}", url.PathEscape(replicationProtectionClusterName))
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-01-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
if err := runtime.MarshalAsJSON(req, cleanupInput); err != nil {
return nil, err
}
return req, nil
}
// BeginUnplannedFailover - Operation to initiate a failover of the replication protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
// - resourceGroupName - The name of the resource group where the recovery services vault is present.
// - resourceName - The name of the recovery services vault.
// - fabricName - Fabric name.
// - protectionContainerName - Protection container name.
// - replicationProtectionClusterName - Replication protection cluster name.
// - failoverInput - Failover input.
// - options - ReplicationProtectionClustersClientBeginUnplannedFailoverOptions contains the optional parameters for the ReplicationProtectionClustersClient.BeginUnplannedFailover
// method.
func (client *ReplicationProtectionClustersClient) BeginUnplannedFailover(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, failoverInput ClusterUnplannedFailoverInput, options *ReplicationProtectionClustersClientBeginUnplannedFailoverOptions) (*runtime.Poller[ReplicationProtectionClustersClientUnplannedFailoverResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.unplannedFailover(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, failoverInput, options)
if err != nil {
return nil, err
}
poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationProtectionClustersClientUnplannedFailoverResponse]{
FinalStateVia: runtime.FinalStateViaLocation,
Tracer: client.internal.Tracer(),
})
return poller, err
} else {
return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ReplicationProtectionClustersClientUnplannedFailoverResponse]{
Tracer: client.internal.Tracer(),
})
}
}
// UnplannedFailover - Operation to initiate a failover of the replication protection cluster.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2025-01-01
func (client *ReplicationProtectionClustersClient) unplannedFailover(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, failoverInput ClusterUnplannedFailoverInput, options *ReplicationProtectionClustersClientBeginUnplannedFailoverOptions) (*http.Response, error) {
var err error
const operationName = "ReplicationProtectionClustersClient.BeginUnplannedFailover"
ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
defer func() { endSpan(err) }()
req, err := client.unplannedFailoverCreateRequest(ctx, resourceGroupName, resourceName, fabricName, protectionContainerName, replicationProtectionClusterName, failoverInput, 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
}
// unplannedFailoverCreateRequest creates the UnplannedFailover request.
func (client *ReplicationProtectionClustersClient) unplannedFailoverCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, failoverInput ClusterUnplannedFailoverInput, _ *ReplicationProtectionClustersClientBeginUnplannedFailoverOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionClusters/{replicationProtectionClusterName}/unplannedFailover"
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
if resourceName == "" {
return nil, errors.New("parameter resourceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if fabricName == "" {
return nil, errors.New("parameter fabricName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName))
if protectionContainerName == "" {
return nil, errors.New("parameter protectionContainerName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{protectionContainerName}", url.PathEscape(protectionContainerName))
if replicationProtectionClusterName == "" {
return nil, errors.New("parameter replicationProtectionClusterName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{replicationProtectionClusterName}", url.PathEscape(replicationProtectionClusterName))
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-01-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
if err := runtime.MarshalAsJSON(req, failoverInput); err != nil {
return nil, err
}
return req, nil
}