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/Azure/go-autorest/tracing" 27 "github.com/gofrs/uuid" 28 "net/http" 29) 30 31// PoolClient is the a client for issuing REST requests to the Azure Batch service. 32type PoolClient struct { 33 BaseClient 34} 35 36// NewPoolClient creates an instance of the PoolClient client. 37func NewPoolClient(batchURL string) PoolClient { 38 return PoolClient{New(batchURL)} 39} 40 41// Add when naming Pools, avoid including sensitive information such as user names or secret project names. This 42// information may appear in telemetry logs accessible to Microsoft Support engineers. 43// Parameters: 44// pool - the Pool to be added. 45// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 46// seconds. 47// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 48// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 49// returnClientRequestID - whether the server should return the client-request-id in the response. 50// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 51// time; set it explicitly if you are calling the REST API directly. 52func (client PoolClient) Add(ctx context.Context, pool PoolAddParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 53 if tracing.IsEnabled() { 54 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.Add") 55 defer func() { 56 sc := -1 57 if result.Response != nil { 58 sc = result.Response.StatusCode 59 } 60 tracing.EndSpan(ctx, sc, err) 61 }() 62 } 63 if err := validation.Validate([]validation.Validation{ 64 {TargetValue: pool, 65 Constraints: []validation.Constraint{{Target: "pool.ID", Name: validation.Null, Rule: true, Chain: nil}, 66 {Target: "pool.VMSize", Name: validation.Null, Rule: true, Chain: nil}, 67 {Target: "pool.CloudServiceConfiguration", Name: validation.Null, Rule: false, 68 Chain: []validation.Constraint{{Target: "pool.CloudServiceConfiguration.OsFamily", Name: validation.Null, Rule: true, Chain: nil}}}, 69 {Target: "pool.VirtualMachineConfiguration", Name: validation.Null, Rule: false, 70 Chain: []validation.Constraint{{Target: "pool.VirtualMachineConfiguration.ImageReference", Name: validation.Null, Rule: true, Chain: nil}, 71 {Target: "pool.VirtualMachineConfiguration.NodeAgentSKUID", Name: validation.Null, Rule: true, Chain: nil}, 72 {Target: "pool.VirtualMachineConfiguration.ContainerConfiguration", Name: validation.Null, Rule: false, 73 Chain: []validation.Constraint{{Target: "pool.VirtualMachineConfiguration.ContainerConfiguration.Type", Name: validation.Null, Rule: true, Chain: nil}}}, 74 }}, 75 {Target: "pool.NetworkConfiguration", Name: validation.Null, Rule: false, 76 Chain: []validation.Constraint{{Target: "pool.NetworkConfiguration.EndpointConfiguration", Name: validation.Null, Rule: false, 77 Chain: []validation.Constraint{{Target: "pool.NetworkConfiguration.EndpointConfiguration.InboundNATPools", Name: validation.Null, Rule: true, Chain: nil}}}, 78 }}, 79 {Target: "pool.StartTask", Name: validation.Null, Rule: false, 80 Chain: []validation.Constraint{{Target: "pool.StartTask.CommandLine", Name: validation.Null, Rule: true, Chain: nil}, 81 {Target: "pool.StartTask.ContainerSettings", Name: validation.Null, Rule: false, 82 Chain: []validation.Constraint{{Target: "pool.StartTask.ContainerSettings.ImageName", Name: validation.Null, Rule: true, Chain: nil}, 83 {Target: "pool.StartTask.ContainerSettings.Registry", Name: validation.Null, Rule: false, 84 Chain: []validation.Constraint{{Target: "pool.StartTask.ContainerSettings.Registry.UserName", Name: validation.Null, Rule: true, Chain: nil}, 85 {Target: "pool.StartTask.ContainerSettings.Registry.Password", Name: validation.Null, Rule: true, Chain: nil}, 86 }}, 87 }}, 88 }}}}}); err != nil { 89 return result, validation.NewError("batch.PoolClient", "Add", err.Error()) 90 } 91 92 req, err := client.AddPreparer(ctx, pool, timeout, clientRequestID, returnClientRequestID, ocpDate) 93 if err != nil { 94 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Add", nil, "Failure preparing request") 95 return 96 } 97 98 resp, err := client.AddSender(req) 99 if err != nil { 100 result.Response = resp 101 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Add", resp, "Failure sending request") 102 return 103 } 104 105 result, err = client.AddResponder(resp) 106 if err != nil { 107 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Add", resp, "Failure responding to request") 108 return 109 } 110 111 return 112} 113 114// AddPreparer prepares the Add request. 115func (client PoolClient) AddPreparer(ctx context.Context, pool PoolAddParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 116 urlParameters := map[string]interface{}{ 117 "batchUrl": client.BatchURL, 118 } 119 120 const APIVersion = "2019-08-01.10.0" 121 queryParameters := map[string]interface{}{ 122 "api-version": APIVersion, 123 } 124 if timeout != nil { 125 queryParameters["timeout"] = autorest.Encode("query", *timeout) 126 } else { 127 queryParameters["timeout"] = autorest.Encode("query", 30) 128 } 129 130 preparer := autorest.CreatePreparer( 131 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 132 autorest.AsPost(), 133 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 134 autorest.WithPath("/pools"), 135 autorest.WithJSON(pool), 136 autorest.WithQueryParameters(queryParameters)) 137 if clientRequestID != nil { 138 preparer = autorest.DecoratePreparer(preparer, 139 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 140 } 141 if returnClientRequestID != nil { 142 preparer = autorest.DecoratePreparer(preparer, 143 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 144 } else { 145 preparer = autorest.DecoratePreparer(preparer, 146 autorest.WithHeader("return-client-request-id", autorest.String(false))) 147 } 148 if ocpDate != nil { 149 preparer = autorest.DecoratePreparer(preparer, 150 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 151 } 152 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 153} 154 155// AddSender sends the Add request. The method will close the 156// http.Response Body if it receives an error. 157func (client PoolClient) AddSender(req *http.Request) (*http.Response, error) { 158 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 159} 160 161// AddResponder handles the response to the Add request. The method always 162// closes the http.Response Body. 163func (client PoolClient) AddResponder(resp *http.Response) (result autorest.Response, err error) { 164 err = autorest.Respond( 165 resp, 166 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 167 autorest.ByClosing()) 168 result.Response = resp 169 return 170} 171 172// Delete when you request that a Pool be deleted, the following actions occur: the Pool state is set to deleting; any 173// ongoing resize operation on the Pool are stopped; the Batch service starts resizing the Pool to zero Compute Nodes; 174// any Tasks running on existing Compute Nodes are terminated and requeued (as if a resize Pool operation had been 175// requested with the default requeue option); finally, the Pool is removed from the system. Because running Tasks are 176// requeued, the user can rerun these Tasks by updating their Job to target a different Pool. The Tasks can then run on 177// the new Pool. If you want to override the requeue behavior, then you should call resize Pool explicitly to shrink 178// the Pool to zero size before deleting the Pool. If you call an Update, Patch or Delete API on a Pool in the deleting 179// state, it will fail with HTTP status code 409 with error code PoolBeingDeleted. 180// Parameters: 181// poolID - the ID of the Pool to delete. 182// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 183// seconds. 184// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 185// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 186// returnClientRequestID - whether the server should return the client-request-id in the response. 187// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 188// time; set it explicitly if you are calling the REST API directly. 189// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will 190// be performed only if the resource's current ETag on the service exactly matches the value specified by the 191// client. 192// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation 193// will be performed only if the resource's current ETag on the service does not match the value specified by 194// the client. 195// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 196// operation will be performed only if the resource on the service has been modified since the specified time. 197// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 198// operation will be performed only if the resource on the service has not been modified since the specified 199// time. 200func (client PoolClient) Delete(ctx context.Context, poolID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) { 201 if tracing.IsEnabled() { 202 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.Delete") 203 defer func() { 204 sc := -1 205 if result.Response != nil { 206 sc = result.Response.StatusCode 207 } 208 tracing.EndSpan(ctx, sc, err) 209 }() 210 } 211 req, err := client.DeletePreparer(ctx, poolID, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince) 212 if err != nil { 213 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Delete", nil, "Failure preparing request") 214 return 215 } 216 217 resp, err := client.DeleteSender(req) 218 if err != nil { 219 result.Response = resp 220 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Delete", resp, "Failure sending request") 221 return 222 } 223 224 result, err = client.DeleteResponder(resp) 225 if err != nil { 226 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Delete", resp, "Failure responding to request") 227 return 228 } 229 230 return 231} 232 233// DeletePreparer prepares the Delete request. 234func (client PoolClient) DeletePreparer(ctx context.Context, poolID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) { 235 urlParameters := map[string]interface{}{ 236 "batchUrl": client.BatchURL, 237 } 238 239 pathParameters := map[string]interface{}{ 240 "poolId": autorest.Encode("path", poolID), 241 } 242 243 const APIVersion = "2019-08-01.10.0" 244 queryParameters := map[string]interface{}{ 245 "api-version": APIVersion, 246 } 247 if timeout != nil { 248 queryParameters["timeout"] = autorest.Encode("query", *timeout) 249 } else { 250 queryParameters["timeout"] = autorest.Encode("query", 30) 251 } 252 253 preparer := autorest.CreatePreparer( 254 autorest.AsDelete(), 255 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 256 autorest.WithPathParameters("/pools/{poolId}", pathParameters), 257 autorest.WithQueryParameters(queryParameters)) 258 if clientRequestID != nil { 259 preparer = autorest.DecoratePreparer(preparer, 260 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 261 } 262 if returnClientRequestID != nil { 263 preparer = autorest.DecoratePreparer(preparer, 264 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 265 } else { 266 preparer = autorest.DecoratePreparer(preparer, 267 autorest.WithHeader("return-client-request-id", autorest.String(false))) 268 } 269 if ocpDate != nil { 270 preparer = autorest.DecoratePreparer(preparer, 271 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 272 } 273 if len(ifMatch) > 0 { 274 preparer = autorest.DecoratePreparer(preparer, 275 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 276 } 277 if len(ifNoneMatch) > 0 { 278 preparer = autorest.DecoratePreparer(preparer, 279 autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) 280 } 281 if ifModifiedSince != nil { 282 preparer = autorest.DecoratePreparer(preparer, 283 autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince))) 284 } 285 if ifUnmodifiedSince != nil { 286 preparer = autorest.DecoratePreparer(preparer, 287 autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince))) 288 } 289 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 290} 291 292// DeleteSender sends the Delete request. The method will close the 293// http.Response Body if it receives an error. 294func (client PoolClient) DeleteSender(req *http.Request) (*http.Response, error) { 295 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 296} 297 298// DeleteResponder handles the response to the Delete request. The method always 299// closes the http.Response Body. 300func (client PoolClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 301 err = autorest.Respond( 302 resp, 303 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 304 autorest.ByClosing()) 305 result.Response = resp 306 return 307} 308 309// DisableAutoScale sends the disable auto scale request. 310// Parameters: 311// poolID - the ID of the Pool on which to disable automatic scaling. 312// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 313// seconds. 314// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 315// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 316// returnClientRequestID - whether the server should return the client-request-id in the response. 317// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 318// time; set it explicitly if you are calling the REST API directly. 319func (client PoolClient) DisableAutoScale(ctx context.Context, poolID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 320 if tracing.IsEnabled() { 321 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.DisableAutoScale") 322 defer func() { 323 sc := -1 324 if result.Response != nil { 325 sc = result.Response.StatusCode 326 } 327 tracing.EndSpan(ctx, sc, err) 328 }() 329 } 330 req, err := client.DisableAutoScalePreparer(ctx, poolID, timeout, clientRequestID, returnClientRequestID, ocpDate) 331 if err != nil { 332 err = autorest.NewErrorWithError(err, "batch.PoolClient", "DisableAutoScale", nil, "Failure preparing request") 333 return 334 } 335 336 resp, err := client.DisableAutoScaleSender(req) 337 if err != nil { 338 result.Response = resp 339 err = autorest.NewErrorWithError(err, "batch.PoolClient", "DisableAutoScale", resp, "Failure sending request") 340 return 341 } 342 343 result, err = client.DisableAutoScaleResponder(resp) 344 if err != nil { 345 err = autorest.NewErrorWithError(err, "batch.PoolClient", "DisableAutoScale", resp, "Failure responding to request") 346 return 347 } 348 349 return 350} 351 352// DisableAutoScalePreparer prepares the DisableAutoScale request. 353func (client PoolClient) DisableAutoScalePreparer(ctx context.Context, poolID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 354 urlParameters := map[string]interface{}{ 355 "batchUrl": client.BatchURL, 356 } 357 358 pathParameters := map[string]interface{}{ 359 "poolId": autorest.Encode("path", poolID), 360 } 361 362 const APIVersion = "2019-08-01.10.0" 363 queryParameters := map[string]interface{}{ 364 "api-version": APIVersion, 365 } 366 if timeout != nil { 367 queryParameters["timeout"] = autorest.Encode("query", *timeout) 368 } else { 369 queryParameters["timeout"] = autorest.Encode("query", 30) 370 } 371 372 preparer := autorest.CreatePreparer( 373 autorest.AsPost(), 374 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 375 autorest.WithPathParameters("/pools/{poolId}/disableautoscale", pathParameters), 376 autorest.WithQueryParameters(queryParameters)) 377 if clientRequestID != nil { 378 preparer = autorest.DecoratePreparer(preparer, 379 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 380 } 381 if returnClientRequestID != nil { 382 preparer = autorest.DecoratePreparer(preparer, 383 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 384 } else { 385 preparer = autorest.DecoratePreparer(preparer, 386 autorest.WithHeader("return-client-request-id", autorest.String(false))) 387 } 388 if ocpDate != nil { 389 preparer = autorest.DecoratePreparer(preparer, 390 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 391 } 392 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 393} 394 395// DisableAutoScaleSender sends the DisableAutoScale request. The method will close the 396// http.Response Body if it receives an error. 397func (client PoolClient) DisableAutoScaleSender(req *http.Request) (*http.Response, error) { 398 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 399} 400 401// DisableAutoScaleResponder handles the response to the DisableAutoScale request. The method always 402// closes the http.Response Body. 403func (client PoolClient) DisableAutoScaleResponder(resp *http.Response) (result autorest.Response, err error) { 404 err = autorest.Respond( 405 resp, 406 azure.WithErrorUnlessStatusCode(http.StatusOK), 407 autorest.ByClosing()) 408 result.Response = resp 409 return 410} 411 412// EnableAutoScale you cannot enable automatic scaling on a Pool if a resize operation is in progress on the Pool. If 413// automatic scaling of the Pool is currently disabled, you must specify a valid autoscale formula as part of the 414// request. If automatic scaling of the Pool is already enabled, you may specify a new autoscale formula and/or a new 415// evaluation interval. You cannot call this API for the same Pool more than once every 30 seconds. 416// Parameters: 417// poolID - the ID of the Pool on which to enable automatic scaling. 418// poolEnableAutoScaleParameter - the parameters for the request. 419// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 420// seconds. 421// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 422// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 423// returnClientRequestID - whether the server should return the client-request-id in the response. 424// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 425// time; set it explicitly if you are calling the REST API directly. 426// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will 427// be performed only if the resource's current ETag on the service exactly matches the value specified by the 428// client. 429// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation 430// will be performed only if the resource's current ETag on the service does not match the value specified by 431// the client. 432// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 433// operation will be performed only if the resource on the service has been modified since the specified time. 434// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 435// operation will be performed only if the resource on the service has not been modified since the specified 436// time. 437func (client PoolClient) EnableAutoScale(ctx context.Context, poolID string, poolEnableAutoScaleParameter PoolEnableAutoScaleParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) { 438 if tracing.IsEnabled() { 439 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.EnableAutoScale") 440 defer func() { 441 sc := -1 442 if result.Response != nil { 443 sc = result.Response.StatusCode 444 } 445 tracing.EndSpan(ctx, sc, err) 446 }() 447 } 448 req, err := client.EnableAutoScalePreparer(ctx, poolID, poolEnableAutoScaleParameter, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince) 449 if err != nil { 450 err = autorest.NewErrorWithError(err, "batch.PoolClient", "EnableAutoScale", nil, "Failure preparing request") 451 return 452 } 453 454 resp, err := client.EnableAutoScaleSender(req) 455 if err != nil { 456 result.Response = resp 457 err = autorest.NewErrorWithError(err, "batch.PoolClient", "EnableAutoScale", resp, "Failure sending request") 458 return 459 } 460 461 result, err = client.EnableAutoScaleResponder(resp) 462 if err != nil { 463 err = autorest.NewErrorWithError(err, "batch.PoolClient", "EnableAutoScale", resp, "Failure responding to request") 464 return 465 } 466 467 return 468} 469 470// EnableAutoScalePreparer prepares the EnableAutoScale request. 471func (client PoolClient) EnableAutoScalePreparer(ctx context.Context, poolID string, poolEnableAutoScaleParameter PoolEnableAutoScaleParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) { 472 urlParameters := map[string]interface{}{ 473 "batchUrl": client.BatchURL, 474 } 475 476 pathParameters := map[string]interface{}{ 477 "poolId": autorest.Encode("path", poolID), 478 } 479 480 const APIVersion = "2019-08-01.10.0" 481 queryParameters := map[string]interface{}{ 482 "api-version": APIVersion, 483 } 484 if timeout != nil { 485 queryParameters["timeout"] = autorest.Encode("query", *timeout) 486 } else { 487 queryParameters["timeout"] = autorest.Encode("query", 30) 488 } 489 490 preparer := autorest.CreatePreparer( 491 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 492 autorest.AsPost(), 493 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 494 autorest.WithPathParameters("/pools/{poolId}/enableautoscale", pathParameters), 495 autorest.WithJSON(poolEnableAutoScaleParameter), 496 autorest.WithQueryParameters(queryParameters)) 497 if clientRequestID != nil { 498 preparer = autorest.DecoratePreparer(preparer, 499 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 500 } 501 if returnClientRequestID != nil { 502 preparer = autorest.DecoratePreparer(preparer, 503 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 504 } else { 505 preparer = autorest.DecoratePreparer(preparer, 506 autorest.WithHeader("return-client-request-id", autorest.String(false))) 507 } 508 if ocpDate != nil { 509 preparer = autorest.DecoratePreparer(preparer, 510 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 511 } 512 if len(ifMatch) > 0 { 513 preparer = autorest.DecoratePreparer(preparer, 514 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 515 } 516 if len(ifNoneMatch) > 0 { 517 preparer = autorest.DecoratePreparer(preparer, 518 autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) 519 } 520 if ifModifiedSince != nil { 521 preparer = autorest.DecoratePreparer(preparer, 522 autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince))) 523 } 524 if ifUnmodifiedSince != nil { 525 preparer = autorest.DecoratePreparer(preparer, 526 autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince))) 527 } 528 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 529} 530 531// EnableAutoScaleSender sends the EnableAutoScale request. The method will close the 532// http.Response Body if it receives an error. 533func (client PoolClient) EnableAutoScaleSender(req *http.Request) (*http.Response, error) { 534 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 535} 536 537// EnableAutoScaleResponder handles the response to the EnableAutoScale request. The method always 538// closes the http.Response Body. 539func (client PoolClient) EnableAutoScaleResponder(resp *http.Response) (result autorest.Response, err error) { 540 err = autorest.Respond( 541 resp, 542 azure.WithErrorUnlessStatusCode(http.StatusOK), 543 autorest.ByClosing()) 544 result.Response = resp 545 return 546} 547 548// EvaluateAutoScale this API is primarily for validating an autoscale formula, as it simply returns the result without 549// applying the formula to the Pool. The Pool must have auto scaling enabled in order to evaluate a formula. 550// Parameters: 551// poolID - the ID of the Pool on which to evaluate the automatic scaling formula. 552// poolEvaluateAutoScaleParameter - the parameters for the request. 553// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 554// seconds. 555// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 556// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 557// returnClientRequestID - whether the server should return the client-request-id in the response. 558// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 559// time; set it explicitly if you are calling the REST API directly. 560func (client PoolClient) EvaluateAutoScale(ctx context.Context, poolID string, poolEvaluateAutoScaleParameter PoolEvaluateAutoScaleParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result AutoScaleRun, err error) { 561 if tracing.IsEnabled() { 562 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.EvaluateAutoScale") 563 defer func() { 564 sc := -1 565 if result.Response.Response != nil { 566 sc = result.Response.Response.StatusCode 567 } 568 tracing.EndSpan(ctx, sc, err) 569 }() 570 } 571 if err := validation.Validate([]validation.Validation{ 572 {TargetValue: poolEvaluateAutoScaleParameter, 573 Constraints: []validation.Constraint{{Target: "poolEvaluateAutoScaleParameter.AutoScaleFormula", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 574 return result, validation.NewError("batch.PoolClient", "EvaluateAutoScale", err.Error()) 575 } 576 577 req, err := client.EvaluateAutoScalePreparer(ctx, poolID, poolEvaluateAutoScaleParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 578 if err != nil { 579 err = autorest.NewErrorWithError(err, "batch.PoolClient", "EvaluateAutoScale", nil, "Failure preparing request") 580 return 581 } 582 583 resp, err := client.EvaluateAutoScaleSender(req) 584 if err != nil { 585 result.Response = autorest.Response{Response: resp} 586 err = autorest.NewErrorWithError(err, "batch.PoolClient", "EvaluateAutoScale", resp, "Failure sending request") 587 return 588 } 589 590 result, err = client.EvaluateAutoScaleResponder(resp) 591 if err != nil { 592 err = autorest.NewErrorWithError(err, "batch.PoolClient", "EvaluateAutoScale", resp, "Failure responding to request") 593 return 594 } 595 596 return 597} 598 599// EvaluateAutoScalePreparer prepares the EvaluateAutoScale request. 600func (client PoolClient) EvaluateAutoScalePreparer(ctx context.Context, poolID string, poolEvaluateAutoScaleParameter PoolEvaluateAutoScaleParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 601 urlParameters := map[string]interface{}{ 602 "batchUrl": client.BatchURL, 603 } 604 605 pathParameters := map[string]interface{}{ 606 "poolId": autorest.Encode("path", poolID), 607 } 608 609 const APIVersion = "2019-08-01.10.0" 610 queryParameters := map[string]interface{}{ 611 "api-version": APIVersion, 612 } 613 if timeout != nil { 614 queryParameters["timeout"] = autorest.Encode("query", *timeout) 615 } else { 616 queryParameters["timeout"] = autorest.Encode("query", 30) 617 } 618 619 preparer := autorest.CreatePreparer( 620 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 621 autorest.AsPost(), 622 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 623 autorest.WithPathParameters("/pools/{poolId}/evaluateautoscale", pathParameters), 624 autorest.WithJSON(poolEvaluateAutoScaleParameter), 625 autorest.WithQueryParameters(queryParameters)) 626 if clientRequestID != nil { 627 preparer = autorest.DecoratePreparer(preparer, 628 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 629 } 630 if returnClientRequestID != nil { 631 preparer = autorest.DecoratePreparer(preparer, 632 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 633 } else { 634 preparer = autorest.DecoratePreparer(preparer, 635 autorest.WithHeader("return-client-request-id", autorest.String(false))) 636 } 637 if ocpDate != nil { 638 preparer = autorest.DecoratePreparer(preparer, 639 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 640 } 641 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 642} 643 644// EvaluateAutoScaleSender sends the EvaluateAutoScale request. The method will close the 645// http.Response Body if it receives an error. 646func (client PoolClient) EvaluateAutoScaleSender(req *http.Request) (*http.Response, error) { 647 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 648} 649 650// EvaluateAutoScaleResponder handles the response to the EvaluateAutoScale request. The method always 651// closes the http.Response Body. 652func (client PoolClient) EvaluateAutoScaleResponder(resp *http.Response) (result AutoScaleRun, err error) { 653 err = autorest.Respond( 654 resp, 655 azure.WithErrorUnlessStatusCode(http.StatusOK), 656 autorest.ByUnmarshallingJSON(&result), 657 autorest.ByClosing()) 658 result.Response = autorest.Response{Response: resp} 659 return 660} 661 662// Exists gets basic properties of a Pool. 663// Parameters: 664// poolID - the ID of the Pool to get. 665// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 666// seconds. 667// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 668// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 669// returnClientRequestID - whether the server should return the client-request-id in the response. 670// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 671// time; set it explicitly if you are calling the REST API directly. 672// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will 673// be performed only if the resource's current ETag on the service exactly matches the value specified by the 674// client. 675// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation 676// will be performed only if the resource's current ETag on the service does not match the value specified by 677// the client. 678// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 679// operation will be performed only if the resource on the service has been modified since the specified time. 680// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 681// operation will be performed only if the resource on the service has not been modified since the specified 682// time. 683func (client PoolClient) Exists(ctx context.Context, poolID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) { 684 if tracing.IsEnabled() { 685 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.Exists") 686 defer func() { 687 sc := -1 688 if result.Response != nil { 689 sc = result.Response.StatusCode 690 } 691 tracing.EndSpan(ctx, sc, err) 692 }() 693 } 694 req, err := client.ExistsPreparer(ctx, poolID, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince) 695 if err != nil { 696 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Exists", nil, "Failure preparing request") 697 return 698 } 699 700 resp, err := client.ExistsSender(req) 701 if err != nil { 702 result.Response = resp 703 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Exists", resp, "Failure sending request") 704 return 705 } 706 707 result, err = client.ExistsResponder(resp) 708 if err != nil { 709 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Exists", resp, "Failure responding to request") 710 return 711 } 712 713 return 714} 715 716// ExistsPreparer prepares the Exists request. 717func (client PoolClient) ExistsPreparer(ctx context.Context, poolID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) { 718 urlParameters := map[string]interface{}{ 719 "batchUrl": client.BatchURL, 720 } 721 722 pathParameters := map[string]interface{}{ 723 "poolId": autorest.Encode("path", poolID), 724 } 725 726 const APIVersion = "2019-08-01.10.0" 727 queryParameters := map[string]interface{}{ 728 "api-version": APIVersion, 729 } 730 if timeout != nil { 731 queryParameters["timeout"] = autorest.Encode("query", *timeout) 732 } else { 733 queryParameters["timeout"] = autorest.Encode("query", 30) 734 } 735 736 preparer := autorest.CreatePreparer( 737 autorest.AsHead(), 738 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 739 autorest.WithPathParameters("/pools/{poolId}", pathParameters), 740 autorest.WithQueryParameters(queryParameters)) 741 if clientRequestID != nil { 742 preparer = autorest.DecoratePreparer(preparer, 743 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 744 } 745 if returnClientRequestID != nil { 746 preparer = autorest.DecoratePreparer(preparer, 747 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 748 } else { 749 preparer = autorest.DecoratePreparer(preparer, 750 autorest.WithHeader("return-client-request-id", autorest.String(false))) 751 } 752 if ocpDate != nil { 753 preparer = autorest.DecoratePreparer(preparer, 754 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 755 } 756 if len(ifMatch) > 0 { 757 preparer = autorest.DecoratePreparer(preparer, 758 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 759 } 760 if len(ifNoneMatch) > 0 { 761 preparer = autorest.DecoratePreparer(preparer, 762 autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) 763 } 764 if ifModifiedSince != nil { 765 preparer = autorest.DecoratePreparer(preparer, 766 autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince))) 767 } 768 if ifUnmodifiedSince != nil { 769 preparer = autorest.DecoratePreparer(preparer, 770 autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince))) 771 } 772 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 773} 774 775// ExistsSender sends the Exists request. The method will close the 776// http.Response Body if it receives an error. 777func (client PoolClient) ExistsSender(req *http.Request) (*http.Response, error) { 778 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 779} 780 781// ExistsResponder handles the response to the Exists request. The method always 782// closes the http.Response Body. 783func (client PoolClient) ExistsResponder(resp *http.Response) (result autorest.Response, err error) { 784 err = autorest.Respond( 785 resp, 786 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), 787 autorest.ByClosing()) 788 result.Response = resp 789 return 790} 791 792// Get gets information about the specified Pool. 793// Parameters: 794// poolID - the ID of the Pool to get. 795// selectParameter - an OData $select clause. 796// expand - an OData $expand clause. 797// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 798// seconds. 799// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 800// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 801// returnClientRequestID - whether the server should return the client-request-id in the response. 802// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 803// time; set it explicitly if you are calling the REST API directly. 804// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will 805// be performed only if the resource's current ETag on the service exactly matches the value specified by the 806// client. 807// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation 808// will be performed only if the resource's current ETag on the service does not match the value specified by 809// the client. 810// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 811// operation will be performed only if the resource on the service has been modified since the specified time. 812// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 813// operation will be performed only if the resource on the service has not been modified since the specified 814// time. 815func (client PoolClient) Get(ctx context.Context, poolID string, selectParameter string, expand string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result CloudPool, err error) { 816 if tracing.IsEnabled() { 817 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.Get") 818 defer func() { 819 sc := -1 820 if result.Response.Response != nil { 821 sc = result.Response.Response.StatusCode 822 } 823 tracing.EndSpan(ctx, sc, err) 824 }() 825 } 826 req, err := client.GetPreparer(ctx, poolID, selectParameter, expand, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince) 827 if err != nil { 828 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Get", nil, "Failure preparing request") 829 return 830 } 831 832 resp, err := client.GetSender(req) 833 if err != nil { 834 result.Response = autorest.Response{Response: resp} 835 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Get", resp, "Failure sending request") 836 return 837 } 838 839 result, err = client.GetResponder(resp) 840 if err != nil { 841 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Get", resp, "Failure responding to request") 842 return 843 } 844 845 return 846} 847 848// GetPreparer prepares the Get request. 849func (client PoolClient) GetPreparer(ctx context.Context, poolID string, selectParameter string, expand string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) { 850 urlParameters := map[string]interface{}{ 851 "batchUrl": client.BatchURL, 852 } 853 854 pathParameters := map[string]interface{}{ 855 "poolId": autorest.Encode("path", poolID), 856 } 857 858 const APIVersion = "2019-08-01.10.0" 859 queryParameters := map[string]interface{}{ 860 "api-version": APIVersion, 861 } 862 if len(selectParameter) > 0 { 863 queryParameters["$select"] = autorest.Encode("query", selectParameter) 864 } 865 if len(expand) > 0 { 866 queryParameters["$expand"] = autorest.Encode("query", expand) 867 } 868 if timeout != nil { 869 queryParameters["timeout"] = autorest.Encode("query", *timeout) 870 } else { 871 queryParameters["timeout"] = autorest.Encode("query", 30) 872 } 873 874 preparer := autorest.CreatePreparer( 875 autorest.AsGet(), 876 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 877 autorest.WithPathParameters("/pools/{poolId}", pathParameters), 878 autorest.WithQueryParameters(queryParameters)) 879 if clientRequestID != nil { 880 preparer = autorest.DecoratePreparer(preparer, 881 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 882 } 883 if returnClientRequestID != nil { 884 preparer = autorest.DecoratePreparer(preparer, 885 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 886 } else { 887 preparer = autorest.DecoratePreparer(preparer, 888 autorest.WithHeader("return-client-request-id", autorest.String(false))) 889 } 890 if ocpDate != nil { 891 preparer = autorest.DecoratePreparer(preparer, 892 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 893 } 894 if len(ifMatch) > 0 { 895 preparer = autorest.DecoratePreparer(preparer, 896 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 897 } 898 if len(ifNoneMatch) > 0 { 899 preparer = autorest.DecoratePreparer(preparer, 900 autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) 901 } 902 if ifModifiedSince != nil { 903 preparer = autorest.DecoratePreparer(preparer, 904 autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince))) 905 } 906 if ifUnmodifiedSince != nil { 907 preparer = autorest.DecoratePreparer(preparer, 908 autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince))) 909 } 910 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 911} 912 913// GetSender sends the Get request. The method will close the 914// http.Response Body if it receives an error. 915func (client PoolClient) GetSender(req *http.Request) (*http.Response, error) { 916 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 917} 918 919// GetResponder handles the response to the Get request. The method always 920// closes the http.Response Body. 921func (client PoolClient) GetResponder(resp *http.Response) (result CloudPool, err error) { 922 err = autorest.Respond( 923 resp, 924 azure.WithErrorUnlessStatusCode(http.StatusOK), 925 autorest.ByUnmarshallingJSON(&result), 926 autorest.ByClosing()) 927 result.Response = autorest.Response{Response: resp} 928 return 929} 930 931// GetAllLifetimeStatistics statistics are aggregated across all Pools that have ever existed in the Account, from 932// Account creation to the last update time of the statistics. The statistics may not be immediately available. The 933// Batch service performs periodic roll-up of statistics. The typical delay is about 30 minutes. 934// Parameters: 935// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 936// seconds. 937// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 938// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 939// returnClientRequestID - whether the server should return the client-request-id in the response. 940// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 941// time; set it explicitly if you are calling the REST API directly. 942func (client PoolClient) GetAllLifetimeStatistics(ctx context.Context, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result PoolStatistics, err error) { 943 if tracing.IsEnabled() { 944 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.GetAllLifetimeStatistics") 945 defer func() { 946 sc := -1 947 if result.Response.Response != nil { 948 sc = result.Response.Response.StatusCode 949 } 950 tracing.EndSpan(ctx, sc, err) 951 }() 952 } 953 req, err := client.GetAllLifetimeStatisticsPreparer(ctx, timeout, clientRequestID, returnClientRequestID, ocpDate) 954 if err != nil { 955 err = autorest.NewErrorWithError(err, "batch.PoolClient", "GetAllLifetimeStatistics", nil, "Failure preparing request") 956 return 957 } 958 959 resp, err := client.GetAllLifetimeStatisticsSender(req) 960 if err != nil { 961 result.Response = autorest.Response{Response: resp} 962 err = autorest.NewErrorWithError(err, "batch.PoolClient", "GetAllLifetimeStatistics", resp, "Failure sending request") 963 return 964 } 965 966 result, err = client.GetAllLifetimeStatisticsResponder(resp) 967 if err != nil { 968 err = autorest.NewErrorWithError(err, "batch.PoolClient", "GetAllLifetimeStatistics", resp, "Failure responding to request") 969 return 970 } 971 972 return 973} 974 975// GetAllLifetimeStatisticsPreparer prepares the GetAllLifetimeStatistics request. 976func (client PoolClient) GetAllLifetimeStatisticsPreparer(ctx context.Context, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 977 urlParameters := map[string]interface{}{ 978 "batchUrl": client.BatchURL, 979 } 980 981 const APIVersion = "2019-08-01.10.0" 982 queryParameters := map[string]interface{}{ 983 "api-version": APIVersion, 984 } 985 if timeout != nil { 986 queryParameters["timeout"] = autorest.Encode("query", *timeout) 987 } else { 988 queryParameters["timeout"] = autorest.Encode("query", 30) 989 } 990 991 preparer := autorest.CreatePreparer( 992 autorest.AsGet(), 993 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 994 autorest.WithPath("/lifetimepoolstats"), 995 autorest.WithQueryParameters(queryParameters)) 996 if clientRequestID != nil { 997 preparer = autorest.DecoratePreparer(preparer, 998 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 999 } 1000 if returnClientRequestID != nil { 1001 preparer = autorest.DecoratePreparer(preparer, 1002 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1003 } else { 1004 preparer = autorest.DecoratePreparer(preparer, 1005 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1006 } 1007 if ocpDate != nil { 1008 preparer = autorest.DecoratePreparer(preparer, 1009 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1010 } 1011 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1012} 1013 1014// GetAllLifetimeStatisticsSender sends the GetAllLifetimeStatistics request. The method will close the 1015// http.Response Body if it receives an error. 1016func (client PoolClient) GetAllLifetimeStatisticsSender(req *http.Request) (*http.Response, error) { 1017 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1018} 1019 1020// GetAllLifetimeStatisticsResponder handles the response to the GetAllLifetimeStatistics request. The method always 1021// closes the http.Response Body. 1022func (client PoolClient) GetAllLifetimeStatisticsResponder(resp *http.Response) (result PoolStatistics, err error) { 1023 err = autorest.Respond( 1024 resp, 1025 azure.WithErrorUnlessStatusCode(http.StatusOK), 1026 autorest.ByUnmarshallingJSON(&result), 1027 autorest.ByClosing()) 1028 result.Response = autorest.Response{Response: resp} 1029 return 1030} 1031 1032// List sends the list request. 1033// Parameters: 1034// filter - an OData $filter clause. For more information on constructing this filter, see 1035// https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-pools. 1036// selectParameter - an OData $select clause. 1037// expand - an OData $expand clause. 1038// maxResults - the maximum number of items to return in the response. A maximum of 1000 Pools can be returned. 1039// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 1040// seconds. 1041// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 1042// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 1043// returnClientRequestID - whether the server should return the client-request-id in the response. 1044// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 1045// time; set it explicitly if you are calling the REST API directly. 1046func (client PoolClient) List(ctx context.Context, filter string, selectParameter string, expand string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CloudPoolListResultPage, err error) { 1047 if tracing.IsEnabled() { 1048 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.List") 1049 defer func() { 1050 sc := -1 1051 if result.cplr.Response.Response != nil { 1052 sc = result.cplr.Response.Response.StatusCode 1053 } 1054 tracing.EndSpan(ctx, sc, err) 1055 }() 1056 } 1057 if err := validation.Validate([]validation.Validation{ 1058 {TargetValue: maxResults, 1059 Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false, 1060 Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 1061 {Target: "maxResults", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 1062 }}}}}); err != nil { 1063 return result, validation.NewError("batch.PoolClient", "List", err.Error()) 1064 } 1065 1066 result.fn = client.listNextResults 1067 req, err := client.ListPreparer(ctx, filter, selectParameter, expand, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 1068 if err != nil { 1069 err = autorest.NewErrorWithError(err, "batch.PoolClient", "List", nil, "Failure preparing request") 1070 return 1071 } 1072 1073 resp, err := client.ListSender(req) 1074 if err != nil { 1075 result.cplr.Response = autorest.Response{Response: resp} 1076 err = autorest.NewErrorWithError(err, "batch.PoolClient", "List", resp, "Failure sending request") 1077 return 1078 } 1079 1080 result.cplr, err = client.ListResponder(resp) 1081 if err != nil { 1082 err = autorest.NewErrorWithError(err, "batch.PoolClient", "List", resp, "Failure responding to request") 1083 return 1084 } 1085 if result.cplr.hasNextLink() && result.cplr.IsEmpty() { 1086 err = result.NextWithContext(ctx) 1087 return 1088 } 1089 1090 return 1091} 1092 1093// ListPreparer prepares the List request. 1094func (client PoolClient) ListPreparer(ctx context.Context, filter string, selectParameter string, expand string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 1095 urlParameters := map[string]interface{}{ 1096 "batchUrl": client.BatchURL, 1097 } 1098 1099 const APIVersion = "2019-08-01.10.0" 1100 queryParameters := map[string]interface{}{ 1101 "api-version": APIVersion, 1102 } 1103 if len(filter) > 0 { 1104 queryParameters["$filter"] = autorest.Encode("query", filter) 1105 } 1106 if len(selectParameter) > 0 { 1107 queryParameters["$select"] = autorest.Encode("query", selectParameter) 1108 } 1109 if len(expand) > 0 { 1110 queryParameters["$expand"] = autorest.Encode("query", expand) 1111 } 1112 if maxResults != nil { 1113 queryParameters["maxresults"] = autorest.Encode("query", *maxResults) 1114 } else { 1115 queryParameters["maxresults"] = autorest.Encode("query", 1000) 1116 } 1117 if timeout != nil { 1118 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1119 } else { 1120 queryParameters["timeout"] = autorest.Encode("query", 30) 1121 } 1122 1123 preparer := autorest.CreatePreparer( 1124 autorest.AsGet(), 1125 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 1126 autorest.WithPath("/pools"), 1127 autorest.WithQueryParameters(queryParameters)) 1128 if clientRequestID != nil { 1129 preparer = autorest.DecoratePreparer(preparer, 1130 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1131 } 1132 if returnClientRequestID != nil { 1133 preparer = autorest.DecoratePreparer(preparer, 1134 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1135 } else { 1136 preparer = autorest.DecoratePreparer(preparer, 1137 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1138 } 1139 if ocpDate != nil { 1140 preparer = autorest.DecoratePreparer(preparer, 1141 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1142 } 1143 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1144} 1145 1146// ListSender sends the List request. The method will close the 1147// http.Response Body if it receives an error. 1148func (client PoolClient) ListSender(req *http.Request) (*http.Response, error) { 1149 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1150} 1151 1152// ListResponder handles the response to the List request. The method always 1153// closes the http.Response Body. 1154func (client PoolClient) ListResponder(resp *http.Response) (result CloudPoolListResult, err error) { 1155 err = autorest.Respond( 1156 resp, 1157 azure.WithErrorUnlessStatusCode(http.StatusOK), 1158 autorest.ByUnmarshallingJSON(&result), 1159 autorest.ByClosing()) 1160 result.Response = autorest.Response{Response: resp} 1161 return 1162} 1163 1164// listNextResults retrieves the next set of results, if any. 1165func (client PoolClient) listNextResults(ctx context.Context, lastResults CloudPoolListResult) (result CloudPoolListResult, err error) { 1166 req, err := lastResults.cloudPoolListResultPreparer(ctx) 1167 if err != nil { 1168 return result, autorest.NewErrorWithError(err, "batch.PoolClient", "listNextResults", nil, "Failure preparing next results request") 1169 } 1170 if req == nil { 1171 return 1172 } 1173 resp, err := client.ListSender(req) 1174 if err != nil { 1175 result.Response = autorest.Response{Response: resp} 1176 return result, autorest.NewErrorWithError(err, "batch.PoolClient", "listNextResults", resp, "Failure sending next results request") 1177 } 1178 result, err = client.ListResponder(resp) 1179 if err != nil { 1180 err = autorest.NewErrorWithError(err, "batch.PoolClient", "listNextResults", resp, "Failure responding to next results request") 1181 } 1182 return 1183} 1184 1185// ListComplete enumerates all values, automatically crossing page boundaries as required. 1186func (client PoolClient) ListComplete(ctx context.Context, filter string, selectParameter string, expand string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CloudPoolListResultIterator, err error) { 1187 if tracing.IsEnabled() { 1188 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.List") 1189 defer func() { 1190 sc := -1 1191 if result.Response().Response.Response != nil { 1192 sc = result.page.Response().Response.Response.StatusCode 1193 } 1194 tracing.EndSpan(ctx, sc, err) 1195 }() 1196 } 1197 result.page, err = client.List(ctx, filter, selectParameter, expand, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 1198 return 1199} 1200 1201// ListUsageMetrics if you do not specify a $filter clause including a poolId, the response includes all Pools that 1202// existed in the Account in the time range of the returned aggregation intervals. If you do not specify a $filter 1203// clause including a startTime or endTime these filters default to the start and end times of the last aggregation 1204// interval currently available; that is, only the last aggregation interval is returned. 1205// Parameters: 1206// startTime - the earliest time from which to include metrics. This must be at least two and a half hours 1207// before the current time. If not specified this defaults to the start time of the last aggregation interval 1208// currently available. 1209// endTime - the latest time from which to include metrics. This must be at least two hours before the current 1210// time. If not specified this defaults to the end time of the last aggregation interval currently available. 1211// filter - an OData $filter clause. For more information on constructing this filter, see 1212// https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-account-usage-metrics. 1213// maxResults - the maximum number of items to return in the response. A maximum of 1000 results will be 1214// returned. 1215// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 1216// seconds. 1217// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 1218// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 1219// returnClientRequestID - whether the server should return the client-request-id in the response. 1220// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 1221// time; set it explicitly if you are calling the REST API directly. 1222func (client PoolClient) ListUsageMetrics(ctx context.Context, startTime *date.Time, endTime *date.Time, filter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result PoolListUsageMetricsResultPage, err error) { 1223 if tracing.IsEnabled() { 1224 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.ListUsageMetrics") 1225 defer func() { 1226 sc := -1 1227 if result.plumr.Response.Response != nil { 1228 sc = result.plumr.Response.Response.StatusCode 1229 } 1230 tracing.EndSpan(ctx, sc, err) 1231 }() 1232 } 1233 if err := validation.Validate([]validation.Validation{ 1234 {TargetValue: maxResults, 1235 Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false, 1236 Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 1237 {Target: "maxResults", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 1238 }}}}}); err != nil { 1239 return result, validation.NewError("batch.PoolClient", "ListUsageMetrics", err.Error()) 1240 } 1241 1242 result.fn = client.listUsageMetricsNextResults 1243 req, err := client.ListUsageMetricsPreparer(ctx, startTime, endTime, filter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 1244 if err != nil { 1245 err = autorest.NewErrorWithError(err, "batch.PoolClient", "ListUsageMetrics", nil, "Failure preparing request") 1246 return 1247 } 1248 1249 resp, err := client.ListUsageMetricsSender(req) 1250 if err != nil { 1251 result.plumr.Response = autorest.Response{Response: resp} 1252 err = autorest.NewErrorWithError(err, "batch.PoolClient", "ListUsageMetrics", resp, "Failure sending request") 1253 return 1254 } 1255 1256 result.plumr, err = client.ListUsageMetricsResponder(resp) 1257 if err != nil { 1258 err = autorest.NewErrorWithError(err, "batch.PoolClient", "ListUsageMetrics", resp, "Failure responding to request") 1259 return 1260 } 1261 if result.plumr.hasNextLink() && result.plumr.IsEmpty() { 1262 err = result.NextWithContext(ctx) 1263 return 1264 } 1265 1266 return 1267} 1268 1269// ListUsageMetricsPreparer prepares the ListUsageMetrics request. 1270func (client PoolClient) ListUsageMetricsPreparer(ctx context.Context, startTime *date.Time, endTime *date.Time, filter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 1271 urlParameters := map[string]interface{}{ 1272 "batchUrl": client.BatchURL, 1273 } 1274 1275 const APIVersion = "2019-08-01.10.0" 1276 queryParameters := map[string]interface{}{ 1277 "api-version": APIVersion, 1278 } 1279 if startTime != nil { 1280 queryParameters["starttime"] = autorest.Encode("query", *startTime) 1281 } 1282 if endTime != nil { 1283 queryParameters["endtime"] = autorest.Encode("query", *endTime) 1284 } 1285 if len(filter) > 0 { 1286 queryParameters["$filter"] = autorest.Encode("query", filter) 1287 } 1288 if maxResults != nil { 1289 queryParameters["maxresults"] = autorest.Encode("query", *maxResults) 1290 } else { 1291 queryParameters["maxresults"] = autorest.Encode("query", 1000) 1292 } 1293 if timeout != nil { 1294 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1295 } else { 1296 queryParameters["timeout"] = autorest.Encode("query", 30) 1297 } 1298 1299 preparer := autorest.CreatePreparer( 1300 autorest.AsGet(), 1301 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 1302 autorest.WithPath("/poolusagemetrics"), 1303 autorest.WithQueryParameters(queryParameters)) 1304 if clientRequestID != nil { 1305 preparer = autorest.DecoratePreparer(preparer, 1306 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1307 } 1308 if returnClientRequestID != nil { 1309 preparer = autorest.DecoratePreparer(preparer, 1310 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1311 } else { 1312 preparer = autorest.DecoratePreparer(preparer, 1313 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1314 } 1315 if ocpDate != nil { 1316 preparer = autorest.DecoratePreparer(preparer, 1317 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1318 } 1319 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1320} 1321 1322// ListUsageMetricsSender sends the ListUsageMetrics request. The method will close the 1323// http.Response Body if it receives an error. 1324func (client PoolClient) ListUsageMetricsSender(req *http.Request) (*http.Response, error) { 1325 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1326} 1327 1328// ListUsageMetricsResponder handles the response to the ListUsageMetrics request. The method always 1329// closes the http.Response Body. 1330func (client PoolClient) ListUsageMetricsResponder(resp *http.Response) (result PoolListUsageMetricsResult, err error) { 1331 err = autorest.Respond( 1332 resp, 1333 azure.WithErrorUnlessStatusCode(http.StatusOK), 1334 autorest.ByUnmarshallingJSON(&result), 1335 autorest.ByClosing()) 1336 result.Response = autorest.Response{Response: resp} 1337 return 1338} 1339 1340// listUsageMetricsNextResults retrieves the next set of results, if any. 1341func (client PoolClient) listUsageMetricsNextResults(ctx context.Context, lastResults PoolListUsageMetricsResult) (result PoolListUsageMetricsResult, err error) { 1342 req, err := lastResults.poolListUsageMetricsResultPreparer(ctx) 1343 if err != nil { 1344 return result, autorest.NewErrorWithError(err, "batch.PoolClient", "listUsageMetricsNextResults", nil, "Failure preparing next results request") 1345 } 1346 if req == nil { 1347 return 1348 } 1349 resp, err := client.ListUsageMetricsSender(req) 1350 if err != nil { 1351 result.Response = autorest.Response{Response: resp} 1352 return result, autorest.NewErrorWithError(err, "batch.PoolClient", "listUsageMetricsNextResults", resp, "Failure sending next results request") 1353 } 1354 result, err = client.ListUsageMetricsResponder(resp) 1355 if err != nil { 1356 err = autorest.NewErrorWithError(err, "batch.PoolClient", "listUsageMetricsNextResults", resp, "Failure responding to next results request") 1357 } 1358 return 1359} 1360 1361// ListUsageMetricsComplete enumerates all values, automatically crossing page boundaries as required. 1362func (client PoolClient) ListUsageMetricsComplete(ctx context.Context, startTime *date.Time, endTime *date.Time, filter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result PoolListUsageMetricsResultIterator, err error) { 1363 if tracing.IsEnabled() { 1364 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.ListUsageMetrics") 1365 defer func() { 1366 sc := -1 1367 if result.Response().Response.Response != nil { 1368 sc = result.page.Response().Response.Response.StatusCode 1369 } 1370 tracing.EndSpan(ctx, sc, err) 1371 }() 1372 } 1373 result.page, err = client.ListUsageMetrics(ctx, startTime, endTime, filter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate) 1374 return 1375} 1376 1377// Patch this only replaces the Pool properties specified in the request. For example, if the Pool has a StartTask 1378// associated with it, and a request does not specify a StartTask element, then the Pool keeps the existing StartTask. 1379// Parameters: 1380// poolID - the ID of the Pool to update. 1381// poolPatchParameter - the parameters for the request. 1382// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 1383// seconds. 1384// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 1385// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 1386// returnClientRequestID - whether the server should return the client-request-id in the response. 1387// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 1388// time; set it explicitly if you are calling the REST API directly. 1389// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will 1390// be performed only if the resource's current ETag on the service exactly matches the value specified by the 1391// client. 1392// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation 1393// will be performed only if the resource's current ETag on the service does not match the value specified by 1394// the client. 1395// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 1396// operation will be performed only if the resource on the service has been modified since the specified time. 1397// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 1398// operation will be performed only if the resource on the service has not been modified since the specified 1399// time. 1400func (client PoolClient) Patch(ctx context.Context, poolID string, poolPatchParameter PoolPatchParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) { 1401 if tracing.IsEnabled() { 1402 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.Patch") 1403 defer func() { 1404 sc := -1 1405 if result.Response != nil { 1406 sc = result.Response.StatusCode 1407 } 1408 tracing.EndSpan(ctx, sc, err) 1409 }() 1410 } 1411 req, err := client.PatchPreparer(ctx, poolID, poolPatchParameter, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince) 1412 if err != nil { 1413 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Patch", nil, "Failure preparing request") 1414 return 1415 } 1416 1417 resp, err := client.PatchSender(req) 1418 if err != nil { 1419 result.Response = resp 1420 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Patch", resp, "Failure sending request") 1421 return 1422 } 1423 1424 result, err = client.PatchResponder(resp) 1425 if err != nil { 1426 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Patch", resp, "Failure responding to request") 1427 return 1428 } 1429 1430 return 1431} 1432 1433// PatchPreparer prepares the Patch request. 1434func (client PoolClient) PatchPreparer(ctx context.Context, poolID string, poolPatchParameter PoolPatchParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) { 1435 urlParameters := map[string]interface{}{ 1436 "batchUrl": client.BatchURL, 1437 } 1438 1439 pathParameters := map[string]interface{}{ 1440 "poolId": autorest.Encode("path", poolID), 1441 } 1442 1443 const APIVersion = "2019-08-01.10.0" 1444 queryParameters := map[string]interface{}{ 1445 "api-version": APIVersion, 1446 } 1447 if timeout != nil { 1448 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1449 } else { 1450 queryParameters["timeout"] = autorest.Encode("query", 30) 1451 } 1452 1453 preparer := autorest.CreatePreparer( 1454 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 1455 autorest.AsPatch(), 1456 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 1457 autorest.WithPathParameters("/pools/{poolId}", pathParameters), 1458 autorest.WithJSON(poolPatchParameter), 1459 autorest.WithQueryParameters(queryParameters)) 1460 if clientRequestID != nil { 1461 preparer = autorest.DecoratePreparer(preparer, 1462 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1463 } 1464 if returnClientRequestID != nil { 1465 preparer = autorest.DecoratePreparer(preparer, 1466 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1467 } else { 1468 preparer = autorest.DecoratePreparer(preparer, 1469 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1470 } 1471 if ocpDate != nil { 1472 preparer = autorest.DecoratePreparer(preparer, 1473 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1474 } 1475 if len(ifMatch) > 0 { 1476 preparer = autorest.DecoratePreparer(preparer, 1477 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 1478 } 1479 if len(ifNoneMatch) > 0 { 1480 preparer = autorest.DecoratePreparer(preparer, 1481 autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) 1482 } 1483 if ifModifiedSince != nil { 1484 preparer = autorest.DecoratePreparer(preparer, 1485 autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince))) 1486 } 1487 if ifUnmodifiedSince != nil { 1488 preparer = autorest.DecoratePreparer(preparer, 1489 autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince))) 1490 } 1491 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1492} 1493 1494// PatchSender sends the Patch request. The method will close the 1495// http.Response Body if it receives an error. 1496func (client PoolClient) PatchSender(req *http.Request) (*http.Response, error) { 1497 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1498} 1499 1500// PatchResponder handles the response to the Patch request. The method always 1501// closes the http.Response Body. 1502func (client PoolClient) PatchResponder(resp *http.Response) (result autorest.Response, err error) { 1503 err = autorest.Respond( 1504 resp, 1505 azure.WithErrorUnlessStatusCode(http.StatusOK), 1506 autorest.ByClosing()) 1507 result.Response = resp 1508 return 1509} 1510 1511// RemoveNodes this operation can only run when the allocation state of the Pool is steady. When this operation runs, 1512// the allocation state changes from steady to resizing. 1513// Parameters: 1514// poolID - the ID of the Pool from which you want to remove Compute Nodes. 1515// nodeRemoveParameter - the parameters for the request. 1516// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 1517// seconds. 1518// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 1519// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 1520// returnClientRequestID - whether the server should return the client-request-id in the response. 1521// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 1522// time; set it explicitly if you are calling the REST API directly. 1523// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will 1524// be performed only if the resource's current ETag on the service exactly matches the value specified by the 1525// client. 1526// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation 1527// will be performed only if the resource's current ETag on the service does not match the value specified by 1528// the client. 1529// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 1530// operation will be performed only if the resource on the service has been modified since the specified time. 1531// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 1532// operation will be performed only if the resource on the service has not been modified since the specified 1533// time. 1534func (client PoolClient) RemoveNodes(ctx context.Context, poolID string, nodeRemoveParameter NodeRemoveParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) { 1535 if tracing.IsEnabled() { 1536 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.RemoveNodes") 1537 defer func() { 1538 sc := -1 1539 if result.Response != nil { 1540 sc = result.Response.StatusCode 1541 } 1542 tracing.EndSpan(ctx, sc, err) 1543 }() 1544 } 1545 if err := validation.Validate([]validation.Validation{ 1546 {TargetValue: nodeRemoveParameter, 1547 Constraints: []validation.Constraint{{Target: "nodeRemoveParameter.NodeList", Name: validation.Null, Rule: true, 1548 Chain: []validation.Constraint{{Target: "nodeRemoveParameter.NodeList", Name: validation.MaxItems, Rule: 100, Chain: nil}}}}}}); err != nil { 1549 return result, validation.NewError("batch.PoolClient", "RemoveNodes", err.Error()) 1550 } 1551 1552 req, err := client.RemoveNodesPreparer(ctx, poolID, nodeRemoveParameter, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince) 1553 if err != nil { 1554 err = autorest.NewErrorWithError(err, "batch.PoolClient", "RemoveNodes", nil, "Failure preparing request") 1555 return 1556 } 1557 1558 resp, err := client.RemoveNodesSender(req) 1559 if err != nil { 1560 result.Response = resp 1561 err = autorest.NewErrorWithError(err, "batch.PoolClient", "RemoveNodes", resp, "Failure sending request") 1562 return 1563 } 1564 1565 result, err = client.RemoveNodesResponder(resp) 1566 if err != nil { 1567 err = autorest.NewErrorWithError(err, "batch.PoolClient", "RemoveNodes", resp, "Failure responding to request") 1568 return 1569 } 1570 1571 return 1572} 1573 1574// RemoveNodesPreparer prepares the RemoveNodes request. 1575func (client PoolClient) RemoveNodesPreparer(ctx context.Context, poolID string, nodeRemoveParameter NodeRemoveParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) { 1576 urlParameters := map[string]interface{}{ 1577 "batchUrl": client.BatchURL, 1578 } 1579 1580 pathParameters := map[string]interface{}{ 1581 "poolId": autorest.Encode("path", poolID), 1582 } 1583 1584 const APIVersion = "2019-08-01.10.0" 1585 queryParameters := map[string]interface{}{ 1586 "api-version": APIVersion, 1587 } 1588 if timeout != nil { 1589 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1590 } else { 1591 queryParameters["timeout"] = autorest.Encode("query", 30) 1592 } 1593 1594 preparer := autorest.CreatePreparer( 1595 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 1596 autorest.AsPost(), 1597 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 1598 autorest.WithPathParameters("/pools/{poolId}/removenodes", pathParameters), 1599 autorest.WithJSON(nodeRemoveParameter), 1600 autorest.WithQueryParameters(queryParameters)) 1601 if clientRequestID != nil { 1602 preparer = autorest.DecoratePreparer(preparer, 1603 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1604 } 1605 if returnClientRequestID != nil { 1606 preparer = autorest.DecoratePreparer(preparer, 1607 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1608 } else { 1609 preparer = autorest.DecoratePreparer(preparer, 1610 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1611 } 1612 if ocpDate != nil { 1613 preparer = autorest.DecoratePreparer(preparer, 1614 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1615 } 1616 if len(ifMatch) > 0 { 1617 preparer = autorest.DecoratePreparer(preparer, 1618 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 1619 } 1620 if len(ifNoneMatch) > 0 { 1621 preparer = autorest.DecoratePreparer(preparer, 1622 autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) 1623 } 1624 if ifModifiedSince != nil { 1625 preparer = autorest.DecoratePreparer(preparer, 1626 autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince))) 1627 } 1628 if ifUnmodifiedSince != nil { 1629 preparer = autorest.DecoratePreparer(preparer, 1630 autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince))) 1631 } 1632 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1633} 1634 1635// RemoveNodesSender sends the RemoveNodes request. The method will close the 1636// http.Response Body if it receives an error. 1637func (client PoolClient) RemoveNodesSender(req *http.Request) (*http.Response, error) { 1638 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1639} 1640 1641// RemoveNodesResponder handles the response to the RemoveNodes request. The method always 1642// closes the http.Response Body. 1643func (client PoolClient) RemoveNodesResponder(resp *http.Response) (result autorest.Response, err error) { 1644 err = autorest.Respond( 1645 resp, 1646 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1647 autorest.ByClosing()) 1648 result.Response = resp 1649 return 1650} 1651 1652// Resize you can only resize a Pool when its allocation state is steady. If the Pool is already resizing, the request 1653// fails with status code 409. When you resize a Pool, the Pool's allocation state changes from steady to resizing. You 1654// cannot resize Pools which are configured for automatic scaling. If you try to do this, the Batch service returns an 1655// error 409. If you resize a Pool downwards, the Batch service chooses which Compute Nodes to remove. To remove 1656// specific Compute Nodes, use the Pool remove Compute Nodes API instead. 1657// Parameters: 1658// poolID - the ID of the Pool to resize. 1659// poolResizeParameter - the parameters for the request. 1660// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 1661// seconds. 1662// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 1663// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 1664// returnClientRequestID - whether the server should return the client-request-id in the response. 1665// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 1666// time; set it explicitly if you are calling the REST API directly. 1667// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will 1668// be performed only if the resource's current ETag on the service exactly matches the value specified by the 1669// client. 1670// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation 1671// will be performed only if the resource's current ETag on the service does not match the value specified by 1672// the client. 1673// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 1674// operation will be performed only if the resource on the service has been modified since the specified time. 1675// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 1676// operation will be performed only if the resource on the service has not been modified since the specified 1677// time. 1678func (client PoolClient) Resize(ctx context.Context, poolID string, poolResizeParameter PoolResizeParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) { 1679 if tracing.IsEnabled() { 1680 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.Resize") 1681 defer func() { 1682 sc := -1 1683 if result.Response != nil { 1684 sc = result.Response.StatusCode 1685 } 1686 tracing.EndSpan(ctx, sc, err) 1687 }() 1688 } 1689 req, err := client.ResizePreparer(ctx, poolID, poolResizeParameter, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince) 1690 if err != nil { 1691 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Resize", nil, "Failure preparing request") 1692 return 1693 } 1694 1695 resp, err := client.ResizeSender(req) 1696 if err != nil { 1697 result.Response = resp 1698 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Resize", resp, "Failure sending request") 1699 return 1700 } 1701 1702 result, err = client.ResizeResponder(resp) 1703 if err != nil { 1704 err = autorest.NewErrorWithError(err, "batch.PoolClient", "Resize", resp, "Failure responding to request") 1705 return 1706 } 1707 1708 return 1709} 1710 1711// ResizePreparer prepares the Resize request. 1712func (client PoolClient) ResizePreparer(ctx context.Context, poolID string, poolResizeParameter PoolResizeParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) { 1713 urlParameters := map[string]interface{}{ 1714 "batchUrl": client.BatchURL, 1715 } 1716 1717 pathParameters := map[string]interface{}{ 1718 "poolId": autorest.Encode("path", poolID), 1719 } 1720 1721 const APIVersion = "2019-08-01.10.0" 1722 queryParameters := map[string]interface{}{ 1723 "api-version": APIVersion, 1724 } 1725 if timeout != nil { 1726 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1727 } else { 1728 queryParameters["timeout"] = autorest.Encode("query", 30) 1729 } 1730 1731 preparer := autorest.CreatePreparer( 1732 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 1733 autorest.AsPost(), 1734 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 1735 autorest.WithPathParameters("/pools/{poolId}/resize", pathParameters), 1736 autorest.WithJSON(poolResizeParameter), 1737 autorest.WithQueryParameters(queryParameters)) 1738 if clientRequestID != nil { 1739 preparer = autorest.DecoratePreparer(preparer, 1740 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1741 } 1742 if returnClientRequestID != nil { 1743 preparer = autorest.DecoratePreparer(preparer, 1744 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1745 } else { 1746 preparer = autorest.DecoratePreparer(preparer, 1747 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1748 } 1749 if ocpDate != nil { 1750 preparer = autorest.DecoratePreparer(preparer, 1751 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1752 } 1753 if len(ifMatch) > 0 { 1754 preparer = autorest.DecoratePreparer(preparer, 1755 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 1756 } 1757 if len(ifNoneMatch) > 0 { 1758 preparer = autorest.DecoratePreparer(preparer, 1759 autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) 1760 } 1761 if ifModifiedSince != nil { 1762 preparer = autorest.DecoratePreparer(preparer, 1763 autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince))) 1764 } 1765 if ifUnmodifiedSince != nil { 1766 preparer = autorest.DecoratePreparer(preparer, 1767 autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince))) 1768 } 1769 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1770} 1771 1772// ResizeSender sends the Resize request. The method will close the 1773// http.Response Body if it receives an error. 1774func (client PoolClient) ResizeSender(req *http.Request) (*http.Response, error) { 1775 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1776} 1777 1778// ResizeResponder handles the response to the Resize request. The method always 1779// closes the http.Response Body. 1780func (client PoolClient) ResizeResponder(resp *http.Response) (result autorest.Response, err error) { 1781 err = autorest.Respond( 1782 resp, 1783 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1784 autorest.ByClosing()) 1785 result.Response = resp 1786 return 1787} 1788 1789// StopResize this does not restore the Pool to its previous state before the resize operation: it only stops any 1790// further changes being made, and the Pool maintains its current state. After stopping, the Pool stabilizes at the 1791// number of Compute Nodes it was at when the stop operation was done. During the stop operation, the Pool allocation 1792// state changes first to stopping and then to steady. A resize operation need not be an explicit resize Pool request; 1793// this API can also be used to halt the initial sizing of the Pool when it is created. 1794// Parameters: 1795// poolID - the ID of the Pool whose resizing you want to stop. 1796// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 1797// seconds. 1798// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 1799// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 1800// returnClientRequestID - whether the server should return the client-request-id in the response. 1801// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 1802// time; set it explicitly if you are calling the REST API directly. 1803// ifMatch - an ETag value associated with the version of the resource known to the client. The operation will 1804// be performed only if the resource's current ETag on the service exactly matches the value specified by the 1805// client. 1806// ifNoneMatch - an ETag value associated with the version of the resource known to the client. The operation 1807// will be performed only if the resource's current ETag on the service does not match the value specified by 1808// the client. 1809// ifModifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 1810// operation will be performed only if the resource on the service has been modified since the specified time. 1811// ifUnmodifiedSince - a timestamp indicating the last modified time of the resource known to the client. The 1812// operation will be performed only if the resource on the service has not been modified since the specified 1813// time. 1814func (client PoolClient) StopResize(ctx context.Context, poolID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (result autorest.Response, err error) { 1815 if tracing.IsEnabled() { 1816 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.StopResize") 1817 defer func() { 1818 sc := -1 1819 if result.Response != nil { 1820 sc = result.Response.StatusCode 1821 } 1822 tracing.EndSpan(ctx, sc, err) 1823 }() 1824 } 1825 req, err := client.StopResizePreparer(ctx, poolID, timeout, clientRequestID, returnClientRequestID, ocpDate, ifMatch, ifNoneMatch, ifModifiedSince, ifUnmodifiedSince) 1826 if err != nil { 1827 err = autorest.NewErrorWithError(err, "batch.PoolClient", "StopResize", nil, "Failure preparing request") 1828 return 1829 } 1830 1831 resp, err := client.StopResizeSender(req) 1832 if err != nil { 1833 result.Response = resp 1834 err = autorest.NewErrorWithError(err, "batch.PoolClient", "StopResize", resp, "Failure sending request") 1835 return 1836 } 1837 1838 result, err = client.StopResizeResponder(resp) 1839 if err != nil { 1840 err = autorest.NewErrorWithError(err, "batch.PoolClient", "StopResize", resp, "Failure responding to request") 1841 return 1842 } 1843 1844 return 1845} 1846 1847// StopResizePreparer prepares the StopResize request. 1848func (client PoolClient) StopResizePreparer(ctx context.Context, poolID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123, ifMatch string, ifNoneMatch string, ifModifiedSince *date.TimeRFC1123, ifUnmodifiedSince *date.TimeRFC1123) (*http.Request, error) { 1849 urlParameters := map[string]interface{}{ 1850 "batchUrl": client.BatchURL, 1851 } 1852 1853 pathParameters := map[string]interface{}{ 1854 "poolId": autorest.Encode("path", poolID), 1855 } 1856 1857 const APIVersion = "2019-08-01.10.0" 1858 queryParameters := map[string]interface{}{ 1859 "api-version": APIVersion, 1860 } 1861 if timeout != nil { 1862 queryParameters["timeout"] = autorest.Encode("query", *timeout) 1863 } else { 1864 queryParameters["timeout"] = autorest.Encode("query", 30) 1865 } 1866 1867 preparer := autorest.CreatePreparer( 1868 autorest.AsPost(), 1869 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 1870 autorest.WithPathParameters("/pools/{poolId}/stopresize", pathParameters), 1871 autorest.WithQueryParameters(queryParameters)) 1872 if clientRequestID != nil { 1873 preparer = autorest.DecoratePreparer(preparer, 1874 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 1875 } 1876 if returnClientRequestID != nil { 1877 preparer = autorest.DecoratePreparer(preparer, 1878 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 1879 } else { 1880 preparer = autorest.DecoratePreparer(preparer, 1881 autorest.WithHeader("return-client-request-id", autorest.String(false))) 1882 } 1883 if ocpDate != nil { 1884 preparer = autorest.DecoratePreparer(preparer, 1885 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 1886 } 1887 if len(ifMatch) > 0 { 1888 preparer = autorest.DecoratePreparer(preparer, 1889 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 1890 } 1891 if len(ifNoneMatch) > 0 { 1892 preparer = autorest.DecoratePreparer(preparer, 1893 autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) 1894 } 1895 if ifModifiedSince != nil { 1896 preparer = autorest.DecoratePreparer(preparer, 1897 autorest.WithHeader("If-Modified-Since", autorest.String(ifModifiedSince))) 1898 } 1899 if ifUnmodifiedSince != nil { 1900 preparer = autorest.DecoratePreparer(preparer, 1901 autorest.WithHeader("If-Unmodified-Since", autorest.String(ifUnmodifiedSince))) 1902 } 1903 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1904} 1905 1906// StopResizeSender sends the StopResize request. The method will close the 1907// http.Response Body if it receives an error. 1908func (client PoolClient) StopResizeSender(req *http.Request) (*http.Response, error) { 1909 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1910} 1911 1912// StopResizeResponder handles the response to the StopResize request. The method always 1913// closes the http.Response Body. 1914func (client PoolClient) StopResizeResponder(resp *http.Response) (result autorest.Response, err error) { 1915 err = autorest.Respond( 1916 resp, 1917 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1918 autorest.ByClosing()) 1919 result.Response = resp 1920 return 1921} 1922 1923// UpdateProperties this fully replaces all the updatable properties of the Pool. For example, if the Pool has a 1924// StartTask associated with it and if StartTask is not specified with this request, then the Batch service will remove 1925// the existing StartTask. 1926// Parameters: 1927// poolID - the ID of the Pool to update. 1928// poolUpdatePropertiesParameter - the parameters for the request. 1929// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30 1930// seconds. 1931// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as 1932// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. 1933// returnClientRequestID - whether the server should return the client-request-id in the response. 1934// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock 1935// time; set it explicitly if you are calling the REST API directly. 1936func (client PoolClient) UpdateProperties(ctx context.Context, poolID string, poolUpdatePropertiesParameter PoolUpdatePropertiesParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) { 1937 if tracing.IsEnabled() { 1938 ctx = tracing.StartSpan(ctx, fqdn+"/PoolClient.UpdateProperties") 1939 defer func() { 1940 sc := -1 1941 if result.Response != nil { 1942 sc = result.Response.StatusCode 1943 } 1944 tracing.EndSpan(ctx, sc, err) 1945 }() 1946 } 1947 if err := validation.Validate([]validation.Validation{ 1948 {TargetValue: poolUpdatePropertiesParameter, 1949 Constraints: []validation.Constraint{{Target: "poolUpdatePropertiesParameter.StartTask", Name: validation.Null, Rule: false, 1950 Chain: []validation.Constraint{{Target: "poolUpdatePropertiesParameter.StartTask.CommandLine", Name: validation.Null, Rule: true, Chain: nil}, 1951 {Target: "poolUpdatePropertiesParameter.StartTask.ContainerSettings", Name: validation.Null, Rule: false, 1952 Chain: []validation.Constraint{{Target: "poolUpdatePropertiesParameter.StartTask.ContainerSettings.ImageName", Name: validation.Null, Rule: true, Chain: nil}, 1953 {Target: "poolUpdatePropertiesParameter.StartTask.ContainerSettings.Registry", Name: validation.Null, Rule: false, 1954 Chain: []validation.Constraint{{Target: "poolUpdatePropertiesParameter.StartTask.ContainerSettings.Registry.UserName", Name: validation.Null, Rule: true, Chain: nil}, 1955 {Target: "poolUpdatePropertiesParameter.StartTask.ContainerSettings.Registry.Password", Name: validation.Null, Rule: true, Chain: nil}, 1956 }}, 1957 }}, 1958 }}, 1959 {Target: "poolUpdatePropertiesParameter.CertificateReferences", Name: validation.Null, Rule: true, Chain: nil}, 1960 {Target: "poolUpdatePropertiesParameter.ApplicationPackageReferences", Name: validation.Null, Rule: true, Chain: nil}, 1961 {Target: "poolUpdatePropertiesParameter.Metadata", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 1962 return result, validation.NewError("batch.PoolClient", "UpdateProperties", err.Error()) 1963 } 1964 1965 req, err := client.UpdatePropertiesPreparer(ctx, poolID, poolUpdatePropertiesParameter, timeout, clientRequestID, returnClientRequestID, ocpDate) 1966 if err != nil { 1967 err = autorest.NewErrorWithError(err, "batch.PoolClient", "UpdateProperties", nil, "Failure preparing request") 1968 return 1969 } 1970 1971 resp, err := client.UpdatePropertiesSender(req) 1972 if err != nil { 1973 result.Response = resp 1974 err = autorest.NewErrorWithError(err, "batch.PoolClient", "UpdateProperties", resp, "Failure sending request") 1975 return 1976 } 1977 1978 result, err = client.UpdatePropertiesResponder(resp) 1979 if err != nil { 1980 err = autorest.NewErrorWithError(err, "batch.PoolClient", "UpdateProperties", resp, "Failure responding to request") 1981 return 1982 } 1983 1984 return 1985} 1986 1987// UpdatePropertiesPreparer prepares the UpdateProperties request. 1988func (client PoolClient) UpdatePropertiesPreparer(ctx context.Context, poolID string, poolUpdatePropertiesParameter PoolUpdatePropertiesParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) { 1989 urlParameters := map[string]interface{}{ 1990 "batchUrl": client.BatchURL, 1991 } 1992 1993 pathParameters := map[string]interface{}{ 1994 "poolId": autorest.Encode("path", poolID), 1995 } 1996 1997 const APIVersion = "2019-08-01.10.0" 1998 queryParameters := map[string]interface{}{ 1999 "api-version": APIVersion, 2000 } 2001 if timeout != nil { 2002 queryParameters["timeout"] = autorest.Encode("query", *timeout) 2003 } else { 2004 queryParameters["timeout"] = autorest.Encode("query", 30) 2005 } 2006 2007 preparer := autorest.CreatePreparer( 2008 autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"), 2009 autorest.AsPost(), 2010 autorest.WithCustomBaseURL("{batchUrl}", urlParameters), 2011 autorest.WithPathParameters("/pools/{poolId}/updateproperties", pathParameters), 2012 autorest.WithJSON(poolUpdatePropertiesParameter), 2013 autorest.WithQueryParameters(queryParameters)) 2014 if clientRequestID != nil { 2015 preparer = autorest.DecoratePreparer(preparer, 2016 autorest.WithHeader("client-request-id", autorest.String(clientRequestID))) 2017 } 2018 if returnClientRequestID != nil { 2019 preparer = autorest.DecoratePreparer(preparer, 2020 autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID))) 2021 } else { 2022 preparer = autorest.DecoratePreparer(preparer, 2023 autorest.WithHeader("return-client-request-id", autorest.String(false))) 2024 } 2025 if ocpDate != nil { 2026 preparer = autorest.DecoratePreparer(preparer, 2027 autorest.WithHeader("ocp-date", autorest.String(ocpDate))) 2028 } 2029 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 2030} 2031 2032// UpdatePropertiesSender sends the UpdateProperties request. The method will close the 2033// http.Response Body if it receives an error. 2034func (client PoolClient) UpdatePropertiesSender(req *http.Request) (*http.Response, error) { 2035 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 2036} 2037 2038// UpdatePropertiesResponder handles the response to the UpdateProperties request. The method always 2039// closes the http.Response Body. 2040func (client PoolClient) UpdatePropertiesResponder(resp *http.Response) (result autorest.Response, err error) { 2041 err = autorest.Respond( 2042 resp, 2043 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 2044 autorest.ByClosing()) 2045 result.Response = resp 2046 return 2047} 2048