1package iothub
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	"net/http"
17)
18
19// DpsCertificateClient is the API for using the Azure IoT Hub Device Provisioning Service features.
20type DpsCertificateClient struct {
21	BaseClient
22}
23
24// NewDpsCertificateClient creates an instance of the DpsCertificateClient client.
25func NewDpsCertificateClient(subscriptionID string) DpsCertificateClient {
26	return NewDpsCertificateClientWithBaseURI(DefaultBaseURI, subscriptionID)
27}
28
29// NewDpsCertificateClientWithBaseURI creates an instance of the DpsCertificateClient client using a custom endpoint.
30// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
31func NewDpsCertificateClientWithBaseURI(baseURI string, subscriptionID string) DpsCertificateClient {
32	return DpsCertificateClient{NewWithBaseURI(baseURI, subscriptionID)}
33}
34
35// CreateOrUpdate add new certificate or update an existing certificate.
36// Parameters:
37// resourceGroupName - resource group identifier.
38// provisioningServiceName - the name of the provisioning service.
39// certificateName - the name of the certificate create or update.
40// certificateDescription - the certificate body.
41// ifMatch - eTag of the certificate. This is required to update an existing certificate, and ignored while
42// creating a brand new certificate.
43func (client DpsCertificateClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, certificateName string, certificateDescription CertificateBodyDescription, ifMatch string) (result CertificateResponse, err error) {
44	if tracing.IsEnabled() {
45		ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.CreateOrUpdate")
46		defer func() {
47			sc := -1
48			if result.Response.Response != nil {
49				sc = result.Response.Response.StatusCode
50			}
51			tracing.EndSpan(ctx, sc, err)
52		}()
53	}
54	if err := validation.Validate([]validation.Validation{
55		{TargetValue: certificateName,
56			Constraints: []validation.Constraint{{Target: "certificateName", Name: validation.MaxLength, Rule: 256, Chain: nil}}}}); err != nil {
57		return result, validation.NewError("iothub.DpsCertificateClient", "CreateOrUpdate", err.Error())
58	}
59
60	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, provisioningServiceName, certificateName, certificateDescription, ifMatch)
61	if err != nil {
62		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "CreateOrUpdate", nil, "Failure preparing request")
63		return
64	}
65
66	resp, err := client.CreateOrUpdateSender(req)
67	if err != nil {
68		result.Response = autorest.Response{Response: resp}
69		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "CreateOrUpdate", resp, "Failure sending request")
70		return
71	}
72
73	result, err = client.CreateOrUpdateResponder(resp)
74	if err != nil {
75		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "CreateOrUpdate", resp, "Failure responding to request")
76		return
77	}
78
79	return
80}
81
82// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
83func (client DpsCertificateClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string, certificateName string, certificateDescription CertificateBodyDescription, ifMatch string) (*http.Request, error) {
84	pathParameters := map[string]interface{}{
85		"certificateName":         autorest.Encode("path", certificateName),
86		"provisioningServiceName": autorest.Encode("path", provisioningServiceName),
87		"resourceGroupName":       autorest.Encode("path", resourceGroupName),
88		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
89	}
90
91	const APIVersion = "2017-08-21-preview"
92	queryParameters := map[string]interface{}{
93		"api-version": APIVersion,
94	}
95
96	preparer := autorest.CreatePreparer(
97		autorest.AsContentType("application/json; charset=utf-8"),
98		autorest.AsPut(),
99		autorest.WithBaseURL(client.BaseURI),
100		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", pathParameters),
101		autorest.WithJSON(certificateDescription),
102		autorest.WithQueryParameters(queryParameters))
103	if len(ifMatch) > 0 {
104		preparer = autorest.DecoratePreparer(preparer,
105			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
106	}
107	return preparer.Prepare((&http.Request{}).WithContext(ctx))
108}
109
110// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
111// http.Response Body if it receives an error.
112func (client DpsCertificateClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
113	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
114}
115
116// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
117// closes the http.Response Body.
118func (client DpsCertificateClient) CreateOrUpdateResponder(resp *http.Response) (result CertificateResponse, err error) {
119	err = autorest.Respond(
120		resp,
121		azure.WithErrorUnlessStatusCode(http.StatusOK),
122		autorest.ByUnmarshallingJSON(&result),
123		autorest.ByClosing())
124	result.Response = autorest.Response{Response: resp}
125	return
126}
127
128// Delete sends the delete request.
129// Parameters:
130// resourceGroupName - resource group identifier.
131// ifMatch - eTag of the certificate
132// provisioningServiceName - the name of the provisioning service.
133// certificateName - this is a mandatory field, and is the logical name of the certificate that the
134// provisioning service will access by.
135// certificatename - this is optional, and it is the Common Name of the certificate.
136// certificaterawBytes - raw data within the certificate.
137// certificateisVerified - indicates if certificate has been verified by owner of the private key.
138// certificatepurpose - a description that mentions the purpose of the certificate.
139// certificatecreated - time the certificate is created.
140// certificatelastUpdated - time the certificate is last updated.
141// certificatehasPrivateKey - indicates if the certificate contains a private key.
142// certificatenonce - random number generated to indicate Proof of Possession.
143func (client DpsCertificateClient) Delete(ctx context.Context, resourceGroupName string, ifMatch string, provisioningServiceName string, certificateName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result autorest.Response, err error) {
144	if tracing.IsEnabled() {
145		ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.Delete")
146		defer func() {
147			sc := -1
148			if result.Response != nil {
149				sc = result.Response.StatusCode
150			}
151			tracing.EndSpan(ctx, sc, err)
152		}()
153	}
154	req, err := client.DeletePreparer(ctx, resourceGroupName, ifMatch, provisioningServiceName, certificateName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce)
155	if err != nil {
156		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Delete", nil, "Failure preparing request")
157		return
158	}
159
160	resp, err := client.DeleteSender(req)
161	if err != nil {
162		result.Response = resp
163		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Delete", resp, "Failure sending request")
164		return
165	}
166
167	result, err = client.DeleteResponder(resp)
168	if err != nil {
169		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Delete", resp, "Failure responding to request")
170		return
171	}
172
173	return
174}
175
176// DeletePreparer prepares the Delete request.
177func (client DpsCertificateClient) DeletePreparer(ctx context.Context, resourceGroupName string, ifMatch string, provisioningServiceName string, certificateName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (*http.Request, error) {
178	pathParameters := map[string]interface{}{
179		"certificateName":         autorest.Encode("path", certificateName),
180		"provisioningServiceName": autorest.Encode("path", provisioningServiceName),
181		"resourceGroupName":       autorest.Encode("path", resourceGroupName),
182		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
183	}
184
185	const APIVersion = "2017-08-21-preview"
186	queryParameters := map[string]interface{}{
187		"api-version": APIVersion,
188	}
189	if len(certificatename) > 0 {
190		queryParameters["certificate.name"] = autorest.Encode("query", certificatename)
191	}
192	if certificaterawBytes != nil && len(certificaterawBytes) > 0 {
193		queryParameters["certificate.rawBytes"] = autorest.Encode("query", certificaterawBytes)
194	}
195	if certificateisVerified != nil {
196		queryParameters["certificate.isVerified"] = autorest.Encode("query", *certificateisVerified)
197	}
198	if len(string(certificatepurpose)) > 0 {
199		queryParameters["certificate.purpose"] = autorest.Encode("query", certificatepurpose)
200	}
201	if certificatecreated != nil {
202		queryParameters["certificate.created"] = autorest.Encode("query", *certificatecreated)
203	}
204	if certificatelastUpdated != nil {
205		queryParameters["certificate.lastUpdated"] = autorest.Encode("query", *certificatelastUpdated)
206	}
207	if certificatehasPrivateKey != nil {
208		queryParameters["certificate.hasPrivateKey"] = autorest.Encode("query", *certificatehasPrivateKey)
209	}
210	if len(certificatenonce) > 0 {
211		queryParameters["certificate.nonce"] = autorest.Encode("query", certificatenonce)
212	}
213
214	preparer := autorest.CreatePreparer(
215		autorest.AsDelete(),
216		autorest.WithBaseURL(client.BaseURI),
217		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", pathParameters),
218		autorest.WithQueryParameters(queryParameters),
219		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
220	return preparer.Prepare((&http.Request{}).WithContext(ctx))
221}
222
223// DeleteSender sends the Delete request. The method will close the
224// http.Response Body if it receives an error.
225func (client DpsCertificateClient) DeleteSender(req *http.Request) (*http.Response, error) {
226	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
227}
228
229// DeleteResponder handles the response to the Delete request. The method always
230// closes the http.Response Body.
231func (client DpsCertificateClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
232	err = autorest.Respond(
233		resp,
234		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
235		autorest.ByClosing())
236	result.Response = resp
237	return
238}
239
240// GenerateVerificationCode generate verification code for Proof of Possession.
241// Parameters:
242// certificateName - the mandatory logical name of the certificate, that the provisioning service uses to
243// access.
244// ifMatch - eTag of the certificate. This is required to update an existing certificate, and ignored while
245// creating a brand new certificate.
246// resourceGroupName - name of resource group.
247// provisioningServiceName - name of provisioning service.
248// certificatename - common Name for the certificate.
249// certificaterawBytes - raw data of certificate.
250// certificateisVerified - indicates if the certificate has been verified by owner of the private key.
251// certificatepurpose - description mentioning the purpose of the certificate.
252// certificatecreated - certificate creation time.
253// certificatelastUpdated - certificate last updated time.
254// certificatehasPrivateKey - indicates if the certificate contains private key.
255// certificatenonce - random number generated to indicate Proof of Possession.
256func (client DpsCertificateClient) GenerateVerificationCode(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result VerificationCodeResponse, err error) {
257	if tracing.IsEnabled() {
258		ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.GenerateVerificationCode")
259		defer func() {
260			sc := -1
261			if result.Response.Response != nil {
262				sc = result.Response.Response.StatusCode
263			}
264			tracing.EndSpan(ctx, sc, err)
265		}()
266	}
267	req, err := client.GenerateVerificationCodePreparer(ctx, certificateName, ifMatch, resourceGroupName, provisioningServiceName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce)
268	if err != nil {
269		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "GenerateVerificationCode", nil, "Failure preparing request")
270		return
271	}
272
273	resp, err := client.GenerateVerificationCodeSender(req)
274	if err != nil {
275		result.Response = autorest.Response{Response: resp}
276		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "GenerateVerificationCode", resp, "Failure sending request")
277		return
278	}
279
280	result, err = client.GenerateVerificationCodeResponder(resp)
281	if err != nil {
282		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "GenerateVerificationCode", resp, "Failure responding to request")
283		return
284	}
285
286	return
287}
288
289// GenerateVerificationCodePreparer prepares the GenerateVerificationCode request.
290func (client DpsCertificateClient) GenerateVerificationCodePreparer(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (*http.Request, error) {
291	pathParameters := map[string]interface{}{
292		"certificateName":         autorest.Encode("path", certificateName),
293		"provisioningServiceName": autorest.Encode("path", provisioningServiceName),
294		"resourceGroupName":       autorest.Encode("path", resourceGroupName),
295		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
296	}
297
298	const APIVersion = "2017-08-21-preview"
299	queryParameters := map[string]interface{}{
300		"api-version": APIVersion,
301	}
302	if len(certificatename) > 0 {
303		queryParameters["certificate.name"] = autorest.Encode("query", certificatename)
304	}
305	if certificaterawBytes != nil && len(certificaterawBytes) > 0 {
306		queryParameters["certificate.rawBytes"] = autorest.Encode("query", certificaterawBytes)
307	}
308	if certificateisVerified != nil {
309		queryParameters["certificate.isVerified"] = autorest.Encode("query", *certificateisVerified)
310	}
311	if len(string(certificatepurpose)) > 0 {
312		queryParameters["certificate.purpose"] = autorest.Encode("query", certificatepurpose)
313	}
314	if certificatecreated != nil {
315		queryParameters["certificate.created"] = autorest.Encode("query", *certificatecreated)
316	}
317	if certificatelastUpdated != nil {
318		queryParameters["certificate.lastUpdated"] = autorest.Encode("query", *certificatelastUpdated)
319	}
320	if certificatehasPrivateKey != nil {
321		queryParameters["certificate.hasPrivateKey"] = autorest.Encode("query", *certificatehasPrivateKey)
322	}
323	if len(certificatenonce) > 0 {
324		queryParameters["certificate.nonce"] = autorest.Encode("query", certificatenonce)
325	}
326
327	preparer := autorest.CreatePreparer(
328		autorest.AsPost(),
329		autorest.WithBaseURL(client.BaseURI),
330		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode", pathParameters),
331		autorest.WithQueryParameters(queryParameters),
332		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
333	return preparer.Prepare((&http.Request{}).WithContext(ctx))
334}
335
336// GenerateVerificationCodeSender sends the GenerateVerificationCode request. The method will close the
337// http.Response Body if it receives an error.
338func (client DpsCertificateClient) GenerateVerificationCodeSender(req *http.Request) (*http.Response, error) {
339	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
340}
341
342// GenerateVerificationCodeResponder handles the response to the GenerateVerificationCode request. The method always
343// closes the http.Response Body.
344func (client DpsCertificateClient) GenerateVerificationCodeResponder(resp *http.Response) (result VerificationCodeResponse, err error) {
345	err = autorest.Respond(
346		resp,
347		azure.WithErrorUnlessStatusCode(http.StatusOK),
348		autorest.ByUnmarshallingJSON(&result),
349		autorest.ByClosing())
350	result.Response = autorest.Response{Response: resp}
351	return
352}
353
354// Get get the certificate from the provisioning service.
355// Parameters:
356// certificateName - name of the certificate to retrieve.
357// resourceGroupName - resource group identifier.
358// provisioningServiceName - name of the provisioning service the certificate is associated with.
359// ifMatch - eTag of the certificate.
360func (client DpsCertificateClient) Get(ctx context.Context, certificateName string, resourceGroupName string, provisioningServiceName string, ifMatch string) (result CertificateResponse, err error) {
361	if tracing.IsEnabled() {
362		ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.Get")
363		defer func() {
364			sc := -1
365			if result.Response.Response != nil {
366				sc = result.Response.Response.StatusCode
367			}
368			tracing.EndSpan(ctx, sc, err)
369		}()
370	}
371	req, err := client.GetPreparer(ctx, certificateName, resourceGroupName, provisioningServiceName, ifMatch)
372	if err != nil {
373		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Get", nil, "Failure preparing request")
374		return
375	}
376
377	resp, err := client.GetSender(req)
378	if err != nil {
379		result.Response = autorest.Response{Response: resp}
380		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Get", resp, "Failure sending request")
381		return
382	}
383
384	result, err = client.GetResponder(resp)
385	if err != nil {
386		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Get", resp, "Failure responding to request")
387		return
388	}
389
390	return
391}
392
393// GetPreparer prepares the Get request.
394func (client DpsCertificateClient) GetPreparer(ctx context.Context, certificateName string, resourceGroupName string, provisioningServiceName string, ifMatch string) (*http.Request, error) {
395	pathParameters := map[string]interface{}{
396		"certificateName":         autorest.Encode("path", certificateName),
397		"provisioningServiceName": autorest.Encode("path", provisioningServiceName),
398		"resourceGroupName":       autorest.Encode("path", resourceGroupName),
399		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
400	}
401
402	const APIVersion = "2017-08-21-preview"
403	queryParameters := map[string]interface{}{
404		"api-version": APIVersion,
405	}
406
407	preparer := autorest.CreatePreparer(
408		autorest.AsGet(),
409		autorest.WithBaseURL(client.BaseURI),
410		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", pathParameters),
411		autorest.WithQueryParameters(queryParameters))
412	if len(ifMatch) > 0 {
413		preparer = autorest.DecoratePreparer(preparer,
414			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
415	}
416	return preparer.Prepare((&http.Request{}).WithContext(ctx))
417}
418
419// GetSender sends the Get request. The method will close the
420// http.Response Body if it receives an error.
421func (client DpsCertificateClient) GetSender(req *http.Request) (*http.Response, error) {
422	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
423}
424
425// GetResponder handles the response to the Get request. The method always
426// closes the http.Response Body.
427func (client DpsCertificateClient) GetResponder(resp *http.Response) (result CertificateResponse, err error) {
428	err = autorest.Respond(
429		resp,
430		azure.WithErrorUnlessStatusCode(http.StatusOK),
431		autorest.ByUnmarshallingJSON(&result),
432		autorest.ByClosing())
433	result.Response = autorest.Response{Response: resp}
434	return
435}
436
437// VerifyCertificate verifies certificate for the provisioning service.
438// Parameters:
439// certificateName - the mandatory logical name of the certificate, that the provisioning service uses to
440// access.
441// ifMatch - eTag of the certificate.
442// resourceGroupName - resource group name.
443// provisioningServiceName - provisioning service name.
444// certificatename - common Name for the certificate.
445// certificaterawBytes - raw data of certificate.
446// certificateisVerified - indicates if the certificate has been verified by owner of the private key.
447// certificatepurpose - describe the purpose of the certificate.
448// certificatecreated - certificate creation time.
449// certificatelastUpdated - certificate last updated time.
450// certificatehasPrivateKey - indicates if the certificate contains private key.
451// certificatenonce - random number generated to indicate Proof of Possession.
452func (client DpsCertificateClient) VerifyCertificate(ctx context.Context, certificateName string, ifMatch string, request VerificationCodeRequest, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result CertificateResponse, err error) {
453	if tracing.IsEnabled() {
454		ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.VerifyCertificate")
455		defer func() {
456			sc := -1
457			if result.Response.Response != nil {
458				sc = result.Response.Response.StatusCode
459			}
460			tracing.EndSpan(ctx, sc, err)
461		}()
462	}
463	req, err := client.VerifyCertificatePreparer(ctx, certificateName, ifMatch, request, resourceGroupName, provisioningServiceName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce)
464	if err != nil {
465		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "VerifyCertificate", nil, "Failure preparing request")
466		return
467	}
468
469	resp, err := client.VerifyCertificateSender(req)
470	if err != nil {
471		result.Response = autorest.Response{Response: resp}
472		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "VerifyCertificate", resp, "Failure sending request")
473		return
474	}
475
476	result, err = client.VerifyCertificateResponder(resp)
477	if err != nil {
478		err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "VerifyCertificate", resp, "Failure responding to request")
479		return
480	}
481
482	return
483}
484
485// VerifyCertificatePreparer prepares the VerifyCertificate request.
486func (client DpsCertificateClient) VerifyCertificatePreparer(ctx context.Context, certificateName string, ifMatch string, request VerificationCodeRequest, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (*http.Request, error) {
487	pathParameters := map[string]interface{}{
488		"certificateName":         autorest.Encode("path", certificateName),
489		"provisioningServiceName": autorest.Encode("path", provisioningServiceName),
490		"resourceGroupName":       autorest.Encode("path", resourceGroupName),
491		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
492	}
493
494	const APIVersion = "2017-08-21-preview"
495	queryParameters := map[string]interface{}{
496		"api-version": APIVersion,
497	}
498	if len(certificatename) > 0 {
499		queryParameters["certificate.name"] = autorest.Encode("query", certificatename)
500	}
501	if certificaterawBytes != nil && len(certificaterawBytes) > 0 {
502		queryParameters["certificate.rawBytes"] = autorest.Encode("query", certificaterawBytes)
503	}
504	if certificateisVerified != nil {
505		queryParameters["certificate.isVerified"] = autorest.Encode("query", *certificateisVerified)
506	}
507	if len(string(certificatepurpose)) > 0 {
508		queryParameters["certificate.purpose"] = autorest.Encode("query", certificatepurpose)
509	}
510	if certificatecreated != nil {
511		queryParameters["certificate.created"] = autorest.Encode("query", *certificatecreated)
512	}
513	if certificatelastUpdated != nil {
514		queryParameters["certificate.lastUpdated"] = autorest.Encode("query", *certificatelastUpdated)
515	}
516	if certificatehasPrivateKey != nil {
517		queryParameters["certificate.hasPrivateKey"] = autorest.Encode("query", *certificatehasPrivateKey)
518	}
519	if len(certificatenonce) > 0 {
520		queryParameters["certificate.nonce"] = autorest.Encode("query", certificatenonce)
521	}
522
523	preparer := autorest.CreatePreparer(
524		autorest.AsContentType("application/json; charset=utf-8"),
525		autorest.AsPost(),
526		autorest.WithBaseURL(client.BaseURI),
527		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify", pathParameters),
528		autorest.WithJSON(request),
529		autorest.WithQueryParameters(queryParameters),
530		autorest.WithHeader("If-Match", autorest.String(ifMatch)))
531	return preparer.Prepare((&http.Request{}).WithContext(ctx))
532}
533
534// VerifyCertificateSender sends the VerifyCertificate request. The method will close the
535// http.Response Body if it receives an error.
536func (client DpsCertificateClient) VerifyCertificateSender(req *http.Request) (*http.Response, error) {
537	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
538}
539
540// VerifyCertificateResponder handles the response to the VerifyCertificate request. The method always
541// closes the http.Response Body.
542func (client DpsCertificateClient) VerifyCertificateResponder(resp *http.Response) (result CertificateResponse, err error) {
543	err = autorest.Respond(
544		resp,
545		azure.WithErrorUnlessStatusCode(http.StatusOK),
546		autorest.ByUnmarshallingJSON(&result),
547		autorest.ByClosing())
548	result.Response = autorest.Response{Response: resp}
549	return
550}
551