1package batch
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
10	"context"
11	"github.com/Azure/go-autorest/autorest"
12	"github.com/Azure/go-autorest/autorest/azure"
13	"github.com/Azure/go-autorest/autorest/date"
14	"github.com/Azure/go-autorest/autorest/validation"
15	"github.com/Azure/go-autorest/tracing"
16	"github.com/gofrs/uuid"
17	"net/http"
18)
19
20// CertificateClient is the a client for issuing REST requests to the Azure Batch service.
21type CertificateClient struct {
22	BaseClient
23}
24
25// NewCertificateClient creates an instance of the CertificateClient client.
26func NewCertificateClient(batchURL string) CertificateClient {
27	return CertificateClient{New(batchURL)}
28}
29
30// Add sends the add request.
31// Parameters:
32// certificate - the Certificate to be added.
33// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
34// seconds.
35// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
36// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
37// returnClientRequestID - whether the server should return the client-request-id in the response.
38// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
39// time; set it explicitly if you are calling the REST API directly.
40func (client CertificateClient) Add(ctx context.Context, certificate CertificateAddParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
41	if tracing.IsEnabled() {
42		ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.Add")
43		defer func() {
44			sc := -1
45			if result.Response != nil {
46				sc = result.Response.StatusCode
47			}
48			tracing.EndSpan(ctx, sc, err)
49		}()
50	}
51	if err := validation.Validate([]validation.Validation{
52		{TargetValue: certificate,
53			Constraints: []validation.Constraint{{Target: "certificate.Thumbprint", Name: validation.Null, Rule: true, Chain: nil},
54				{Target: "certificate.ThumbprintAlgorithm", Name: validation.Null, Rule: true, Chain: nil},
55				{Target: "certificate.Data", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
56		return result, validation.NewError("batch.CertificateClient", "Add", err.Error())
57	}
58
59	req, err := client.AddPreparer(ctx, certificate, timeout, clientRequestID, returnClientRequestID, ocpDate)
60	if err != nil {
61		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Add", nil, "Failure preparing request")
62		return
63	}
64
65	resp, err := client.AddSender(req)
66	if err != nil {
67		result.Response = resp
68		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Add", resp, "Failure sending request")
69		return
70	}
71
72	result, err = client.AddResponder(resp)
73	if err != nil {
74		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Add", resp, "Failure responding to request")
75		return
76	}
77
78	return
79}
80
81// AddPreparer prepares the Add request.
82func (client CertificateClient) AddPreparer(ctx context.Context, certificate CertificateAddParameter, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
83	urlParameters := map[string]interface{}{
84		"batchUrl": client.BatchURL,
85	}
86
87	const APIVersion = "2019-08-01.10.0"
88	queryParameters := map[string]interface{}{
89		"api-version": APIVersion,
90	}
91	if timeout != nil {
92		queryParameters["timeout"] = autorest.Encode("query", *timeout)
93	} else {
94		queryParameters["timeout"] = autorest.Encode("query", 30)
95	}
96
97	preparer := autorest.CreatePreparer(
98		autorest.AsContentType("application/json; odata=minimalmetadata; charset=utf-8"),
99		autorest.AsPost(),
100		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
101		autorest.WithPath("/certificates"),
102		autorest.WithJSON(certificate),
103		autorest.WithQueryParameters(queryParameters))
104	if clientRequestID != nil {
105		preparer = autorest.DecoratePreparer(preparer,
106			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
107	}
108	if returnClientRequestID != nil {
109		preparer = autorest.DecoratePreparer(preparer,
110			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
111	} else {
112		preparer = autorest.DecoratePreparer(preparer,
113			autorest.WithHeader("return-client-request-id", autorest.String(false)))
114	}
115	if ocpDate != nil {
116		preparer = autorest.DecoratePreparer(preparer,
117			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
118	}
119	return preparer.Prepare((&http.Request{}).WithContext(ctx))
120}
121
122// AddSender sends the Add request. The method will close the
123// http.Response Body if it receives an error.
124func (client CertificateClient) AddSender(req *http.Request) (*http.Response, error) {
125	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
126}
127
128// AddResponder handles the response to the Add request. The method always
129// closes the http.Response Body.
130func (client CertificateClient) AddResponder(resp *http.Response) (result autorest.Response, err error) {
131	err = autorest.Respond(
132		resp,
133		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
134		autorest.ByClosing())
135	result.Response = resp
136	return
137}
138
139// CancelDeletion if you try to delete a Certificate that is being used by a Pool or Compute Node, the status of the
140// Certificate changes to deleteFailed. If you decide that you want to continue using the Certificate, you can use this
141// operation to set the status of the Certificate back to active. If you intend to delete the Certificate, you do not
142// need to run this operation after the deletion failed. You must make sure that the Certificate is not being used by
143// any resources, and then you can try again to delete the Certificate.
144// Parameters:
145// thumbprintAlgorithm - the algorithm used to derive the thumbprint parameter. This must be sha1.
146// thumbprint - the thumbprint of the Certificate being deleted.
147// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
148// seconds.
149// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
150// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
151// returnClientRequestID - whether the server should return the client-request-id in the response.
152// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
153// time; set it explicitly if you are calling the REST API directly.
154func (client CertificateClient) CancelDeletion(ctx context.Context, thumbprintAlgorithm string, thumbprint string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
155	if tracing.IsEnabled() {
156		ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.CancelDeletion")
157		defer func() {
158			sc := -1
159			if result.Response != nil {
160				sc = result.Response.StatusCode
161			}
162			tracing.EndSpan(ctx, sc, err)
163		}()
164	}
165	req, err := client.CancelDeletionPreparer(ctx, thumbprintAlgorithm, thumbprint, timeout, clientRequestID, returnClientRequestID, ocpDate)
166	if err != nil {
167		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "CancelDeletion", nil, "Failure preparing request")
168		return
169	}
170
171	resp, err := client.CancelDeletionSender(req)
172	if err != nil {
173		result.Response = resp
174		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "CancelDeletion", resp, "Failure sending request")
175		return
176	}
177
178	result, err = client.CancelDeletionResponder(resp)
179	if err != nil {
180		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "CancelDeletion", resp, "Failure responding to request")
181		return
182	}
183
184	return
185}
186
187// CancelDeletionPreparer prepares the CancelDeletion request.
188func (client CertificateClient) CancelDeletionPreparer(ctx context.Context, thumbprintAlgorithm string, thumbprint string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
189	urlParameters := map[string]interface{}{
190		"batchUrl": client.BatchURL,
191	}
192
193	pathParameters := map[string]interface{}{
194		"thumbprint":          autorest.Encode("path", thumbprint),
195		"thumbprintAlgorithm": autorest.Encode("path", thumbprintAlgorithm),
196	}
197
198	const APIVersion = "2019-08-01.10.0"
199	queryParameters := map[string]interface{}{
200		"api-version": APIVersion,
201	}
202	if timeout != nil {
203		queryParameters["timeout"] = autorest.Encode("query", *timeout)
204	} else {
205		queryParameters["timeout"] = autorest.Encode("query", 30)
206	}
207
208	preparer := autorest.CreatePreparer(
209		autorest.AsPost(),
210		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
211		autorest.WithPathParameters("/certificates(thumbprintAlgorithm={thumbprintAlgorithm},thumbprint={thumbprint})/canceldelete", pathParameters),
212		autorest.WithQueryParameters(queryParameters))
213	if clientRequestID != nil {
214		preparer = autorest.DecoratePreparer(preparer,
215			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
216	}
217	if returnClientRequestID != nil {
218		preparer = autorest.DecoratePreparer(preparer,
219			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
220	} else {
221		preparer = autorest.DecoratePreparer(preparer,
222			autorest.WithHeader("return-client-request-id", autorest.String(false)))
223	}
224	if ocpDate != nil {
225		preparer = autorest.DecoratePreparer(preparer,
226			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
227	}
228	return preparer.Prepare((&http.Request{}).WithContext(ctx))
229}
230
231// CancelDeletionSender sends the CancelDeletion request. The method will close the
232// http.Response Body if it receives an error.
233func (client CertificateClient) CancelDeletionSender(req *http.Request) (*http.Response, error) {
234	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
235}
236
237// CancelDeletionResponder handles the response to the CancelDeletion request. The method always
238// closes the http.Response Body.
239func (client CertificateClient) CancelDeletionResponder(resp *http.Response) (result autorest.Response, err error) {
240	err = autorest.Respond(
241		resp,
242		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
243		autorest.ByClosing())
244	result.Response = resp
245	return
246}
247
248// Delete you cannot delete a Certificate if a resource (Pool or Compute Node) is using it. Before you can delete a
249// Certificate, you must therefore make sure that the Certificate is not associated with any existing Pools, the
250// Certificate is not installed on any Nodes (even if you remove a Certificate from a Pool, it is not removed from
251// existing Compute Nodes in that Pool until they restart), and no running Tasks depend on the Certificate. If you try
252// to delete a Certificate that is in use, the deletion fails. The Certificate status changes to deleteFailed. You can
253// use Cancel Delete Certificate to set the status back to active if you decide that you want to continue using the
254// Certificate.
255// Parameters:
256// thumbprintAlgorithm - the algorithm used to derive the thumbprint parameter. This must be sha1.
257// thumbprint - the thumbprint of the Certificate to be deleted.
258// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
259// seconds.
260// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
261// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
262// returnClientRequestID - whether the server should return the client-request-id in the response.
263// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
264// time; set it explicitly if you are calling the REST API directly.
265func (client CertificateClient) Delete(ctx context.Context, thumbprintAlgorithm string, thumbprint string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result autorest.Response, err error) {
266	if tracing.IsEnabled() {
267		ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.Delete")
268		defer func() {
269			sc := -1
270			if result.Response != nil {
271				sc = result.Response.StatusCode
272			}
273			tracing.EndSpan(ctx, sc, err)
274		}()
275	}
276	req, err := client.DeletePreparer(ctx, thumbprintAlgorithm, thumbprint, timeout, clientRequestID, returnClientRequestID, ocpDate)
277	if err != nil {
278		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Delete", nil, "Failure preparing request")
279		return
280	}
281
282	resp, err := client.DeleteSender(req)
283	if err != nil {
284		result.Response = resp
285		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Delete", resp, "Failure sending request")
286		return
287	}
288
289	result, err = client.DeleteResponder(resp)
290	if err != nil {
291		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Delete", resp, "Failure responding to request")
292		return
293	}
294
295	return
296}
297
298// DeletePreparer prepares the Delete request.
299func (client CertificateClient) DeletePreparer(ctx context.Context, thumbprintAlgorithm string, thumbprint string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
300	urlParameters := map[string]interface{}{
301		"batchUrl": client.BatchURL,
302	}
303
304	pathParameters := map[string]interface{}{
305		"thumbprint":          autorest.Encode("path", thumbprint),
306		"thumbprintAlgorithm": autorest.Encode("path", thumbprintAlgorithm),
307	}
308
309	const APIVersion = "2019-08-01.10.0"
310	queryParameters := map[string]interface{}{
311		"api-version": APIVersion,
312	}
313	if timeout != nil {
314		queryParameters["timeout"] = autorest.Encode("query", *timeout)
315	} else {
316		queryParameters["timeout"] = autorest.Encode("query", 30)
317	}
318
319	preparer := autorest.CreatePreparer(
320		autorest.AsDelete(),
321		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
322		autorest.WithPathParameters("/certificates(thumbprintAlgorithm={thumbprintAlgorithm},thumbprint={thumbprint})", pathParameters),
323		autorest.WithQueryParameters(queryParameters))
324	if clientRequestID != nil {
325		preparer = autorest.DecoratePreparer(preparer,
326			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
327	}
328	if returnClientRequestID != nil {
329		preparer = autorest.DecoratePreparer(preparer,
330			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
331	} else {
332		preparer = autorest.DecoratePreparer(preparer,
333			autorest.WithHeader("return-client-request-id", autorest.String(false)))
334	}
335	if ocpDate != nil {
336		preparer = autorest.DecoratePreparer(preparer,
337			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
338	}
339	return preparer.Prepare((&http.Request{}).WithContext(ctx))
340}
341
342// DeleteSender sends the Delete request. The method will close the
343// http.Response Body if it receives an error.
344func (client CertificateClient) DeleteSender(req *http.Request) (*http.Response, error) {
345	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
346}
347
348// DeleteResponder handles the response to the Delete request. The method always
349// closes the http.Response Body.
350func (client CertificateClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
351	err = autorest.Respond(
352		resp,
353		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
354		autorest.ByClosing())
355	result.Response = resp
356	return
357}
358
359// Get gets information about the specified Certificate.
360// Parameters:
361// thumbprintAlgorithm - the algorithm used to derive the thumbprint parameter. This must be sha1.
362// thumbprint - the thumbprint of the Certificate to get.
363// selectParameter - an OData $select clause.
364// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
365// seconds.
366// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
367// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
368// returnClientRequestID - whether the server should return the client-request-id in the response.
369// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
370// time; set it explicitly if you are calling the REST API directly.
371func (client CertificateClient) Get(ctx context.Context, thumbprintAlgorithm string, thumbprint string, selectParameter string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result Certificate, err error) {
372	if tracing.IsEnabled() {
373		ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.Get")
374		defer func() {
375			sc := -1
376			if result.Response.Response != nil {
377				sc = result.Response.Response.StatusCode
378			}
379			tracing.EndSpan(ctx, sc, err)
380		}()
381	}
382	req, err := client.GetPreparer(ctx, thumbprintAlgorithm, thumbprint, selectParameter, timeout, clientRequestID, returnClientRequestID, ocpDate)
383	if err != nil {
384		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Get", nil, "Failure preparing request")
385		return
386	}
387
388	resp, err := client.GetSender(req)
389	if err != nil {
390		result.Response = autorest.Response{Response: resp}
391		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Get", resp, "Failure sending request")
392		return
393	}
394
395	result, err = client.GetResponder(resp)
396	if err != nil {
397		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "Get", resp, "Failure responding to request")
398		return
399	}
400
401	return
402}
403
404// GetPreparer prepares the Get request.
405func (client CertificateClient) GetPreparer(ctx context.Context, thumbprintAlgorithm string, thumbprint string, selectParameter string, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
406	urlParameters := map[string]interface{}{
407		"batchUrl": client.BatchURL,
408	}
409
410	pathParameters := map[string]interface{}{
411		"thumbprint":          autorest.Encode("path", thumbprint),
412		"thumbprintAlgorithm": autorest.Encode("path", thumbprintAlgorithm),
413	}
414
415	const APIVersion = "2019-08-01.10.0"
416	queryParameters := map[string]interface{}{
417		"api-version": APIVersion,
418	}
419	if len(selectParameter) > 0 {
420		queryParameters["$select"] = autorest.Encode("query", selectParameter)
421	}
422	if timeout != nil {
423		queryParameters["timeout"] = autorest.Encode("query", *timeout)
424	} else {
425		queryParameters["timeout"] = autorest.Encode("query", 30)
426	}
427
428	preparer := autorest.CreatePreparer(
429		autorest.AsGet(),
430		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
431		autorest.WithPathParameters("/certificates(thumbprintAlgorithm={thumbprintAlgorithm},thumbprint={thumbprint})", pathParameters),
432		autorest.WithQueryParameters(queryParameters))
433	if clientRequestID != nil {
434		preparer = autorest.DecoratePreparer(preparer,
435			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
436	}
437	if returnClientRequestID != nil {
438		preparer = autorest.DecoratePreparer(preparer,
439			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
440	} else {
441		preparer = autorest.DecoratePreparer(preparer,
442			autorest.WithHeader("return-client-request-id", autorest.String(false)))
443	}
444	if ocpDate != nil {
445		preparer = autorest.DecoratePreparer(preparer,
446			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
447	}
448	return preparer.Prepare((&http.Request{}).WithContext(ctx))
449}
450
451// GetSender sends the Get request. The method will close the
452// http.Response Body if it receives an error.
453func (client CertificateClient) GetSender(req *http.Request) (*http.Response, error) {
454	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
455}
456
457// GetResponder handles the response to the Get request. The method always
458// closes the http.Response Body.
459func (client CertificateClient) GetResponder(resp *http.Response) (result Certificate, err error) {
460	err = autorest.Respond(
461		resp,
462		azure.WithErrorUnlessStatusCode(http.StatusOK),
463		autorest.ByUnmarshallingJSON(&result),
464		autorest.ByClosing())
465	result.Response = autorest.Response{Response: resp}
466	return
467}
468
469// List sends the list request.
470// Parameters:
471// filter - an OData $filter clause. For more information on constructing this filter, see
472// https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-certificates.
473// selectParameter - an OData $select clause.
474// maxResults - the maximum number of items to return in the response. A maximum of 1000 Certificates can be
475// returned.
476// timeout - the maximum time that the server can spend processing the request, in seconds. The default is 30
477// seconds.
478// clientRequestID - the caller-generated request identity, in the form of a GUID with no decoration such as
479// curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
480// returnClientRequestID - whether the server should return the client-request-id in the response.
481// ocpDate - the time the request was issued. Client libraries typically set this to the current system clock
482// time; set it explicitly if you are calling the REST API directly.
483func (client CertificateClient) List(ctx context.Context, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CertificateListResultPage, err error) {
484	if tracing.IsEnabled() {
485		ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.List")
486		defer func() {
487			sc := -1
488			if result.clr.Response.Response != nil {
489				sc = result.clr.Response.Response.StatusCode
490			}
491			tracing.EndSpan(ctx, sc, err)
492		}()
493	}
494	if err := validation.Validate([]validation.Validation{
495		{TargetValue: maxResults,
496			Constraints: []validation.Constraint{{Target: "maxResults", Name: validation.Null, Rule: false,
497				Chain: []validation.Constraint{{Target: "maxResults", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},
498					{Target: "maxResults", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
499				}}}}}); err != nil {
500		return result, validation.NewError("batch.CertificateClient", "List", err.Error())
501	}
502
503	result.fn = client.listNextResults
504	req, err := client.ListPreparer(ctx, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
505	if err != nil {
506		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "List", nil, "Failure preparing request")
507		return
508	}
509
510	resp, err := client.ListSender(req)
511	if err != nil {
512		result.clr.Response = autorest.Response{Response: resp}
513		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "List", resp, "Failure sending request")
514		return
515	}
516
517	result.clr, err = client.ListResponder(resp)
518	if err != nil {
519		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "List", resp, "Failure responding to request")
520		return
521	}
522	if result.clr.hasNextLink() && result.clr.IsEmpty() {
523		err = result.NextWithContext(ctx)
524		return
525	}
526
527	return
528}
529
530// ListPreparer prepares the List request.
531func (client CertificateClient) ListPreparer(ctx context.Context, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (*http.Request, error) {
532	urlParameters := map[string]interface{}{
533		"batchUrl": client.BatchURL,
534	}
535
536	const APIVersion = "2019-08-01.10.0"
537	queryParameters := map[string]interface{}{
538		"api-version": APIVersion,
539	}
540	if len(filter) > 0 {
541		queryParameters["$filter"] = autorest.Encode("query", filter)
542	}
543	if len(selectParameter) > 0 {
544		queryParameters["$select"] = autorest.Encode("query", selectParameter)
545	}
546	if maxResults != nil {
547		queryParameters["maxresults"] = autorest.Encode("query", *maxResults)
548	} else {
549		queryParameters["maxresults"] = autorest.Encode("query", 1000)
550	}
551	if timeout != nil {
552		queryParameters["timeout"] = autorest.Encode("query", *timeout)
553	} else {
554		queryParameters["timeout"] = autorest.Encode("query", 30)
555	}
556
557	preparer := autorest.CreatePreparer(
558		autorest.AsGet(),
559		autorest.WithCustomBaseURL("{batchUrl}", urlParameters),
560		autorest.WithPath("/certificates"),
561		autorest.WithQueryParameters(queryParameters))
562	if clientRequestID != nil {
563		preparer = autorest.DecoratePreparer(preparer,
564			autorest.WithHeader("client-request-id", autorest.String(clientRequestID)))
565	}
566	if returnClientRequestID != nil {
567		preparer = autorest.DecoratePreparer(preparer,
568			autorest.WithHeader("return-client-request-id", autorest.String(returnClientRequestID)))
569	} else {
570		preparer = autorest.DecoratePreparer(preparer,
571			autorest.WithHeader("return-client-request-id", autorest.String(false)))
572	}
573	if ocpDate != nil {
574		preparer = autorest.DecoratePreparer(preparer,
575			autorest.WithHeader("ocp-date", autorest.String(ocpDate)))
576	}
577	return preparer.Prepare((&http.Request{}).WithContext(ctx))
578}
579
580// ListSender sends the List request. The method will close the
581// http.Response Body if it receives an error.
582func (client CertificateClient) ListSender(req *http.Request) (*http.Response, error) {
583	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
584}
585
586// ListResponder handles the response to the List request. The method always
587// closes the http.Response Body.
588func (client CertificateClient) ListResponder(resp *http.Response) (result CertificateListResult, err error) {
589	err = autorest.Respond(
590		resp,
591		azure.WithErrorUnlessStatusCode(http.StatusOK),
592		autorest.ByUnmarshallingJSON(&result),
593		autorest.ByClosing())
594	result.Response = autorest.Response{Response: resp}
595	return
596}
597
598// listNextResults retrieves the next set of results, if any.
599func (client CertificateClient) listNextResults(ctx context.Context, lastResults CertificateListResult) (result CertificateListResult, err error) {
600	req, err := lastResults.certificateListResultPreparer(ctx)
601	if err != nil {
602		return result, autorest.NewErrorWithError(err, "batch.CertificateClient", "listNextResults", nil, "Failure preparing next results request")
603	}
604	if req == nil {
605		return
606	}
607	resp, err := client.ListSender(req)
608	if err != nil {
609		result.Response = autorest.Response{Response: resp}
610		return result, autorest.NewErrorWithError(err, "batch.CertificateClient", "listNextResults", resp, "Failure sending next results request")
611	}
612	result, err = client.ListResponder(resp)
613	if err != nil {
614		err = autorest.NewErrorWithError(err, "batch.CertificateClient", "listNextResults", resp, "Failure responding to next results request")
615	}
616	return
617}
618
619// ListComplete enumerates all values, automatically crossing page boundaries as required.
620func (client CertificateClient) ListComplete(ctx context.Context, filter string, selectParameter string, maxResults *int32, timeout *int32, clientRequestID *uuid.UUID, returnClientRequestID *bool, ocpDate *date.TimeRFC1123) (result CertificateListResultIterator, err error) {
621	if tracing.IsEnabled() {
622		ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.List")
623		defer func() {
624			sc := -1
625			if result.Response().Response.Response != nil {
626				sc = result.page.Response().Response.Response.StatusCode
627			}
628			tracing.EndSpan(ctx, sc, err)
629		}()
630	}
631	result.page, err = client.List(ctx, filter, selectParameter, maxResults, timeout, clientRequestID, returnClientRequestID, ocpDate)
632	return
633}
634