/
devices_client.go
917 lines (870 loc) · 43.8 KB
/
devices_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
//go:build go1.18
// +build go1.18
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// DO NOT EDIT.
package armdataboxedge
import (
"context"
"errors"
"github.com/Azure/azure-sdk-for-go/profile/v20200901/internal"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"net/http"
"net/url"
"strings"
)
// DevicesClient contains the methods for the Devices group.
// Don't use this type directly, use NewDevicesClient() instead.
type DevicesClient struct {
internal *arm.Client
subscriptionID string
}
// NewDevicesClient creates a new instance of DevicesClient with the specified values.
// - subscriptionID - The subscription ID.
// - credential - used to authorize requests. Usually a credential from azidentity.
// - options - pass nil to accept the default values.
func NewDevicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DevicesClient, error) {
cl, err := arm.NewClient(internal.ModuleName+"/armdataboxedge.DevicesClient", internal.ModuleVersion, credential, options)
if err != nil {
return nil, err
}
client := &DevicesClient{
subscriptionID: subscriptionID,
internal: cl,
}
return client, nil
}
// BeginCreateOrUpdate - Creates or updates a Data Box Edge/Data Box Gateway resource.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
// - deviceName - The device name.
// - resourceGroupName - The resource group name.
// - dataBoxEdgeDevice - The resource object.
// - options - DevicesClientBeginCreateOrUpdateOptions contains the optional parameters for the DevicesClient.BeginCreateOrUpdate
// method.
func (client *DevicesClient) BeginCreateOrUpdate(ctx context.Context, deviceName string, resourceGroupName string, dataBoxEdgeDevice Device, options *DevicesClientBeginCreateOrUpdateOptions) (*runtime.Poller[DevicesClientCreateOrUpdateResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.createOrUpdate(ctx, deviceName, resourceGroupName, dataBoxEdgeDevice, options)
if err != nil {
return nil, err
}
return runtime.NewPoller[DevicesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil)
} else {
return runtime.NewPollerFromResumeToken[DevicesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil)
}
}
// CreateOrUpdate - Creates or updates a Data Box Edge/Data Box Gateway resource.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
func (client *DevicesClient) createOrUpdate(ctx context.Context, deviceName string, resourceGroupName string, dataBoxEdgeDevice Device, options *DevicesClientBeginCreateOrUpdateOptions) (*http.Response, error) {
req, err := client.createOrUpdateCreateRequest(ctx, deviceName, resourceGroupName, dataBoxEdgeDevice, options)
if err != nil {
return nil, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return nil, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return nil, runtime.NewResponseError(resp)
}
return resp, nil
}
// createOrUpdateCreateRequest creates the CreateOrUpdate request.
func (client *DevicesClient) createOrUpdateCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, dataBoxEdgeDevice Device, options *DevicesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}"
if deviceName == "" {
return nil, errors.New("parameter deviceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, runtime.MarshalAsJSON(req, dataBoxEdgeDevice)
}
// BeginCreateOrUpdateSecuritySettings - Updates the security settings on a Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
// - deviceName - The device name.
// - resourceGroupName - The resource group name.
// - securitySettings - The security settings.
// - options - DevicesClientBeginCreateOrUpdateSecuritySettingsOptions contains the optional parameters for the DevicesClient.BeginCreateOrUpdateSecuritySettings
// method.
func (client *DevicesClient) BeginCreateOrUpdateSecuritySettings(ctx context.Context, deviceName string, resourceGroupName string, securitySettings SecuritySettings, options *DevicesClientBeginCreateOrUpdateSecuritySettingsOptions) (*runtime.Poller[DevicesClientCreateOrUpdateSecuritySettingsResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.createOrUpdateSecuritySettings(ctx, deviceName, resourceGroupName, securitySettings, options)
if err != nil {
return nil, err
}
return runtime.NewPoller[DevicesClientCreateOrUpdateSecuritySettingsResponse](resp, client.internal.Pipeline(), nil)
} else {
return runtime.NewPollerFromResumeToken[DevicesClientCreateOrUpdateSecuritySettingsResponse](options.ResumeToken, client.internal.Pipeline(), nil)
}
}
// CreateOrUpdateSecuritySettings - Updates the security settings on a Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
func (client *DevicesClient) createOrUpdateSecuritySettings(ctx context.Context, deviceName string, resourceGroupName string, securitySettings SecuritySettings, options *DevicesClientBeginCreateOrUpdateSecuritySettingsOptions) (*http.Response, error) {
req, err := client.createOrUpdateSecuritySettingsCreateRequest(ctx, deviceName, resourceGroupName, securitySettings, options)
if err != nil {
return nil, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return nil, err
}
if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) {
return nil, runtime.NewResponseError(resp)
}
return resp, nil
}
// createOrUpdateSecuritySettingsCreateRequest creates the CreateOrUpdateSecuritySettings request.
func (client *DevicesClient) createOrUpdateSecuritySettingsCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, securitySettings SecuritySettings, options *DevicesClientBeginCreateOrUpdateSecuritySettingsOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update"
if deviceName == "" {
return nil, errors.New("parameter deviceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, runtime.MarshalAsJSON(req, securitySettings)
}
// BeginDelete - Deletes the Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
// - deviceName - The device name.
// - resourceGroupName - The resource group name.
// - options - DevicesClientBeginDeleteOptions contains the optional parameters for the DevicesClient.BeginDelete method.
func (client *DevicesClient) BeginDelete(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientBeginDeleteOptions) (*runtime.Poller[DevicesClientDeleteResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.deleteOperation(ctx, deviceName, resourceGroupName, options)
if err != nil {
return nil, err
}
return runtime.NewPoller[DevicesClientDeleteResponse](resp, client.internal.Pipeline(), nil)
} else {
return runtime.NewPollerFromResumeToken[DevicesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil)
}
}
// Delete - Deletes the Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
func (client *DevicesClient) deleteOperation(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientBeginDeleteOptions) (*http.Response, error) {
req, err := client.deleteCreateRequest(ctx, deviceName, resourceGroupName, options)
if err != nil {
return nil, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return nil, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) {
return nil, runtime.NewResponseError(resp)
}
return resp, nil
}
// deleteCreateRequest creates the Delete request.
func (client *DevicesClient) deleteCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientBeginDeleteOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}"
if deviceName == "" {
return nil, errors.New("parameter deviceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// BeginDownloadUpdates - Downloads the updates on a Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
// - deviceName - The device name.
// - resourceGroupName - The resource group name.
// - options - DevicesClientBeginDownloadUpdatesOptions contains the optional parameters for the DevicesClient.BeginDownloadUpdates
// method.
func (client *DevicesClient) BeginDownloadUpdates(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientBeginDownloadUpdatesOptions) (*runtime.Poller[DevicesClientDownloadUpdatesResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.downloadUpdates(ctx, deviceName, resourceGroupName, options)
if err != nil {
return nil, err
}
return runtime.NewPoller[DevicesClientDownloadUpdatesResponse](resp, client.internal.Pipeline(), nil)
} else {
return runtime.NewPollerFromResumeToken[DevicesClientDownloadUpdatesResponse](options.ResumeToken, client.internal.Pipeline(), nil)
}
}
// DownloadUpdates - Downloads the updates on a Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
func (client *DevicesClient) downloadUpdates(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientBeginDownloadUpdatesOptions) (*http.Response, error) {
req, err := client.downloadUpdatesCreateRequest(ctx, deviceName, resourceGroupName, options)
if err != nil {
return nil, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return nil, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) {
return nil, runtime.NewResponseError(resp)
}
return resp, nil
}
// downloadUpdatesCreateRequest creates the DownloadUpdates request.
func (client *DevicesClient) downloadUpdatesCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientBeginDownloadUpdatesOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates"
if deviceName == "" {
return nil, errors.New("parameter deviceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// Get - Gets the properties of the Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
// - deviceName - The device name.
// - resourceGroupName - The resource group name.
// - options - DevicesClientGetOptions contains the optional parameters for the DevicesClient.Get method.
func (client *DevicesClient) Get(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientGetOptions) (DevicesClientGetResponse, error) {
req, err := client.getCreateRequest(ctx, deviceName, resourceGroupName, options)
if err != nil {
return DevicesClientGetResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return DevicesClientGetResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return DevicesClientGetResponse{}, runtime.NewResponseError(resp)
}
return client.getHandleResponse(resp)
}
// getCreateRequest creates the Get request.
func (client *DevicesClient) getCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientGetOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}"
if deviceName == "" {
return nil, errors.New("parameter deviceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// getHandleResponse handles the Get response.
func (client *DevicesClient) getHandleResponse(resp *http.Response) (DevicesClientGetResponse, error) {
result := DevicesClientGetResponse{}
if err := runtime.UnmarshalAsJSON(resp, &result.Device); err != nil {
return DevicesClientGetResponse{}, err
}
return result, nil
}
// GetExtendedInformation - Gets additional information for the specified Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
// - deviceName - The device name.
// - resourceGroupName - The resource group name.
// - options - DevicesClientGetExtendedInformationOptions contains the optional parameters for the DevicesClient.GetExtendedInformation
// method.
func (client *DevicesClient) GetExtendedInformation(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientGetExtendedInformationOptions) (DevicesClientGetExtendedInformationResponse, error) {
req, err := client.getExtendedInformationCreateRequest(ctx, deviceName, resourceGroupName, options)
if err != nil {
return DevicesClientGetExtendedInformationResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return DevicesClientGetExtendedInformationResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return DevicesClientGetExtendedInformationResponse{}, runtime.NewResponseError(resp)
}
return client.getExtendedInformationHandleResponse(resp)
}
// getExtendedInformationCreateRequest creates the GetExtendedInformation request.
func (client *DevicesClient) getExtendedInformationCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientGetExtendedInformationOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation"
if deviceName == "" {
return nil, errors.New("parameter deviceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// getExtendedInformationHandleResponse handles the GetExtendedInformation response.
func (client *DevicesClient) getExtendedInformationHandleResponse(resp *http.Response) (DevicesClientGetExtendedInformationResponse, error) {
result := DevicesClientGetExtendedInformationResponse{}
if err := runtime.UnmarshalAsJSON(resp, &result.DeviceExtendedInfo); err != nil {
return DevicesClientGetExtendedInformationResponse{}, err
}
return result, nil
}
// GetNetworkSettings - Gets the network settings of the specified Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
// - deviceName - The device name.
// - resourceGroupName - The resource group name.
// - options - DevicesClientGetNetworkSettingsOptions contains the optional parameters for the DevicesClient.GetNetworkSettings
// method.
func (client *DevicesClient) GetNetworkSettings(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientGetNetworkSettingsOptions) (DevicesClientGetNetworkSettingsResponse, error) {
req, err := client.getNetworkSettingsCreateRequest(ctx, deviceName, resourceGroupName, options)
if err != nil {
return DevicesClientGetNetworkSettingsResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return DevicesClientGetNetworkSettingsResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return DevicesClientGetNetworkSettingsResponse{}, runtime.NewResponseError(resp)
}
return client.getNetworkSettingsHandleResponse(resp)
}
// getNetworkSettingsCreateRequest creates the GetNetworkSettings request.
func (client *DevicesClient) getNetworkSettingsCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientGetNetworkSettingsOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default"
if deviceName == "" {
return nil, errors.New("parameter deviceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// getNetworkSettingsHandleResponse handles the GetNetworkSettings response.
func (client *DevicesClient) getNetworkSettingsHandleResponse(resp *http.Response) (DevicesClientGetNetworkSettingsResponse, error) {
result := DevicesClientGetNetworkSettingsResponse{}
if err := runtime.UnmarshalAsJSON(resp, &result.NetworkSettings); err != nil {
return DevicesClientGetNetworkSettingsResponse{}, err
}
return result, nil
}
// GetUpdateSummary - Gets information about the availability of updates based on the last scan of the device. It also gets
// information about any ongoing download or install jobs on the device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
// - deviceName - The device name.
// - resourceGroupName - The resource group name.
// - options - DevicesClientGetUpdateSummaryOptions contains the optional parameters for the DevicesClient.GetUpdateSummary
// method.
func (client *DevicesClient) GetUpdateSummary(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientGetUpdateSummaryOptions) (DevicesClientGetUpdateSummaryResponse, error) {
req, err := client.getUpdateSummaryCreateRequest(ctx, deviceName, resourceGroupName, options)
if err != nil {
return DevicesClientGetUpdateSummaryResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return DevicesClientGetUpdateSummaryResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return DevicesClientGetUpdateSummaryResponse{}, runtime.NewResponseError(resp)
}
return client.getUpdateSummaryHandleResponse(resp)
}
// getUpdateSummaryCreateRequest creates the GetUpdateSummary request.
func (client *DevicesClient) getUpdateSummaryCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientGetUpdateSummaryOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default"
if deviceName == "" {
return nil, errors.New("parameter deviceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// getUpdateSummaryHandleResponse handles the GetUpdateSummary response.
func (client *DevicesClient) getUpdateSummaryHandleResponse(resp *http.Response) (DevicesClientGetUpdateSummaryResponse, error) {
result := DevicesClientGetUpdateSummaryResponse{}
if err := runtime.UnmarshalAsJSON(resp, &result.UpdateSummary); err != nil {
return DevicesClientGetUpdateSummaryResponse{}, err
}
return result, nil
}
// BeginInstallUpdates - Installs the updates on the Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
// - deviceName - The device name.
// - resourceGroupName - The resource group name.
// - options - DevicesClientBeginInstallUpdatesOptions contains the optional parameters for the DevicesClient.BeginInstallUpdates
// method.
func (client *DevicesClient) BeginInstallUpdates(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientBeginInstallUpdatesOptions) (*runtime.Poller[DevicesClientInstallUpdatesResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.installUpdates(ctx, deviceName, resourceGroupName, options)
if err != nil {
return nil, err
}
return runtime.NewPoller[DevicesClientInstallUpdatesResponse](resp, client.internal.Pipeline(), nil)
} else {
return runtime.NewPollerFromResumeToken[DevicesClientInstallUpdatesResponse](options.ResumeToken, client.internal.Pipeline(), nil)
}
}
// InstallUpdates - Installs the updates on the Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
func (client *DevicesClient) installUpdates(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientBeginInstallUpdatesOptions) (*http.Response, error) {
req, err := client.installUpdatesCreateRequest(ctx, deviceName, resourceGroupName, options)
if err != nil {
return nil, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return nil, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) {
return nil, runtime.NewResponseError(resp)
}
return resp, nil
}
// installUpdatesCreateRequest creates the InstallUpdates request.
func (client *DevicesClient) installUpdatesCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientBeginInstallUpdatesOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates"
if deviceName == "" {
return nil, errors.New("parameter deviceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// NewListByResourceGroupPager - Gets all the Data Box Edge/Data Box Gateway devices in a resource group.
//
// Generated from API version 2019-08-01
// - resourceGroupName - The resource group name.
// - options - DevicesClientListByResourceGroupOptions contains the optional parameters for the DevicesClient.NewListByResourceGroupPager
// method.
func (client *DevicesClient) NewListByResourceGroupPager(resourceGroupName string, options *DevicesClientListByResourceGroupOptions) *runtime.Pager[DevicesClientListByResourceGroupResponse] {
return runtime.NewPager(runtime.PagingHandler[DevicesClientListByResourceGroupResponse]{
More: func(page DevicesClientListByResourceGroupResponse) bool {
return page.NextLink != nil && len(*page.NextLink) > 0
},
Fetcher: func(ctx context.Context, page *DevicesClientListByResourceGroupResponse) (DevicesClientListByResourceGroupResponse, error) {
var req *policy.Request
var err error
if page == nil {
req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options)
} else {
req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink)
}
if err != nil {
return DevicesClientListByResourceGroupResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return DevicesClientListByResourceGroupResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return DevicesClientListByResourceGroupResponse{}, runtime.NewResponseError(resp)
}
return client.listByResourceGroupHandleResponse(resp)
},
})
}
// listByResourceGroupCreateRequest creates the ListByResourceGroup request.
func (client *DevicesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DevicesClientListByResourceGroupOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices"
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
if options != nil && options.Expand != nil {
reqQP.Set("$expand", *options.Expand)
}
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// listByResourceGroupHandleResponse handles the ListByResourceGroup response.
func (client *DevicesClient) listByResourceGroupHandleResponse(resp *http.Response) (DevicesClientListByResourceGroupResponse, error) {
result := DevicesClientListByResourceGroupResponse{}
if err := runtime.UnmarshalAsJSON(resp, &result.DeviceList); err != nil {
return DevicesClientListByResourceGroupResponse{}, err
}
return result, nil
}
// NewListBySubscriptionPager - Gets all the Data Box Edge/Data Box Gateway devices in a subscription.
//
// Generated from API version 2019-08-01
// - options - DevicesClientListBySubscriptionOptions contains the optional parameters for the DevicesClient.NewListBySubscriptionPager
// method.
func (client *DevicesClient) NewListBySubscriptionPager(options *DevicesClientListBySubscriptionOptions) *runtime.Pager[DevicesClientListBySubscriptionResponse] {
return runtime.NewPager(runtime.PagingHandler[DevicesClientListBySubscriptionResponse]{
More: func(page DevicesClientListBySubscriptionResponse) bool {
return page.NextLink != nil && len(*page.NextLink) > 0
},
Fetcher: func(ctx context.Context, page *DevicesClientListBySubscriptionResponse) (DevicesClientListBySubscriptionResponse, error) {
var req *policy.Request
var err error
if page == nil {
req, err = client.listBySubscriptionCreateRequest(ctx, options)
} else {
req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink)
}
if err != nil {
return DevicesClientListBySubscriptionResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return DevicesClientListBySubscriptionResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return DevicesClientListBySubscriptionResponse{}, runtime.NewResponseError(resp)
}
return client.listBySubscriptionHandleResponse(resp)
},
})
}
// listBySubscriptionCreateRequest creates the ListBySubscription request.
func (client *DevicesClient) listBySubscriptionCreateRequest(ctx context.Context, options *DevicesClientListBySubscriptionOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices"
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
if options != nil && options.Expand != nil {
reqQP.Set("$expand", *options.Expand)
}
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// listBySubscriptionHandleResponse handles the ListBySubscription response.
func (client *DevicesClient) listBySubscriptionHandleResponse(resp *http.Response) (DevicesClientListBySubscriptionResponse, error) {
result := DevicesClientListBySubscriptionResponse{}
if err := runtime.UnmarshalAsJSON(resp, &result.DeviceList); err != nil {
return DevicesClientListBySubscriptionResponse{}, err
}
return result, nil
}
// BeginScanForUpdates - Scans for updates on a Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
// - deviceName - The device name.
// - resourceGroupName - The resource group name.
// - options - DevicesClientBeginScanForUpdatesOptions contains the optional parameters for the DevicesClient.BeginScanForUpdates
// method.
func (client *DevicesClient) BeginScanForUpdates(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientBeginScanForUpdatesOptions) (*runtime.Poller[DevicesClientScanForUpdatesResponse], error) {
if options == nil || options.ResumeToken == "" {
resp, err := client.scanForUpdates(ctx, deviceName, resourceGroupName, options)
if err != nil {
return nil, err
}
return runtime.NewPoller[DevicesClientScanForUpdatesResponse](resp, client.internal.Pipeline(), nil)
} else {
return runtime.NewPollerFromResumeToken[DevicesClientScanForUpdatesResponse](options.ResumeToken, client.internal.Pipeline(), nil)
}
}
// ScanForUpdates - Scans for updates on a Data Box Edge/Data Box Gateway device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
func (client *DevicesClient) scanForUpdates(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientBeginScanForUpdatesOptions) (*http.Response, error) {
req, err := client.scanForUpdatesCreateRequest(ctx, deviceName, resourceGroupName, options)
if err != nil {
return nil, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return nil, err
}
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) {
return nil, runtime.NewResponseError(resp)
}
return resp, nil
}
// scanForUpdatesCreateRequest creates the ScanForUpdates request.
func (client *DevicesClient) scanForUpdatesCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, options *DevicesClientBeginScanForUpdatesOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates"
if deviceName == "" {
return nil, errors.New("parameter deviceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, nil
}
// Update - Modifies a Data Box Edge/Data Box Gateway resource.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
// - deviceName - The device name.
// - resourceGroupName - The resource group name.
// - parameters - The resource parameters.
// - options - DevicesClientUpdateOptions contains the optional parameters for the DevicesClient.Update method.
func (client *DevicesClient) Update(ctx context.Context, deviceName string, resourceGroupName string, parameters DevicePatch, options *DevicesClientUpdateOptions) (DevicesClientUpdateResponse, error) {
req, err := client.updateCreateRequest(ctx, deviceName, resourceGroupName, parameters, options)
if err != nil {
return DevicesClientUpdateResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return DevicesClientUpdateResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return DevicesClientUpdateResponse{}, runtime.NewResponseError(resp)
}
return client.updateHandleResponse(resp)
}
// updateCreateRequest creates the Update request.
func (client *DevicesClient) updateCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, parameters DevicePatch, options *DevicesClientUpdateOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}"
if deviceName == "" {
return nil, errors.New("parameter deviceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, runtime.MarshalAsJSON(req, parameters)
}
// updateHandleResponse handles the Update response.
func (client *DevicesClient) updateHandleResponse(resp *http.Response) (DevicesClientUpdateResponse, error) {
result := DevicesClientUpdateResponse{}
if err := runtime.UnmarshalAsJSON(resp, &result.Device); err != nil {
return DevicesClientUpdateResponse{}, err
}
return result, nil
}
// UploadCertificate - Uploads registration certificate for the device.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2019-08-01
// - deviceName - The device name.
// - resourceGroupName - The resource group name.
// - parameters - The upload certificate request.
// - options - DevicesClientUploadCertificateOptions contains the optional parameters for the DevicesClient.UploadCertificate
// method.
func (client *DevicesClient) UploadCertificate(ctx context.Context, deviceName string, resourceGroupName string, parameters UploadCertificateRequest, options *DevicesClientUploadCertificateOptions) (DevicesClientUploadCertificateResponse, error) {
req, err := client.uploadCertificateCreateRequest(ctx, deviceName, resourceGroupName, parameters, options)
if err != nil {
return DevicesClientUploadCertificateResponse{}, err
}
resp, err := client.internal.Pipeline().Do(req)
if err != nil {
return DevicesClientUploadCertificateResponse{}, err
}
if !runtime.HasStatusCode(resp, http.StatusOK) {
return DevicesClientUploadCertificateResponse{}, runtime.NewResponseError(resp)
}
return client.uploadCertificateHandleResponse(resp)
}
// uploadCertificateCreateRequest creates the UploadCertificate request.
func (client *DevicesClient) uploadCertificateCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, parameters UploadCertificateRequest, options *DevicesClientUploadCertificateOptions) (*policy.Request, error) {
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate"
if deviceName == "" {
return nil, errors.New("parameter deviceName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName))
if client.subscriptionID == "" {
return nil, errors.New("parameter client.subscriptionID cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
if resourceGroupName == "" {
return nil, errors.New("parameter resourceGroupName cannot be empty")
}
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
if err != nil {
return nil, err
}
reqQP := req.Raw().URL.Query()
reqQP.Set("api-version", "2019-08-01")
req.Raw().URL.RawQuery = reqQP.Encode()
req.Raw().Header["Accept"] = []string{"application/json"}
return req, runtime.MarshalAsJSON(req, parameters)
}
// uploadCertificateHandleResponse handles the UploadCertificate response.
func (client *DevicesClient) uploadCertificateHandleResponse(resp *http.Response) (DevicesClientUploadCertificateResponse, error) {
result := DevicesClientUploadCertificateResponse{}
if err := runtime.UnmarshalAsJSON(resp, &result.UploadCertificateResponse); err != nil {
return DevicesClientUploadCertificateResponse{}, err
}
return result, nil
}