1package databoxedge 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/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// DevicesClient is the client for the Devices methods of the Databoxedge service. 19type DevicesClient struct { 20 BaseClient 21} 22 23// NewDevicesClient creates an instance of the DevicesClient client. 24func NewDevicesClient(subscriptionID string) DevicesClient { 25 return NewDevicesClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewDevicesClientWithBaseURI creates an instance of the DevicesClient client using a custom endpoint. Use this when 29// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewDevicesClientWithBaseURI(baseURI string, subscriptionID string) DevicesClient { 31 return DevicesClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// CreateOrUpdate creates or updates a Data Box Edge/Data Box Gateway resource. 35// Parameters: 36// deviceName - the device name. 37// dataBoxEdgeDevice - the resource object. 38// resourceGroupName - the resource group name. 39func (client DevicesClient) CreateOrUpdate(ctx context.Context, deviceName string, dataBoxEdgeDevice Device, resourceGroupName string) (result DevicesCreateOrUpdateFuture, err error) { 40 if tracing.IsEnabled() { 41 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.CreateOrUpdate") 42 defer func() { 43 sc := -1 44 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 45 sc = result.FutureAPI.Response().StatusCode 46 } 47 tracing.EndSpan(ctx, sc, err) 48 }() 49 } 50 if err := validation.Validate([]validation.Validation{ 51 {TargetValue: dataBoxEdgeDevice, 52 Constraints: []validation.Constraint{{Target: "dataBoxEdgeDevice.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 53 return result, validation.NewError("databoxedge.DevicesClient", "CreateOrUpdate", err.Error()) 54 } 55 56 req, err := client.CreateOrUpdatePreparer(ctx, deviceName, dataBoxEdgeDevice, resourceGroupName) 57 if err != nil { 58 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "CreateOrUpdate", nil, "Failure preparing request") 59 return 60 } 61 62 result, err = client.CreateOrUpdateSender(req) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "CreateOrUpdate", nil, "Failure sending request") 65 return 66 } 67 68 return 69} 70 71// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 72func (client DevicesClient) CreateOrUpdatePreparer(ctx context.Context, deviceName string, dataBoxEdgeDevice Device, resourceGroupName string) (*http.Request, error) { 73 pathParameters := map[string]interface{}{ 74 "deviceName": autorest.Encode("path", deviceName), 75 "resourceGroupName": autorest.Encode("path", resourceGroupName), 76 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 77 } 78 79 const APIVersion = "2019-08-01" 80 queryParameters := map[string]interface{}{ 81 "api-version": APIVersion, 82 } 83 84 preparer := autorest.CreatePreparer( 85 autorest.AsContentType("application/json; charset=utf-8"), 86 autorest.AsPut(), 87 autorest.WithBaseURL(client.BaseURI), 88 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", pathParameters), 89 autorest.WithJSON(dataBoxEdgeDevice), 90 autorest.WithQueryParameters(queryParameters)) 91 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 92} 93 94// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 95// http.Response Body if it receives an error. 96func (client DevicesClient) CreateOrUpdateSender(req *http.Request) (future DevicesCreateOrUpdateFuture, err error) { 97 var resp *http.Response 98 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 99 if err != nil { 100 return 101 } 102 var azf azure.Future 103 azf, err = azure.NewFutureFromResponse(resp) 104 future.FutureAPI = &azf 105 future.Result = future.result 106 return 107} 108 109// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 110// closes the http.Response Body. 111func (client DevicesClient) CreateOrUpdateResponder(resp *http.Response) (result Device, err error) { 112 err = autorest.Respond( 113 resp, 114 azure.WithErrorUnlessStatusCode(http.StatusOK), 115 autorest.ByUnmarshallingJSON(&result), 116 autorest.ByClosing()) 117 result.Response = autorest.Response{Response: resp} 118 return 119} 120 121// CreateOrUpdateSecuritySettings updates the security settings on a Data Box Edge/Data Box Gateway device. 122// Parameters: 123// deviceName - the device name. 124// securitySettings - the security settings. 125// resourceGroupName - the resource group name. 126func (client DevicesClient) CreateOrUpdateSecuritySettings(ctx context.Context, deviceName string, securitySettings SecuritySettings, resourceGroupName string) (result DevicesCreateOrUpdateSecuritySettingsFuture, err error) { 127 if tracing.IsEnabled() { 128 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.CreateOrUpdateSecuritySettings") 129 defer func() { 130 sc := -1 131 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 132 sc = result.FutureAPI.Response().StatusCode 133 } 134 tracing.EndSpan(ctx, sc, err) 135 }() 136 } 137 if err := validation.Validate([]validation.Validation{ 138 {TargetValue: securitySettings, 139 Constraints: []validation.Constraint{{Target: "securitySettings.SecuritySettingsProperties", Name: validation.Null, Rule: true, 140 Chain: []validation.Constraint{{Target: "securitySettings.SecuritySettingsProperties.DeviceAdminPassword", Name: validation.Null, Rule: true, 141 Chain: []validation.Constraint{{Target: "securitySettings.SecuritySettingsProperties.DeviceAdminPassword.Value", Name: validation.Null, Rule: true, Chain: nil}}}, 142 }}}}}); err != nil { 143 return result, validation.NewError("databoxedge.DevicesClient", "CreateOrUpdateSecuritySettings", err.Error()) 144 } 145 146 req, err := client.CreateOrUpdateSecuritySettingsPreparer(ctx, deviceName, securitySettings, resourceGroupName) 147 if err != nil { 148 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "CreateOrUpdateSecuritySettings", nil, "Failure preparing request") 149 return 150 } 151 152 result, err = client.CreateOrUpdateSecuritySettingsSender(req) 153 if err != nil { 154 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "CreateOrUpdateSecuritySettings", nil, "Failure sending request") 155 return 156 } 157 158 return 159} 160 161// CreateOrUpdateSecuritySettingsPreparer prepares the CreateOrUpdateSecuritySettings request. 162func (client DevicesClient) CreateOrUpdateSecuritySettingsPreparer(ctx context.Context, deviceName string, securitySettings SecuritySettings, resourceGroupName string) (*http.Request, error) { 163 pathParameters := map[string]interface{}{ 164 "deviceName": autorest.Encode("path", deviceName), 165 "resourceGroupName": autorest.Encode("path", resourceGroupName), 166 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 167 } 168 169 const APIVersion = "2019-08-01" 170 queryParameters := map[string]interface{}{ 171 "api-version": APIVersion, 172 } 173 174 preparer := autorest.CreatePreparer( 175 autorest.AsContentType("application/json; charset=utf-8"), 176 autorest.AsPost(), 177 autorest.WithBaseURL(client.BaseURI), 178 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update", pathParameters), 179 autorest.WithJSON(securitySettings), 180 autorest.WithQueryParameters(queryParameters)) 181 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 182} 183 184// CreateOrUpdateSecuritySettingsSender sends the CreateOrUpdateSecuritySettings request. The method will close the 185// http.Response Body if it receives an error. 186func (client DevicesClient) CreateOrUpdateSecuritySettingsSender(req *http.Request) (future DevicesCreateOrUpdateSecuritySettingsFuture, err error) { 187 var resp *http.Response 188 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 189 if err != nil { 190 return 191 } 192 var azf azure.Future 193 azf, err = azure.NewFutureFromResponse(resp) 194 future.FutureAPI = &azf 195 future.Result = future.result 196 return 197} 198 199// CreateOrUpdateSecuritySettingsResponder handles the response to the CreateOrUpdateSecuritySettings request. The method always 200// closes the http.Response Body. 201func (client DevicesClient) CreateOrUpdateSecuritySettingsResponder(resp *http.Response) (result autorest.Response, err error) { 202 err = autorest.Respond( 203 resp, 204 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 205 autorest.ByClosing()) 206 result.Response = resp 207 return 208} 209 210// Delete deletes the Data Box Edge/Data Box Gateway device. 211// Parameters: 212// deviceName - the device name. 213// resourceGroupName - the resource group name. 214func (client DevicesClient) Delete(ctx context.Context, deviceName string, resourceGroupName string) (result DevicesDeleteFuture, err error) { 215 if tracing.IsEnabled() { 216 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.Delete") 217 defer func() { 218 sc := -1 219 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 220 sc = result.FutureAPI.Response().StatusCode 221 } 222 tracing.EndSpan(ctx, sc, err) 223 }() 224 } 225 req, err := client.DeletePreparer(ctx, deviceName, resourceGroupName) 226 if err != nil { 227 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "Delete", nil, "Failure preparing request") 228 return 229 } 230 231 result, err = client.DeleteSender(req) 232 if err != nil { 233 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "Delete", nil, "Failure sending request") 234 return 235 } 236 237 return 238} 239 240// DeletePreparer prepares the Delete request. 241func (client DevicesClient) DeletePreparer(ctx context.Context, deviceName string, resourceGroupName string) (*http.Request, error) { 242 pathParameters := map[string]interface{}{ 243 "deviceName": autorest.Encode("path", deviceName), 244 "resourceGroupName": autorest.Encode("path", resourceGroupName), 245 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 246 } 247 248 const APIVersion = "2019-08-01" 249 queryParameters := map[string]interface{}{ 250 "api-version": APIVersion, 251 } 252 253 preparer := autorest.CreatePreparer( 254 autorest.AsDelete(), 255 autorest.WithBaseURL(client.BaseURI), 256 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", pathParameters), 257 autorest.WithQueryParameters(queryParameters)) 258 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 259} 260 261// DeleteSender sends the Delete request. The method will close the 262// http.Response Body if it receives an error. 263func (client DevicesClient) DeleteSender(req *http.Request) (future DevicesDeleteFuture, err error) { 264 var resp *http.Response 265 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 266 if err != nil { 267 return 268 } 269 var azf azure.Future 270 azf, err = azure.NewFutureFromResponse(resp) 271 future.FutureAPI = &azf 272 future.Result = future.result 273 return 274} 275 276// DeleteResponder handles the response to the Delete request. The method always 277// closes the http.Response Body. 278func (client DevicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 279 err = autorest.Respond( 280 resp, 281 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 282 autorest.ByClosing()) 283 result.Response = resp 284 return 285} 286 287// DownloadUpdates sends the download updates request. 288// Parameters: 289// deviceName - the device name. 290// resourceGroupName - the resource group name. 291func (client DevicesClient) DownloadUpdates(ctx context.Context, deviceName string, resourceGroupName string) (result DevicesDownloadUpdatesFuture, err error) { 292 if tracing.IsEnabled() { 293 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.DownloadUpdates") 294 defer func() { 295 sc := -1 296 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 297 sc = result.FutureAPI.Response().StatusCode 298 } 299 tracing.EndSpan(ctx, sc, err) 300 }() 301 } 302 req, err := client.DownloadUpdatesPreparer(ctx, deviceName, resourceGroupName) 303 if err != nil { 304 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "DownloadUpdates", nil, "Failure preparing request") 305 return 306 } 307 308 result, err = client.DownloadUpdatesSender(req) 309 if err != nil { 310 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "DownloadUpdates", nil, "Failure sending request") 311 return 312 } 313 314 return 315} 316 317// DownloadUpdatesPreparer prepares the DownloadUpdates request. 318func (client DevicesClient) DownloadUpdatesPreparer(ctx context.Context, deviceName string, resourceGroupName string) (*http.Request, error) { 319 pathParameters := map[string]interface{}{ 320 "deviceName": autorest.Encode("path", deviceName), 321 "resourceGroupName": autorest.Encode("path", resourceGroupName), 322 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 323 } 324 325 const APIVersion = "2019-08-01" 326 queryParameters := map[string]interface{}{ 327 "api-version": APIVersion, 328 } 329 330 preparer := autorest.CreatePreparer( 331 autorest.AsPost(), 332 autorest.WithBaseURL(client.BaseURI), 333 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates", pathParameters), 334 autorest.WithQueryParameters(queryParameters)) 335 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 336} 337 338// DownloadUpdatesSender sends the DownloadUpdates request. The method will close the 339// http.Response Body if it receives an error. 340func (client DevicesClient) DownloadUpdatesSender(req *http.Request) (future DevicesDownloadUpdatesFuture, err error) { 341 var resp *http.Response 342 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 343 if err != nil { 344 return 345 } 346 var azf azure.Future 347 azf, err = azure.NewFutureFromResponse(resp) 348 future.FutureAPI = &azf 349 future.Result = future.result 350 return 351} 352 353// DownloadUpdatesResponder handles the response to the DownloadUpdates request. The method always 354// closes the http.Response Body. 355func (client DevicesClient) DownloadUpdatesResponder(resp *http.Response) (result autorest.Response, err error) { 356 err = autorest.Respond( 357 resp, 358 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 359 autorest.ByClosing()) 360 result.Response = resp 361 return 362} 363 364// Get gets the properties of the Data Box Edge/Data Box Gateway device. 365// Parameters: 366// deviceName - the device name. 367// resourceGroupName - the resource group name. 368func (client DevicesClient) Get(ctx context.Context, deviceName string, resourceGroupName string) (result Device, err error) { 369 if tracing.IsEnabled() { 370 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.Get") 371 defer func() { 372 sc := -1 373 if result.Response.Response != nil { 374 sc = result.Response.Response.StatusCode 375 } 376 tracing.EndSpan(ctx, sc, err) 377 }() 378 } 379 req, err := client.GetPreparer(ctx, deviceName, resourceGroupName) 380 if err != nil { 381 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "Get", nil, "Failure preparing request") 382 return 383 } 384 385 resp, err := client.GetSender(req) 386 if err != nil { 387 result.Response = autorest.Response{Response: resp} 388 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "Get", resp, "Failure sending request") 389 return 390 } 391 392 result, err = client.GetResponder(resp) 393 if err != nil { 394 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "Get", resp, "Failure responding to request") 395 return 396 } 397 398 return 399} 400 401// GetPreparer prepares the Get request. 402func (client DevicesClient) GetPreparer(ctx context.Context, deviceName string, resourceGroupName string) (*http.Request, error) { 403 pathParameters := map[string]interface{}{ 404 "deviceName": autorest.Encode("path", deviceName), 405 "resourceGroupName": autorest.Encode("path", resourceGroupName), 406 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 407 } 408 409 const APIVersion = "2019-08-01" 410 queryParameters := map[string]interface{}{ 411 "api-version": APIVersion, 412 } 413 414 preparer := autorest.CreatePreparer( 415 autorest.AsGet(), 416 autorest.WithBaseURL(client.BaseURI), 417 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", pathParameters), 418 autorest.WithQueryParameters(queryParameters)) 419 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 420} 421 422// GetSender sends the Get request. The method will close the 423// http.Response Body if it receives an error. 424func (client DevicesClient) GetSender(req *http.Request) (*http.Response, error) { 425 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 426} 427 428// GetResponder handles the response to the Get request. The method always 429// closes the http.Response Body. 430func (client DevicesClient) GetResponder(resp *http.Response) (result Device, err error) { 431 err = autorest.Respond( 432 resp, 433 azure.WithErrorUnlessStatusCode(http.StatusOK), 434 autorest.ByUnmarshallingJSON(&result), 435 autorest.ByClosing()) 436 result.Response = autorest.Response{Response: resp} 437 return 438} 439 440// GetExtendedInformation gets additional information for the specified Data Box Edge/Data Box Gateway device. 441// Parameters: 442// deviceName - the device name. 443// resourceGroupName - the resource group name. 444func (client DevicesClient) GetExtendedInformation(ctx context.Context, deviceName string, resourceGroupName string) (result DeviceExtendedInfo, err error) { 445 if tracing.IsEnabled() { 446 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.GetExtendedInformation") 447 defer func() { 448 sc := -1 449 if result.Response.Response != nil { 450 sc = result.Response.Response.StatusCode 451 } 452 tracing.EndSpan(ctx, sc, err) 453 }() 454 } 455 req, err := client.GetExtendedInformationPreparer(ctx, deviceName, resourceGroupName) 456 if err != nil { 457 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "GetExtendedInformation", nil, "Failure preparing request") 458 return 459 } 460 461 resp, err := client.GetExtendedInformationSender(req) 462 if err != nil { 463 result.Response = autorest.Response{Response: resp} 464 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "GetExtendedInformation", resp, "Failure sending request") 465 return 466 } 467 468 result, err = client.GetExtendedInformationResponder(resp) 469 if err != nil { 470 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "GetExtendedInformation", resp, "Failure responding to request") 471 return 472 } 473 474 return 475} 476 477// GetExtendedInformationPreparer prepares the GetExtendedInformation request. 478func (client DevicesClient) GetExtendedInformationPreparer(ctx context.Context, deviceName string, resourceGroupName string) (*http.Request, error) { 479 pathParameters := map[string]interface{}{ 480 "deviceName": autorest.Encode("path", deviceName), 481 "resourceGroupName": autorest.Encode("path", resourceGroupName), 482 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 483 } 484 485 const APIVersion = "2019-08-01" 486 queryParameters := map[string]interface{}{ 487 "api-version": APIVersion, 488 } 489 490 preparer := autorest.CreatePreparer( 491 autorest.AsPost(), 492 autorest.WithBaseURL(client.BaseURI), 493 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation", pathParameters), 494 autorest.WithQueryParameters(queryParameters)) 495 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 496} 497 498// GetExtendedInformationSender sends the GetExtendedInformation request. The method will close the 499// http.Response Body if it receives an error. 500func (client DevicesClient) GetExtendedInformationSender(req *http.Request) (*http.Response, error) { 501 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 502} 503 504// GetExtendedInformationResponder handles the response to the GetExtendedInformation request. The method always 505// closes the http.Response Body. 506func (client DevicesClient) GetExtendedInformationResponder(resp *http.Response) (result DeviceExtendedInfo, err error) { 507 err = autorest.Respond( 508 resp, 509 azure.WithErrorUnlessStatusCode(http.StatusOK), 510 autorest.ByUnmarshallingJSON(&result), 511 autorest.ByClosing()) 512 result.Response = autorest.Response{Response: resp} 513 return 514} 515 516// GetNetworkSettings gets the network settings of the specified Data Box Edge/Data Box Gateway device. 517// Parameters: 518// deviceName - the device name. 519// resourceGroupName - the resource group name. 520func (client DevicesClient) GetNetworkSettings(ctx context.Context, deviceName string, resourceGroupName string) (result NetworkSettings, err error) { 521 if tracing.IsEnabled() { 522 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.GetNetworkSettings") 523 defer func() { 524 sc := -1 525 if result.Response.Response != nil { 526 sc = result.Response.Response.StatusCode 527 } 528 tracing.EndSpan(ctx, sc, err) 529 }() 530 } 531 req, err := client.GetNetworkSettingsPreparer(ctx, deviceName, resourceGroupName) 532 if err != nil { 533 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "GetNetworkSettings", nil, "Failure preparing request") 534 return 535 } 536 537 resp, err := client.GetNetworkSettingsSender(req) 538 if err != nil { 539 result.Response = autorest.Response{Response: resp} 540 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "GetNetworkSettings", resp, "Failure sending request") 541 return 542 } 543 544 result, err = client.GetNetworkSettingsResponder(resp) 545 if err != nil { 546 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "GetNetworkSettings", resp, "Failure responding to request") 547 return 548 } 549 550 return 551} 552 553// GetNetworkSettingsPreparer prepares the GetNetworkSettings request. 554func (client DevicesClient) GetNetworkSettingsPreparer(ctx context.Context, deviceName string, resourceGroupName string) (*http.Request, error) { 555 pathParameters := map[string]interface{}{ 556 "deviceName": autorest.Encode("path", deviceName), 557 "resourceGroupName": autorest.Encode("path", resourceGroupName), 558 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 559 } 560 561 const APIVersion = "2019-08-01" 562 queryParameters := map[string]interface{}{ 563 "api-version": APIVersion, 564 } 565 566 preparer := autorest.CreatePreparer( 567 autorest.AsGet(), 568 autorest.WithBaseURL(client.BaseURI), 569 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default", pathParameters), 570 autorest.WithQueryParameters(queryParameters)) 571 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 572} 573 574// GetNetworkSettingsSender sends the GetNetworkSettings request. The method will close the 575// http.Response Body if it receives an error. 576func (client DevicesClient) GetNetworkSettingsSender(req *http.Request) (*http.Response, error) { 577 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 578} 579 580// GetNetworkSettingsResponder handles the response to the GetNetworkSettings request. The method always 581// closes the http.Response Body. 582func (client DevicesClient) GetNetworkSettingsResponder(resp *http.Response) (result NetworkSettings, err error) { 583 err = autorest.Respond( 584 resp, 585 azure.WithErrorUnlessStatusCode(http.StatusOK), 586 autorest.ByUnmarshallingJSON(&result), 587 autorest.ByClosing()) 588 result.Response = autorest.Response{Response: resp} 589 return 590} 591 592// GetUpdateSummary sends the get update summary request. 593// Parameters: 594// deviceName - the device name. 595// resourceGroupName - the resource group name. 596func (client DevicesClient) GetUpdateSummary(ctx context.Context, deviceName string, resourceGroupName string) (result UpdateSummary, err error) { 597 if tracing.IsEnabled() { 598 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.GetUpdateSummary") 599 defer func() { 600 sc := -1 601 if result.Response.Response != nil { 602 sc = result.Response.Response.StatusCode 603 } 604 tracing.EndSpan(ctx, sc, err) 605 }() 606 } 607 req, err := client.GetUpdateSummaryPreparer(ctx, deviceName, resourceGroupName) 608 if err != nil { 609 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "GetUpdateSummary", nil, "Failure preparing request") 610 return 611 } 612 613 resp, err := client.GetUpdateSummarySender(req) 614 if err != nil { 615 result.Response = autorest.Response{Response: resp} 616 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "GetUpdateSummary", resp, "Failure sending request") 617 return 618 } 619 620 result, err = client.GetUpdateSummaryResponder(resp) 621 if err != nil { 622 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "GetUpdateSummary", resp, "Failure responding to request") 623 return 624 } 625 626 return 627} 628 629// GetUpdateSummaryPreparer prepares the GetUpdateSummary request. 630func (client DevicesClient) GetUpdateSummaryPreparer(ctx context.Context, deviceName string, resourceGroupName string) (*http.Request, error) { 631 pathParameters := map[string]interface{}{ 632 "deviceName": autorest.Encode("path", deviceName), 633 "resourceGroupName": autorest.Encode("path", resourceGroupName), 634 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 635 } 636 637 const APIVersion = "2019-08-01" 638 queryParameters := map[string]interface{}{ 639 "api-version": APIVersion, 640 } 641 642 preparer := autorest.CreatePreparer( 643 autorest.AsGet(), 644 autorest.WithBaseURL(client.BaseURI), 645 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default", pathParameters), 646 autorest.WithQueryParameters(queryParameters)) 647 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 648} 649 650// GetUpdateSummarySender sends the GetUpdateSummary request. The method will close the 651// http.Response Body if it receives an error. 652func (client DevicesClient) GetUpdateSummarySender(req *http.Request) (*http.Response, error) { 653 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 654} 655 656// GetUpdateSummaryResponder handles the response to the GetUpdateSummary request. The method always 657// closes the http.Response Body. 658func (client DevicesClient) GetUpdateSummaryResponder(resp *http.Response) (result UpdateSummary, err error) { 659 err = autorest.Respond( 660 resp, 661 azure.WithErrorUnlessStatusCode(http.StatusOK), 662 autorest.ByUnmarshallingJSON(&result), 663 autorest.ByClosing()) 664 result.Response = autorest.Response{Response: resp} 665 return 666} 667 668// InstallUpdates sends the install updates request. 669// Parameters: 670// deviceName - the device name. 671// resourceGroupName - the resource group name. 672func (client DevicesClient) InstallUpdates(ctx context.Context, deviceName string, resourceGroupName string) (result DevicesInstallUpdatesFuture, err error) { 673 if tracing.IsEnabled() { 674 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.InstallUpdates") 675 defer func() { 676 sc := -1 677 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 678 sc = result.FutureAPI.Response().StatusCode 679 } 680 tracing.EndSpan(ctx, sc, err) 681 }() 682 } 683 req, err := client.InstallUpdatesPreparer(ctx, deviceName, resourceGroupName) 684 if err != nil { 685 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "InstallUpdates", nil, "Failure preparing request") 686 return 687 } 688 689 result, err = client.InstallUpdatesSender(req) 690 if err != nil { 691 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "InstallUpdates", nil, "Failure sending request") 692 return 693 } 694 695 return 696} 697 698// InstallUpdatesPreparer prepares the InstallUpdates request. 699func (client DevicesClient) InstallUpdatesPreparer(ctx context.Context, deviceName string, resourceGroupName string) (*http.Request, error) { 700 pathParameters := map[string]interface{}{ 701 "deviceName": autorest.Encode("path", deviceName), 702 "resourceGroupName": autorest.Encode("path", resourceGroupName), 703 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 704 } 705 706 const APIVersion = "2019-08-01" 707 queryParameters := map[string]interface{}{ 708 "api-version": APIVersion, 709 } 710 711 preparer := autorest.CreatePreparer( 712 autorest.AsPost(), 713 autorest.WithBaseURL(client.BaseURI), 714 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates", pathParameters), 715 autorest.WithQueryParameters(queryParameters)) 716 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 717} 718 719// InstallUpdatesSender sends the InstallUpdates request. The method will close the 720// http.Response Body if it receives an error. 721func (client DevicesClient) InstallUpdatesSender(req *http.Request) (future DevicesInstallUpdatesFuture, err error) { 722 var resp *http.Response 723 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 724 if err != nil { 725 return 726 } 727 var azf azure.Future 728 azf, err = azure.NewFutureFromResponse(resp) 729 future.FutureAPI = &azf 730 future.Result = future.result 731 return 732} 733 734// InstallUpdatesResponder handles the response to the InstallUpdates request. The method always 735// closes the http.Response Body. 736func (client DevicesClient) InstallUpdatesResponder(resp *http.Response) (result autorest.Response, err error) { 737 err = autorest.Respond( 738 resp, 739 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 740 autorest.ByClosing()) 741 result.Response = resp 742 return 743} 744 745// ListByResourceGroup gets all the Data Box Edge/Data Box Gateway devices in a resource group. 746// Parameters: 747// resourceGroupName - the resource group name. 748// expand - specify $expand=details to populate additional fields related to the resource or Specify 749// $skipToken=<token> to populate the next page in the list. 750func (client DevicesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, expand string) (result DeviceListPage, err error) { 751 if tracing.IsEnabled() { 752 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.ListByResourceGroup") 753 defer func() { 754 sc := -1 755 if result.dl.Response.Response != nil { 756 sc = result.dl.Response.Response.StatusCode 757 } 758 tracing.EndSpan(ctx, sc, err) 759 }() 760 } 761 result.fn = client.listByResourceGroupNextResults 762 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, expand) 763 if err != nil { 764 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "ListByResourceGroup", nil, "Failure preparing request") 765 return 766 } 767 768 resp, err := client.ListByResourceGroupSender(req) 769 if err != nil { 770 result.dl.Response = autorest.Response{Response: resp} 771 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "ListByResourceGroup", resp, "Failure sending request") 772 return 773 } 774 775 result.dl, err = client.ListByResourceGroupResponder(resp) 776 if err != nil { 777 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "ListByResourceGroup", resp, "Failure responding to request") 778 return 779 } 780 if result.dl.hasNextLink() && result.dl.IsEmpty() { 781 err = result.NextWithContext(ctx) 782 return 783 } 784 785 return 786} 787 788// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 789func (client DevicesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, expand string) (*http.Request, error) { 790 pathParameters := map[string]interface{}{ 791 "resourceGroupName": autorest.Encode("path", resourceGroupName), 792 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 793 } 794 795 const APIVersion = "2019-08-01" 796 queryParameters := map[string]interface{}{ 797 "api-version": APIVersion, 798 } 799 if len(expand) > 0 { 800 queryParameters["$expand"] = autorest.Encode("query", expand) 801 } 802 803 preparer := autorest.CreatePreparer( 804 autorest.AsGet(), 805 autorest.WithBaseURL(client.BaseURI), 806 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices", pathParameters), 807 autorest.WithQueryParameters(queryParameters)) 808 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 809} 810 811// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 812// http.Response Body if it receives an error. 813func (client DevicesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 814 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 815} 816 817// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 818// closes the http.Response Body. 819func (client DevicesClient) ListByResourceGroupResponder(resp *http.Response) (result DeviceList, err error) { 820 err = autorest.Respond( 821 resp, 822 azure.WithErrorUnlessStatusCode(http.StatusOK), 823 autorest.ByUnmarshallingJSON(&result), 824 autorest.ByClosing()) 825 result.Response = autorest.Response{Response: resp} 826 return 827} 828 829// listByResourceGroupNextResults retrieves the next set of results, if any. 830func (client DevicesClient) listByResourceGroupNextResults(ctx context.Context, lastResults DeviceList) (result DeviceList, err error) { 831 req, err := lastResults.deviceListPreparer(ctx) 832 if err != nil { 833 return result, autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") 834 } 835 if req == nil { 836 return 837 } 838 resp, err := client.ListByResourceGroupSender(req) 839 if err != nil { 840 result.Response = autorest.Response{Response: resp} 841 return result, autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") 842 } 843 result, err = client.ListByResourceGroupResponder(resp) 844 if err != nil { 845 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") 846 } 847 return 848} 849 850// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. 851func (client DevicesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, expand string) (result DeviceListIterator, err error) { 852 if tracing.IsEnabled() { 853 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.ListByResourceGroup") 854 defer func() { 855 sc := -1 856 if result.Response().Response.Response != nil { 857 sc = result.page.Response().Response.Response.StatusCode 858 } 859 tracing.EndSpan(ctx, sc, err) 860 }() 861 } 862 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, expand) 863 return 864} 865 866// ListBySubscription gets all the Data Box Edge/Data Box Gateway devices in a subscription. 867// Parameters: 868// expand - specify $expand=details to populate additional fields related to the resource or Specify 869// $skipToken=<token> to populate the next page in the list. 870func (client DevicesClient) ListBySubscription(ctx context.Context, expand string) (result DeviceListPage, err error) { 871 if tracing.IsEnabled() { 872 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.ListBySubscription") 873 defer func() { 874 sc := -1 875 if result.dl.Response.Response != nil { 876 sc = result.dl.Response.Response.StatusCode 877 } 878 tracing.EndSpan(ctx, sc, err) 879 }() 880 } 881 result.fn = client.listBySubscriptionNextResults 882 req, err := client.ListBySubscriptionPreparer(ctx, expand) 883 if err != nil { 884 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "ListBySubscription", nil, "Failure preparing request") 885 return 886 } 887 888 resp, err := client.ListBySubscriptionSender(req) 889 if err != nil { 890 result.dl.Response = autorest.Response{Response: resp} 891 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "ListBySubscription", resp, "Failure sending request") 892 return 893 } 894 895 result.dl, err = client.ListBySubscriptionResponder(resp) 896 if err != nil { 897 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "ListBySubscription", resp, "Failure responding to request") 898 return 899 } 900 if result.dl.hasNextLink() && result.dl.IsEmpty() { 901 err = result.NextWithContext(ctx) 902 return 903 } 904 905 return 906} 907 908// ListBySubscriptionPreparer prepares the ListBySubscription request. 909func (client DevicesClient) ListBySubscriptionPreparer(ctx context.Context, expand string) (*http.Request, error) { 910 pathParameters := map[string]interface{}{ 911 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 912 } 913 914 const APIVersion = "2019-08-01" 915 queryParameters := map[string]interface{}{ 916 "api-version": APIVersion, 917 } 918 if len(expand) > 0 { 919 queryParameters["$expand"] = autorest.Encode("query", expand) 920 } 921 922 preparer := autorest.CreatePreparer( 923 autorest.AsGet(), 924 autorest.WithBaseURL(client.BaseURI), 925 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices", pathParameters), 926 autorest.WithQueryParameters(queryParameters)) 927 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 928} 929 930// ListBySubscriptionSender sends the ListBySubscription request. The method will close the 931// http.Response Body if it receives an error. 932func (client DevicesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { 933 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 934} 935 936// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always 937// closes the http.Response Body. 938func (client DevicesClient) ListBySubscriptionResponder(resp *http.Response) (result DeviceList, err error) { 939 err = autorest.Respond( 940 resp, 941 azure.WithErrorUnlessStatusCode(http.StatusOK), 942 autorest.ByUnmarshallingJSON(&result), 943 autorest.ByClosing()) 944 result.Response = autorest.Response{Response: resp} 945 return 946} 947 948// listBySubscriptionNextResults retrieves the next set of results, if any. 949func (client DevicesClient) listBySubscriptionNextResults(ctx context.Context, lastResults DeviceList) (result DeviceList, err error) { 950 req, err := lastResults.deviceListPreparer(ctx) 951 if err != nil { 952 return result, autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") 953 } 954 if req == nil { 955 return 956 } 957 resp, err := client.ListBySubscriptionSender(req) 958 if err != nil { 959 result.Response = autorest.Response{Response: resp} 960 return result, autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") 961 } 962 result, err = client.ListBySubscriptionResponder(resp) 963 if err != nil { 964 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") 965 } 966 return 967} 968 969// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. 970func (client DevicesClient) ListBySubscriptionComplete(ctx context.Context, expand string) (result DeviceListIterator, err error) { 971 if tracing.IsEnabled() { 972 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.ListBySubscription") 973 defer func() { 974 sc := -1 975 if result.Response().Response.Response != nil { 976 sc = result.page.Response().Response.Response.StatusCode 977 } 978 tracing.EndSpan(ctx, sc, err) 979 }() 980 } 981 result.page, err = client.ListBySubscription(ctx, expand) 982 return 983} 984 985// ScanForUpdates sends the scan for updates request. 986// Parameters: 987// deviceName - the device name. 988// resourceGroupName - the resource group name. 989func (client DevicesClient) ScanForUpdates(ctx context.Context, deviceName string, resourceGroupName string) (result DevicesScanForUpdatesFuture, err error) { 990 if tracing.IsEnabled() { 991 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.ScanForUpdates") 992 defer func() { 993 sc := -1 994 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 995 sc = result.FutureAPI.Response().StatusCode 996 } 997 tracing.EndSpan(ctx, sc, err) 998 }() 999 } 1000 req, err := client.ScanForUpdatesPreparer(ctx, deviceName, resourceGroupName) 1001 if err != nil { 1002 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "ScanForUpdates", nil, "Failure preparing request") 1003 return 1004 } 1005 1006 result, err = client.ScanForUpdatesSender(req) 1007 if err != nil { 1008 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "ScanForUpdates", nil, "Failure sending request") 1009 return 1010 } 1011 1012 return 1013} 1014 1015// ScanForUpdatesPreparer prepares the ScanForUpdates request. 1016func (client DevicesClient) ScanForUpdatesPreparer(ctx context.Context, deviceName string, resourceGroupName string) (*http.Request, error) { 1017 pathParameters := map[string]interface{}{ 1018 "deviceName": autorest.Encode("path", deviceName), 1019 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1020 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1021 } 1022 1023 const APIVersion = "2019-08-01" 1024 queryParameters := map[string]interface{}{ 1025 "api-version": APIVersion, 1026 } 1027 1028 preparer := autorest.CreatePreparer( 1029 autorest.AsPost(), 1030 autorest.WithBaseURL(client.BaseURI), 1031 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates", pathParameters), 1032 autorest.WithQueryParameters(queryParameters)) 1033 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1034} 1035 1036// ScanForUpdatesSender sends the ScanForUpdates request. The method will close the 1037// http.Response Body if it receives an error. 1038func (client DevicesClient) ScanForUpdatesSender(req *http.Request) (future DevicesScanForUpdatesFuture, err error) { 1039 var resp *http.Response 1040 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1041 if err != nil { 1042 return 1043 } 1044 var azf azure.Future 1045 azf, err = azure.NewFutureFromResponse(resp) 1046 future.FutureAPI = &azf 1047 future.Result = future.result 1048 return 1049} 1050 1051// ScanForUpdatesResponder handles the response to the ScanForUpdates request. The method always 1052// closes the http.Response Body. 1053func (client DevicesClient) ScanForUpdatesResponder(resp *http.Response) (result autorest.Response, err error) { 1054 err = autorest.Respond( 1055 resp, 1056 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1057 autorest.ByClosing()) 1058 result.Response = resp 1059 return 1060} 1061 1062// Update modifies a Data Box Edge/Data Box Gateway resource. 1063// Parameters: 1064// deviceName - the device name. 1065// parameters - the resource parameters. 1066// resourceGroupName - the resource group name. 1067func (client DevicesClient) Update(ctx context.Context, deviceName string, parameters DevicePatch, resourceGroupName string) (result Device, err error) { 1068 if tracing.IsEnabled() { 1069 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.Update") 1070 defer func() { 1071 sc := -1 1072 if result.Response.Response != nil { 1073 sc = result.Response.Response.StatusCode 1074 } 1075 tracing.EndSpan(ctx, sc, err) 1076 }() 1077 } 1078 req, err := client.UpdatePreparer(ctx, deviceName, parameters, resourceGroupName) 1079 if err != nil { 1080 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "Update", nil, "Failure preparing request") 1081 return 1082 } 1083 1084 resp, err := client.UpdateSender(req) 1085 if err != nil { 1086 result.Response = autorest.Response{Response: resp} 1087 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "Update", resp, "Failure sending request") 1088 return 1089 } 1090 1091 result, err = client.UpdateResponder(resp) 1092 if err != nil { 1093 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "Update", resp, "Failure responding to request") 1094 return 1095 } 1096 1097 return 1098} 1099 1100// UpdatePreparer prepares the Update request. 1101func (client DevicesClient) UpdatePreparer(ctx context.Context, deviceName string, parameters DevicePatch, resourceGroupName string) (*http.Request, error) { 1102 pathParameters := map[string]interface{}{ 1103 "deviceName": autorest.Encode("path", deviceName), 1104 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1105 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1106 } 1107 1108 const APIVersion = "2019-08-01" 1109 queryParameters := map[string]interface{}{ 1110 "api-version": APIVersion, 1111 } 1112 1113 preparer := autorest.CreatePreparer( 1114 autorest.AsContentType("application/json; charset=utf-8"), 1115 autorest.AsPatch(), 1116 autorest.WithBaseURL(client.BaseURI), 1117 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", pathParameters), 1118 autorest.WithJSON(parameters), 1119 autorest.WithQueryParameters(queryParameters)) 1120 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1121} 1122 1123// UpdateSender sends the Update request. The method will close the 1124// http.Response Body if it receives an error. 1125func (client DevicesClient) UpdateSender(req *http.Request) (*http.Response, error) { 1126 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1127} 1128 1129// UpdateResponder handles the response to the Update request. The method always 1130// closes the http.Response Body. 1131func (client DevicesClient) UpdateResponder(resp *http.Response) (result Device, err error) { 1132 err = autorest.Respond( 1133 resp, 1134 azure.WithErrorUnlessStatusCode(http.StatusOK), 1135 autorest.ByUnmarshallingJSON(&result), 1136 autorest.ByClosing()) 1137 result.Response = autorest.Response{Response: resp} 1138 return 1139} 1140 1141// UploadCertificate uploads registration certificate for the device. 1142// Parameters: 1143// deviceName - the device name. 1144// parameters - the upload certificate request. 1145// resourceGroupName - the resource group name. 1146func (client DevicesClient) UploadCertificate(ctx context.Context, deviceName string, parameters UploadCertificateRequest, resourceGroupName string) (result UploadCertificateResponse, err error) { 1147 if tracing.IsEnabled() { 1148 ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.UploadCertificate") 1149 defer func() { 1150 sc := -1 1151 if result.Response.Response != nil { 1152 sc = result.Response.Response.StatusCode 1153 } 1154 tracing.EndSpan(ctx, sc, err) 1155 }() 1156 } 1157 if err := validation.Validate([]validation.Validation{ 1158 {TargetValue: parameters, 1159 Constraints: []validation.Constraint{{Target: "parameters.RawCertificateData", Name: validation.Null, Rule: true, 1160 Chain: []validation.Constraint{{Target: "parameters.RawCertificateData.Certificate", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { 1161 return result, validation.NewError("databoxedge.DevicesClient", "UploadCertificate", err.Error()) 1162 } 1163 1164 req, err := client.UploadCertificatePreparer(ctx, deviceName, parameters, resourceGroupName) 1165 if err != nil { 1166 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "UploadCertificate", nil, "Failure preparing request") 1167 return 1168 } 1169 1170 resp, err := client.UploadCertificateSender(req) 1171 if err != nil { 1172 result.Response = autorest.Response{Response: resp} 1173 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "UploadCertificate", resp, "Failure sending request") 1174 return 1175 } 1176 1177 result, err = client.UploadCertificateResponder(resp) 1178 if err != nil { 1179 err = autorest.NewErrorWithError(err, "databoxedge.DevicesClient", "UploadCertificate", resp, "Failure responding to request") 1180 return 1181 } 1182 1183 return 1184} 1185 1186// UploadCertificatePreparer prepares the UploadCertificate request. 1187func (client DevicesClient) UploadCertificatePreparer(ctx context.Context, deviceName string, parameters UploadCertificateRequest, resourceGroupName string) (*http.Request, error) { 1188 pathParameters := map[string]interface{}{ 1189 "deviceName": autorest.Encode("path", deviceName), 1190 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1191 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1192 } 1193 1194 const APIVersion = "2019-08-01" 1195 queryParameters := map[string]interface{}{ 1196 "api-version": APIVersion, 1197 } 1198 1199 preparer := autorest.CreatePreparer( 1200 autorest.AsContentType("application/json; charset=utf-8"), 1201 autorest.AsPost(), 1202 autorest.WithBaseURL(client.BaseURI), 1203 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate", pathParameters), 1204 autorest.WithJSON(parameters), 1205 autorest.WithQueryParameters(queryParameters)) 1206 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1207} 1208 1209// UploadCertificateSender sends the UploadCertificate request. The method will close the 1210// http.Response Body if it receives an error. 1211func (client DevicesClient) UploadCertificateSender(req *http.Request) (*http.Response, error) { 1212 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1213} 1214 1215// UploadCertificateResponder handles the response to the UploadCertificate request. The method always 1216// closes the http.Response Body. 1217func (client DevicesClient) UploadCertificateResponder(resp *http.Response) (result UploadCertificateResponse, err error) { 1218 err = autorest.Respond( 1219 resp, 1220 azure.WithErrorUnlessStatusCode(http.StatusOK), 1221 autorest.ByUnmarshallingJSON(&result), 1222 autorest.ByClosing()) 1223 result.Response = autorest.Response{Response: resp} 1224 return 1225} 1226