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