1package batch 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "net/http" 25) 26 27// LocationClient is the client for the Location methods of the Batch service. 28type LocationClient struct { 29 BaseClient 30} 31 32// NewLocationClient creates an instance of the LocationClient client. 33func NewLocationClient(subscriptionID string) LocationClient { 34 return NewLocationClientWithBaseURI(DefaultBaseURI, subscriptionID) 35} 36 37// NewLocationClientWithBaseURI creates an instance of the LocationClient client. 38func NewLocationClientWithBaseURI(baseURI string, subscriptionID string) LocationClient { 39 return LocationClient{NewWithBaseURI(baseURI, subscriptionID)} 40} 41 42// GetQuotas gets the Batch service quotas for the specified subscription at the given location. 43// Parameters: 44// locationName - the desired region for the quotas. 45func (client LocationClient) GetQuotas(ctx context.Context, locationName string) (result LocationQuota, err error) { 46 req, err := client.GetQuotasPreparer(ctx, locationName) 47 if err != nil { 48 err = autorest.NewErrorWithError(err, "batch.LocationClient", "GetQuotas", nil, "Failure preparing request") 49 return 50 } 51 52 resp, err := client.GetQuotasSender(req) 53 if err != nil { 54 result.Response = autorest.Response{Response: resp} 55 err = autorest.NewErrorWithError(err, "batch.LocationClient", "GetQuotas", resp, "Failure sending request") 56 return 57 } 58 59 result, err = client.GetQuotasResponder(resp) 60 if err != nil { 61 err = autorest.NewErrorWithError(err, "batch.LocationClient", "GetQuotas", resp, "Failure responding to request") 62 } 63 64 return 65} 66 67// GetQuotasPreparer prepares the GetQuotas request. 68func (client LocationClient) GetQuotasPreparer(ctx context.Context, locationName string) (*http.Request, error) { 69 pathParameters := map[string]interface{}{ 70 "locationName": autorest.Encode("path", locationName), 71 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 72 } 73 74 const APIVersion = "2015-12-01" 75 queryParameters := map[string]interface{}{ 76 "api-version": APIVersion, 77 } 78 79 preparer := autorest.CreatePreparer( 80 autorest.AsGet(), 81 autorest.WithBaseURL(client.BaseURI), 82 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/quotas", pathParameters), 83 autorest.WithQueryParameters(queryParameters)) 84 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 85} 86 87// GetQuotasSender sends the GetQuotas request. The method will close the 88// http.Response Body if it receives an error. 89func (client LocationClient) GetQuotasSender(req *http.Request) (*http.Response, error) { 90 return autorest.SendWithSender(client, req, 91 azure.DoRetryWithRegistration(client.Client)) 92} 93 94// GetQuotasResponder handles the response to the GetQuotas request. The method always 95// closes the http.Response Body. 96func (client LocationClient) GetQuotasResponder(resp *http.Response) (result LocationQuota, err error) { 97 err = autorest.Respond( 98 resp, 99 client.ByInspecting(), 100 azure.WithErrorUnlessStatusCode(http.StatusOK), 101 autorest.ByUnmarshallingJSON(&result), 102 autorest.ByClosing()) 103 result.Response = autorest.Response{Response: resp} 104 return 105} 106