sdk/resourcemanager/recoveryservices/armrecoveryservicessiterecovery/fake/replicationprotectionclusters_server.go (752 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 fake
import (
"context"
"errors"
"fmt"
azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservices/armrecoveryservicessiterecovery/v2"
"net/http"
"net/url"
"regexp"
)
// ReplicationProtectionClustersServer is a fake server for instances of the armrecoveryservicessiterecovery.ReplicationProtectionClustersClient type.
type ReplicationProtectionClustersServer struct {
// BeginApplyRecoveryPoint is the fake for method ReplicationProtectionClustersClient.BeginApplyRecoveryPoint
// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
BeginApplyRecoveryPoint func(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, applyClusterRecoveryPointInput armrecoveryservicessiterecovery.ApplyClusterRecoveryPointInput, options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientBeginApplyRecoveryPointOptions) (resp azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientApplyRecoveryPointResponse], errResp azfake.ErrorResponder)
// BeginCreate is the fake for method ReplicationProtectionClustersClient.BeginCreate
// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
BeginCreate func(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, replicationProtectionCluster armrecoveryservicessiterecovery.ReplicationProtectionCluster, options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientBeginCreateOptions) (resp azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientCreateResponse], errResp azfake.ErrorResponder)
// BeginFailoverCommit is the fake for method ReplicationProtectionClustersClient.BeginFailoverCommit
// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
BeginFailoverCommit func(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientBeginFailoverCommitOptions) (resp azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientFailoverCommitResponse], errResp azfake.ErrorResponder)
// Get is the fake for method ReplicationProtectionClustersClient.Get
// HTTP status codes to indicate success: http.StatusOK
Get func(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientGetOptions) (resp azfake.Responder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientGetResponse], errResp azfake.ErrorResponder)
// GetOperationResults is the fake for method ReplicationProtectionClustersClient.GetOperationResults
// HTTP status codes to indicate success: http.StatusOK
GetOperationResults func(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, jobID string, options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientGetOperationResultsOptions) (resp azfake.Responder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientGetOperationResultsResponse], errResp azfake.ErrorResponder)
// NewListPager is the fake for method ReplicationProtectionClustersClient.NewListPager
// HTTP status codes to indicate success: http.StatusOK
NewListPager func(resourceGroupName string, resourceName string, options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientListOptions) (resp azfake.PagerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientListResponse])
// NewListByReplicationProtectionContainersPager is the fake for method ReplicationProtectionClustersClient.NewListByReplicationProtectionContainersPager
// HTTP status codes to indicate success: http.StatusOK
NewListByReplicationProtectionContainersPager func(resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientListByReplicationProtectionContainersOptions) (resp azfake.PagerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse])
// BeginPurge is the fake for method ReplicationProtectionClustersClient.BeginPurge
// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent
BeginPurge func(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientBeginPurgeOptions) (resp azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientPurgeResponse], errResp azfake.ErrorResponder)
// BeginRepairReplication is the fake for method ReplicationProtectionClustersClient.BeginRepairReplication
// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
BeginRepairReplication func(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientBeginRepairReplicationOptions) (resp azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientRepairReplicationResponse], errResp azfake.ErrorResponder)
// BeginTestFailover is the fake for method ReplicationProtectionClustersClient.BeginTestFailover
// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
BeginTestFailover func(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, failoverInput armrecoveryservicessiterecovery.ClusterTestFailoverInput, options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientBeginTestFailoverOptions) (resp azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientTestFailoverResponse], errResp azfake.ErrorResponder)
// BeginTestFailoverCleanup is the fake for method ReplicationProtectionClustersClient.BeginTestFailoverCleanup
// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
BeginTestFailoverCleanup func(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, cleanupInput armrecoveryservicessiterecovery.ClusterTestFailoverCleanupInput, options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientBeginTestFailoverCleanupOptions) (resp azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientTestFailoverCleanupResponse], errResp azfake.ErrorResponder)
// BeginUnplannedFailover is the fake for method ReplicationProtectionClustersClient.BeginUnplannedFailover
// HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted
BeginUnplannedFailover func(ctx context.Context, resourceGroupName string, resourceName string, fabricName string, protectionContainerName string, replicationProtectionClusterName string, failoverInput armrecoveryservicessiterecovery.ClusterUnplannedFailoverInput, options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientBeginUnplannedFailoverOptions) (resp azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientUnplannedFailoverResponse], errResp azfake.ErrorResponder)
}
// NewReplicationProtectionClustersServerTransport creates a new instance of ReplicationProtectionClustersServerTransport with the provided implementation.
// The returned ReplicationProtectionClustersServerTransport instance is connected to an instance of armrecoveryservicessiterecovery.ReplicationProtectionClustersClient via the
// azcore.ClientOptions.Transporter field in the client's constructor parameters.
func NewReplicationProtectionClustersServerTransport(srv *ReplicationProtectionClustersServer) *ReplicationProtectionClustersServerTransport {
return &ReplicationProtectionClustersServerTransport{
srv: srv,
beginApplyRecoveryPoint: newTracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientApplyRecoveryPointResponse]](),
beginCreate: newTracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientCreateResponse]](),
beginFailoverCommit: newTracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientFailoverCommitResponse]](),
newListPager: newTracker[azfake.PagerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientListResponse]](),
newListByReplicationProtectionContainersPager: newTracker[azfake.PagerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse]](),
beginPurge: newTracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientPurgeResponse]](),
beginRepairReplication: newTracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientRepairReplicationResponse]](),
beginTestFailover: newTracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientTestFailoverResponse]](),
beginTestFailoverCleanup: newTracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientTestFailoverCleanupResponse]](),
beginUnplannedFailover: newTracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientUnplannedFailoverResponse]](),
}
}
// ReplicationProtectionClustersServerTransport connects instances of armrecoveryservicessiterecovery.ReplicationProtectionClustersClient to instances of ReplicationProtectionClustersServer.
// Don't use this type directly, use NewReplicationProtectionClustersServerTransport instead.
type ReplicationProtectionClustersServerTransport struct {
srv *ReplicationProtectionClustersServer
beginApplyRecoveryPoint *tracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientApplyRecoveryPointResponse]]
beginCreate *tracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientCreateResponse]]
beginFailoverCommit *tracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientFailoverCommitResponse]]
newListPager *tracker[azfake.PagerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientListResponse]]
newListByReplicationProtectionContainersPager *tracker[azfake.PagerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse]]
beginPurge *tracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientPurgeResponse]]
beginRepairReplication *tracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientRepairReplicationResponse]]
beginTestFailover *tracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientTestFailoverResponse]]
beginTestFailoverCleanup *tracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientTestFailoverCleanupResponse]]
beginUnplannedFailover *tracker[azfake.PollerResponder[armrecoveryservicessiterecovery.ReplicationProtectionClustersClientUnplannedFailoverResponse]]
}
// Do implements the policy.Transporter interface for ReplicationProtectionClustersServerTransport.
func (r *ReplicationProtectionClustersServerTransport) Do(req *http.Request) (*http.Response, error) {
rawMethod := req.Context().Value(runtime.CtxAPINameKey{})
method, ok := rawMethod.(string)
if !ok {
return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")}
}
return r.dispatchToMethodFake(req, method)
}
func (r *ReplicationProtectionClustersServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) {
resultChan := make(chan result)
defer close(resultChan)
go func() {
var intercepted bool
var res result
if replicationProtectionClustersServerTransportInterceptor != nil {
res.resp, res.err, intercepted = replicationProtectionClustersServerTransportInterceptor.Do(req)
}
if !intercepted {
switch method {
case "ReplicationProtectionClustersClient.BeginApplyRecoveryPoint":
res.resp, res.err = r.dispatchBeginApplyRecoveryPoint(req)
case "ReplicationProtectionClustersClient.BeginCreate":
res.resp, res.err = r.dispatchBeginCreate(req)
case "ReplicationProtectionClustersClient.BeginFailoverCommit":
res.resp, res.err = r.dispatchBeginFailoverCommit(req)
case "ReplicationProtectionClustersClient.Get":
res.resp, res.err = r.dispatchGet(req)
case "ReplicationProtectionClustersClient.GetOperationResults":
res.resp, res.err = r.dispatchGetOperationResults(req)
case "ReplicationProtectionClustersClient.NewListPager":
res.resp, res.err = r.dispatchNewListPager(req)
case "ReplicationProtectionClustersClient.NewListByReplicationProtectionContainersPager":
res.resp, res.err = r.dispatchNewListByReplicationProtectionContainersPager(req)
case "ReplicationProtectionClustersClient.BeginPurge":
res.resp, res.err = r.dispatchBeginPurge(req)
case "ReplicationProtectionClustersClient.BeginRepairReplication":
res.resp, res.err = r.dispatchBeginRepairReplication(req)
case "ReplicationProtectionClustersClient.BeginTestFailover":
res.resp, res.err = r.dispatchBeginTestFailover(req)
case "ReplicationProtectionClustersClient.BeginTestFailoverCleanup":
res.resp, res.err = r.dispatchBeginTestFailoverCleanup(req)
case "ReplicationProtectionClustersClient.BeginUnplannedFailover":
res.resp, res.err = r.dispatchBeginUnplannedFailover(req)
default:
res.err = fmt.Errorf("unhandled API %s", method)
}
}
select {
case resultChan <- res:
case <-req.Context().Done():
}
}()
select {
case <-req.Context().Done():
return nil, req.Context().Err()
case res := <-resultChan:
return res.resp, res.err
}
}
func (r *ReplicationProtectionClustersServerTransport) dispatchBeginApplyRecoveryPoint(req *http.Request) (*http.Response, error) {
if r.srv.BeginApplyRecoveryPoint == nil {
return nil, &nonRetriableError{errors.New("fake for method BeginApplyRecoveryPoint not implemented")}
}
beginApplyRecoveryPoint := r.beginApplyRecoveryPoint.get(req)
if beginApplyRecoveryPoint == nil {
const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RecoveryServices/vaults/(?P<resourceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationFabrics/(?P<fabricName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionContainers/(?P<protectionContainerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionClusters/(?P<replicationProtectionClusterName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applyRecoveryPoint`
regex := regexp.MustCompile(regexStr)
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
if matches == nil || len(matches) < 6 {
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
}
body, err := server.UnmarshalRequestAsJSON[armrecoveryservicessiterecovery.ApplyClusterRecoveryPointInput](req)
if err != nil {
return nil, err
}
resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
if err != nil {
return nil, err
}
resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")])
if err != nil {
return nil, err
}
fabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fabricName")])
if err != nil {
return nil, err
}
protectionContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("protectionContainerName")])
if err != nil {
return nil, err
}
replicationProtectionClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("replicationProtectionClusterName")])
if err != nil {
return nil, err
}
respr, errRespr := r.srv.BeginApplyRecoveryPoint(req.Context(), resourceGroupNameParam, resourceNameParam, fabricNameParam, protectionContainerNameParam, replicationProtectionClusterNameParam, body, nil)
if respErr := server.GetError(errRespr, req); respErr != nil {
return nil, respErr
}
beginApplyRecoveryPoint = &respr
r.beginApplyRecoveryPoint.add(req, beginApplyRecoveryPoint)
}
resp, err := server.PollerResponderNext(beginApplyRecoveryPoint, req)
if err != nil {
return nil, err
}
if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) {
r.beginApplyRecoveryPoint.remove(req)
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)}
}
if !server.PollerResponderMore(beginApplyRecoveryPoint) {
r.beginApplyRecoveryPoint.remove(req)
}
return resp, nil
}
func (r *ReplicationProtectionClustersServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) {
if r.srv.BeginCreate == nil {
return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")}
}
beginCreate := r.beginCreate.get(req)
if beginCreate == nil {
const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RecoveryServices/vaults/(?P<resourceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationFabrics/(?P<fabricName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionContainers/(?P<protectionContainerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionClusters/(?P<replicationProtectionClusterName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
regex := regexp.MustCompile(regexStr)
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
if matches == nil || len(matches) < 6 {
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
}
body, err := server.UnmarshalRequestAsJSON[armrecoveryservicessiterecovery.ReplicationProtectionCluster](req)
if err != nil {
return nil, err
}
resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
if err != nil {
return nil, err
}
resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")])
if err != nil {
return nil, err
}
fabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fabricName")])
if err != nil {
return nil, err
}
protectionContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("protectionContainerName")])
if err != nil {
return nil, err
}
replicationProtectionClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("replicationProtectionClusterName")])
if err != nil {
return nil, err
}
respr, errRespr := r.srv.BeginCreate(req.Context(), resourceGroupNameParam, resourceNameParam, fabricNameParam, protectionContainerNameParam, replicationProtectionClusterNameParam, body, nil)
if respErr := server.GetError(errRespr, req); respErr != nil {
return nil, respErr
}
beginCreate = &respr
r.beginCreate.add(req, beginCreate)
}
resp, err := server.PollerResponderNext(beginCreate, req)
if err != nil {
return nil, err
}
if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) {
r.beginCreate.remove(req)
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)}
}
if !server.PollerResponderMore(beginCreate) {
r.beginCreate.remove(req)
}
return resp, nil
}
func (r *ReplicationProtectionClustersServerTransport) dispatchBeginFailoverCommit(req *http.Request) (*http.Response, error) {
if r.srv.BeginFailoverCommit == nil {
return nil, &nonRetriableError{errors.New("fake for method BeginFailoverCommit not implemented")}
}
beginFailoverCommit := r.beginFailoverCommit.get(req)
if beginFailoverCommit == nil {
const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RecoveryServices/vaults/(?P<resourceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationFabrics/(?P<fabricName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionContainers/(?P<protectionContainerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionClusters/(?P<replicationProtectionClusterName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/failoverCommit`
regex := regexp.MustCompile(regexStr)
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
if matches == nil || len(matches) < 6 {
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
}
resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
if err != nil {
return nil, err
}
resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")])
if err != nil {
return nil, err
}
fabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fabricName")])
if err != nil {
return nil, err
}
protectionContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("protectionContainerName")])
if err != nil {
return nil, err
}
replicationProtectionClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("replicationProtectionClusterName")])
if err != nil {
return nil, err
}
respr, errRespr := r.srv.BeginFailoverCommit(req.Context(), resourceGroupNameParam, resourceNameParam, fabricNameParam, protectionContainerNameParam, replicationProtectionClusterNameParam, nil)
if respErr := server.GetError(errRespr, req); respErr != nil {
return nil, respErr
}
beginFailoverCommit = &respr
r.beginFailoverCommit.add(req, beginFailoverCommit)
}
resp, err := server.PollerResponderNext(beginFailoverCommit, req)
if err != nil {
return nil, err
}
if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) {
r.beginFailoverCommit.remove(req)
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)}
}
if !server.PollerResponderMore(beginFailoverCommit) {
r.beginFailoverCommit.remove(req)
}
return resp, nil
}
func (r *ReplicationProtectionClustersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) {
if r.srv.Get == nil {
return nil, &nonRetriableError{errors.New("fake for method Get not implemented")}
}
const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RecoveryServices/vaults/(?P<resourceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationFabrics/(?P<fabricName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionContainers/(?P<protectionContainerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionClusters/(?P<replicationProtectionClusterName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
regex := regexp.MustCompile(regexStr)
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
if matches == nil || len(matches) < 6 {
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
}
resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
if err != nil {
return nil, err
}
resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")])
if err != nil {
return nil, err
}
fabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fabricName")])
if err != nil {
return nil, err
}
protectionContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("protectionContainerName")])
if err != nil {
return nil, err
}
replicationProtectionClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("replicationProtectionClusterName")])
if err != nil {
return nil, err
}
respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, fabricNameParam, protectionContainerNameParam, replicationProtectionClusterNameParam, nil)
if respErr := server.GetError(errRespr, req); respErr != nil {
return nil, respErr
}
respContent := server.GetResponseContent(respr)
if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
}
resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ReplicationProtectionCluster, req)
if err != nil {
return nil, err
}
return resp, nil
}
func (r *ReplicationProtectionClustersServerTransport) dispatchGetOperationResults(req *http.Request) (*http.Response, error) {
if r.srv.GetOperationResults == nil {
return nil, &nonRetriableError{errors.New("fake for method GetOperationResults not implemented")}
}
const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RecoveryServices/vaults/(?P<resourceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationFabrics/(?P<fabricName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionContainers/(?P<protectionContainerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionClusters/(?P<replicationProtectionClusterName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationResults/(?P<jobId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
regex := regexp.MustCompile(regexStr)
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
if matches == nil || len(matches) < 7 {
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
}
resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
if err != nil {
return nil, err
}
resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")])
if err != nil {
return nil, err
}
fabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fabricName")])
if err != nil {
return nil, err
}
protectionContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("protectionContainerName")])
if err != nil {
return nil, err
}
replicationProtectionClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("replicationProtectionClusterName")])
if err != nil {
return nil, err
}
jobIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("jobId")])
if err != nil {
return nil, err
}
respr, errRespr := r.srv.GetOperationResults(req.Context(), resourceGroupNameParam, resourceNameParam, fabricNameParam, protectionContainerNameParam, replicationProtectionClusterNameParam, jobIDParam, nil)
if respErr := server.GetError(errRespr, req); respErr != nil {
return nil, respErr
}
respContent := server.GetResponseContent(respr)
if !contains([]int{http.StatusOK}, respContent.HTTPStatus) {
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)}
}
resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ReplicationProtectionCluster, req)
if err != nil {
return nil, err
}
return resp, nil
}
func (r *ReplicationProtectionClustersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) {
if r.srv.NewListPager == nil {
return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")}
}
newListPager := r.newListPager.get(req)
if newListPager == nil {
const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RecoveryServices/vaults/(?P<resourceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionClusters`
regex := regexp.MustCompile(regexStr)
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
if matches == nil || len(matches) < 3 {
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
}
qp := req.URL.Query()
resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
if err != nil {
return nil, err
}
resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")])
if err != nil {
return nil, err
}
skipTokenUnescaped, err := url.QueryUnescape(qp.Get("skipToken"))
if err != nil {
return nil, err
}
skipTokenParam := getOptional(skipTokenUnescaped)
filterUnescaped, err := url.QueryUnescape(qp.Get("$filter"))
if err != nil {
return nil, err
}
filterParam := getOptional(filterUnescaped)
var options *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientListOptions
if skipTokenParam != nil || filterParam != nil {
options = &armrecoveryservicessiterecovery.ReplicationProtectionClustersClientListOptions{
SkipToken: skipTokenParam,
Filter: filterParam,
}
}
resp := r.srv.NewListPager(resourceGroupNameParam, resourceNameParam, options)
newListPager = &resp
r.newListPager.add(req, newListPager)
server.PagerResponderInjectNextLinks(newListPager, req, func(page *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientListResponse, createLink func() string) {
page.NextLink = to.Ptr(createLink())
})
}
resp, err := server.PagerResponderNext(newListPager, req)
if err != nil {
return nil, err
}
if !contains([]int{http.StatusOK}, resp.StatusCode) {
r.newListPager.remove(req)
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
}
if !server.PagerResponderMore(newListPager) {
r.newListPager.remove(req)
}
return resp, nil
}
func (r *ReplicationProtectionClustersServerTransport) dispatchNewListByReplicationProtectionContainersPager(req *http.Request) (*http.Response, error) {
if r.srv.NewListByReplicationProtectionContainersPager == nil {
return nil, &nonRetriableError{errors.New("fake for method NewListByReplicationProtectionContainersPager not implemented")}
}
newListByReplicationProtectionContainersPager := r.newListByReplicationProtectionContainersPager.get(req)
if newListByReplicationProtectionContainersPager == nil {
const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RecoveryServices/vaults/(?P<resourceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationFabrics/(?P<fabricName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionContainers/(?P<protectionContainerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionClusters`
regex := regexp.MustCompile(regexStr)
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
if matches == nil || len(matches) < 5 {
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
}
resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
if err != nil {
return nil, err
}
resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")])
if err != nil {
return nil, err
}
fabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fabricName")])
if err != nil {
return nil, err
}
protectionContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("protectionContainerName")])
if err != nil {
return nil, err
}
resp := r.srv.NewListByReplicationProtectionContainersPager(resourceGroupNameParam, resourceNameParam, fabricNameParam, protectionContainerNameParam, nil)
newListByReplicationProtectionContainersPager = &resp
r.newListByReplicationProtectionContainersPager.add(req, newListByReplicationProtectionContainersPager)
server.PagerResponderInjectNextLinks(newListByReplicationProtectionContainersPager, req, func(page *armrecoveryservicessiterecovery.ReplicationProtectionClustersClientListByReplicationProtectionContainersResponse, createLink func() string) {
page.NextLink = to.Ptr(createLink())
})
}
resp, err := server.PagerResponderNext(newListByReplicationProtectionContainersPager, req)
if err != nil {
return nil, err
}
if !contains([]int{http.StatusOK}, resp.StatusCode) {
r.newListByReplicationProtectionContainersPager.remove(req)
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)}
}
if !server.PagerResponderMore(newListByReplicationProtectionContainersPager) {
r.newListByReplicationProtectionContainersPager.remove(req)
}
return resp, nil
}
func (r *ReplicationProtectionClustersServerTransport) dispatchBeginPurge(req *http.Request) (*http.Response, error) {
if r.srv.BeginPurge == nil {
return nil, &nonRetriableError{errors.New("fake for method BeginPurge not implemented")}
}
beginPurge := r.beginPurge.get(req)
if beginPurge == nil {
const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RecoveryServices/vaults/(?P<resourceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationFabrics/(?P<fabricName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionContainers/(?P<protectionContainerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionClusters/(?P<replicationProtectionClusterName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)`
regex := regexp.MustCompile(regexStr)
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
if matches == nil || len(matches) < 6 {
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
}
resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
if err != nil {
return nil, err
}
resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")])
if err != nil {
return nil, err
}
fabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fabricName")])
if err != nil {
return nil, err
}
protectionContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("protectionContainerName")])
if err != nil {
return nil, err
}
replicationProtectionClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("replicationProtectionClusterName")])
if err != nil {
return nil, err
}
respr, errRespr := r.srv.BeginPurge(req.Context(), resourceGroupNameParam, resourceNameParam, fabricNameParam, protectionContainerNameParam, replicationProtectionClusterNameParam, nil)
if respErr := server.GetError(errRespr, req); respErr != nil {
return nil, respErr
}
beginPurge = &respr
r.beginPurge.add(req, beginPurge)
}
resp, err := server.PollerResponderNext(beginPurge, req)
if err != nil {
return nil, err
}
if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) {
r.beginPurge.remove(req)
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)}
}
if !server.PollerResponderMore(beginPurge) {
r.beginPurge.remove(req)
}
return resp, nil
}
func (r *ReplicationProtectionClustersServerTransport) dispatchBeginRepairReplication(req *http.Request) (*http.Response, error) {
if r.srv.BeginRepairReplication == nil {
return nil, &nonRetriableError{errors.New("fake for method BeginRepairReplication not implemented")}
}
beginRepairReplication := r.beginRepairReplication.get(req)
if beginRepairReplication == nil {
const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RecoveryServices/vaults/(?P<resourceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationFabrics/(?P<fabricName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionContainers/(?P<protectionContainerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionClusters/(?P<replicationProtectionClusterName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/repairReplication`
regex := regexp.MustCompile(regexStr)
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
if matches == nil || len(matches) < 6 {
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
}
resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
if err != nil {
return nil, err
}
resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")])
if err != nil {
return nil, err
}
fabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fabricName")])
if err != nil {
return nil, err
}
protectionContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("protectionContainerName")])
if err != nil {
return nil, err
}
replicationProtectionClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("replicationProtectionClusterName")])
if err != nil {
return nil, err
}
respr, errRespr := r.srv.BeginRepairReplication(req.Context(), resourceGroupNameParam, resourceNameParam, fabricNameParam, protectionContainerNameParam, replicationProtectionClusterNameParam, nil)
if respErr := server.GetError(errRespr, req); respErr != nil {
return nil, respErr
}
beginRepairReplication = &respr
r.beginRepairReplication.add(req, beginRepairReplication)
}
resp, err := server.PollerResponderNext(beginRepairReplication, req)
if err != nil {
return nil, err
}
if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) {
r.beginRepairReplication.remove(req)
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)}
}
if !server.PollerResponderMore(beginRepairReplication) {
r.beginRepairReplication.remove(req)
}
return resp, nil
}
func (r *ReplicationProtectionClustersServerTransport) dispatchBeginTestFailover(req *http.Request) (*http.Response, error) {
if r.srv.BeginTestFailover == nil {
return nil, &nonRetriableError{errors.New("fake for method BeginTestFailover not implemented")}
}
beginTestFailover := r.beginTestFailover.get(req)
if beginTestFailover == nil {
const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RecoveryServices/vaults/(?P<resourceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationFabrics/(?P<fabricName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionContainers/(?P<protectionContainerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionClusters/(?P<replicationProtectionClusterName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/testFailover`
regex := regexp.MustCompile(regexStr)
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
if matches == nil || len(matches) < 6 {
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
}
body, err := server.UnmarshalRequestAsJSON[armrecoveryservicessiterecovery.ClusterTestFailoverInput](req)
if err != nil {
return nil, err
}
resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
if err != nil {
return nil, err
}
resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")])
if err != nil {
return nil, err
}
fabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fabricName")])
if err != nil {
return nil, err
}
protectionContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("protectionContainerName")])
if err != nil {
return nil, err
}
replicationProtectionClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("replicationProtectionClusterName")])
if err != nil {
return nil, err
}
respr, errRespr := r.srv.BeginTestFailover(req.Context(), resourceGroupNameParam, resourceNameParam, fabricNameParam, protectionContainerNameParam, replicationProtectionClusterNameParam, body, nil)
if respErr := server.GetError(errRespr, req); respErr != nil {
return nil, respErr
}
beginTestFailover = &respr
r.beginTestFailover.add(req, beginTestFailover)
}
resp, err := server.PollerResponderNext(beginTestFailover, req)
if err != nil {
return nil, err
}
if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) {
r.beginTestFailover.remove(req)
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)}
}
if !server.PollerResponderMore(beginTestFailover) {
r.beginTestFailover.remove(req)
}
return resp, nil
}
func (r *ReplicationProtectionClustersServerTransport) dispatchBeginTestFailoverCleanup(req *http.Request) (*http.Response, error) {
if r.srv.BeginTestFailoverCleanup == nil {
return nil, &nonRetriableError{errors.New("fake for method BeginTestFailoverCleanup not implemented")}
}
beginTestFailoverCleanup := r.beginTestFailoverCleanup.get(req)
if beginTestFailoverCleanup == nil {
const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RecoveryServices/vaults/(?P<resourceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationFabrics/(?P<fabricName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionContainers/(?P<protectionContainerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionClusters/(?P<replicationProtectionClusterName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/testFailoverCleanup`
regex := regexp.MustCompile(regexStr)
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
if matches == nil || len(matches) < 6 {
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
}
body, err := server.UnmarshalRequestAsJSON[armrecoveryservicessiterecovery.ClusterTestFailoverCleanupInput](req)
if err != nil {
return nil, err
}
resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
if err != nil {
return nil, err
}
resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")])
if err != nil {
return nil, err
}
fabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fabricName")])
if err != nil {
return nil, err
}
protectionContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("protectionContainerName")])
if err != nil {
return nil, err
}
replicationProtectionClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("replicationProtectionClusterName")])
if err != nil {
return nil, err
}
respr, errRespr := r.srv.BeginTestFailoverCleanup(req.Context(), resourceGroupNameParam, resourceNameParam, fabricNameParam, protectionContainerNameParam, replicationProtectionClusterNameParam, body, nil)
if respErr := server.GetError(errRespr, req); respErr != nil {
return nil, respErr
}
beginTestFailoverCleanup = &respr
r.beginTestFailoverCleanup.add(req, beginTestFailoverCleanup)
}
resp, err := server.PollerResponderNext(beginTestFailoverCleanup, req)
if err != nil {
return nil, err
}
if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) {
r.beginTestFailoverCleanup.remove(req)
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)}
}
if !server.PollerResponderMore(beginTestFailoverCleanup) {
r.beginTestFailoverCleanup.remove(req)
}
return resp, nil
}
func (r *ReplicationProtectionClustersServerTransport) dispatchBeginUnplannedFailover(req *http.Request) (*http.Response, error) {
if r.srv.BeginUnplannedFailover == nil {
return nil, &nonRetriableError{errors.New("fake for method BeginUnplannedFailover not implemented")}
}
beginUnplannedFailover := r.beginUnplannedFailover.get(req)
if beginUnplannedFailover == nil {
const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.RecoveryServices/vaults/(?P<resourceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationFabrics/(?P<fabricName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionContainers/(?P<protectionContainerName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicationProtectionClusters/(?P<replicationProtectionClusterName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/unplannedFailover`
regex := regexp.MustCompile(regexStr)
matches := regex.FindStringSubmatch(req.URL.EscapedPath())
if matches == nil || len(matches) < 6 {
return nil, fmt.Errorf("failed to parse path %s", req.URL.Path)
}
body, err := server.UnmarshalRequestAsJSON[armrecoveryservicessiterecovery.ClusterUnplannedFailoverInput](req)
if err != nil {
return nil, err
}
resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")])
if err != nil {
return nil, err
}
resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")])
if err != nil {
return nil, err
}
fabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fabricName")])
if err != nil {
return nil, err
}
protectionContainerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("protectionContainerName")])
if err != nil {
return nil, err
}
replicationProtectionClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("replicationProtectionClusterName")])
if err != nil {
return nil, err
}
respr, errRespr := r.srv.BeginUnplannedFailover(req.Context(), resourceGroupNameParam, resourceNameParam, fabricNameParam, protectionContainerNameParam, replicationProtectionClusterNameParam, body, nil)
if respErr := server.GetError(errRespr, req); respErr != nil {
return nil, respErr
}
beginUnplannedFailover = &respr
r.beginUnplannedFailover.add(req, beginUnplannedFailover)
}
resp, err := server.PollerResponderNext(beginUnplannedFailover, req)
if err != nil {
return nil, err
}
if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) {
r.beginUnplannedFailover.remove(req)
return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)}
}
if !server.PollerResponderMore(beginUnplannedFailover) {
r.beginUnplannedFailover.remove(req)
}
return resp, nil
}
// set this to conditionally intercept incoming requests to ReplicationProtectionClustersServerTransport
var replicationProtectionClustersServerTransportInterceptor interface {
// Do returns true if the server transport should use the returned response/error
Do(*http.Request) (*http.Response, error, bool)
}