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