mirror of
https://github.com/octoleo/restic.git
synced 2024-12-04 19:03:46 +00:00
946c8399e2
Exclude minio-go for now (pin to 3.x.y).
918 lines
36 KiB
Go
Executable File
918 lines
36 KiB
Go
Executable File
package batch
|
|
|
|
// 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 client for the Account methods of the Batch service.
|
|
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)}
|
|
}
|
|
|
|
// Create creates a new Batch account with the specified parameters. Existing accounts cannot be updated with this API
|
|
// and should instead be updated with the Update Batch Account API. 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.
|
|
//
|
|
// resourceGroupName is the name of the resource group that contains the Batch account. accountName is a name for the
|
|
// Batch account which must be unique within the region. Batch account names must be between 3 and 24 characters in
|
|
// length and must use only numbers and lowercase letters. This name is used as part of the DNS name that is used to
|
|
// access the Batch service in the region in which the account is created. For example:
|
|
// http://accountname.region.batch.azure.com/. parameters is additional parameters for account creation.
|
|
func (client AccountClient) Create(resourceGroupName string, accountName string, parameters AccountCreateParameters, cancel <-chan struct{}) (<-chan Account, <-chan error) {
|
|
resultChan := make(chan Account, 1)
|
|
errChan := make(chan error, 1)
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}},
|
|
{TargetValue: accountName,
|
|
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
|
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
|
{Target: "accountName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}},
|
|
{TargetValue: parameters,
|
|
Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil},
|
|
{Target: "parameters.AccountCreateProperties", Name: validation.Null, Rule: false,
|
|
Chain: []validation.Constraint{{Target: "parameters.AccountCreateProperties.AutoStorage", Name: validation.Null, Rule: false,
|
|
Chain: []validation.Constraint{{Target: "parameters.AccountCreateProperties.AutoStorage.StorageAccountID", Name: validation.Null, Rule: true, Chain: nil}}},
|
|
{Target: "parameters.AccountCreateProperties.KeyVaultReference", Name: validation.Null, Rule: false,
|
|
Chain: []validation.Constraint{{Target: "parameters.AccountCreateProperties.KeyVaultReference.ID", Name: validation.Null, Rule: true, Chain: nil},
|
|
{Target: "parameters.AccountCreateProperties.KeyVaultReference.URL", Name: validation.Null, Rule: true, Chain: nil},
|
|
}},
|
|
}}}}}); err != nil {
|
|
errChan <- validation.NewErrorWithValidationError(err, "batch.AccountClient", "Create")
|
|
close(errChan)
|
|
close(resultChan)
|
|
return resultChan, errChan
|
|
}
|
|
|
|
go func() {
|
|
var err error
|
|
var result Account
|
|
defer func() {
|
|
if err != nil {
|
|
errChan <- err
|
|
}
|
|
resultChan <- result
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
req, err := client.CreatePreparer(resourceGroupName, accountName, parameters, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "Create", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.CreateSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "Create", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.CreateResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "Create", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// CreatePreparer prepares the Create request.
|
|
func (client AccountClient) CreatePreparer(resourceGroupName string, accountName string, parameters AccountCreateParameters, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"accountName": autorest.Encode("path", accountName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2017-05-01"
|
|
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.Batch/batchAccounts/{accountName}", pathParameters),
|
|
autorest.WithJSON(parameters),
|
|
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 AccountClient) 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 AccountClient) CreateResponder(resp *http.Response) (result Account, 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 deletes the specified Batch account. 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.
|
|
//
|
|
// resourceGroupName is the name of the resource group that contains the Batch account. accountName is the name of the
|
|
// Batch account.
|
|
func (client AccountClient) Delete(resourceGroupName string, accountName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
|
resultChan := make(chan autorest.Response, 1)
|
|
errChan := make(chan error, 1)
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}},
|
|
{TargetValue: accountName,
|
|
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
|
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
|
{Target: "accountName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
|
errChan <- validation.NewErrorWithValidationError(err, "batch.AccountClient", "Delete")
|
|
close(errChan)
|
|
close(resultChan)
|
|
return resultChan, errChan
|
|
}
|
|
|
|
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(resourceGroupName, accountName, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "Delete", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.DeleteSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "Delete", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.DeleteResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "Delete", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// DeletePreparer prepares the Delete request.
|
|
func (client AccountClient) DeletePreparer(resourceGroupName string, accountName string, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"accountName": autorest.Encode("path", accountName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2017-05-01"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsDelete(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}", 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 AccountClient) 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 AccountClient) 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 information about the specified Batch account.
|
|
//
|
|
// resourceGroupName is the name of the resource group that contains the Batch account. accountName is the name of the
|
|
// Batch account.
|
|
func (client AccountClient) Get(resourceGroupName string, accountName 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}}},
|
|
{TargetValue: accountName,
|
|
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
|
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
|
{Target: "accountName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "batch.AccountClient", "Get")
|
|
}
|
|
|
|
req, err := client.GetPreparer(resourceGroupName, accountName)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.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, "batch.AccountClient", "Get", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "Get", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetPreparer prepares the Get request.
|
|
func (client AccountClient) GetPreparer(resourceGroupName string, accountName string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"accountName": autorest.Encode("path", accountName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2017-05-01"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}", 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,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|
|
// GetKeys this operation applies only to Batch accounts created with a poolAllocationMode of 'BatchService'. If the
|
|
// Batch account was created with a poolAllocationMode of 'UserSubscription', clients cannot use access to keys to
|
|
// authenticate, and must use Azure Active Directory instead. In this case, getting the keys will fail.
|
|
//
|
|
// resourceGroupName is the name of the resource group that contains the Batch account. accountName is the name of the
|
|
// Batch account.
|
|
func (client AccountClient) GetKeys(resourceGroupName string, accountName string) (result AccountKeys, err error) {
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}},
|
|
{TargetValue: accountName,
|
|
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
|
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
|
{Target: "accountName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "batch.AccountClient", "GetKeys")
|
|
}
|
|
|
|
req, err := client.GetKeysPreparer(resourceGroupName, accountName)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "GetKeys", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.GetKeysSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "GetKeys", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetKeysResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "GetKeys", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetKeysPreparer prepares the GetKeys request.
|
|
func (client AccountClient) GetKeysPreparer(resourceGroupName string, accountName string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"accountName": autorest.Encode("path", accountName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2017-05-01"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsPost(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/listKeys", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// GetKeysSender sends the GetKeys request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client AccountClient) GetKeysSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// GetKeysResponder handles the response to the GetKeys request. The method always
|
|
// closes the http.Response Body.
|
|
func (client AccountClient) GetKeysResponder(resp *http.Response) (result AccountKeys, 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 gets information about the Batch accounts associated with the subscription.
|
|
func (client AccountClient) List() (result AccountListResult, err error) {
|
|
req, err := client.ListPreparer()
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.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, "batch.AccountClient", "List", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.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 = "2017-05-01"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Batch/batchAccounts", 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,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// 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, "batch.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, "batch.AccountClient", "List", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.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 gets information about the Batch accounts associated with the specified resource group.
|
|
//
|
|
// resourceGroupName is the name of the resource group that contains the Batch account.
|
|
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, "batch.AccountClient", "ListByResourceGroup")
|
|
}
|
|
|
|
req, err := client.ListByResourceGroupPreparer(resourceGroupName)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.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, "batch.AccountClient", "ListByResourceGroup", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListByResourceGroupResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.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 = "2017-05-01"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts", 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,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// 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, "batch.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, "batch.AccountClient", "ListByResourceGroup", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListByResourceGroupResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.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
|
|
}
|
|
|
|
// RegenerateKey regenerates the specified account key for the Batch account.
|
|
//
|
|
// resourceGroupName is the name of the resource group that contains the Batch account. accountName is the name of the
|
|
// Batch account. parameters is the type of key to regenerate.
|
|
func (client AccountClient) RegenerateKey(resourceGroupName string, accountName string, parameters AccountRegenerateKeyParameters) (result AccountKeys, err error) {
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}},
|
|
{TargetValue: accountName,
|
|
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
|
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
|
{Target: "accountName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "batch.AccountClient", "RegenerateKey")
|
|
}
|
|
|
|
req, err := client.RegenerateKeyPreparer(resourceGroupName, accountName, parameters)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "RegenerateKey", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.RegenerateKeySender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "RegenerateKey", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.RegenerateKeyResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "RegenerateKey", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// RegenerateKeyPreparer prepares the RegenerateKey request.
|
|
func (client AccountClient) RegenerateKeyPreparer(resourceGroupName string, accountName string, parameters AccountRegenerateKeyParameters) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"accountName": autorest.Encode("path", accountName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2017-05-01"
|
|
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.Batch/batchAccounts/{accountName}/regenerateKeys", pathParameters),
|
|
autorest.WithJSON(parameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// RegenerateKeySender sends the RegenerateKey request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client AccountClient) RegenerateKeySender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always
|
|
// closes the http.Response Body.
|
|
func (client AccountClient) RegenerateKeyResponder(resp *http.Response) (result AccountKeys, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// SynchronizeAutoStorageKeys synchronizes access keys for the auto-storage account configured for the specified Batch
|
|
// account.
|
|
//
|
|
// resourceGroupName is the name of the resource group that contains the Batch account. accountName is the name of the
|
|
// Batch account.
|
|
func (client AccountClient) SynchronizeAutoStorageKeys(resourceGroupName string, accountName 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}}},
|
|
{TargetValue: accountName,
|
|
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
|
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
|
{Target: "accountName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "batch.AccountClient", "SynchronizeAutoStorageKeys")
|
|
}
|
|
|
|
req, err := client.SynchronizeAutoStorageKeysPreparer(resourceGroupName, accountName)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "SynchronizeAutoStorageKeys", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.SynchronizeAutoStorageKeysSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "SynchronizeAutoStorageKeys", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.SynchronizeAutoStorageKeysResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "SynchronizeAutoStorageKeys", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// SynchronizeAutoStorageKeysPreparer prepares the SynchronizeAutoStorageKeys request.
|
|
func (client AccountClient) SynchronizeAutoStorageKeysPreparer(resourceGroupName string, accountName string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"accountName": autorest.Encode("path", accountName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2017-05-01"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsPost(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/syncAutoStorageKeys", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// SynchronizeAutoStorageKeysSender sends the SynchronizeAutoStorageKeys request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client AccountClient) SynchronizeAutoStorageKeysSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// SynchronizeAutoStorageKeysResponder handles the response to the SynchronizeAutoStorageKeys request. The method always
|
|
// closes the http.Response Body.
|
|
func (client AccountClient) SynchronizeAutoStorageKeysResponder(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
|
|
}
|
|
|
|
// Update updates the properties of an existing Batch account.
|
|
//
|
|
// resourceGroupName is the name of the resource group that contains the Batch account. accountName is the name of the
|
|
// Batch account. parameters is additional parameters for account update.
|
|
func (client AccountClient) Update(resourceGroupName string, accountName 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}}},
|
|
{TargetValue: accountName,
|
|
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
|
|
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
|
{Target: "accountName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "batch.AccountClient", "Update")
|
|
}
|
|
|
|
req, err := client.UpdatePreparer(resourceGroupName, accountName, parameters)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.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, "batch.AccountClient", "Update", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.UpdateResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "batch.AccountClient", "Update", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UpdatePreparer prepares the Update request.
|
|
func (client AccountClient) UpdatePreparer(resourceGroupName string, accountName string, parameters AccountUpdateParameters) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"accountName": autorest.Encode("path", accountName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2017-05-01"
|
|
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.Batch/batchAccounts/{accountName}", 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,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// 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
|
|
}
|