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 "github.com/Azure/go-autorest/autorest/date" 25 "github.com/Azure/go-autorest/autorest/validation" 26 "github.com/satori/go.uuid" 27 "net/http" 28) 29 30// AccountClient is the a client for issuing REST requests to the Azure Batch service. 31type AccountClient struct { 32 BaseClient 33} 34 35// NewAccountClient creates an instance of the AccountClient client. 36func NewAccountClient() AccountClient { 37 return NewAccountClientWithBaseURI(DefaultBaseURI) 38} 39 40// NewAccountClientWithBaseURI creates an instance of the AccountClient client. 41func NewAccountClientWithBaseURI(baseURI string) AccountClient { 42 return AccountClient{NewWithBaseURI(baseURI)} 43} 44 45// ListNodeAgentSkus sends the list node agent skus request. 46// 47// filter is an OData $filter clause. For more information on constructing this filter, see 48// https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-node-agent-skus. maxResults 49// is the maximum number of items to return in the response. A maximum of 1000 results will be returned. timeout is 50// the maximum time that the server can spend processing the request, in seconds. The default is 30 seconds. 51// clientRequestID is the caller-generated request identity, in the form of a GUID with no decoration such as curly 52// braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. returnClientRequestID is whether the server should return the 53// client-request-id in the response. ocpDate is the time the request was issued. Client libraries typically set 54// this to the current system clock time; set it explicitly if you are calling the REST API directly. 55func (client AccountClient) ListNodeAgentSkus(ctx context.Context, filter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result AccountListNodeAgentSkusResultPage, err error) { 56 if err := validation.Validate([]validation.Validation{ 57 {TargetValue: maxResults, 58 Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false, 59 Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil}, 60 {Target: "maxResults", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, 61 }}}}}); err != nil { 62 return result, validation.NewError("batch.AccountClient", "ListNodeAgentSkus", err.Error()) 63 } 64 65 result.fn = client.listNodeAgentSkusNextResults 66 req, err := client.ListNodeAgentSkusPreparer(ctx, filter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 67 if err != nil { 68 err = autorest.NewErrorWithError(err, "batch.AccountClient", "ListNodeAgentSkus", nil, "Failure preparing request") 69 return 70 } 71 72 resp, err := client.ListNodeAgentSkusSender(req) 73 if err != nil { 74 result.alnasr.Response = autorest.Response{Response: resp} 75 err = autorest.NewErrorWithError(err, "batch.AccountClient", "ListNodeAgentSkus", resp, "Failure sending request") 76 return 77 } 78 79 result.alnasr, err = client.ListNodeAgentSkusResponder(resp) 80 if err != nil { 81 err = autorest.NewErrorWithError(err, "batch.AccountClient", "ListNodeAgentSkus", resp, "Failure responding to request") 82 } 83 84 return 85} 86 87// ListNodeAgentSkusPreparer prepares the ListNodeAgentSkus request. 88func (client AccountClient) ListNodeAgentSkusPreparer(ctx context.Context, filter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 89 const APIVersion = "2017-09-01.6.0" 90 queryParameters := map[string]interface{}{ 91 "api-version": APIVersion, 92 } 93 if len(filter) > 0 { 94 queryParameters["$filter"] = autorest.Encode("query", filter) 95 } 96 if maxResults != nil { 97 queryParameters["maxresults"] = autorest.Encode("query", *maxResults) 98 } else { 99 queryParameters["maxresults"] = autorest.Encode("query", 1000) 100 } 101 if timeout != nil { 102 queryParameters["timeout"] = autorest.Encode("query", *timeout) 103 } else { 104 queryParameters["timeout"] = autorest.Encode("query", 30) 105 } 106 107 preparer := autorest.CreatePreparer( 108 autorest.AsGet(), 109 autorest.WithBaseURL(client.BaseURI), 110 autorest.WithPath("/nodeagentskus"), 111 autorest.WithQueryParameters(queryParameters)) 112 if clientRequestID != nil { 113 preparer = autorest.DecoratePreparer(preparer, 114 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 115 } 116 if returnClientRequestID != nil { 117 preparer = autorest.DecoratePreparer(preparer, 118 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 119 } else { 120 preparer = autorest.DecoratePreparer(preparer, 121 autorest.WithHeader("return-client-request-id", autorest.String(false))) 122 } 123 if ocpDate != nil { 124 preparer = autorest.DecoratePreparer(preparer, 125 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 126 } 127 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 128} 129 130// ListNodeAgentSkusSender sends the ListNodeAgentSkus request. The method will close the 131// http.Response Body if it receives an error. 132func (client AccountClient) ListNodeAgentSkusSender(req *http.Request) (*http.Response, error) { 133 return autorest.SendWithSender(client, req, 134 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 135} 136 137// ListNodeAgentSkusResponder handles the response to the ListNodeAgentSkus request. The method always 138// closes the http.Response Body. 139func (client AccountClient) ListNodeAgentSkusResponder(resp *http.Response) (result AccountListNodeAgentSkusResult, err error) { 140 err = autorest.Respond( 141 resp, 142 client.ByInspecting(), 143 azure.WithErrorUnlessStatusCode(http.StatusOK), 144 autorest.ByUnmarshallingJSON(&result), 145 autorest.ByClosing()) 146 result.Response = autorest.Response{Response: resp} 147 return 148} 149 150// listNodeAgentSkusNextResults retrieves the next set of results, if any. 151func (client AccountClient) listNodeAgentSkusNextResults(lastResults AccountListNodeAgentSkusResult) (result AccountListNodeAgentSkusResult, err error) { 152 req, err := lastResults.accountListNodeAgentSkusResultPreparer() 153 if err != nil { 154 return result, autorest.NewErrorWithError(err, "batch.AccountClient", "listNodeAgentSkusNextResults", nil, "Failure preparing next results request") 155 } 156 if req == nil { 157 return 158 } 159 resp, err := client.ListNodeAgentSkusSender(req) 160 if err != nil { 161 result.Response = autorest.Response{Response: resp} 162 return result, autorest.NewErrorWithError(err, "batch.AccountClient", "listNodeAgentSkusNextResults", resp, "Failure sending next results request") 163 } 164 result, err = client.ListNodeAgentSkusResponder(resp) 165 if err != nil { 166 err = autorest.NewErrorWithError(err, "batch.AccountClient", "listNodeAgentSkusNextResults", resp, "Failure responding to next results request") 167 } 168 return 169} 170 171// ListNodeAgentSkusComplete enumerates all values, automatically crossing page boundaries as required. 172func (client AccountClient) ListNodeAgentSkusComplete(ctx context.Context, filter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result AccountListNodeAgentSkusResultIterator, err error) { 173 result.page, err = client.ListNodeAgentSkus(ctx, filter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 174 return 175} 176