mirror of
https://github.com/octoleo/restic.git
synced 2024-11-15 09:44:15 +00:00
61cb1cc6f8
This includes github.com/kurin/blazer 0.2.0, which resolves #1291
599 lines
22 KiB
Go
Executable File
599 lines
22 KiB
Go
Executable File
package automation
|
|
|
|
// 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"
|
|
)
|
|
|
|
// AccountClient is the automation Client
|
|
type AccountClient struct {
|
|
ManagementClient
|
|
}
|
|
|
|
// NewAccountClient creates an instance of the AccountClient client.
|
|
func NewAccountClient(subscriptionID string) AccountClient {
|
|
return NewAccountClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
|
}
|
|
|
|
// NewAccountClientWithBaseURI creates an instance of the AccountClient client.
|
|
func NewAccountClientWithBaseURI(baseURI string, subscriptionID string) AccountClient {
|
|
return AccountClient{NewWithBaseURI(baseURI, subscriptionID)}
|
|
}
|
|
|
|
// CreateOrUpdate create or update automation account.
|
|
//
|
|
// resourceGroupName is the resource group name. automationAccountName is parameters supplied to the create or update
|
|
// automation account. parameters is parameters supplied to the create or update automation account.
|
|
func (client AccountClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, parameters AccountCreateOrUpdateParameters) (result Account, err error) {
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "CreateOrUpdate")
|
|
}
|
|
|
|
req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, parameters)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.CreateOrUpdateSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.CreateOrUpdateResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
|
func (client AccountClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, parameters AccountCreateOrUpdateParameters) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"automationAccountName": autorest.Encode("path", automationAccountName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2015-10-31"
|
|
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.Automation/automationAccounts/{automationAccountName}", pathParameters),
|
|
autorest.WithJSON(parameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client AccountClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
|
// closes the http.Response Body.
|
|
func (client AccountClient) CreateOrUpdateResponder(resp *http.Response) (result Account, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// Delete delete an automation account.
|
|
//
|
|
// resourceGroupName is the resource group name. automationAccountName is automation account name.
|
|
func (client AccountClient) Delete(resourceGroupName string, automationAccountName string) (result autorest.Response, err error) {
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "Delete")
|
|
}
|
|
|
|
req, err := client.DeletePreparer(resourceGroupName, automationAccountName)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.DeleteSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.DeleteResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// DeletePreparer prepares the Delete request.
|
|
func (client AccountClient) DeletePreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"automationAccountName": autorest.Encode("path", automationAccountName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2015-10-31"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsDelete(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// DeleteSender sends the Delete request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client AccountClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// DeleteResponder handles the response to the Delete request. The method always
|
|
// closes the http.Response Body.
|
|
func (client AccountClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
|
|
autorest.ByClosing())
|
|
result.Response = resp
|
|
return
|
|
}
|
|
|
|
// Get get information about an Automation Account.
|
|
//
|
|
// resourceGroupName is the resource group name. automationAccountName is the automation account name.
|
|
func (client AccountClient) Get(resourceGroupName string, automationAccountName string) (result Account, err error) {
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "Get")
|
|
}
|
|
|
|
req, err := client.GetPreparer(resourceGroupName, automationAccountName)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.GetSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetPreparer prepares the Get request.
|
|
func (client AccountClient) GetPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"automationAccountName": autorest.Encode("path", automationAccountName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2015-10-31"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", 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 AccountClient) 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 AccountClient) GetResponder(resp *http.Response) (result Account, 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 retrieve a list of accounts within a given subscription.
|
|
func (client AccountClient) List() (result AccountListResult, err error) {
|
|
req, err := client.ListPreparer()
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListPreparer prepares the List request.
|
|
func (client AccountClient) ListPreparer() (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2015-10-31"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts", 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 AccountClient) 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 AccountClient) ListResponder(resp *http.Response) (result AccountListResult, 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 AccountClient) ListNextResults(lastResults AccountListResult) (result AccountListResult, err error) {
|
|
req, err := lastResults.AccountListResultPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "automation.AccountClient", "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, "automation.AccountClient", "List", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListComplete gets all elements from the list without paging.
|
|
func (client AccountClient) ListComplete(cancel <-chan struct{}) (<-chan Account, <-chan error) {
|
|
resultChan := make(chan Account)
|
|
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
|
|
}
|
|
|
|
// ListByResourceGroup retrieve a list of accounts within a given resource group.
|
|
//
|
|
// resourceGroupName is the resource group name.
|
|
func (client AccountClient) ListByResourceGroup(resourceGroupName string) (result AccountListResult, err error) {
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "ListByResourceGroup")
|
|
}
|
|
|
|
req, err := client.ListByResourceGroupPreparer(resourceGroupName)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListByResourceGroupSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListByResourceGroupResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
|
func (client AccountClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2015-10-31"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client AccountClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
|
|
// closes the http.Response Body.
|
|
func (client AccountClient) ListByResourceGroupResponder(resp *http.Response) (result AccountListResult, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// ListByResourceGroupNextResults retrieves the next set of results, if any.
|
|
func (client AccountClient) ListByResourceGroupNextResults(lastResults AccountListResult) (result AccountListResult, err error) {
|
|
req, err := lastResults.AccountListResultPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", nil, "Failure preparing next results request")
|
|
}
|
|
if req == nil {
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListByResourceGroupSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
return result, autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListByResourceGroupResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListByResourceGroupComplete gets all elements from the list without paging.
|
|
func (client AccountClient) ListByResourceGroupComplete(resourceGroupName string, cancel <-chan struct{}) (<-chan Account, <-chan error) {
|
|
resultChan := make(chan Account)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
defer func() {
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
list, err := client.ListByResourceGroup(resourceGroupName)
|
|
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.ListByResourceGroupNextResults(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 update an automation account.
|
|
//
|
|
// resourceGroupName is the resource group name. automationAccountName is automation account name. parameters is
|
|
// parameters supplied to the update automation account.
|
|
func (client AccountClient) Update(resourceGroupName string, automationAccountName string, parameters AccountUpdateParameters) (result Account, err error) {
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "Update")
|
|
}
|
|
|
|
req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, parameters)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.UpdateSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.UpdateResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UpdatePreparer prepares the Update request.
|
|
func (client AccountClient) UpdatePreparer(resourceGroupName string, automationAccountName string, parameters AccountUpdateParameters) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"automationAccountName": autorest.Encode("path", automationAccountName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2015-10-31"
|
|
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.Automation/automationAccounts/{automationAccountName}", pathParameters),
|
|
autorest.WithJSON(parameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// UpdateSender sends the Update request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client AccountClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// UpdateResponder handles the response to the Update request. The method always
|
|
// closes the http.Response Body.
|
|
func (client AccountClient) UpdateResponder(resp *http.Response) (result Account, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|