1package batch
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
10	"context"
11	"github.com/Azure/go-autorest/autorest"
12	"github.com/Azure/go-autorest/autorest/azure"
13	"github.com/Azure/go-autorest/autorest/date"
14	"github.com/Azure/go-autorest/autorest/validation"
15	"github.com/Azure/go-autorest/tracing"
16	"github.com/gofrs/uuid"
17	"net/http"
18)
19
20// ComputeNodeClient is the a client for issuing REST requests to the Azure Batch service.
21type ComputeNodeClient struct {
22	BaseClient
23}
24
25// NewComputeNodeClient creates an instance of the ComputeNodeClient client.
26func NewComputeNodeClient(batchURL string) ComputeNodeClient {
27	return ComputeNodeClient{New(batchURL)}
28}
29
30// AddUser you can add a user Account to a Compute Node only when it is in the idle or running state.
31// Parameters:
32// poolID - the ID of the Pool that contains the Compute Node.
33// nodeID - the ID of the machine on which you want to create a user Account.
34// userParameter - the user Account to be created.
35// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
36// seconds.
37// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
38// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
39// returnClientRequestID - whether the server should return the client-request-id in the response.
40// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
41// time; set it explicitly if you are calling the REST API directly.
42func (client ComputeNodeClient) AddUser(ctx context.Context, poolID string, nodeID string, userParameter ComputeNodeUser, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
43	if tracing.IsEnabled() {
44		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.AddUser")
45		defer func() {
46			sc := -1
47			if result.Response != nil {
48				sc = result.Response.StatusCode
49			}
50			tracing.EndSpan(ctx, sc, err)
51		}()
52	}
53	if err := validation.Validate([]validation.Validation{
54		{TargetValue: userParameter,
55			Constraints: []validation.Constraint{{Target: "userParameter.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
56		return result, validation.NewError("batch.ComputeNodeClient", "AddUser", err.Error())
57	}
58
59	req, err := client.AddUserPreparer(ctx, poolID, nodeID, userParameter, timeout, clientRequestID, returnClientRequestID, ocpDate)
60	if err != nil {
61		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "AddUser", nil, "Failure preparing request")
62		return
63	}
64
65	resp, err := client.AddUserSender(req)
66	if err != nil {
67		result.Response = resp
68		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "AddUser", resp, "Failure sending request")
69		return
70	}
71
72	result, err = client.AddUserResponder(resp)
73	if err != nil {
74		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "AddUser", resp, "Failure responding to request")
75		return
76	}
77
78	return
79}
80
81// AddUserPreparer prepares the AddUser request.
82func (client ComputeNodeClient) AddUserPreparer(ctx context.Context, poolID string, nodeID string, userParameter ComputeNodeUser, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
83	urlParameters := map[string]interface{}{
84		"batchUrl": client.BatchURL,
85	}
86
87	pathParameters := map[string]interface{}{
88		"nodeId": autorest.Encode("path", nodeID),
89		"poolId": autorest.Encode("path", poolID),
90	}
91
92	const APIVersion = "2019-08-01.10.0"
93	queryParameters := map[string]interface{}{
94		"api-version": APIVersion,
95	}
96	if timeout != nil {
97		queryParameters["timeout"] = autorest.Encode("query", *timeout)
98	} else {
99		queryParameters["timeout"] = autorest.Encode("query", 30)
100	}
101
102	preparer := autorest.CreatePreparer(
103		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
104		autorest.AsPost(),
105		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
106		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/users", pathParameters),
107		autorest.WithJSON(userParameter),
108		autorest.WithQueryParameters(queryParameters))
109	if clientRequestID != nil {
110		preparer = autorest.DecoratePreparer(preparer,
111			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
112	}
113	if returnClientRequestID != nil {
114		preparer = autorest.DecoratePreparer(preparer,
115			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
116	} else {
117		preparer = autorest.DecoratePreparer(preparer,
118			autorest.WithHeader("return-client-request-id", autorest.String(false)))
119	}
120	if ocpDate != nil {
121		preparer = autorest.DecoratePreparer(preparer,
122			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
123	}
124	return preparer.Prepare((&http.Request{}).WithContext(ctx))
125}
126
127// AddUserSender sends the AddUser request. The method will close the
128// http.Response Body if it receives an error.
129func (client ComputeNodeClient) AddUserSender(req *http.Request) (*http.Response, error) {
130	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
131}
132
133// AddUserResponder handles the response to the AddUser request. The method always
134// closes the http.Response Body.
135func (client ComputeNodeClient) AddUserResponder(resp *http.Response) (result autorest.Response, err error) {
136	err = autorest.Respond(
137		resp,
138		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
139		autorest.ByClosing())
140	result.Response = resp
141	return
142}
143
144// DeleteUser you can delete a user Account to a Compute Node only when it is in the idle or running state.
145// Parameters:
146// poolID - the ID of the Pool that contains the Compute Node.
147// nodeID - the ID of the machine on which you want to delete a user Account.
148// userName - the name of the user Account to delete.
149// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
150// seconds.
151// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
152// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
153// returnClientRequestID - whether the server should return the client-request-id in the response.
154// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
155// time; set it explicitly if you are calling the REST API directly.
156func (client ComputeNodeClient) DeleteUser(ctx context.Context, poolID string, nodeID string, userName string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
157	if tracing.IsEnabled() {
158		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.DeleteUser")
159		defer func() {
160			sc := -1
161			if result.Response != nil {
162				sc = result.Response.StatusCode
163			}
164			tracing.EndSpan(ctx, sc, err)
165		}()
166	}
167	req, err := client.DeleteUserPreparer(ctx, poolID, nodeID, userName, timeout, clientRequestID, returnClientRequestID, ocpDate)
168	if err != nil {
169		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DeleteUser", nil, "Failure preparing request")
170		return
171	}
172
173	resp, err := client.DeleteUserSender(req)
174	if err != nil {
175		result.Response = resp
176		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DeleteUser", resp, "Failure sending request")
177		return
178	}
179
180	result, err = client.DeleteUserResponder(resp)
181	if err != nil {
182		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DeleteUser", resp, "Failure responding to request")
183		return
184	}
185
186	return
187}
188
189// DeleteUserPreparer prepares the DeleteUser request.
190func (client ComputeNodeClient) DeleteUserPreparer(ctx context.Context, poolID string, nodeID string, userName string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
191	urlParameters := map[string]interface{}{
192		"batchUrl": client.BatchURL,
193	}
194
195	pathParameters := map[string]interface{}{
196		"nodeId":   autorest.Encode("path", nodeID),
197		"poolId":   autorest.Encode("path", poolID),
198		"userName": autorest.Encode("path", userName),
199	}
200
201	const APIVersion = "2019-08-01.10.0"
202	queryParameters := map[string]interface{}{
203		"api-version": APIVersion,
204	}
205	if timeout != nil {
206		queryParameters["timeout"] = autorest.Encode("query", *timeout)
207	} else {
208		queryParameters["timeout"] = autorest.Encode("query", 30)
209	}
210
211	preparer := autorest.CreatePreparer(
212		autorest.AsDelete(),
213		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
214		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/users/{userName}", pathParameters),
215		autorest.WithQueryParameters(queryParameters))
216	if clientRequestID != nil {
217		preparer = autorest.DecoratePreparer(preparer,
218			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
219	}
220	if returnClientRequestID != nil {
221		preparer = autorest.DecoratePreparer(preparer,
222			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
223	} else {
224		preparer = autorest.DecoratePreparer(preparer,
225			autorest.WithHeader("return-client-request-id", autorest.String(false)))
226	}
227	if ocpDate != nil {
228		preparer = autorest.DecoratePreparer(preparer,
229			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
230	}
231	return preparer.Prepare((&http.Request{}).WithContext(ctx))
232}
233
234// DeleteUserSender sends the DeleteUser request. The method will close the
235// http.Response Body if it receives an error.
236func (client ComputeNodeClient) DeleteUserSender(req *http.Request) (*http.Response, error) {
237	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
238}
239
240// DeleteUserResponder handles the response to the DeleteUser request. The method always
241// closes the http.Response Body.
242func (client ComputeNodeClient) DeleteUserResponder(resp *http.Response) (result autorest.Response, err error) {
243	err = autorest.Respond(
244		resp,
245		azure.WithErrorUnlessStatusCode(http.StatusOK),
246		autorest.ByClosing())
247	result.Response = resp
248	return
249}
250
251// DisableScheduling you can disable Task scheduling on a Compute Node only if its current scheduling state is enabled.
252// Parameters:
253// poolID - the ID of the Pool that contains the Compute Node.
254// nodeID - the ID of the Compute Node on which you want to disable Task scheduling.
255// nodeDisableSchedulingParameter - the parameters for the request.
256// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
257// seconds.
258// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
259// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
260// returnClientRequestID - whether the server should return the client-request-id in the response.
261// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
262// time; set it explicitly if you are calling the REST API directly.
263func (client ComputeNodeClient) DisableScheduling(ctx context.Context, poolID string, nodeID string, nodeDisableSchedulingParameter *NodeDisableSchedulingParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
264	if tracing.IsEnabled() {
265		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.DisableScheduling")
266		defer func() {
267			sc := -1
268			if result.Response != nil {
269				sc = result.Response.StatusCode
270			}
271			tracing.EndSpan(ctx, sc, err)
272		}()
273	}
274	req, err := client.DisableSchedulingPreparer(ctx, poolID, nodeID, nodeDisableSchedulingParameter, timeout, clientRequestID, returnClientRequestID, ocpDate)
275	if err != nil {
276		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DisableScheduling", nil, "Failure preparing request")
277		return
278	}
279
280	resp, err := client.DisableSchedulingSender(req)
281	if err != nil {
282		result.Response = resp
283		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DisableScheduling", resp, "Failure sending request")
284		return
285	}
286
287	result, err = client.DisableSchedulingResponder(resp)
288	if err != nil {
289		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "DisableScheduling", resp, "Failure responding to request")
290		return
291	}
292
293	return
294}
295
296// DisableSchedulingPreparer prepares the DisableScheduling request.
297func (client ComputeNodeClient) DisableSchedulingPreparer(ctx context.Context, poolID string, nodeID string, nodeDisableSchedulingParameter *NodeDisableSchedulingParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
298	urlParameters := map[string]interface{}{
299		"batchUrl": client.BatchURL,
300	}
301
302	pathParameters := map[string]interface{}{
303		"nodeId": autorest.Encode("path", nodeID),
304		"poolId": autorest.Encode("path", poolID),
305	}
306
307	const APIVersion = "2019-08-01.10.0"
308	queryParameters := map[string]interface{}{
309		"api-version": APIVersion,
310	}
311	if timeout != nil {
312		queryParameters["timeout"] = autorest.Encode("query", *timeout)
313	} else {
314		queryParameters["timeout"] = autorest.Encode("query", 30)
315	}
316
317	preparer := autorest.CreatePreparer(
318		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
319		autorest.AsPost(),
320		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
321		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/disablescheduling", pathParameters),
322		autorest.WithQueryParameters(queryParameters))
323	if nodeDisableSchedulingParameter != nil {
324		preparer = autorest.DecoratePreparer(preparer,
325			autorest.WithJSON(nodeDisableSchedulingParameter))
326	}
327	if clientRequestID != nil {
328		preparer = autorest.DecoratePreparer(preparer,
329			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
330	}
331	if returnClientRequestID != nil {
332		preparer = autorest.DecoratePreparer(preparer,
333			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
334	} else {
335		preparer = autorest.DecoratePreparer(preparer,
336			autorest.WithHeader("return-client-request-id", autorest.String(false)))
337	}
338	if ocpDate != nil {
339		preparer = autorest.DecoratePreparer(preparer,
340			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
341	}
342	return preparer.Prepare((&http.Request{}).WithContext(ctx))
343}
344
345// DisableSchedulingSender sends the DisableScheduling request. The method will close the
346// http.Response Body if it receives an error.
347func (client ComputeNodeClient) DisableSchedulingSender(req *http.Request) (*http.Response, error) {
348	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
349}
350
351// DisableSchedulingResponder handles the response to the DisableScheduling request. The method always
352// closes the http.Response Body.
353func (client ComputeNodeClient) DisableSchedulingResponder(resp *http.Response) (result autorest.Response, err error) {
354	err = autorest.Respond(
355		resp,
356		azure.WithErrorUnlessStatusCode(http.StatusOK),
357		autorest.ByClosing())
358	result.Response = resp
359	return
360}
361
362// EnableScheduling you can enable Task scheduling on a Compute Node only if its current scheduling state is disabled
363// Parameters:
364// poolID - the ID of the Pool that contains the Compute Node.
365// nodeID - the ID of the Compute Node on which you want to enable Task scheduling.
366// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
367// seconds.
368// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
369// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
370// returnClientRequestID - whether the server should return the client-request-id in the response.
371// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
372// time; set it explicitly if you are calling the REST API directly.
373func (client ComputeNodeClient) EnableScheduling(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
374	if tracing.IsEnabled() {
375		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.EnableScheduling")
376		defer func() {
377			sc := -1
378			if result.Response != nil {
379				sc = result.Response.StatusCode
380			}
381			tracing.EndSpan(ctx, sc, err)
382		}()
383	}
384	req, err := client.EnableSchedulingPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate)
385	if err != nil {
386		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "EnableScheduling", nil, "Failure preparing request")
387		return
388	}
389
390	resp, err := client.EnableSchedulingSender(req)
391	if err != nil {
392		result.Response = resp
393		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "EnableScheduling", resp, "Failure sending request")
394		return
395	}
396
397	result, err = client.EnableSchedulingResponder(resp)
398	if err != nil {
399		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "EnableScheduling", resp, "Failure responding to request")
400		return
401	}
402
403	return
404}
405
406// EnableSchedulingPreparer prepares the EnableScheduling request.
407func (client ComputeNodeClient) EnableSchedulingPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
408	urlParameters := map[string]interface{}{
409		"batchUrl": client.BatchURL,
410	}
411
412	pathParameters := map[string]interface{}{
413		"nodeId": autorest.Encode("path", nodeID),
414		"poolId": autorest.Encode("path", poolID),
415	}
416
417	const APIVersion = "2019-08-01.10.0"
418	queryParameters := map[string]interface{}{
419		"api-version": APIVersion,
420	}
421	if timeout != nil {
422		queryParameters["timeout"] = autorest.Encode("query", *timeout)
423	} else {
424		queryParameters["timeout"] = autorest.Encode("query", 30)
425	}
426
427	preparer := autorest.CreatePreparer(
428		autorest.AsPost(),
429		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
430		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/enablescheduling", pathParameters),
431		autorest.WithQueryParameters(queryParameters))
432	if clientRequestID != nil {
433		preparer = autorest.DecoratePreparer(preparer,
434			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
435	}
436	if returnClientRequestID != nil {
437		preparer = autorest.DecoratePreparer(preparer,
438			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
439	} else {
440		preparer = autorest.DecoratePreparer(preparer,
441			autorest.WithHeader("return-client-request-id", autorest.String(false)))
442	}
443	if ocpDate != nil {
444		preparer = autorest.DecoratePreparer(preparer,
445			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
446	}
447	return preparer.Prepare((&http.Request{}).WithContext(ctx))
448}
449
450// EnableSchedulingSender sends the EnableScheduling request. The method will close the
451// http.Response Body if it receives an error.
452func (client ComputeNodeClient) EnableSchedulingSender(req *http.Request) (*http.Response, error) {
453	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
454}
455
456// EnableSchedulingResponder handles the response to the EnableScheduling request. The method always
457// closes the http.Response Body.
458func (client ComputeNodeClient) EnableSchedulingResponder(resp *http.Response) (result autorest.Response, err error) {
459	err = autorest.Respond(
460		resp,
461		azure.WithErrorUnlessStatusCode(http.StatusOK),
462		autorest.ByClosing())
463	result.Response = resp
464	return
465}
466
467// Get sends the get request.
468// Parameters:
469// poolID - the ID of the Pool that contains the Compute Node.
470// nodeID - the ID of the Compute Node that you want to get information about.
471// selectParameter - an OData $select clause.
472// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
473// seconds.
474// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
475// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
476// returnClientRequestID - whether the server should return the client-request-id in the response.
477// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
478// time; set it explicitly if you are calling the REST API directly.
479func (client ComputeNodeClient) Get(ctx context.Context, poolID string, nodeID string, selectParameter string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNode, err error) {
480	if tracing.IsEnabled() {
481		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.Get")
482		defer func() {
483			sc := -1
484			if result.Response.Response != nil {
485				sc = result.Response.Response.StatusCode
486			}
487			tracing.EndSpan(ctx, sc, err)
488		}()
489	}
490	req, err := client.GetPreparer(ctx, poolID, nodeID, selectParameter, timeout, clientRequestID, returnClientRequestID, ocpDate)
491	if err != nil {
492		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Get", nil, "Failure preparing request")
493		return
494	}
495
496	resp, err := client.GetSender(req)
497	if err != nil {
498		result.Response = autorest.Response{Response: resp}
499		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Get", resp, "Failure sending request")
500		return
501	}
502
503	result, err = client.GetResponder(resp)
504	if err != nil {
505		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Get", resp, "Failure responding to request")
506		return
507	}
508
509	return
510}
511
512// GetPreparer prepares the Get request.
513func (client ComputeNodeClient) GetPreparer(ctx context.Context, poolID string, nodeID string, selectParameter string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
514	urlParameters := map[string]interface{}{
515		"batchUrl": client.BatchURL,
516	}
517
518	pathParameters := map[string]interface{}{
519		"nodeId": autorest.Encode("path", nodeID),
520		"poolId": autorest.Encode("path", poolID),
521	}
522
523	const APIVersion = "2019-08-01.10.0"
524	queryParameters := map[string]interface{}{
525		"api-version": APIVersion,
526	}
527	if len(selectParameter) > 0 {
528		queryParameters["$select"] = autorest.Encode("query", selectParameter)
529	}
530	if timeout != nil {
531		queryParameters["timeout"] = autorest.Encode("query", *timeout)
532	} else {
533		queryParameters["timeout"] = autorest.Encode("query", 30)
534	}
535
536	preparer := autorest.CreatePreparer(
537		autorest.AsGet(),
538		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
539		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}", pathParameters),
540		autorest.WithQueryParameters(queryParameters))
541	if clientRequestID != nil {
542		preparer = autorest.DecoratePreparer(preparer,
543			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
544	}
545	if returnClientRequestID != nil {
546		preparer = autorest.DecoratePreparer(preparer,
547			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
548	} else {
549		preparer = autorest.DecoratePreparer(preparer,
550			autorest.WithHeader("return-client-request-id", autorest.String(false)))
551	}
552	if ocpDate != nil {
553		preparer = autorest.DecoratePreparer(preparer,
554			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
555	}
556	return preparer.Prepare((&http.Request{}).WithContext(ctx))
557}
558
559// GetSender sends the Get request. The method will close the
560// http.Response Body if it receives an error.
561func (client ComputeNodeClient) GetSender(req *http.Request) (*http.Response, error) {
562	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
563}
564
565// GetResponder handles the response to the Get request. The method always
566// closes the http.Response Body.
567func (client ComputeNodeClient) GetResponder(resp *http.Response) (result ComputeNode, err error) {
568	err = autorest.Respond(
569		resp,
570		azure.WithErrorUnlessStatusCode(http.StatusOK),
571		autorest.ByUnmarshallingJSON(&result),
572		autorest.ByClosing())
573	result.Response = autorest.Response{Response: resp}
574	return
575}
576
577// GetRemoteDesktop before you can access a Compute Node by using the RDP file, you must create a user Account on the
578// Compute Node. This API can only be invoked on Pools created with a cloud service configuration. For Pools created
579// with a virtual machine configuration, see the GetRemoteLoginSettings API.
580// Parameters:
581// poolID - the ID of the Pool that contains the Compute Node.
582// nodeID - the ID of the Compute Node for which you want to get the Remote Desktop Protocol file.
583// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
584// seconds.
585// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
586// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
587// returnClientRequestID - whether the server should return the client-request-id in the response.
588// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
589// time; set it explicitly if you are calling the REST API directly.
590func (client ComputeNodeClient) GetRemoteDesktop(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ReadCloser, err error) {
591	if tracing.IsEnabled() {
592		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.GetRemoteDesktop")
593		defer func() {
594			sc := -1
595			if result.Response.Response != nil {
596				sc = result.Response.Response.StatusCode
597			}
598			tracing.EndSpan(ctx, sc, err)
599		}()
600	}
601	req, err := client.GetRemoteDesktopPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate)
602	if err != nil {
603		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", nil, "Failure preparing request")
604		return
605	}
606
607	resp, err := client.GetRemoteDesktopSender(req)
608	if err != nil {
609		result.Response = autorest.Response{Response: resp}
610		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", resp, "Failure sending request")
611		return
612	}
613
614	result, err = client.GetRemoteDesktopResponder(resp)
615	if err != nil {
616		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteDesktop", resp, "Failure responding to request")
617		return
618	}
619
620	return
621}
622
623// GetRemoteDesktopPreparer prepares the GetRemoteDesktop request.
624func (client ComputeNodeClient) GetRemoteDesktopPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
625	urlParameters := map[string]interface{}{
626		"batchUrl": client.BatchURL,
627	}
628
629	pathParameters := map[string]interface{}{
630		"nodeId": autorest.Encode("path", nodeID),
631		"poolId": autorest.Encode("path", poolID),
632	}
633
634	const APIVersion = "2019-08-01.10.0"
635	queryParameters := map[string]interface{}{
636		"api-version": APIVersion,
637	}
638	if timeout != nil {
639		queryParameters["timeout"] = autorest.Encode("query", *timeout)
640	} else {
641		queryParameters["timeout"] = autorest.Encode("query", 30)
642	}
643
644	preparer := autorest.CreatePreparer(
645		autorest.AsGet(),
646		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
647		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/rdp", pathParameters),
648		autorest.WithQueryParameters(queryParameters))
649	if clientRequestID != nil {
650		preparer = autorest.DecoratePreparer(preparer,
651			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
652	}
653	if returnClientRequestID != nil {
654		preparer = autorest.DecoratePreparer(preparer,
655			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
656	} else {
657		preparer = autorest.DecoratePreparer(preparer,
658			autorest.WithHeader("return-client-request-id", autorest.String(false)))
659	}
660	if ocpDate != nil {
661		preparer = autorest.DecoratePreparer(preparer,
662			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
663	}
664	return preparer.Prepare((&http.Request{}).WithContext(ctx))
665}
666
667// GetRemoteDesktopSender sends the GetRemoteDesktop request. The method will close the
668// http.Response Body if it receives an error.
669func (client ComputeNodeClient) GetRemoteDesktopSender(req *http.Request) (*http.Response, error) {
670	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
671}
672
673// GetRemoteDesktopResponder handles the response to the GetRemoteDesktop request. The method always
674// closes the http.Response Body.
675func (client ComputeNodeClient) GetRemoteDesktopResponder(resp *http.Response) (result ReadCloser, err error) {
676	result.Value = &resp.Body
677	err = autorest.Respond(
678		resp,
679		azure.WithErrorUnlessStatusCode(http.StatusOK))
680	result.Response = autorest.Response{Response: resp}
681	return
682}
683
684// GetRemoteLoginSettings before you can remotely login to a Compute Node using the remote login settings, you must
685// create a user Account on the Compute Node. This API can be invoked only on Pools created with the virtual machine
686// configuration property. For Pools created with a cloud service configuration, see the GetRemoteDesktop API.
687// Parameters:
688// poolID - the ID of the Pool that contains the Compute Node.
689// nodeID - the ID of the Compute Node for which to obtain the remote login settings.
690// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
691// seconds.
692// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
693// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
694// returnClientRequestID - whether the server should return the client-request-id in the response.
695// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
696// time; set it explicitly if you are calling the REST API directly.
697func (client ComputeNodeClient) GetRemoteLoginSettings(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNodeGetRemoteLoginSettingsResult, err error) {
698	if tracing.IsEnabled() {
699		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.GetRemoteLoginSettings")
700		defer func() {
701			sc := -1
702			if result.Response.Response != nil {
703				sc = result.Response.Response.StatusCode
704			}
705			tracing.EndSpan(ctx, sc, err)
706		}()
707	}
708	req, err := client.GetRemoteLoginSettingsPreparer(ctx, poolID, nodeID, timeout, clientRequestID, returnClientRequestID, ocpDate)
709	if err != nil {
710		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteLoginSettings", nil, "Failure preparing request")
711		return
712	}
713
714	resp, err := client.GetRemoteLoginSettingsSender(req)
715	if err != nil {
716		result.Response = autorest.Response{Response: resp}
717		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteLoginSettings", resp, "Failure sending request")
718		return
719	}
720
721	result, err = client.GetRemoteLoginSettingsResponder(resp)
722	if err != nil {
723		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "GetRemoteLoginSettings", resp, "Failure responding to request")
724		return
725	}
726
727	return
728}
729
730// GetRemoteLoginSettingsPreparer prepares the GetRemoteLoginSettings request.
731func (client ComputeNodeClient) GetRemoteLoginSettingsPreparer(ctx context.Context, poolID string, nodeID string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
732	urlParameters := map[string]interface{}{
733		"batchUrl": client.BatchURL,
734	}
735
736	pathParameters := map[string]interface{}{
737		"nodeId": autorest.Encode("path", nodeID),
738		"poolId": autorest.Encode("path", poolID),
739	}
740
741	const APIVersion = "2019-08-01.10.0"
742	queryParameters := map[string]interface{}{
743		"api-version": APIVersion,
744	}
745	if timeout != nil {
746		queryParameters["timeout"] = autorest.Encode("query", *timeout)
747	} else {
748		queryParameters["timeout"] = autorest.Encode("query", 30)
749	}
750
751	preparer := autorest.CreatePreparer(
752		autorest.AsGet(),
753		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
754		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/remoteloginsettings", pathParameters),
755		autorest.WithQueryParameters(queryParameters))
756	if clientRequestID != nil {
757		preparer = autorest.DecoratePreparer(preparer,
758			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
759	}
760	if returnClientRequestID != nil {
761		preparer = autorest.DecoratePreparer(preparer,
762			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
763	} else {
764		preparer = autorest.DecoratePreparer(preparer,
765			autorest.WithHeader("return-client-request-id", autorest.String(false)))
766	}
767	if ocpDate != nil {
768		preparer = autorest.DecoratePreparer(preparer,
769			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
770	}
771	return preparer.Prepare((&http.Request{}).WithContext(ctx))
772}
773
774// GetRemoteLoginSettingsSender sends the GetRemoteLoginSettings request. The method will close the
775// http.Response Body if it receives an error.
776func (client ComputeNodeClient) GetRemoteLoginSettingsSender(req *http.Request) (*http.Response, error) {
777	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
778}
779
780// GetRemoteLoginSettingsResponder handles the response to the GetRemoteLoginSettings request. The method always
781// closes the http.Response Body.
782func (client ComputeNodeClient) GetRemoteLoginSettingsResponder(resp *http.Response) (result ComputeNodeGetRemoteLoginSettingsResult, err error) {
783	err = autorest.Respond(
784		resp,
785		azure.WithErrorUnlessStatusCode(http.StatusOK),
786		autorest.ByUnmarshallingJSON(&result),
787		autorest.ByClosing())
788	result.Response = autorest.Response{Response: resp}
789	return
790}
791
792// List sends the list request.
793// Parameters:
794// poolID - the ID of the Pool from which you want to list Compute Nodes.
795// filter - an OData $filter clause. For more information on constructing this filter, see
796// https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-nodes-in-a-pool.
797// selectParameter - an OData $select clause.
798// maxResults - the maximum number of items to return in the response. A maximum of 1000 Compute Nodes can be
799// returned.
800// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
801// seconds.
802// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
803// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
804// returnClientRequestID - whether the server should return the client-request-id in the response.
805// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
806// time; set it explicitly if you are calling the REST API directly.
807func (client ComputeNodeClient) List(ctx context.Context, poolID string, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNodeListResultPage, err error) {
808	if tracing.IsEnabled() {
809		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.List")
810		defer func() {
811			sc := -1
812			if result.cnlr.Response.Response != nil {
813				sc = result.cnlr.Response.Response.StatusCode
814			}
815			tracing.EndSpan(ctx, sc, err)
816		}()
817	}
818	if err := validation.Validate([]validation.Validation{
819		{TargetValue: maxResults,
820			Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false,
821				Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
822					{Target: "maxResults", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
823				}}}}}); err != nil {
824		return result, validation.NewError("batch.ComputeNodeClient", "List", err.Error())
825	}
826
827	result.fn = client.listNextResults
828	req, err := client.ListPreparer(ctx, poolID, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
829	if err != nil {
830		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", nil, "Failure preparing request")
831		return
832	}
833
834	resp, err := client.ListSender(req)
835	if err != nil {
836		result.cnlr.Response = autorest.Response{Response: resp}
837		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", resp, "Failure sending request")
838		return
839	}
840
841	result.cnlr, err = client.ListResponder(resp)
842	if err != nil {
843		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "List", resp, "Failure responding to request")
844		return
845	}
846	if result.cnlr.hasNextLink() && result.cnlr.IsEmpty() {
847		err = result.NextWithContext(ctx)
848		return
849	}
850
851	return
852}
853
854// ListPreparer prepares the List request.
855func (client ComputeNodeClient) ListPreparer(ctx context.Context, poolID string, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
856	urlParameters := map[string]interface{}{
857		"batchUrl": client.BatchURL,
858	}
859
860	pathParameters := map[string]interface{}{
861		"poolId": autorest.Encode("path", poolID),
862	}
863
864	const APIVersion = "2019-08-01.10.0"
865	queryParameters := map[string]interface{}{
866		"api-version": APIVersion,
867	}
868	if len(filter) > 0 {
869		queryParameters["$filter"] = autorest.Encode("query", filter)
870	}
871	if len(selectParameter) > 0 {
872		queryParameters["$select"] = autorest.Encode("query", selectParameter)
873	}
874	if maxResults != nil {
875		queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
876	} else {
877		queryParameters["maxresults"] = autorest.Encode("query", 1000)
878	}
879	if timeout != nil {
880		queryParameters["timeout"] = autorest.Encode("query", *timeout)
881	} else {
882		queryParameters["timeout"] = autorest.Encode("query", 30)
883	}
884
885	preparer := autorest.CreatePreparer(
886		autorest.AsGet(),
887		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
888		autorest.WithPathParameters("/pools/{poolId}/nodes", pathParameters),
889		autorest.WithQueryParameters(queryParameters))
890	if clientRequestID != nil {
891		preparer = autorest.DecoratePreparer(preparer,
892			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
893	}
894	if returnClientRequestID != nil {
895		preparer = autorest.DecoratePreparer(preparer,
896			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
897	} else {
898		preparer = autorest.DecoratePreparer(preparer,
899			autorest.WithHeader("return-client-request-id", autorest.String(false)))
900	}
901	if ocpDate != nil {
902		preparer = autorest.DecoratePreparer(preparer,
903			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
904	}
905	return preparer.Prepare((&http.Request{}).WithContext(ctx))
906}
907
908// ListSender sends the List request. The method will close the
909// http.Response Body if it receives an error.
910func (client ComputeNodeClient) ListSender(req *http.Request) (*http.Response, error) {
911	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
912}
913
914// ListResponder handles the response to the List request. The method always
915// closes the http.Response Body.
916func (client ComputeNodeClient) ListResponder(resp *http.Response) (result ComputeNodeListResult, err error) {
917	err = autorest.Respond(
918		resp,
919		azure.WithErrorUnlessStatusCode(http.StatusOK),
920		autorest.ByUnmarshallingJSON(&result),
921		autorest.ByClosing())
922	result.Response = autorest.Response{Response: resp}
923	return
924}
925
926// listNextResults retrieves the next set of results, if any.
927func (client ComputeNodeClient) listNextResults(ctx context.Context, lastResults ComputeNodeListResult) (result ComputeNodeListResult, err error) {
928	req, err := lastResults.computeNodeListResultPreparer(ctx)
929	if err != nil {
930		return result, autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", nil, "Failure preparing next results request")
931	}
932	if req == nil {
933		return
934	}
935	resp, err := client.ListSender(req)
936	if err != nil {
937		result.Response = autorest.Response{Response: resp}
938		return result, autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", resp, "Failure sending next results request")
939	}
940	result, err = client.ListResponder(resp)
941	if err != nil {
942		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "listNextResults", resp, "Failure responding to next results request")
943	}
944	return
945}
946
947// ListComplete enumerates all values, automatically crossing page boundaries as required.
948func (client ComputeNodeClient) ListComplete(ctx context.Context, poolID string, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result ComputeNodeListResultIterator, err error) {
949	if tracing.IsEnabled() {
950		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.List")
951		defer func() {
952			sc := -1
953			if result.Response().Response.Response != nil {
954				sc = result.page.Response().Response.Response.StatusCode
955			}
956			tracing.EndSpan(ctx, sc, err)
957		}()
958	}
959	result.page, err = client.List(ctx, poolID, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
960	return
961}
962
963// Reboot you can restart a Compute Node only if it is in an idle or running state.
964// Parameters:
965// poolID - the ID of the Pool that contains the Compute Node.
966// nodeID - the ID of the Compute Node that you want to restart.
967// nodeRebootParameter - the parameters for the request.
968// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
969// seconds.
970// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
971// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
972// returnClientRequestID - whether the server should return the client-request-id in the response.
973// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
974// time; set it explicitly if you are calling the REST API directly.
975func (client ComputeNodeClient) Reboot(ctx context.Context, poolID string, nodeID string, nodeRebootParameter *NodeRebootParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
976	if tracing.IsEnabled() {
977		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.Reboot")
978		defer func() {
979			sc := -1
980			if result.Response != nil {
981				sc = result.Response.StatusCode
982			}
983			tracing.EndSpan(ctx, sc, err)
984		}()
985	}
986	req, err := client.RebootPreparer(ctx, poolID, nodeID, nodeRebootParameter, timeout, clientRequestID, returnClientRequestID, ocpDate)
987	if err != nil {
988		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", nil, "Failure preparing request")
989		return
990	}
991
992	resp, err := client.RebootSender(req)
993	if err != nil {
994		result.Response = resp
995		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", resp, "Failure sending request")
996		return
997	}
998
999	result, err = client.RebootResponder(resp)
1000	if err != nil {
1001		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reboot", resp, "Failure responding to request")
1002		return
1003	}
1004
1005	return
1006}
1007
1008// RebootPreparer prepares the Reboot request.
1009func (client ComputeNodeClient) RebootPreparer(ctx context.Context, poolID string, nodeID string, nodeRebootParameter *NodeRebootParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
1010	urlParameters := map[string]interface{}{
1011		"batchUrl": client.BatchURL,
1012	}
1013
1014	pathParameters := map[string]interface{}{
1015		"nodeId": autorest.Encode("path", nodeID),
1016		"poolId": autorest.Encode("path", poolID),
1017	}
1018
1019	const APIVersion = "2019-08-01.10.0"
1020	queryParameters := map[string]interface{}{
1021		"api-version": APIVersion,
1022	}
1023	if timeout != nil {
1024		queryParameters["timeout"] = autorest.Encode("query", *timeout)
1025	} else {
1026		queryParameters["timeout"] = autorest.Encode("query", 30)
1027	}
1028
1029	preparer := autorest.CreatePreparer(
1030		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
1031		autorest.AsPost(),
1032		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
1033		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/reboot", pathParameters),
1034		autorest.WithQueryParameters(queryParameters))
1035	if nodeRebootParameter != nil {
1036		preparer = autorest.DecoratePreparer(preparer,
1037			autorest.WithJSON(nodeRebootParameter))
1038	}
1039	if clientRequestID != nil {
1040		preparer = autorest.DecoratePreparer(preparer,
1041			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
1042	}
1043	if returnClientRequestID != nil {
1044		preparer = autorest.DecoratePreparer(preparer,
1045			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
1046	} else {
1047		preparer = autorest.DecoratePreparer(preparer,
1048			autorest.WithHeader("return-client-request-id", autorest.String(false)))
1049	}
1050	if ocpDate != nil {
1051		preparer = autorest.DecoratePreparer(preparer,
1052			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
1053	}
1054	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1055}
1056
1057// RebootSender sends the Reboot request. The method will close the
1058// http.Response Body if it receives an error.
1059func (client ComputeNodeClient) RebootSender(req *http.Request) (*http.Response, error) {
1060	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1061}
1062
1063// RebootResponder handles the response to the Reboot request. The method always
1064// closes the http.Response Body.
1065func (client ComputeNodeClient) RebootResponder(resp *http.Response) (result autorest.Response, err error) {
1066	err = autorest.Respond(
1067		resp,
1068		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1069		autorest.ByClosing())
1070	result.Response = resp
1071	return
1072}
1073
1074// Reimage you can reinstall the operating system on a Compute Node only if it is in an idle or running state. This API
1075// can be invoked only on Pools created with the cloud service configuration property.
1076// Parameters:
1077// poolID - the ID of the Pool that contains the Compute Node.
1078// nodeID - the ID of the Compute Node that you want to restart.
1079// nodeReimageParameter - the parameters for the request.
1080// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
1081// seconds.
1082// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
1083// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
1084// returnClientRequestID - whether the server should return the client-request-id in the response.
1085// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
1086// time; set it explicitly if you are calling the REST API directly.
1087func (client ComputeNodeClient) Reimage(ctx context.Context, poolID string, nodeID string, nodeReimageParameter *NodeReimageParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
1088	if tracing.IsEnabled() {
1089		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.Reimage")
1090		defer func() {
1091			sc := -1
1092			if result.Response != nil {
1093				sc = result.Response.StatusCode
1094			}
1095			tracing.EndSpan(ctx, sc, err)
1096		}()
1097	}
1098	req, err := client.ReimagePreparer(ctx, poolID, nodeID, nodeReimageParameter, timeout, clientRequestID, returnClientRequestID, ocpDate)
1099	if err != nil {
1100		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", nil, "Failure preparing request")
1101		return
1102	}
1103
1104	resp, err := client.ReimageSender(req)
1105	if err != nil {
1106		result.Response = resp
1107		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", resp, "Failure sending request")
1108		return
1109	}
1110
1111	result, err = client.ReimageResponder(resp)
1112	if err != nil {
1113		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "Reimage", resp, "Failure responding to request")
1114		return
1115	}
1116
1117	return
1118}
1119
1120// ReimagePreparer prepares the Reimage request.
1121func (client ComputeNodeClient) ReimagePreparer(ctx context.Context, poolID string, nodeID string, nodeReimageParameter *NodeReimageParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
1122	urlParameters := map[string]interface{}{
1123		"batchUrl": client.BatchURL,
1124	}
1125
1126	pathParameters := map[string]interface{}{
1127		"nodeId": autorest.Encode("path", nodeID),
1128		"poolId": autorest.Encode("path", poolID),
1129	}
1130
1131	const APIVersion = "2019-08-01.10.0"
1132	queryParameters := map[string]interface{}{
1133		"api-version": APIVersion,
1134	}
1135	if timeout != nil {
1136		queryParameters["timeout"] = autorest.Encode("query", *timeout)
1137	} else {
1138		queryParameters["timeout"] = autorest.Encode("query", 30)
1139	}
1140
1141	preparer := autorest.CreatePreparer(
1142		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
1143		autorest.AsPost(),
1144		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
1145		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/reimage", pathParameters),
1146		autorest.WithQueryParameters(queryParameters))
1147	if nodeReimageParameter != nil {
1148		preparer = autorest.DecoratePreparer(preparer,
1149			autorest.WithJSON(nodeReimageParameter))
1150	}
1151	if clientRequestID != nil {
1152		preparer = autorest.DecoratePreparer(preparer,
1153			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
1154	}
1155	if returnClientRequestID != nil {
1156		preparer = autorest.DecoratePreparer(preparer,
1157			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
1158	} else {
1159		preparer = autorest.DecoratePreparer(preparer,
1160			autorest.WithHeader("return-client-request-id", autorest.String(false)))
1161	}
1162	if ocpDate != nil {
1163		preparer = autorest.DecoratePreparer(preparer,
1164			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
1165	}
1166	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1167}
1168
1169// ReimageSender sends the Reimage request. The method will close the
1170// http.Response Body if it receives an error.
1171func (client ComputeNodeClient) ReimageSender(req *http.Request) (*http.Response, error) {
1172	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1173}
1174
1175// ReimageResponder handles the response to the Reimage request. The method always
1176// closes the http.Response Body.
1177func (client ComputeNodeClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) {
1178	err = autorest.Respond(
1179		resp,
1180		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1181		autorest.ByClosing())
1182	result.Response = resp
1183	return
1184}
1185
1186// UpdateUser this operation replaces of all the updatable properties of the Account. For example, if the expiryTime
1187// element is not specified, the current value is replaced with the default value, not left unmodified. You can update
1188// a user Account on a Compute Node only when it is in the idle or running state.
1189// Parameters:
1190// poolID - the ID of the Pool that contains the Compute Node.
1191// nodeID - the ID of the machine on which you want to update a user Account.
1192// userName - the name of the user Account to update.
1193// nodeUpdateUserParameter - the parameters for the request.
1194// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
1195// seconds.
1196// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
1197// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
1198// returnClientRequestID - whether the server should return the client-request-id in the response.
1199// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
1200// time; set it explicitly if you are calling the REST API directly.
1201func (client ComputeNodeClient) UpdateUser(ctx context.Context, poolID string, nodeID string, userName string, nodeUpdateUserParameter NodeUpdateUserParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
1202	if tracing.IsEnabled() {
1203		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.UpdateUser")
1204		defer func() {
1205			sc := -1
1206			if result.Response != nil {
1207				sc = result.Response.StatusCode
1208			}
1209			tracing.EndSpan(ctx, sc, err)
1210		}()
1211	}
1212	req, err := client.UpdateUserPreparer(ctx, poolID, nodeID, userName, nodeUpdateUserParameter, timeout, clientRequestID, returnClientRequestID, ocpDate)
1213	if err != nil {
1214		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", nil, "Failure preparing request")
1215		return
1216	}
1217
1218	resp, err := client.UpdateUserSender(req)
1219	if err != nil {
1220		result.Response = resp
1221		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", resp, "Failure sending request")
1222		return
1223	}
1224
1225	result, err = client.UpdateUserResponder(resp)
1226	if err != nil {
1227		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UpdateUser", resp, "Failure responding to request")
1228		return
1229	}
1230
1231	return
1232}
1233
1234// UpdateUserPreparer prepares the UpdateUser request.
1235func (client ComputeNodeClient) UpdateUserPreparer(ctx context.Context, poolID string, nodeID string, userName string, nodeUpdateUserParameter NodeUpdateUserParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
1236	urlParameters := map[string]interface{}{
1237		"batchUrl": client.BatchURL,
1238	}
1239
1240	pathParameters := map[string]interface{}{
1241		"nodeId":   autorest.Encode("path", nodeID),
1242		"poolId":   autorest.Encode("path", poolID),
1243		"userName": autorest.Encode("path", userName),
1244	}
1245
1246	const APIVersion = "2019-08-01.10.0"
1247	queryParameters := map[string]interface{}{
1248		"api-version": APIVersion,
1249	}
1250	if timeout != nil {
1251		queryParameters["timeout"] = autorest.Encode("query", *timeout)
1252	} else {
1253		queryParameters["timeout"] = autorest.Encode("query", 30)
1254	}
1255
1256	preparer := autorest.CreatePreparer(
1257		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
1258		autorest.AsPut(),
1259		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
1260		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/users/{userName}", pathParameters),
1261		autorest.WithJSON(nodeUpdateUserParameter),
1262		autorest.WithQueryParameters(queryParameters))
1263	if clientRequestID != nil {
1264		preparer = autorest.DecoratePreparer(preparer,
1265			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
1266	}
1267	if returnClientRequestID != nil {
1268		preparer = autorest.DecoratePreparer(preparer,
1269			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
1270	} else {
1271		preparer = autorest.DecoratePreparer(preparer,
1272			autorest.WithHeader("return-client-request-id", autorest.String(false)))
1273	}
1274	if ocpDate != nil {
1275		preparer = autorest.DecoratePreparer(preparer,
1276			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
1277	}
1278	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1279}
1280
1281// UpdateUserSender sends the UpdateUser request. The method will close the
1282// http.Response Body if it receives an error.
1283func (client ComputeNodeClient) UpdateUserSender(req *http.Request) (*http.Response, error) {
1284	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1285}
1286
1287// UpdateUserResponder handles the response to the UpdateUser request. The method always
1288// closes the http.Response Body.
1289func (client ComputeNodeClient) UpdateUserResponder(resp *http.Response) (result autorest.Response, err error) {
1290	err = autorest.Respond(
1291		resp,
1292		azure.WithErrorUnlessStatusCode(http.StatusOK),
1293		autorest.ByClosing())
1294	result.Response = resp
1295	return
1296}
1297
1298// UploadBatchServiceLogs this is for gathering Azure Batch service log files in an automated fashion from Compute
1299// Nodes if you are experiencing an error and wish to escalate to Azure support. The Azure Batch service log files
1300// should be shared with Azure support to aid in debugging issues with the Batch service.
1301// Parameters:
1302// poolID - the ID of the Pool that contains the Compute Node.
1303// nodeID - the ID of the Compute Node from which you want to upload the Azure Batch service log files.
1304// uploadBatchServiceLogsConfiguration - the Azure Batch service log files upload configuration.
1305// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
1306// seconds.
1307// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
1308// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
1309// returnClientRequestID - whether the server should return the client-request-id in the response.
1310// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
1311// time; set it explicitly if you are calling the REST API directly.
1312func (client ComputeNodeClient) UploadBatchServiceLogs(ctx context.Context, poolID string, nodeID string, uploadBatchServiceLogsConfiguration UploadBatchServiceLogsConfiguration, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result UploadBatchServiceLogsResult, err error) {
1313	if tracing.IsEnabled() {
1314		ctx = tracing.StartSpan(ctx, fqdn+"/ComputeNodeClient.UploadBatchServiceLogs")
1315		defer func() {
1316			sc := -1
1317			if result.Response.Response != nil {
1318				sc = result.Response.Response.StatusCode
1319			}
1320			tracing.EndSpan(ctx, sc, err)
1321		}()
1322	}
1323	if err := validation.Validate([]validation.Validation{
1324		{TargetValue: uploadBatchServiceLogsConfiguration,
1325			Constraints: []validation.Constraint{{Target: "uploadBatchServiceLogsConfiguration.ContainerURL", Name: validation.Null, Rule: true, Chain: nil},
1326				{Target: "uploadBatchServiceLogsConfiguration.StartTime", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
1327		return result, validation.NewError("batch.ComputeNodeClient", "UploadBatchServiceLogs", err.Error())
1328	}
1329
1330	req, err := client.UploadBatchServiceLogsPreparer(ctx, poolID, nodeID, uploadBatchServiceLogsConfiguration, timeout, clientRequestID, returnClientRequestID, ocpDate)
1331	if err != nil {
1332		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UploadBatchServiceLogs", nil, "Failure preparing request")
1333		return
1334	}
1335
1336	resp, err := client.UploadBatchServiceLogsSender(req)
1337	if err != nil {
1338		result.Response = autorest.Response{Response: resp}
1339		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UploadBatchServiceLogs", resp, "Failure sending request")
1340		return
1341	}
1342
1343	result, err = client.UploadBatchServiceLogsResponder(resp)
1344	if err != nil {
1345		err = autorest.NewErrorWithError(err, "batch.ComputeNodeClient", "UploadBatchServiceLogs", resp, "Failure responding to request")
1346		return
1347	}
1348
1349	return
1350}
1351
1352// UploadBatchServiceLogsPreparer prepares the UploadBatchServiceLogs request.
1353func (client ComputeNodeClient) UploadBatchServiceLogsPreparer(ctx context.Context, poolID string, nodeID string, uploadBatchServiceLogsConfiguration UploadBatchServiceLogsConfiguration, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
1354	urlParameters := map[string]interface{}{
1355		"batchUrl": client.BatchURL,
1356	}
1357
1358	pathParameters := map[string]interface{}{
1359		"nodeId": autorest.Encode("path", nodeID),
1360		"poolId": autorest.Encode("path", poolID),
1361	}
1362
1363	const APIVersion = "2019-08-01.10.0"
1364	queryParameters := map[string]interface{}{
1365		"api-version": APIVersion,
1366	}
1367	if timeout != nil {
1368		queryParameters["timeout"] = autorest.Encode("query", *timeout)
1369	} else {
1370		queryParameters["timeout"] = autorest.Encode("query", 30)
1371	}
1372
1373	preparer := autorest.CreatePreparer(
1374		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
1375		autorest.AsPost(),
1376		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
1377		autorest.WithPathParameters("/pools/{poolId}/nodes/{nodeId}/uploadbatchservicelogs", pathParameters),
1378		autorest.WithJSON(uploadBatchServiceLogsConfiguration),
1379		autorest.WithQueryParameters(queryParameters))
1380	if clientRequestID != nil {
1381		preparer = autorest.DecoratePreparer(preparer,
1382			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
1383	}
1384	if returnClientRequestID != nil {
1385		preparer = autorest.DecoratePreparer(preparer,
1386			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
1387	} else {
1388		preparer = autorest.DecoratePreparer(preparer,
1389			autorest.WithHeader("return-client-request-id", autorest.String(false)))
1390	}
1391	if ocpDate != nil {
1392		preparer = autorest.DecoratePreparer(preparer,
1393			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
1394	}
1395	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1396}
1397
1398// UploadBatchServiceLogsSender sends the UploadBatchServiceLogs request. The method will close the
1399// http.Response Body if it receives an error.
1400func (client ComputeNodeClient) UploadBatchServiceLogsSender(req *http.Request) (*http.Response, error) {
1401	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1402}
1403
1404// UploadBatchServiceLogsResponder handles the response to the UploadBatchServiceLogs request. The method always
1405// closes the http.Response Body.
1406func (client ComputeNodeClient) UploadBatchServiceLogsResponder(resp *http.Response) (result UploadBatchServiceLogsResult, err error) {
1407	err = autorest.Respond(
1408		resp,
1409		azure.WithErrorUnlessStatusCode(http.StatusOK),
1410		autorest.ByUnmarshallingJSON(&result),
1411		autorest.ByClosing())
1412	result.Response = autorest.Response{Response: resp}
1413	return
1414}
1415