mirror of
https://github.com/octoleo/restic.git
synced 2024-11-16 01:57:10 +00:00
629 lines
24 KiB
Go
629 lines
24 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"
|
|
)
|
|
|
|
// ReplicationvCentersClient is the client for the ReplicationvCenters methods of the Recoveryservicessiterecovery
|
|
// service.
|
|
type ReplicationvCentersClient struct {
|
|
ManagementClient
|
|
}
|
|
|
|
// NewReplicationvCentersClient creates an instance of the ReplicationvCentersClient client.
|
|
func NewReplicationvCentersClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationvCentersClient {
|
|
return NewReplicationvCentersClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
|
|
}
|
|
|
|
// NewReplicationvCentersClientWithBaseURI creates an instance of the ReplicationvCentersClient client.
|
|
func NewReplicationvCentersClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationvCentersClient {
|
|
return ReplicationvCentersClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
|
|
}
|
|
|
|
// Create the operation to create a vCenter object.. 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. vCenterName is vCenter name. addVCenterRequest is the input to the add vCenter operation.
|
|
func (client ReplicationvCentersClient) Create(fabricName string, vCenterName string, addVCenterRequest AddVCenterRequest, cancel <-chan struct{}) (<-chan VCenter, <-chan error) {
|
|
resultChan := make(chan VCenter, 1)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
var err error
|
|
var result VCenter
|
|
defer func() {
|
|
if err != nil {
|
|
errChan <- err
|
|
}
|
|
resultChan <- result
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
req, err := client.CreatePreparer(fabricName, vCenterName, addVCenterRequest, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "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.ReplicationvCentersClient", "Create", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.CreateResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Create", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// CreatePreparer prepares the Create request.
|
|
func (client ReplicationvCentersClient) CreatePreparer(fabricName string, vCenterName string, addVCenterRequest AddVCenterRequest, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"fabricName": autorest.Encode("path", fabricName),
|
|
"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
|
|
"resourceName": autorest.Encode("path", client.ResourceName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
"vCenterName": autorest.Encode("path", vCenterName),
|
|
}
|
|
|
|
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}/replicationvCenters/{vCenterName}", pathParameters),
|
|
autorest.WithJSON(addVCenterRequest),
|
|
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 ReplicationvCentersClient) 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 ReplicationvCentersClient) CreateResponder(resp *http.Response) (result VCenter, 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 remove(unregister) a registered vCenter server from the vault. 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. vCenterName is vCenter name.
|
|
func (client ReplicationvCentersClient) Delete(fabricName string, vCenterName 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(fabricName, vCenterName, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Delete", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.DeleteSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Delete", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.DeleteResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Delete", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// DeletePreparer prepares the Delete request.
|
|
func (client ReplicationvCentersClient) DeletePreparer(fabricName string, vCenterName string, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"fabricName": autorest.Encode("path", fabricName),
|
|
"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
|
|
"resourceName": autorest.Encode("path", client.ResourceName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
"vCenterName": autorest.Encode("path", vCenterName),
|
|
}
|
|
|
|
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}/replicationvCenters/{vCenterName}", 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 ReplicationvCentersClient) 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 ReplicationvCentersClient) 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 registered vCenter server(Add vCenter server.)
|
|
//
|
|
// fabricName is fabric name. vCenterName is vCenter name.
|
|
func (client ReplicationvCentersClient) Get(fabricName string, vCenterName string) (result VCenter, err error) {
|
|
req, err := client.GetPreparer(fabricName, vCenterName)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "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.ReplicationvCentersClient", "Get", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Get", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetPreparer prepares the Get request.
|
|
func (client ReplicationvCentersClient) GetPreparer(fabricName string, vCenterName string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"fabricName": autorest.Encode("path", fabricName),
|
|
"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
|
|
"resourceName": autorest.Encode("path", client.ResourceName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
"vCenterName": autorest.Encode("path", vCenterName),
|
|
}
|
|
|
|
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}/replicationvCenters/{vCenterName}", 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 ReplicationvCentersClient) 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 ReplicationvCentersClient) GetResponder(resp *http.Response) (result VCenter, 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 vCenter servers registered in the vault.
|
|
func (client ReplicationvCentersClient) List() (result VCenterCollection, err error) {
|
|
req, err := client.ListPreparer()
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "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.ReplicationvCentersClient", "List", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "List", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListPreparer prepares the List request.
|
|
func (client ReplicationvCentersClient) 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}/replicationvCenters", 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 ReplicationvCentersClient) 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 ReplicationvCentersClient) ListResponder(resp *http.Response) (result VCenterCollection, 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 ReplicationvCentersClient) ListNextResults(lastResults VCenterCollection) (result VCenterCollection, err error) {
|
|
req, err := lastResults.VCenterCollectionPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "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.ReplicationvCentersClient", "List", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "List", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListComplete gets all elements from the list without paging.
|
|
func (client ReplicationvCentersClient) ListComplete(cancel <-chan struct{}) (<-chan VCenter, <-chan error) {
|
|
resultChan := make(chan VCenter)
|
|
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
|
|
}
|
|
|
|
// ListByReplicationFabrics lists the vCenter servers registered in a fabric.
|
|
//
|
|
// fabricName is fabric name.
|
|
func (client ReplicationvCentersClient) ListByReplicationFabrics(fabricName string) (result VCenterCollection, err error) {
|
|
req, err := client.ListByReplicationFabricsPreparer(fabricName)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "ListByReplicationFabrics", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListByReplicationFabricsSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "ListByReplicationFabrics", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListByReplicationFabricsResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "ListByReplicationFabrics", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListByReplicationFabricsPreparer prepares the ListByReplicationFabrics request.
|
|
func (client ReplicationvCentersClient) ListByReplicationFabricsPreparer(fabricName string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"fabricName": autorest.Encode("path", fabricName),
|
|
"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}/replicationvCenters", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// ListByReplicationFabricsSender sends the ListByReplicationFabrics request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client ReplicationvCentersClient) ListByReplicationFabricsSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// ListByReplicationFabricsResponder handles the response to the ListByReplicationFabrics request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ReplicationvCentersClient) ListByReplicationFabricsResponder(resp *http.Response) (result VCenterCollection, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// ListByReplicationFabricsNextResults retrieves the next set of results, if any.
|
|
func (client ReplicationvCentersClient) ListByReplicationFabricsNextResults(lastResults VCenterCollection) (result VCenterCollection, err error) {
|
|
req, err := lastResults.VCenterCollectionPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "ListByReplicationFabrics", nil, "Failure preparing next results request")
|
|
}
|
|
if req == nil {
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListByReplicationFabricsSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "ListByReplicationFabrics", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListByReplicationFabricsResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "ListByReplicationFabrics", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListByReplicationFabricsComplete gets all elements from the list without paging.
|
|
func (client ReplicationvCentersClient) ListByReplicationFabricsComplete(fabricName string, cancel <-chan struct{}) (<-chan VCenter, <-chan error) {
|
|
resultChan := make(chan VCenter)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
defer func() {
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
list, err := client.ListByReplicationFabrics(fabricName)
|
|
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.ListByReplicationFabricsNextResults(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
|
|
}
|
|
|
|
// Update the operation to update a registered vCenter. 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. vCenterName is vCeneter name updateVCenterRequest is the input to the update vCenter
|
|
// operation.
|
|
func (client ReplicationvCentersClient) Update(fabricName string, vCenterName string, updateVCenterRequest UpdateVCenterRequest, cancel <-chan struct{}) (<-chan VCenter, <-chan error) {
|
|
resultChan := make(chan VCenter, 1)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
var err error
|
|
var result VCenter
|
|
defer func() {
|
|
if err != nil {
|
|
errChan <- err
|
|
}
|
|
resultChan <- result
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
req, err := client.UpdatePreparer(fabricName, vCenterName, updateVCenterRequest, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "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.ReplicationvCentersClient", "Update", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.UpdateResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Update", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// UpdatePreparer prepares the Update request.
|
|
func (client ReplicationvCentersClient) UpdatePreparer(fabricName string, vCenterName string, updateVCenterRequest UpdateVCenterRequest, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"fabricName": autorest.Encode("path", fabricName),
|
|
"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
|
|
"resourceName": autorest.Encode("path", client.ResourceName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
"vCenterName": autorest.Encode("path", vCenterName),
|
|
}
|
|
|
|
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}/replicationFabrics/{fabricName}/replicationvCenters/{vCenterName}", pathParameters),
|
|
autorest.WithJSON(updateVCenterRequest),
|
|
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 ReplicationvCentersClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
}
|
|
|
|
// UpdateResponder handles the response to the Update request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ReplicationvCentersClient) UpdateResponder(resp *http.Response) (result VCenter, 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
|
|
}
|