mirror of
https://github.com/octoleo/restic.git
synced 2024-11-15 17:47:21 +00:00
640 lines
28 KiB
Go
640 lines
28 KiB
Go
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 1.1.0.0
|
|
// 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"
|
|
"net/http"
|
|
)
|
|
|
|
// ReplicationProtectionContainerMappingsClient is the client for the ReplicationProtectionContainerMappings methods of
|
|
// the Recoveryservicessiterecovery service.
|
|
type ReplicationProtectionContainerMappingsClient struct {
|
|
ManagementClient
|
|
}
|
|
|
|
// NewReplicationProtectionContainerMappingsClient creates an instance of the
|
|
// ReplicationProtectionContainerMappingsClient client.
|
|
func NewReplicationProtectionContainerMappingsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationProtectionContainerMappingsClient {
|
|
return NewReplicationProtectionContainerMappingsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
|
|
}
|
|
|
|
// NewReplicationProtectionContainerMappingsClientWithBaseURI creates an instance of the
|
|
// ReplicationProtectionContainerMappingsClient client.
|
|
func NewReplicationProtectionContainerMappingsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationProtectionContainerMappingsClient {
|
|
return ReplicationProtectionContainerMappingsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
|
|
}
|
|
|
|
// Create the operation to create a protection container mapping. 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.
|
|
//
|
|
// fabricName is fabric name. protectionContainerName is protection container name. mappingName is protection container
|
|
// mapping name. creationInput is mapping creation input.
|
|
func (client ReplicationProtectionContainerMappingsClient) Create(fabricName string, protectionContainerName string, mappingName string, creationInput CreateProtectionContainerMappingInput, cancel <-chan struct{}) (<-chan ProtectionContainerMapping, <-chan error) {
|
|
resultChan := make(chan ProtectionContainerMapping, 1)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
var err error
|
|
var result ProtectionContainerMapping
|
|
defer func() {
|
|
if err != nil {
|
|
errChan <- err
|
|
}
|
|
resultChan <- result
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
req, err := client.CreatePreparer(fabricName, protectionContainerName, mappingName, creationInput, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "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.ReplicationProtectionContainerMappingsClient", "Create", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.CreateResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Create", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// CreatePreparer prepares the Create request.
|
|
func (client ReplicationProtectionContainerMappingsClient) CreatePreparer(fabricName string, protectionContainerName string, mappingName string, creationInput CreateProtectionContainerMappingInput, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"fabricName": autorest.Encode("path", fabricName),
|
|
"mappingName": autorest.Encode("path", mappingName),
|
|
"protectionContainerName": autorest.Encode("path", protectionContainerName),
|
|
"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}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionContainerMappings/{mappingName}", pathParameters),
|
|
autorest.WithJSON(creationInput),
|
|
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 ReplicationProtectionContainerMappingsClient) CreateSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
}
|
|
|
|
// CreateResponder handles the response to the Create request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ReplicationProtectionContainerMappingsClient) CreateResponder(resp *http.Response) (result ProtectionContainerMapping, 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 the operation to delete or remove a protection container mapping. 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.
|
|
//
|
|
// fabricName is fabric name. protectionContainerName is protection container name. mappingName is protection container
|
|
// mapping name. removalInput is removal input.
|
|
func (client ReplicationProtectionContainerMappingsClient) Delete(fabricName string, protectionContainerName string, mappingName string, removalInput RemoveProtectionContainerMappingInput, 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(fabricName, protectionContainerName, mappingName, removalInput, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Delete", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.DeleteSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Delete", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.DeleteResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Delete", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// DeletePreparer prepares the Delete request.
|
|
func (client ReplicationProtectionContainerMappingsClient) DeletePreparer(fabricName string, protectionContainerName string, mappingName string, removalInput RemoveProtectionContainerMappingInput, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"fabricName": autorest.Encode("path", fabricName),
|
|
"mappingName": autorest.Encode("path", mappingName),
|
|
"protectionContainerName": autorest.Encode("path", protectionContainerName),
|
|
"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}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionContainerMappings/{mappingName}/remove", pathParameters),
|
|
autorest.WithJSON(removalInput),
|
|
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 ReplicationProtectionContainerMappingsClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
}
|
|
|
|
// DeleteResponder handles the response to the Delete request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ReplicationProtectionContainerMappingsClient) 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
|
|
}
|
|
|
|
// Get gets the details of a protection container mapping.
|
|
//
|
|
// fabricName is fabric name. protectionContainerName is protection container name. mappingName is protection Container
|
|
// mapping name.
|
|
func (client ReplicationProtectionContainerMappingsClient) Get(fabricName string, protectionContainerName string, mappingName string) (result ProtectionContainerMapping, err error) {
|
|
req, err := client.GetPreparer(fabricName, protectionContainerName, mappingName)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "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.ReplicationProtectionContainerMappingsClient", "Get", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Get", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetPreparer prepares the Get request.
|
|
func (client ReplicationProtectionContainerMappingsClient) GetPreparer(fabricName string, protectionContainerName string, mappingName string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"fabricName": autorest.Encode("path", fabricName),
|
|
"mappingName": autorest.Encode("path", mappingName),
|
|
"protectionContainerName": autorest.Encode("path", protectionContainerName),
|
|
"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}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionContainerMappings/{mappingName}", 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 ReplicationProtectionContainerMappingsClient) GetSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// GetResponder handles the response to the Get request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ReplicationProtectionContainerMappingsClient) GetResponder(resp *http.Response) (result ProtectionContainerMapping, 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 protection container mappings in the vault.
|
|
func (client ReplicationProtectionContainerMappingsClient) List() (result ProtectionContainerMappingCollection, err error) {
|
|
req, err := client.ListPreparer()
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "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.ReplicationProtectionContainerMappingsClient", "List", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "List", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListPreparer prepares the List request.
|
|
func (client ReplicationProtectionContainerMappingsClient) 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}/replicationProtectionContainerMappings", 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 ReplicationProtectionContainerMappingsClient) ListSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// ListResponder handles the response to the List request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ReplicationProtectionContainerMappingsClient) ListResponder(resp *http.Response) (result ProtectionContainerMappingCollection, 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 ReplicationProtectionContainerMappingsClient) ListNextResults(lastResults ProtectionContainerMappingCollection) (result ProtectionContainerMappingCollection, err error) {
|
|
req, err := lastResults.ProtectionContainerMappingCollectionPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "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.ReplicationProtectionContainerMappingsClient", "List", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "List", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListComplete gets all elements from the list without paging.
|
|
func (client ReplicationProtectionContainerMappingsClient) ListComplete(cancel <-chan struct{}) (<-chan ProtectionContainerMapping, <-chan error) {
|
|
resultChan := make(chan ProtectionContainerMapping)
|
|
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
|
|
}
|
|
|
|
// ListByReplicationProtectionContainers lists the protection container mappings for a protection container.
|
|
//
|
|
// fabricName is fabric name. protectionContainerName is protection container name.
|
|
func (client ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainers(fabricName string, protectionContainerName string) (result ProtectionContainerMappingCollection, err error) {
|
|
req, err := client.ListByReplicationProtectionContainersPreparer(fabricName, protectionContainerName)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "ListByReplicationProtectionContainers", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListByReplicationProtectionContainersSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "ListByReplicationProtectionContainers", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListByReplicationProtectionContainersResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "ListByReplicationProtectionContainers", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListByReplicationProtectionContainersPreparer prepares the ListByReplicationProtectionContainers request.
|
|
func (client ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersPreparer(fabricName string, protectionContainerName string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"fabricName": autorest.Encode("path", fabricName),
|
|
"protectionContainerName": autorest.Encode("path", protectionContainerName),
|
|
"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}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionContainerMappings", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// ListByReplicationProtectionContainersSender sends the ListByReplicationProtectionContainers request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// ListByReplicationProtectionContainersResponder handles the response to the ListByReplicationProtectionContainers request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersResponder(resp *http.Response) (result ProtectionContainerMappingCollection, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// ListByReplicationProtectionContainersNextResults retrieves the next set of results, if any.
|
|
func (client ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersNextResults(lastResults ProtectionContainerMappingCollection) (result ProtectionContainerMappingCollection, err error) {
|
|
req, err := lastResults.ProtectionContainerMappingCollectionPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "ListByReplicationProtectionContainers", nil, "Failure preparing next results request")
|
|
}
|
|
if req == nil {
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListByReplicationProtectionContainersSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "ListByReplicationProtectionContainers", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListByReplicationProtectionContainersResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "ListByReplicationProtectionContainers", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListByReplicationProtectionContainersComplete gets all elements from the list without paging.
|
|
func (client ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersComplete(fabricName string, protectionContainerName string, cancel <-chan struct{}) (<-chan ProtectionContainerMapping, <-chan error) {
|
|
resultChan := make(chan ProtectionContainerMapping)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
defer func() {
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
list, err := client.ListByReplicationProtectionContainers(fabricName, protectionContainerName)
|
|
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.ListByReplicationProtectionContainersNextResults(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
|
|
}
|
|
|
|
// Purge the operation to purge(force delete) a protection container mapping 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.
|
|
//
|
|
// fabricName is fabric name. protectionContainerName is protection container name. mappingName is protection container
|
|
// mapping name.
|
|
func (client ReplicationProtectionContainerMappingsClient) Purge(fabricName string, protectionContainerName string, mappingName 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.PurgePreparer(fabricName, protectionContainerName, mappingName, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Purge", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.PurgeSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Purge", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.PurgeResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Purge", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// PurgePreparer prepares the Purge request.
|
|
func (client ReplicationProtectionContainerMappingsClient) PurgePreparer(fabricName string, protectionContainerName string, mappingName string, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"fabricName": autorest.Encode("path", fabricName),
|
|
"mappingName": autorest.Encode("path", mappingName),
|
|
"protectionContainerName": autorest.Encode("path", protectionContainerName),
|
|
"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}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionContainerMappings/{mappingName}", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
|
}
|
|
|
|
// PurgeSender sends the Purge request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client ReplicationProtectionContainerMappingsClient) PurgeSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
}
|
|
|
|
// PurgeResponder handles the response to the Purge request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ReplicationProtectionContainerMappingsClient) PurgeResponder(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
|
|
}
|