package recoveryservicessiterecovery // Copyright (c) Microsoft and contributors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // limitations under the License. // // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "net/http" ) // ReplicationRecoveryPlansClient is the client for the ReplicationRecoveryPlans methods of the // Recoveryservicessiterecovery service. type ReplicationRecoveryPlansClient struct { ManagementClient } // NewReplicationRecoveryPlansClient creates an instance of the ReplicationRecoveryPlansClient client. func NewReplicationRecoveryPlansClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationRecoveryPlansClient { return NewReplicationRecoveryPlansClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) } // NewReplicationRecoveryPlansClientWithBaseURI creates an instance of the ReplicationRecoveryPlansClient client. func NewReplicationRecoveryPlansClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationRecoveryPlansClient { return ReplicationRecoveryPlansClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} } // Create the operation to create a recovery plan. This method may poll for completion. Polling can be canceled by // passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. // // recoveryPlanName is recovery plan name. input is recovery Plan creation input. func (client ReplicationRecoveryPlansClient) Create(recoveryPlanName string, input CreateRecoveryPlanInput, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { resultChan := make(chan RecoveryPlan, 1) errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: input, Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "input.Properties.PrimaryFabricID", Name: validation.Null, Rule: true, Chain: nil}, {Target: "input.Properties.RecoveryFabricID", Name: validation.Null, Rule: true, Chain: nil}, {Target: "input.Properties.Groups", Name: validation.Null, Rule: true, Chain: nil}, }}}}}); err != nil { errChan <- validation.NewErrorWithValidationError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Create") close(errChan) close(resultChan) return resultChan, errChan } go func() { var err error var result RecoveryPlan defer func() { if err != nil { errChan <- err } resultChan <- result close(resultChan) close(errChan) }() req, err := client.CreatePreparer(recoveryPlanName, input, cancel) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Create", nil, "Failure preparing request") return } resp, err := client.CreateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Create", resp, "Failure sending request") return } result, err = client.CreateResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Create", resp, "Failure responding to request") } }() return resultChan, errChan } // CreatePreparer prepares the Create request. func (client ReplicationRecoveryPlansClient) CreatePreparer(recoveryPlanName string, input CreateRecoveryPlanInput, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "recoveryPlanName": autorest.Encode("path", recoveryPlanName), "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), "resourceName": autorest.Encode("path", client.ResourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2016-08-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}", pathParameters), autorest.WithJSON(input), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateSender sends the Create request. The method will close the // http.Response Body if it receives an error. func (client ReplicationRecoveryPlansClient) CreateSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client), azure.DoPollForAsynchronous(client.PollingDelay)) } // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. func (client ReplicationRecoveryPlansClient) CreateResponder(resp *http.Response) (result RecoveryPlan, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // Delete delete a recovery plan. This method may poll for completion. Polling can be canceled by passing the cancel // channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. // // recoveryPlanName is recovery plan name. func (client ReplicationRecoveryPlansClient) Delete(recoveryPlanName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { resultChan := make(chan autorest.Response, 1) errChan := make(chan error, 1) go func() { var err error var result autorest.Response defer func() { if err != nil { errChan <- err } resultChan <- result close(resultChan) close(errChan) }() req, err := client.DeletePreparer(recoveryPlanName, cancel) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Delete", nil, "Failure preparing request") return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Delete", resp, "Failure sending request") return } result, err = client.DeleteResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Delete", resp, "Failure responding to request") } }() return resultChan, errChan } // DeletePreparer prepares the Delete request. func (client ReplicationRecoveryPlansClient) DeletePreparer(recoveryPlanName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "recoveryPlanName": autorest.Encode("path", recoveryPlanName), "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), "resourceName": autorest.Encode("path", client.ResourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2016-08-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the // http.Response Body if it receives an error. func (client ReplicationRecoveryPlansClient) DeleteSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client), azure.DoPollForAsynchronous(client.PollingDelay)) } // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. func (client ReplicationRecoveryPlansClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), autorest.ByClosing()) result.Response = resp return } // FailoverCommit the operation to commit the fail over of a recovery plan. This method may poll for completion. // Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // // recoveryPlanName is recovery plan name. func (client ReplicationRecoveryPlansClient) FailoverCommit(recoveryPlanName string, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { resultChan := make(chan RecoveryPlan, 1) errChan := make(chan error, 1) go func() { var err error var result RecoveryPlan defer func() { if err != nil { errChan <- err } resultChan <- result close(resultChan) close(errChan) }() req, err := client.FailoverCommitPreparer(recoveryPlanName, cancel) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "FailoverCommit", nil, "Failure preparing request") return } resp, err := client.FailoverCommitSender(req) if err != nil { result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "FailoverCommit", resp, "Failure sending request") return } result, err = client.FailoverCommitResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "FailoverCommit", resp, "Failure responding to request") } }() return resultChan, errChan } // FailoverCommitPreparer prepares the FailoverCommit request. func (client ReplicationRecoveryPlansClient) FailoverCommitPreparer(recoveryPlanName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "recoveryPlanName": autorest.Encode("path", recoveryPlanName), "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), "resourceName": autorest.Encode("path", client.ResourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2016-08-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/failoverCommit", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{Cancel: cancel}) } // FailoverCommitSender sends the FailoverCommit request. The method will close the // http.Response Body if it receives an error. func (client ReplicationRecoveryPlansClient) FailoverCommitSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client), azure.DoPollForAsynchronous(client.PollingDelay)) } // FailoverCommitResponder handles the response to the FailoverCommit request. The method always // closes the http.Response Body. func (client ReplicationRecoveryPlansClient) FailoverCommitResponder(resp *http.Response) (result RecoveryPlan, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // Get gets the details of the recovery plan. // // recoveryPlanName is name of the recovery plan. func (client ReplicationRecoveryPlansClient) Get(recoveryPlanName string) (result RecoveryPlan, err error) { req, err := client.GetPreparer(recoveryPlanName) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Get", nil, "Failure preparing request") return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Get", resp, "Failure sending request") return } result, err = client.GetResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Get", resp, "Failure responding to request") } return } // GetPreparer prepares the Get request. func (client ReplicationRecoveryPlansClient) GetPreparer(recoveryPlanName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "recoveryPlanName": autorest.Encode("path", recoveryPlanName), "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), "resourceName": autorest.Encode("path", client.ResourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2016-08-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the // http.Response Body if it receives an error. func (client ReplicationRecoveryPlansClient) GetSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client)) } // GetResponder handles the response to the Get request. The method always // closes the http.Response Body. func (client ReplicationRecoveryPlansClient) GetResponder(resp *http.Response) (result RecoveryPlan, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // List lists the recovery plans in the vault. func (client ReplicationRecoveryPlansClient) List() (result RecoveryPlanCollection, err error) { req, err := client.ListPreparer() if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "List", nil, "Failure preparing request") return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "List", resp, "Failure sending request") return } result, err = client.ListResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "List", resp, "Failure responding to request") } return } // ListPreparer prepares the List request. func (client ReplicationRecoveryPlansClient) ListPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), "resourceName": autorest.Encode("path", client.ResourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2016-08-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the // http.Response Body if it receives an error. func (client ReplicationRecoveryPlansClient) ListSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client)) } // ListResponder handles the response to the List request. The method always // closes the http.Response Body. func (client ReplicationRecoveryPlansClient) ListResponder(resp *http.Response) (result RecoveryPlanCollection, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // ListNextResults retrieves the next set of results, if any. func (client ReplicationRecoveryPlansClient) ListNextResults(lastResults RecoveryPlanCollection) (result RecoveryPlanCollection, err error) { req, err := lastResults.RecoveryPlanCollectionPreparer() if err != nil { return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "List", nil, "Failure preparing next results request") } if req == nil { return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "List", resp, "Failure sending next results request") } result, err = client.ListResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "List", resp, "Failure responding to next results request") } return } // ListComplete gets all elements from the list without paging. func (client ReplicationRecoveryPlansClient) ListComplete(cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { resultChan := make(chan RecoveryPlan) errChan := make(chan error, 1) go func() { defer func() { close(resultChan) close(errChan) }() list, err := client.List() if err != nil { errChan <- err return } if list.Value != nil { for _, item := range *list.Value { select { case <-cancel: return case resultChan <- item: // Intentionally left blank } } } for list.NextLink != nil { list, err = client.ListNextResults(list) if err != nil { errChan <- err return } if list.Value != nil { for _, item := range *list.Value { select { case <-cancel: return case resultChan <- item: // Intentionally left blank } } } } }() return resultChan, errChan } // PlannedFailover the operation to start the planned failover of a recovery plan. This method may poll for completion. // Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // // recoveryPlanName is recovery plan name. input is failover input. func (client ReplicationRecoveryPlansClient) PlannedFailover(recoveryPlanName string, input RecoveryPlanPlannedFailoverInput, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { resultChan := make(chan RecoveryPlan, 1) errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: input, Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { errChan <- validation.NewErrorWithValidationError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "PlannedFailover") close(errChan) close(resultChan) return resultChan, errChan } go func() { var err error var result RecoveryPlan defer func() { if err != nil { errChan <- err } resultChan <- result close(resultChan) close(errChan) }() req, err := client.PlannedFailoverPreparer(recoveryPlanName, input, cancel) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "PlannedFailover", nil, "Failure preparing request") return } resp, err := client.PlannedFailoverSender(req) if err != nil { result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "PlannedFailover", resp, "Failure sending request") return } result, err = client.PlannedFailoverResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "PlannedFailover", resp, "Failure responding to request") } }() return resultChan, errChan } // PlannedFailoverPreparer prepares the PlannedFailover request. func (client ReplicationRecoveryPlansClient) PlannedFailoverPreparer(recoveryPlanName string, input RecoveryPlanPlannedFailoverInput, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "recoveryPlanName": autorest.Encode("path", recoveryPlanName), "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), "resourceName": autorest.Encode("path", client.ResourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2016-08-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/plannedFailover", pathParameters), autorest.WithJSON(input), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{Cancel: cancel}) } // PlannedFailoverSender sends the PlannedFailover request. The method will close the // http.Response Body if it receives an error. func (client ReplicationRecoveryPlansClient) PlannedFailoverSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client), azure.DoPollForAsynchronous(client.PollingDelay)) } // PlannedFailoverResponder handles the response to the PlannedFailover request. The method always // closes the http.Response Body. func (client ReplicationRecoveryPlansClient) PlannedFailoverResponder(resp *http.Response) (result RecoveryPlan, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // Reprotect the operation to reprotect(reverse replicate) a recovery plan. This method may poll for completion. // Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // // recoveryPlanName is recovery plan name. func (client ReplicationRecoveryPlansClient) Reprotect(recoveryPlanName string, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { resultChan := make(chan RecoveryPlan, 1) errChan := make(chan error, 1) go func() { var err error var result RecoveryPlan defer func() { if err != nil { errChan <- err } resultChan <- result close(resultChan) close(errChan) }() req, err := client.ReprotectPreparer(recoveryPlanName, cancel) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Reprotect", nil, "Failure preparing request") return } resp, err := client.ReprotectSender(req) if err != nil { result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Reprotect", resp, "Failure sending request") return } result, err = client.ReprotectResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Reprotect", resp, "Failure responding to request") } }() return resultChan, errChan } // ReprotectPreparer prepares the Reprotect request. func (client ReplicationRecoveryPlansClient) ReprotectPreparer(recoveryPlanName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "recoveryPlanName": autorest.Encode("path", recoveryPlanName), "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), "resourceName": autorest.Encode("path", client.ResourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2016-08-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/reProtect", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{Cancel: cancel}) } // ReprotectSender sends the Reprotect request. The method will close the // http.Response Body if it receives an error. func (client ReplicationRecoveryPlansClient) ReprotectSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client), azure.DoPollForAsynchronous(client.PollingDelay)) } // ReprotectResponder handles the response to the Reprotect request. The method always // closes the http.Response Body. func (client ReplicationRecoveryPlansClient) ReprotectResponder(resp *http.Response) (result RecoveryPlan, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // TestFailover the operation to start the test failover of a recovery plan. This method may poll for completion. // Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // // recoveryPlanName is recovery plan name. input is failover input. func (client ReplicationRecoveryPlansClient) TestFailover(recoveryPlanName string, input RecoveryPlanTestFailoverInput, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { resultChan := make(chan RecoveryPlan, 1) errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: input, Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "input.Properties.NetworkType", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { errChan <- validation.NewErrorWithValidationError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailover") close(errChan) close(resultChan) return resultChan, errChan } go func() { var err error var result RecoveryPlan defer func() { if err != nil { errChan <- err } resultChan <- result close(resultChan) close(errChan) }() req, err := client.TestFailoverPreparer(recoveryPlanName, input, cancel) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailover", nil, "Failure preparing request") return } resp, err := client.TestFailoverSender(req) if err != nil { result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailover", resp, "Failure sending request") return } result, err = client.TestFailoverResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailover", resp, "Failure responding to request") } }() return resultChan, errChan } // TestFailoverPreparer prepares the TestFailover request. func (client ReplicationRecoveryPlansClient) TestFailoverPreparer(recoveryPlanName string, input RecoveryPlanTestFailoverInput, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "recoveryPlanName": autorest.Encode("path", recoveryPlanName), "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), "resourceName": autorest.Encode("path", client.ResourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2016-08-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/testFailover", pathParameters), autorest.WithJSON(input), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{Cancel: cancel}) } // TestFailoverSender sends the TestFailover request. The method will close the // http.Response Body if it receives an error. func (client ReplicationRecoveryPlansClient) TestFailoverSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client), azure.DoPollForAsynchronous(client.PollingDelay)) } // TestFailoverResponder handles the response to the TestFailover request. The method always // closes the http.Response Body. func (client ReplicationRecoveryPlansClient) TestFailoverResponder(resp *http.Response) (result RecoveryPlan, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // TestFailoverCleanup the operation to cleanup test failover of a recovery plan. This method may poll for completion. // Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // // recoveryPlanName is recovery plan name. input is test failover cleanup input. func (client ReplicationRecoveryPlansClient) TestFailoverCleanup(recoveryPlanName string, input RecoveryPlanTestFailoverCleanupInput, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { resultChan := make(chan RecoveryPlan, 1) errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: input, Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { errChan <- validation.NewErrorWithValidationError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailoverCleanup") close(errChan) close(resultChan) return resultChan, errChan } go func() { var err error var result RecoveryPlan defer func() { if err != nil { errChan <- err } resultChan <- result close(resultChan) close(errChan) }() req, err := client.TestFailoverCleanupPreparer(recoveryPlanName, input, cancel) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailoverCleanup", nil, "Failure preparing request") return } resp, err := client.TestFailoverCleanupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailoverCleanup", resp, "Failure sending request") return } result, err = client.TestFailoverCleanupResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailoverCleanup", resp, "Failure responding to request") } }() return resultChan, errChan } // TestFailoverCleanupPreparer prepares the TestFailoverCleanup request. func (client ReplicationRecoveryPlansClient) TestFailoverCleanupPreparer(recoveryPlanName string, input RecoveryPlanTestFailoverCleanupInput, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "recoveryPlanName": autorest.Encode("path", recoveryPlanName), "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), "resourceName": autorest.Encode("path", client.ResourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2016-08-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/testFailoverCleanup", pathParameters), autorest.WithJSON(input), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{Cancel: cancel}) } // TestFailoverCleanupSender sends the TestFailoverCleanup request. The method will close the // http.Response Body if it receives an error. func (client ReplicationRecoveryPlansClient) TestFailoverCleanupSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client), azure.DoPollForAsynchronous(client.PollingDelay)) } // TestFailoverCleanupResponder handles the response to the TestFailoverCleanup request. The method always // closes the http.Response Body. func (client ReplicationRecoveryPlansClient) TestFailoverCleanupResponder(resp *http.Response) (result RecoveryPlan, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // UnplannedFailover the operation to start the failover of a recovery plan. This method may poll for completion. // Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // // recoveryPlanName is recovery plan name. input is failover input. func (client ReplicationRecoveryPlansClient) UnplannedFailover(recoveryPlanName string, input RecoveryPlanUnplannedFailoverInput, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { resultChan := make(chan RecoveryPlan, 1) errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: input, Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { errChan <- validation.NewErrorWithValidationError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "UnplannedFailover") close(errChan) close(resultChan) return resultChan, errChan } go func() { var err error var result RecoveryPlan defer func() { if err != nil { errChan <- err } resultChan <- result close(resultChan) close(errChan) }() req, err := client.UnplannedFailoverPreparer(recoveryPlanName, input, cancel) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "UnplannedFailover", nil, "Failure preparing request") return } resp, err := client.UnplannedFailoverSender(req) if err != nil { result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "UnplannedFailover", resp, "Failure sending request") return } result, err = client.UnplannedFailoverResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "UnplannedFailover", resp, "Failure responding to request") } }() return resultChan, errChan } // UnplannedFailoverPreparer prepares the UnplannedFailover request. func (client ReplicationRecoveryPlansClient) UnplannedFailoverPreparer(recoveryPlanName string, input RecoveryPlanUnplannedFailoverInput, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "recoveryPlanName": autorest.Encode("path", recoveryPlanName), "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), "resourceName": autorest.Encode("path", client.ResourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2016-08-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/unplannedFailover", pathParameters), autorest.WithJSON(input), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{Cancel: cancel}) } // UnplannedFailoverSender sends the UnplannedFailover request. The method will close the // http.Response Body if it receives an error. func (client ReplicationRecoveryPlansClient) UnplannedFailoverSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client), azure.DoPollForAsynchronous(client.PollingDelay)) } // UnplannedFailoverResponder handles the response to the UnplannedFailover request. The method always // closes the http.Response Body. func (client ReplicationRecoveryPlansClient) UnplannedFailoverResponder(resp *http.Response) (result RecoveryPlan, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // Update the operation to update a recovery plan. This method may poll for completion. Polling can be canceled by // passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. // // recoveryPlanName is recovery plan name. input is update recovery plan input func (client ReplicationRecoveryPlansClient) Update(recoveryPlanName string, input UpdateRecoveryPlanInput, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { resultChan := make(chan RecoveryPlan, 1) errChan := make(chan error, 1) go func() { var err error var result RecoveryPlan defer func() { if err != nil { errChan <- err } resultChan <- result close(resultChan) close(errChan) }() req, err := client.UpdatePreparer(recoveryPlanName, input, cancel) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Update", nil, "Failure preparing request") return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Update", resp, "Failure sending request") return } result, err = client.UpdateResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Update", resp, "Failure responding to request") } }() return resultChan, errChan } // UpdatePreparer prepares the Update request. func (client ReplicationRecoveryPlansClient) UpdatePreparer(recoveryPlanName string, input UpdateRecoveryPlanInput, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "recoveryPlanName": autorest.Encode("path", recoveryPlanName), "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), "resourceName": autorest.Encode("path", client.ResourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2016-08-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPatch(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}", pathParameters), autorest.WithJSON(input), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{Cancel: cancel}) } // UpdateSender sends the Update request. The method will close the // http.Response Body if it receives an error. func (client ReplicationRecoveryPlansClient) UpdateSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client), azure.DoPollForAsynchronous(client.PollingDelay)) } // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. func (client ReplicationRecoveryPlansClient) UpdateResponder(resp *http.Response) (result RecoveryPlan, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return }