From 074673f3b5822885b72af344af8d42e7f53bf744 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 13 Jan 2022 22:04:46 +0000 Subject: [PATCH] CodeGen from PR 17329 in Azure/azure-rest-api-specs Update SDK client names (#17329) --- .../src/Generated/DeploymentsClient.cs | 349 -- .../src/Generated/DeploymentsRestClient.cs | 762 ----- .../src/Generated/DeviceManagementClient.cs | 1609 +++++++++ .../DeviceManagementGetOperationHeaders.cs | 23 + .../DeviceManagementImportDevicesHeaders.cs | 23 + .../DeviceManagementImportDevicesOperation.cs | 53 + .../Generated/DeviceManagementRestClient.cs | 3005 +++++++++++++++++ ...UpdatesClient.cs => DeviceUpdateClient.cs} | 351 +- .../Generated/DeviceUpdateClientOptions.cs | 8 +- ....cs => DeviceUpdateDeleteUpdateHeaders.cs} | 6 +- .../DeviceUpdateDeleteUpdateOperation.cs | 53 + ....cs => DeviceUpdateGetOperationHeaders.cs} | 4 +- ....cs => DeviceUpdateImportUpdateHeaders.cs} | 6 +- .../DeviceUpdateImportUpdateOperation.cs | 73 + .../src/Generated/DeviceUpdateModelFactory.cs | 220 +- ...estClient.cs => DeviceUpdateRestClient.cs} | 478 ++- .../src/Generated/DevicesClient.cs | 889 ----- .../src/Generated/DevicesRestClient.cs | 1561 --------- .../Models/Compatibility.Serialization.cs | 35 - .../src/Generated/Models/Compatibility.cs | 39 - .../Models/Deployment.Serialization.cs | 70 +- .../src/Generated/Models/Deployment.cs | 60 +- .../Models/DeploymentCancelAction.cs | 48 + .../DeploymentDeviceState.Serialization.cs | 8 +- .../Generated/Models/DeploymentDeviceState.cs | 17 + .../Models/DeploymentDeviceStatesFilter.cs | 2 + ...ploymentDeviceStatesList.Serialization.cs} | 13 +- ...tates.cs => DeploymentDeviceStatesList.cs} | 22 +- .../Generated/Models/DeploymentRetryAction.cs | 48 + .../src/Generated/Models/DeploymentState.cs | 6 +- .../Models/DeploymentStatus.Serialization.cs | 13 +- .../src/Generated/Models/DeploymentStatus.cs | 32 +- .../src/Generated/Models/DeploymentType.cs | 54 - ...on.cs => DeploymentsList.Serialization.cs} | 13 +- ...istOfDeployments.cs => DeploymentsList.cs} | 22 +- .../Generated/Models/Device.Serialization.cs | 19 +- .../src/Generated/Models/Device.cs | 10 +- .../Models/DeviceClass.Serialization.cs | 20 +- .../src/Generated/Models/DeviceClass.cs | 25 +- ....cs => DeviceClassesList.Serialization.cs} | 13 +- ...fDeviceClasses.cs => DeviceClassesList.cs} | 22 +- .../src/Generated/Models/DeviceFilter.cs | 2 +- .../src/Generated/Models/DeviceGroupType.cs | 54 - .../Models/DeviceOperation.Serialization.cs | 71 + .../src/Generated/Models/DeviceOperation.cs | 68 + .../DeviceOperationsList.Serialization.cs | 41 + .../Generated/Models/DeviceOperationsList.cs | 44 + ...ion.cs => DeviceTagsList.Serialization.cs} | 13 +- ...eListOfDeviceTags.cs => DeviceTagsList.cs} | 22 +- .../DeviceUpdateAgentId.Serialization.cs | 48 + .../Generated/Models/DeviceUpdateAgentId.cs | 42 + ...zation.cs => DevicesList.Serialization.cs} | 13 +- ...ageableListOfDevices.cs => DevicesList.cs} | 22 +- .../Models/ErrorResponse.Serialization.cs | 29 + .../src/Generated/Models/ErrorResponse.cs | 31 + .../Generated/Models/Group.Serialization.cs | 24 +- .../src/Generated/Models/Group.cs | 10 +- .../src/Generated/Models/GroupType.cs | 14 +- ...ization.cs => GroupsList.Serialization.cs} | 13 +- ...{PageableListOfGroups.cs => GroupsList.cs} | 22 +- .../src/Generated/Models/ImportAction.cs | 48 + .../src/Generated/Models/ImportType.cs | 54 + .../Models/ImportUpdateInput.Serialization.cs | 30 - .../ImportUpdateInputItem.Serialization.cs | 38 + ...pdateInput.cs => ImportUpdateInputItem.cs} | 21 +- .../Models/InstallResult.Serialization.cs | 58 + .../src/Generated/Models/InstallResult.cs | 48 + .../Models/Instructions.Serialization.cs | 35 + .../src/Generated/Models/Instructions.cs | 40 + .../LogCollectionOperation.Serialization.cs | 93 + .../Models/LogCollectionOperation.cs | 60 + ...onOperationDetailedStatus.Serialization.cs | 75 + .../LogCollectionOperationDetailedStatus.cs | 52 + ...ogCollectionOperationDetailedStatusList.cs | 35 + ...tionOperationDeviceStatus.Serialization.cs | 59 + .../LogCollectionOperationDeviceStatus.cs | 60 + ...ogCollectionOperationList.Serialization.cs | 41 + .../Models/LogCollectionOperationList.cs | 44 + .../PageableListOfOperations.Serialization.cs | 46 - .../Models/PageableListOfOperations.cs | 36 - .../Generated/Models/Step.Serialization.cs | 85 + .../src/Generated/Models/Step.cs | 52 + .../Models/StepResult.Serialization.cs | 58 + .../src/Generated/Models/StepResult.cs | 48 + .../src/Generated/Models/StepType.cs | 51 + ...zation.cs => StringsList.Serialization.cs} | 13 +- ...ageableListOfStrings.cs => StringsList.cs} | 22 +- ... => UpdatableDevicesList.Serialization.cs} | 13 +- ...ableDevices.cs => UpdatableDevicesList.cs} | 22 +- .../Generated/Models/Update.Serialization.cs | 73 +- .../src/Generated/Models/Update.cs | 54 +- ...ization.cs => UpdateFile.Serialization.cs} | 18 +- .../Models/{File.cs => UpdateFile.cs} | 18 +- .../src/Generated/Models/UpdateFilter.cs | 21 + ...tion.cs => UpdateIdsList.Serialization.cs} | 13 +- ...bleListOfUpdateIds.cs => UpdateIdsList.cs} | 22 +- .../Models/UpdateList.Serialization.cs | 41 + .../src/Generated/Models/UpdateList.cs | 44 + ...on.cs => UpdateOperation.Serialization.cs} | 6 +- .../{Operation.cs => UpdateOperation.cs} | 10 +- .../UpdateOperationsList.Serialization.cs | 41 + .../Generated/Models/UpdateOperationsList.cs | 44 + .../Azure.IoT.DeviceUpdate/src/autorest.md | 2 +- 103 files changed, 7892 insertions(+), 4519 deletions(-) delete mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeploymentsClient.cs delete mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeploymentsRestClient.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementClient.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementGetOperationHeaders.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementImportDevicesHeaders.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementImportDevicesOperation.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementRestClient.cs rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/{UpdatesClient.cs => DeviceUpdateClient.cs} (57%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/{UpdatesDeleteUpdateHeaders.cs => DeviceUpdateDeleteUpdateHeaders.cs} (63%) create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateDeleteUpdateOperation.cs rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/{UpdatesGetOperationHeaders.cs => DeviceUpdateGetOperationHeaders.cs} (81%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/{UpdatesImportUpdateHeaders.cs => DeviceUpdateImportUpdateHeaders.cs} (63%) create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateImportUpdateOperation.cs rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/{UpdatesRestClient.cs => DeviceUpdateRestClient.cs} (69%) delete mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DevicesClient.cs delete mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DevicesRestClient.cs delete mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Compatibility.Serialization.cs delete mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Compatibility.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentCancelAction.cs rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfDeploymentDeviceStates.Serialization.cs => DeploymentDeviceStatesList.Serialization.cs} (64%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfDeploymentDeviceStates.cs => DeploymentDeviceStatesList.cs} (50%) create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentRetryAction.cs delete mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentType.cs rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfDeployments.Serialization.cs => DeploymentsList.Serialization.cs} (65%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfDeployments.cs => DeploymentsList.cs} (51%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfDeviceClasses.Serialization.cs => DeviceClassesList.Serialization.cs} (65%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfDeviceClasses.cs => DeviceClassesList.cs} (51%) delete mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceGroupType.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperation.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperation.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperationsList.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperationsList.cs rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfDeviceTags.Serialization.cs => DeviceTagsList.Serialization.cs} (65%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfDeviceTags.cs => DeviceTagsList.cs} (52%) create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceUpdateAgentId.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceUpdateAgentId.cs rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfDevices.Serialization.cs => DevicesList.Serialization.cs} (66%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfDevices.cs => DevicesList.cs} (52%) create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ErrorResponse.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ErrorResponse.cs rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfGroups.Serialization.cs => GroupsList.Serialization.cs} (66%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfGroups.cs => GroupsList.cs} (52%) create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportAction.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportType.cs delete mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInput.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInputItem.Serialization.cs rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{ImportUpdateInput.cs => ImportUpdateInputItem.cs} (63%) create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/InstallResult.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/InstallResult.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Instructions.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Instructions.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperation.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperation.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDetailedStatus.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDetailedStatus.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDetailedStatusList.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDeviceStatus.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDeviceStatus.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationList.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationList.cs delete mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfOperations.Serialization.cs delete mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfOperations.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Step.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Step.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StepResult.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StepResult.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StepType.cs rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfStrings.Serialization.cs => StringsList.Serialization.cs} (65%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfStrings.cs => StringsList.cs} (53%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfUpdatableDevices.Serialization.cs => UpdatableDevicesList.Serialization.cs} (65%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfUpdatableDevices.cs => UpdatableDevicesList.cs} (50%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{File.Serialization.cs => UpdateFile.Serialization.cs} (73%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{File.cs => UpdateFile.cs} (73%) create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateFilter.cs rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfUpdateIds.Serialization.cs => UpdateIdsList.Serialization.cs} (65%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{PageableListOfUpdateIds.cs => UpdateIdsList.cs} (52%) create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateList.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateList.cs rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{Operation.Serialization.cs => UpdateOperation.Serialization.cs} (90%) rename sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/{Operation.cs => UpdateOperation.cs} (85%) create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperationsList.Serialization.cs create mode 100644 sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperationsList.cs diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeploymentsClient.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeploymentsClient.cs deleted file mode 100644 index 43ea15562fe5e..0000000000000 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeploymentsClient.cs +++ /dev/null @@ -1,349 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.IoT.DeviceUpdate.Models; - -namespace Azure.IoT.DeviceUpdate -{ - /// The Deployments service client. - public partial class DeploymentsClient - { - private readonly ClientDiagnostics _clientDiagnostics; - private readonly HttpPipeline _pipeline; - internal DeploymentsRestClient RestClient { get; } - - /// Initializes a new instance of DeploymentsClient. - /// The handler for diagnostic messaging in the client. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Account endpoint. - /// Account instance identifier. - internal DeploymentsClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string accountEndpoint, string instanceId) - { - RestClient = new DeploymentsRestClient(clientDiagnostics, pipeline, accountEndpoint, instanceId); - _clientDiagnostics = clientDiagnostics; - _pipeline = pipeline; - } - - /// Gets the properties of a deployment. - /// Deployment identifier. - /// The cancellation token to use. - public virtual async Task> GetDeploymentAsync(string deploymentId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.GetDeployment"); - scope.Start(); - try - { - return await RestClient.GetDeploymentAsync(deploymentId, cancellationToken).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets the properties of a deployment. - /// Deployment identifier. - /// The cancellation token to use. - public virtual Response GetDeployment(string deploymentId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.GetDeployment"); - scope.Start(); - try - { - return RestClient.GetDeployment(deploymentId, cancellationToken); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Creates or updates a deployment. - /// Deployment identifier. - /// The deployment properties. - /// The cancellation token to use. - public virtual async Task> CreateOrUpdateDeploymentAsync(string deploymentId, Deployment deployment, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.CreateOrUpdateDeployment"); - scope.Start(); - try - { - return await RestClient.CreateOrUpdateDeploymentAsync(deploymentId, deployment, cancellationToken).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Creates or updates a deployment. - /// Deployment identifier. - /// The deployment properties. - /// The cancellation token to use. - public virtual Response CreateOrUpdateDeployment(string deploymentId, Deployment deployment, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.CreateOrUpdateDeployment"); - scope.Start(); - try - { - return RestClient.CreateOrUpdateDeployment(deploymentId, deployment, cancellationToken); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Deletes a deployment. - /// Deployment identifier. - /// The cancellation token to use. - public virtual async Task DeleteDeploymentAsync(string deploymentId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.DeleteDeployment"); - scope.Start(); - try - { - return await RestClient.DeleteDeploymentAsync(deploymentId, cancellationToken).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Deletes a deployment. - /// Deployment identifier. - /// The cancellation token to use. - public virtual Response DeleteDeployment(string deploymentId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.DeleteDeployment"); - scope.Start(); - try - { - return RestClient.DeleteDeployment(deploymentId, cancellationToken); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets the status of a deployment including a breakdown of how many devices in the deployment are in progress, completed, or failed. - /// Deployment identifier. - /// The cancellation token to use. - public virtual async Task> GetDeploymentStatusAsync(string deploymentId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.GetDeploymentStatus"); - scope.Start(); - try - { - return await RestClient.GetDeploymentStatusAsync(deploymentId, cancellationToken).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets the status of a deployment including a breakdown of how many devices in the deployment are in progress, completed, or failed. - /// Deployment identifier. - /// The cancellation token to use. - public virtual Response GetDeploymentStatus(string deploymentId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.GetDeploymentStatus"); - scope.Start(); - try - { - return RestClient.GetDeploymentStatus(deploymentId, cancellationToken); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets a list of deployments. - /// Restricts the set of deployments returned. You can filter on update Provider, Name and Version property. - /// The cancellation token to use. - public virtual AsyncPageable GetAllDeploymentsAsync(string filter = null, CancellationToken cancellationToken = default) - { - async Task> FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.GetAllDeployments"); - scope.Start(); - try - { - var response = await RestClient.GetAllDeploymentsAsync(filter, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.GetAllDeployments"); - scope.Start(); - try - { - var response = await RestClient.GetAllDeploymentsNextPageAsync(nextLink, filter, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of deployments. - /// Restricts the set of deployments returned. You can filter on update Provider, Name and Version property. - /// The cancellation token to use. - public virtual Pageable GetAllDeployments(string filter = null, CancellationToken cancellationToken = default) - { - Page FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.GetAllDeployments"); - scope.Start(); - try - { - var response = RestClient.GetAllDeployments(filter, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - Page NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.GetAllDeployments"); - scope.Start(); - try - { - var response = RestClient.GetAllDeploymentsNextPage(nextLink, filter, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. - /// Deployment identifier. - /// Restricts the set of deployment device states returned. You can filter on deviceId and/or deviceState. - /// The cancellation token to use. - /// is null. - public virtual AsyncPageable GetDeploymentDevicesAsync(string deploymentId, string filter = null, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - async Task> FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.GetDeploymentDevices"); - scope.Start(); - try - { - var response = await RestClient.GetDeploymentDevicesAsync(deploymentId, filter, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.GetDeploymentDevices"); - scope.Start(); - try - { - var response = await RestClient.GetDeploymentDevicesNextPageAsync(nextLink, deploymentId, filter, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. - /// Deployment identifier. - /// Restricts the set of deployment device states returned. You can filter on deviceId and/or deviceState. - /// The cancellation token to use. - /// is null. - public virtual Pageable GetDeploymentDevices(string deploymentId, string filter = null, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - Page FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.GetDeploymentDevices"); - scope.Start(); - try - { - var response = RestClient.GetDeploymentDevices(deploymentId, filter, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - Page NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DeploymentsClient.GetDeploymentDevices"); - scope.Start(); - try - { - var response = RestClient.GetDeploymentDevicesNextPage(nextLink, deploymentId, filter, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); - } - } -} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeploymentsRestClient.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeploymentsRestClient.cs deleted file mode 100644 index f596be4e258af..0000000000000 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeploymentsRestClient.cs +++ /dev/null @@ -1,762 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.IoT.DeviceUpdate.Models; - -namespace Azure.IoT.DeviceUpdate -{ - internal partial class DeploymentsRestClient - { - private string accountEndpoint; - private string instanceId; - private ClientDiagnostics _clientDiagnostics; - private HttpPipeline _pipeline; - - /// Initializes a new instance of DeploymentsRestClient. - /// The handler for diagnostic messaging in the client. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Account endpoint. - /// Account instance identifier. - /// or is null. - public DeploymentsRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string accountEndpoint, string instanceId) - { - this.accountEndpoint = accountEndpoint ?? throw new ArgumentNullException(nameof(accountEndpoint)); - this.instanceId = instanceId ?? throw new ArgumentNullException(nameof(instanceId)); - _clientDiagnostics = clientDiagnostics; - _pipeline = pipeline; - } - - internal HttpMessage CreateGetAllDeploymentsRequest(string filter) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/deployments", false); - if (filter != null) - { - uri.AppendQuery("$filter", filter, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of deployments. - /// Restricts the set of deployments returned. You can filter on update Provider, Name and Version property. - /// The cancellation token to use. - public async Task> GetAllDeploymentsAsync(string filter = null, CancellationToken cancellationToken = default) - { - using var message = CreateGetAllDeploymentsRequest(filter); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeployments value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfDeployments.DeserializePageableListOfDeployments(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of deployments. - /// Restricts the set of deployments returned. You can filter on update Provider, Name and Version property. - /// The cancellation token to use. - public Response GetAllDeployments(string filter = null, CancellationToken cancellationToken = default) - { - using var message = CreateGetAllDeploymentsRequest(filter); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeployments value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfDeployments.DeserializePageableListOfDeployments(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetDeploymentRequest(string deploymentId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/deployments/", false); - uri.AppendPath(deploymentId, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets the properties of a deployment. - /// Deployment identifier. - /// The cancellation token to use. - /// is null. - public async Task> GetDeploymentAsync(string deploymentId, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateGetDeploymentRequest(deploymentId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - Deployment value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = Deployment.DeserializeDeployment(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets the properties of a deployment. - /// Deployment identifier. - /// The cancellation token to use. - /// is null. - public Response GetDeployment(string deploymentId, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateGetDeploymentRequest(deploymentId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - Deployment value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = Deployment.DeserializeDeployment(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateCreateOrUpdateDeploymentRequest(string deploymentId, Deployment deployment) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/deployments/", false); - uri.AppendPath(deploymentId, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(deployment); - request.Content = content; - return message; - } - - /// Creates or updates a deployment. - /// Deployment identifier. - /// The deployment properties. - /// The cancellation token to use. - /// or is null. - public async Task> CreateOrUpdateDeploymentAsync(string deploymentId, Deployment deployment, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - if (deployment == null) - { - throw new ArgumentNullException(nameof(deployment)); - } - - using var message = CreateCreateOrUpdateDeploymentRequest(deploymentId, deployment); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - Deployment value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = Deployment.DeserializeDeployment(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Creates or updates a deployment. - /// Deployment identifier. - /// The deployment properties. - /// The cancellation token to use. - /// or is null. - public Response CreateOrUpdateDeployment(string deploymentId, Deployment deployment, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - if (deployment == null) - { - throw new ArgumentNullException(nameof(deployment)); - } - - using var message = CreateCreateOrUpdateDeploymentRequest(deploymentId, deployment); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - Deployment value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = Deployment.DeserializeDeployment(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateDeleteDeploymentRequest(string deploymentId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/deployments/", false); - uri.AppendPath(deploymentId, true); - request.Uri = uri; - return message; - } - - /// Deletes a deployment. - /// Deployment identifier. - /// The cancellation token to use. - /// is null. - public async Task DeleteDeploymentAsync(string deploymentId, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateDeleteDeploymentRequest(deploymentId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - return message.Response; - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Deletes a deployment. - /// Deployment identifier. - /// The cancellation token to use. - /// is null. - public Response DeleteDeployment(string deploymentId, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateDeleteDeploymentRequest(deploymentId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - return message.Response; - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetDeploymentStatusRequest(string deploymentId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/deployments/", false); - uri.AppendPath(deploymentId, true); - uri.AppendPath("/status", false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets the status of a deployment including a breakdown of how many devices in the deployment are in progress, completed, or failed. - /// Deployment identifier. - /// The cancellation token to use. - /// is null. - public async Task> GetDeploymentStatusAsync(string deploymentId, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateGetDeploymentStatusRequest(deploymentId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DeploymentStatus value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = DeploymentStatus.DeserializeDeploymentStatus(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets the status of a deployment including a breakdown of how many devices in the deployment are in progress, completed, or failed. - /// Deployment identifier. - /// The cancellation token to use. - /// is null. - public Response GetDeploymentStatus(string deploymentId, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateGetDeploymentStatusRequest(deploymentId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DeploymentStatus value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = DeploymentStatus.DeserializeDeploymentStatus(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetDeploymentDevicesRequest(string deploymentId, string filter) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/deployments/", false); - uri.AppendPath(deploymentId, true); - uri.AppendPath("/devicestates", false); - if (filter != null) - { - uri.AppendQuery("$filter", filter, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. - /// Deployment identifier. - /// Restricts the set of deployment device states returned. You can filter on deviceId and/or deviceState. - /// The cancellation token to use. - /// is null. - public async Task> GetDeploymentDevicesAsync(string deploymentId, string filter = null, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateGetDeploymentDevicesRequest(deploymentId, filter); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeploymentDeviceStates value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfDeploymentDeviceStates.DeserializePageableListOfDeploymentDeviceStates(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. - /// Deployment identifier. - /// Restricts the set of deployment device states returned. You can filter on deviceId and/or deviceState. - /// The cancellation token to use. - /// is null. - public Response GetDeploymentDevices(string deploymentId, string filter = null, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateGetDeploymentDevicesRequest(deploymentId, filter); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeploymentDeviceStates value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfDeploymentDeviceStates.DeserializePageableListOfDeploymentDeviceStates(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateCancelDeploymentRequest(string deploymentId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/deployments/", false); - uri.AppendPath(deploymentId, true); - uri.AppendQuery("action", "cancel", true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Cancels a deployment. - /// Deployment identifier. - /// The cancellation token to use. - /// is null. - public async Task> CancelDeploymentAsync(string deploymentId, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateCancelDeploymentRequest(deploymentId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - Deployment value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = Deployment.DeserializeDeployment(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Cancels a deployment. - /// Deployment identifier. - /// The cancellation token to use. - /// is null. - public Response CancelDeployment(string deploymentId, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateCancelDeploymentRequest(deploymentId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - Deployment value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = Deployment.DeserializeDeployment(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateRetryDeploymentRequest(string deploymentId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/deployments/", false); - uri.AppendPath(deploymentId, true); - uri.AppendQuery("action", "retry", true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Retries a deployment with failed devices. - /// Deployment identifier. - /// The cancellation token to use. - /// is null. - public async Task> RetryDeploymentAsync(string deploymentId, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateRetryDeploymentRequest(deploymentId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - Deployment value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = Deployment.DeserializeDeployment(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Retries a deployment with failed devices. - /// Deployment identifier. - /// The cancellation token to use. - /// is null. - public Response RetryDeployment(string deploymentId, CancellationToken cancellationToken = default) - { - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateRetryDeploymentRequest(deploymentId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - Deployment value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = Deployment.DeserializeDeployment(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetAllDeploymentsNextPageRequest(string nextLink, string filter) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of deployments. - /// The URL to the next page of results. - /// Restricts the set of deployments returned. You can filter on update Provider, Name and Version property. - /// The cancellation token to use. - /// is null. - public async Task> GetAllDeploymentsNextPageAsync(string nextLink, string filter = null, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - - using var message = CreateGetAllDeploymentsNextPageRequest(nextLink, filter); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeployments value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfDeployments.DeserializePageableListOfDeployments(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of deployments. - /// The URL to the next page of results. - /// Restricts the set of deployments returned. You can filter on update Provider, Name and Version property. - /// The cancellation token to use. - /// is null. - public Response GetAllDeploymentsNextPage(string nextLink, string filter = null, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - - using var message = CreateGetAllDeploymentsNextPageRequest(nextLink, filter); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeployments value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfDeployments.DeserializePageableListOfDeployments(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetDeploymentDevicesNextPageRequest(string nextLink, string deploymentId, string filter) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. - /// The URL to the next page of results. - /// Deployment identifier. - /// Restricts the set of deployment device states returned. You can filter on deviceId and/or deviceState. - /// The cancellation token to use. - /// or is null. - public async Task> GetDeploymentDevicesNextPageAsync(string nextLink, string deploymentId, string filter = null, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateGetDeploymentDevicesNextPageRequest(nextLink, deploymentId, filter); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeploymentDeviceStates value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfDeploymentDeviceStates.DeserializePageableListOfDeploymentDeviceStates(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. - /// The URL to the next page of results. - /// Deployment identifier. - /// Restricts the set of deployment device states returned. You can filter on deviceId and/or deviceState. - /// The cancellation token to use. - /// or is null. - public Response GetDeploymentDevicesNextPage(string nextLink, string deploymentId, string filter = null, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - if (deploymentId == null) - { - throw new ArgumentNullException(nameof(deploymentId)); - } - - using var message = CreateGetDeploymentDevicesNextPageRequest(nextLink, deploymentId, filter); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeploymentDeviceStates value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfDeploymentDeviceStates.DeserializePageableListOfDeploymentDeviceStates(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - } -} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementClient.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementClient.cs new file mode 100644 index 0000000000000..1f2134fd3d077 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementClient.cs @@ -0,0 +1,1609 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.IoT.DeviceUpdate.Models; + +namespace Azure.IoT.DeviceUpdate +{ + /// The DeviceManagement service client. + public partial class DeviceManagementClient + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly HttpPipeline _pipeline; + internal DeviceManagementRestClient RestClient { get; } + + /// Initializes a new instance of DeviceManagementClient for mocking. + protected DeviceManagementClient() + { + } + + /// Initializes a new instance of DeviceManagementClient. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Account endpoint. + /// Account instance identifier. + /// Api Version. + internal DeviceManagementClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string instanceId, string apiVersion = "2021-06-01-preview") + { + RestClient = new DeviceManagementRestClient(clientDiagnostics, pipeline, endpoint, instanceId, apiVersion); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + /// Gets the properties of a device class. + /// Device class identifier. + /// The cancellation token to use. + public virtual async Task> GetDeviceClassAsync(string deviceClassId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetDeviceClass"); + scope.Start(); + try + { + return await RestClient.GetDeviceClassAsync(deviceClassId, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the properties of a device class. + /// Device class identifier. + /// The cancellation token to use. + public virtual Response GetDeviceClass(string deviceClassId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetDeviceClass"); + scope.Start(); + try + { + return RestClient.GetDeviceClass(deviceClassId, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the device properties and latest deployment status for a device connected to Device Update for IoT Hub. + /// Device identifier in Azure IoT Hub. + /// The cancellation token to use. + public virtual async Task> GetDeviceAsync(string deviceId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetDevice"); + scope.Start(); + try + { + return await RestClient.GetDeviceAsync(deviceId, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the device properties and latest deployment status for a device connected to Device Update for IoT Hub. + /// Device identifier in Azure IoT Hub. + /// The cancellation token to use. + public virtual Response GetDevice(string deviceId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetDevice"); + scope.Start(); + try + { + return RestClient.GetDevice(deviceId, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the device module properties and latest deployment status for a device module connected to Device Update for IoT Hub. + /// Device identifier in Azure IoT Hub. + /// Device module identifier in Azure IoT Hub. + /// The cancellation token to use. + public virtual async Task> GetDeviceModuleAsync(string deviceId, string moduleId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetDeviceModule"); + scope.Start(); + try + { + return await RestClient.GetDeviceModuleAsync(deviceId, moduleId, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the device module properties and latest deployment status for a device module connected to Device Update for IoT Hub. + /// Device identifier in Azure IoT Hub. + /// Device module identifier in Azure IoT Hub. + /// The cancellation token to use. + public virtual Response GetDeviceModule(string deviceId, string moduleId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetDeviceModule"); + scope.Start(); + try + { + return RestClient.GetDeviceModule(deviceId, moduleId, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the breakdown of how many devices are on their latest update, have new updates available, or are in progress receiving new updates. + /// The cancellation token to use. + public virtual async Task> GetUpdateComplianceAsync(CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetUpdateCompliance"); + scope.Start(); + try + { + return await RestClient.GetUpdateComplianceAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the breakdown of how many devices are on their latest update, have new updates available, or are in progress receiving new updates. + /// The cancellation token to use. + public virtual Response GetUpdateCompliance(CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetUpdateCompliance"); + scope.Start(); + try + { + return RestClient.GetUpdateCompliance(cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a count of how many devices have a device tag. + /// Tag name. + /// The cancellation token to use. + public virtual async Task> GetDeviceTagAsync(string tagName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetDeviceTag"); + scope.Start(); + try + { + return await RestClient.GetDeviceTagAsync(tagName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a count of how many devices have a device tag. + /// Tag name. + /// The cancellation token to use. + public virtual Response GetDeviceTag(string tagName, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetDeviceTag"); + scope.Start(); + try + { + return RestClient.GetDeviceTag(tagName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the properties of a group. + /// Group identity. + /// The cancellation token to use. + public virtual async Task> GetGroupAsync(string groupId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetGroup"); + scope.Start(); + try + { + return await RestClient.GetGroupAsync(groupId, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the properties of a group. + /// Group identity. + /// The cancellation token to use. + public virtual Response GetGroup(string groupId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetGroup"); + scope.Start(); + try + { + return RestClient.GetGroup(groupId, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create or update a device group. + /// Group identity. + /// The group properties. + /// The cancellation token to use. + public virtual async Task> CreateOrUpdateGroupAsync(string groupId, Group group, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.CreateOrUpdateGroup"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateGroupAsync(groupId, group, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create or update a device group. + /// Group identity. + /// The group properties. + /// The cancellation token to use. + public virtual Response CreateOrUpdateGroup(string groupId, Group group, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.CreateOrUpdateGroup"); + scope.Start(); + try + { + return RestClient.CreateOrUpdateGroup(groupId, group, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes a device group. + /// Group identity. + /// The cancellation token to use. + public virtual async Task DeleteGroupAsync(string groupId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.DeleteGroup"); + scope.Start(); + try + { + return await RestClient.DeleteGroupAsync(groupId, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes a device group. + /// Group identity. + /// The cancellation token to use. + public virtual Response DeleteGroup(string groupId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.DeleteGroup"); + scope.Start(); + try + { + return RestClient.DeleteGroup(groupId, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get group update compliance information such as how many devices are on their latest update, how many need new updates, and how many are in progress on receiving a new update. + /// Group identity. + /// The cancellation token to use. + public virtual async Task> GetGroupUpdateComplianceAsync(string groupId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetGroupUpdateCompliance"); + scope.Start(); + try + { + return await RestClient.GetGroupUpdateComplianceAsync(groupId, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get group update compliance information such as how many devices are on their latest update, how many need new updates, and how many are in progress on receiving a new update. + /// Group identity. + /// The cancellation token to use. + public virtual Response GetGroupUpdateCompliance(string groupId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetGroupUpdateCompliance"); + scope.Start(); + try + { + return RestClient.GetGroupUpdateCompliance(groupId, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the properties of a deployment. + /// Group identity. + /// Deployment identifier. + /// The cancellation token to use. + public virtual async Task> GetDeploymentAsync(string groupId, string deploymentId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetDeployment"); + scope.Start(); + try + { + return await RestClient.GetDeploymentAsync(groupId, deploymentId, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the properties of a deployment. + /// Group identity. + /// Deployment identifier. + /// The cancellation token to use. + public virtual Response GetDeployment(string groupId, string deploymentId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetDeployment"); + scope.Start(); + try + { + return RestClient.GetDeployment(groupId, deploymentId, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates or updates a deployment. + /// Deployment identifier. + /// Group identity. + /// The deployment properties. + /// The cancellation token to use. + public virtual async Task> CreateOrUpdateDeploymentAsync(string deploymentId, string groupId, Deployment deployment, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.CreateOrUpdateDeployment"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateDeploymentAsync(deploymentId, groupId, deployment, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates or updates a deployment. + /// Deployment identifier. + /// Group identity. + /// The deployment properties. + /// The cancellation token to use. + public virtual Response CreateOrUpdateDeployment(string deploymentId, string groupId, Deployment deployment, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.CreateOrUpdateDeployment"); + scope.Start(); + try + { + return RestClient.CreateOrUpdateDeployment(deploymentId, groupId, deployment, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes a deployment. + /// Group identity. + /// Deployment identifier. + /// The cancellation token to use. + public virtual async Task DeleteDeploymentAsync(string groupId, string deploymentId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.DeleteDeployment"); + scope.Start(); + try + { + return await RestClient.DeleteDeploymentAsync(groupId, deploymentId, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes a deployment. + /// Group identity. + /// Deployment identifier. + /// The cancellation token to use. + public virtual Response DeleteDeployment(string groupId, string deploymentId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.DeleteDeployment"); + scope.Start(); + try + { + return RestClient.DeleteDeployment(groupId, deploymentId, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the status of a deployment including a breakdown of how many devices in the deployment are in progress, completed, or failed. + /// Group identity. + /// Deployment identifier. + /// The cancellation token to use. + public virtual async Task> GetDeploymentStatusAsync(string groupId, string deploymentId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetDeploymentStatus"); + scope.Start(); + try + { + return await RestClient.GetDeploymentStatusAsync(groupId, deploymentId, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets the status of a deployment including a breakdown of how many devices in the deployment are in progress, completed, or failed. + /// Group identity. + /// Deployment identifier. + /// The cancellation token to use. + public virtual Response GetDeploymentStatus(string groupId, string deploymentId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetDeploymentStatus"); + scope.Start(); + try + { + return RestClient.GetDeploymentStatus(groupId, deploymentId, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieve operation status. + /// Operation identifier. + /// Parameter group. + /// The cancellation token to use. + public virtual async Task> GetOperationAsync(string operationId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetOperation"); + scope.Start(); + try + { + return await RestClient.GetOperationAsync(operationId, accessCondition, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieve operation status. + /// Operation identifier. + /// Parameter group. + /// The cancellation token to use. + public virtual Response GetOperation(string operationId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetOperation"); + scope.Start(); + try + { + return RestClient.GetOperation(operationId, accessCondition, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Start the device diagnostics log collection operation on specified devices. + /// Operation identifier. + /// The deployment properties. + /// The cancellation token to use. + public virtual async Task> CollectLogsAsync(string operationId, LogCollectionOperation logCollectionRequest, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.CollectLogs"); + scope.Start(); + try + { + return await RestClient.CollectLogsAsync(operationId, logCollectionRequest, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Start the device diagnostics log collection operation on specified devices. + /// Operation identifier. + /// The deployment properties. + /// The cancellation token to use. + public virtual Response CollectLogs(string operationId, LogCollectionOperation logCollectionRequest, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.CollectLogs"); + scope.Start(); + try + { + return RestClient.CollectLogs(operationId, logCollectionRequest, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get the device diagnostics log collection operation. + /// Operation identifier. + /// The cancellation token to use. + public virtual async Task> GetLogCollectionOperationAsync(string operationId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetLogCollectionOperation"); + scope.Start(); + try + { + return await RestClient.GetLogCollectionOperationAsync(operationId, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get the device diagnostics log collection operation. + /// Operation identifier. + /// The cancellation token to use. + public virtual Response GetLogCollectionOperation(string operationId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetLogCollectionOperation"); + scope.Start(); + try + { + return RestClient.GetLogCollectionOperation(operationId, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get device diagnostics log collection operation with detailed status. + /// Operation identifier. + /// The cancellation token to use. + public virtual async Task> GetLogCollectionOperationDetailedStatusAsync(string operationId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetLogCollectionOperationDetailedStatus"); + scope.Start(); + try + { + return await RestClient.GetLogCollectionOperationDetailedStatusAsync(operationId, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get device diagnostics log collection operation with detailed status. + /// Operation identifier. + /// The cancellation token to use. + public virtual Response GetLogCollectionOperationDetailedStatus(string operationId, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.GetLogCollectionOperationDetailedStatus"); + scope.Start(); + try + { + return RestClient.GetLogCollectionOperationDetailedStatus(operationId, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Stops a deployment. + /// Group identity. + /// Deployment identifier. + /// Cancel deployment action. + /// The cancellation token to use. + public virtual async Task> StopDeploymentAsync(string groupId, string deploymentId, DeploymentCancelAction action, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.StopDeployment"); + scope.Start(); + try + { + return await RestClient.StopDeploymentAsync(groupId, deploymentId, action, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Stops a deployment. + /// Group identity. + /// Deployment identifier. + /// Cancel deployment action. + /// The cancellation token to use. + public virtual Response StopDeployment(string groupId, string deploymentId, DeploymentCancelAction action, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.StopDeployment"); + scope.Start(); + try + { + return RestClient.StopDeployment(groupId, deploymentId, action, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retries a deployment with failed devices. + /// Group identity. + /// Deployment identifier. + /// Retry deployment action. + /// The cancellation token to use. + public virtual async Task> RetryDeploymentAsync(string groupId, string deploymentId, DeploymentRetryAction action, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.RetryDeployment"); + scope.Start(); + try + { + return await RestClient.RetryDeploymentAsync(groupId, deploymentId, action, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retries a deployment with failed devices. + /// Group identity. + /// Deployment identifier. + /// Retry deployment action. + /// The cancellation token to use. + public virtual Response RetryDeployment(string groupId, string deploymentId, DeploymentRetryAction action, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.RetryDeployment"); + scope.Start(); + try + { + return RestClient.RetryDeployment(groupId, deploymentId, action, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. + /// The cancellation token to use. + public virtual AsyncPageable ListDeviceClassesAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeviceClasses"); + scope.Start(); + try + { + var response = await RestClient.ListDeviceClassesAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeviceClasses"); + scope.Start(); + try + { + var response = await RestClient.ListDeviceClassesNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. + /// The cancellation token to use. + public virtual Pageable ListDeviceClasses(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeviceClasses"); + scope.Start(); + try + { + var response = RestClient.ListDeviceClasses(cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeviceClasses"); + scope.Start(); + try + { + var response = RestClient.ListDeviceClassesNextPage(nextLink, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of installable updates for a device class. + /// Device class identifier. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListInstallableUpdatesForDeviceClassAsync(string deviceClassId, CancellationToken cancellationToken = default) + { + if (deviceClassId == null) + { + throw new ArgumentNullException(nameof(deviceClassId)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListInstallableUpdatesForDeviceClass"); + scope.Start(); + try + { + var response = await RestClient.ListInstallableUpdatesForDeviceClassAsync(deviceClassId, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListInstallableUpdatesForDeviceClass"); + scope.Start(); + try + { + var response = await RestClient.ListInstallableUpdatesForDeviceClassNextPageAsync(nextLink, deviceClassId, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of installable updates for a device class. + /// Device class identifier. + /// The cancellation token to use. + /// is null. + public virtual Pageable ListInstallableUpdatesForDeviceClass(string deviceClassId, CancellationToken cancellationToken = default) + { + if (deviceClassId == null) + { + throw new ArgumentNullException(nameof(deviceClassId)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListInstallableUpdatesForDeviceClass"); + scope.Start(); + try + { + var response = RestClient.ListInstallableUpdatesForDeviceClass(deviceClassId, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListInstallableUpdatesForDeviceClass"); + scope.Start(); + try + { + var response = RestClient.ListInstallableUpdatesForDeviceClassNextPage(nextLink, deviceClassId, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of devices connected to Device Update for IoT Hub. + /// Restricts the set of devices returned. You can filter on device GroupId or DeviceClassId. + /// The cancellation token to use. + public virtual AsyncPageable ListDevicesAsync(string filter = null, CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDevices"); + scope.Start(); + try + { + var response = await RestClient.ListDevicesAsync(filter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDevices"); + scope.Start(); + try + { + var response = await RestClient.ListDevicesNextPageAsync(nextLink, filter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of devices connected to Device Update for IoT Hub. + /// Restricts the set of devices returned. You can filter on device GroupId or DeviceClassId. + /// The cancellation token to use. + public virtual Pageable ListDevices(string filter = null, CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDevices"); + scope.Start(); + try + { + var response = RestClient.ListDevices(filter, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDevices"); + scope.Start(); + try + { + var response = RestClient.ListDevicesNextPage(nextLink, filter, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. + /// The cancellation token to use. + public virtual AsyncPageable ListDeviceTagsAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeviceTags"); + scope.Start(); + try + { + var response = await RestClient.ListDeviceTagsAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeviceTags"); + scope.Start(); + try + { + var response = await RestClient.ListDeviceTagsNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. + /// The cancellation token to use. + public virtual Pageable ListDeviceTags(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeviceTags"); + scope.Start(); + try + { + var response = RestClient.ListDeviceTags(cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeviceTags"); + scope.Start(); + try + { + var response = RestClient.ListDeviceTagsNextPage(nextLink, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of all device groups. + /// The cancellation token to use. + public virtual AsyncPageable ListGroupsAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListGroups"); + scope.Start(); + try + { + var response = await RestClient.ListGroupsAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListGroups"); + scope.Start(); + try + { + var response = await RestClient.ListGroupsNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of all device groups. + /// The cancellation token to use. + public virtual Pageable ListGroups(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListGroups"); + scope.Start(); + try + { + var response = RestClient.ListGroups(cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListGroups"); + scope.Start(); + try + { + var response = RestClient.ListGroupsNextPage(nextLink, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Get the best available updates for a group and a count of how many devices need each update. + /// Group identity. + /// Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListBestUpdatesForGroupAsync(string groupId, string filter = null, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListBestUpdatesForGroup"); + scope.Start(); + try + { + var response = await RestClient.ListBestUpdatesForGroupAsync(groupId, filter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListBestUpdatesForGroup"); + scope.Start(); + try + { + var response = await RestClient.ListBestUpdatesForGroupNextPageAsync(nextLink, groupId, filter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Get the best available updates for a group and a count of how many devices need each update. + /// Group identity. + /// Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. + /// The cancellation token to use. + /// is null. + public virtual Pageable ListBestUpdatesForGroup(string groupId, string filter = null, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListBestUpdatesForGroup"); + scope.Start(); + try + { + var response = RestClient.ListBestUpdatesForGroup(groupId, filter, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListBestUpdatesForGroup"); + scope.Start(); + try + { + var response = RestClient.ListBestUpdatesForGroupNextPage(nextLink, groupId, filter, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of deployments for a group. + /// Group identity. + /// Restricts the set of deployments returned. You can filter on update Provider, Name and Version property. + /// The cancellation token to use. + /// is null. + public virtual AsyncPageable ListDeploymentsForGroupAsync(string groupId, string filter = null, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeploymentsForGroup"); + scope.Start(); + try + { + var response = await RestClient.ListDeploymentsForGroupAsync(groupId, filter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeploymentsForGroup"); + scope.Start(); + try + { + var response = await RestClient.ListDeploymentsForGroupNextPageAsync(nextLink, groupId, filter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of deployments for a group. + /// Group identity. + /// Restricts the set of deployments returned. You can filter on update Provider, Name and Version property. + /// The cancellation token to use. + /// is null. + public virtual Pageable ListDeploymentsForGroup(string groupId, string filter = null, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeploymentsForGroup"); + scope.Start(); + try + { + var response = RestClient.ListDeploymentsForGroup(groupId, filter, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeploymentsForGroup"); + scope.Start(); + try + { + var response = RestClient.ListDeploymentsForGroupNextPage(nextLink, groupId, filter, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. + /// Group identity. + /// Deployment identifier. + /// Restricts the set of deployment device states returned. You can filter on deviceId and moduleId and/or deviceState. + /// The cancellation token to use. + /// or is null. + public virtual AsyncPageable ListDeploymentDevicesAsync(string groupId, string deploymentId, string filter = null, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeploymentDevices"); + scope.Start(); + try + { + var response = await RestClient.ListDeploymentDevicesAsync(groupId, deploymentId, filter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeploymentDevices"); + scope.Start(); + try + { + var response = await RestClient.ListDeploymentDevicesNextPageAsync(nextLink, groupId, deploymentId, filter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. + /// Group identity. + /// Deployment identifier. + /// Restricts the set of deployment device states returned. You can filter on deviceId and moduleId and/or deviceState. + /// The cancellation token to use. + /// or is null. + public virtual Pageable ListDeploymentDevices(string groupId, string deploymentId, string filter = null, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeploymentDevices"); + scope.Start(); + try + { + var response = RestClient.ListDeploymentDevices(groupId, deploymentId, filter, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListDeploymentDevices"); + scope.Start(); + try + { + var response = RestClient.ListDeploymentDevicesNextPage(nextLink, groupId, deploymentId, filter, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Get a list of all device import operations. Completed operations are kept for 7 days before auto-deleted. + /// Restricts the set of operations returned. Only one specific filter is supported: "status eq 'NotStarted' or status eq 'Running'". + /// Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n. + /// The cancellation token to use. + public virtual AsyncPageable ListOperationsAsync(string filter = null, int? top = null, CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListOperations"); + scope.Start(); + try + { + var response = await RestClient.ListOperationsAsync(filter, top, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListOperations"); + scope.Start(); + try + { + var response = await RestClient.ListOperationsNextPageAsync(nextLink, filter, top, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Get a list of all device import operations. Completed operations are kept for 7 days before auto-deleted. + /// Restricts the set of operations returned. Only one specific filter is supported: "status eq 'NotStarted' or status eq 'Running'". + /// Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n. + /// The cancellation token to use. + public virtual Pageable ListOperations(string filter = null, int? top = null, CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListOperations"); + scope.Start(); + try + { + var response = RestClient.ListOperations(filter, top, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListOperations"); + scope.Start(); + try + { + var response = RestClient.ListOperationsNextPage(nextLink, filter, top, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Get all device diagnostics log collection operations. + /// The cancellation token to use. + public virtual AsyncPageable ListLogCollectionOperationsAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListLogCollectionOperations"); + scope.Start(); + try + { + var response = await RestClient.ListLogCollectionOperationsAsync(cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListLogCollectionOperations"); + scope.Start(); + try + { + var response = await RestClient.ListLogCollectionOperationsNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Get all device diagnostics log collection operations. + /// The cancellation token to use. + public virtual Pageable ListLogCollectionOperations(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListLogCollectionOperations"); + scope.Start(); + try + { + var response = RestClient.ListLogCollectionOperations(cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.ListLogCollectionOperations"); + scope.Start(); + try + { + var response = RestClient.ListLogCollectionOperationsNextPage(nextLink, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Import existing devices from IoT Hub. + /// Devices action. + /// The types of devices to import. + /// The cancellation token to use. + public virtual async Task StartImportDevicesAsync(ImportAction action, ImportType importType, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.StartImportDevices"); + scope.Start(); + try + { + var originalResponse = await RestClient.ImportDevicesAsync(action, importType, cancellationToken).ConfigureAwait(false); + return new DeviceManagementImportDevicesOperation(_clientDiagnostics, _pipeline, RestClient.CreateImportDevicesRequest(action, importType).Request, originalResponse); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Import existing devices from IoT Hub. + /// Devices action. + /// The types of devices to import. + /// The cancellation token to use. + public virtual DeviceManagementImportDevicesOperation StartImportDevices(ImportAction action, ImportType importType, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DeviceManagementClient.StartImportDevices"); + scope.Start(); + try + { + var originalResponse = RestClient.ImportDevices(action, importType, cancellationToken); + return new DeviceManagementImportDevicesOperation(_clientDiagnostics, _pipeline, RestClient.CreateImportDevicesRequest(action, importType).Request, originalResponse); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementGetOperationHeaders.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementGetOperationHeaders.cs new file mode 100644 index 0000000000000..c6cd1e77f114c --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementGetOperationHeaders.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate +{ + internal partial class DeviceManagementGetOperationHeaders + { + private readonly Response _response; + public DeviceManagementGetOperationHeaders(Response response) + { + _response = response; + } + /// Number of seconds to wait before checking the operation status again. + public string RetryAfter => _response.Headers.TryGetValue("Retry-After", out string value) ? value : null; + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementImportDevicesHeaders.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementImportDevicesHeaders.cs new file mode 100644 index 0000000000000..d44f4db48e74e --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementImportDevicesHeaders.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate +{ + internal partial class DeviceManagementImportDevicesHeaders + { + private readonly Response _response; + public DeviceManagementImportDevicesHeaders(Response response) + { + _response = response; + } + /// Url to retrieve the device import operation status. + public string OperationLocation => _response.Headers.TryGetValue("Operation-Location", out string value) ? value : null; + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementImportDevicesOperation.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementImportDevicesOperation.cs new file mode 100644 index 0000000000000..af2e4760a0786 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementImportDevicesOperation.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.IoT.DeviceUpdate +{ + /// Import existing devices from IoT Hub. + public partial class DeviceManagementImportDevicesOperation : Operation + { + private readonly OperationInternals _operation; + + /// Initializes a new instance of DeviceManagementImportDevicesOperation for mocking. + protected DeviceManagementImportDevicesOperation() + { + } + + internal DeviceManagementImportDevicesOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response) + { + _operation = new OperationInternals(clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "DeviceManagementImportDevicesOperation"); + } + + /// + public override string Id => _operation.Id; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.GetRawResponse(); + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementRestClient.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementRestClient.cs new file mode 100644 index 0000000000000..78a4e34d3a002 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceManagementRestClient.cs @@ -0,0 +1,3005 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.IoT.DeviceUpdate.Models; + +namespace Azure.IoT.DeviceUpdate +{ + internal partial class DeviceManagementRestClient + { + private string endpoint; + private string instanceId; + private string apiVersion; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + + /// Initializes a new instance of DeviceManagementRestClient. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Account endpoint. + /// Account instance identifier. + /// Api Version. + /// , , or is null. + public DeviceManagementRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string instanceId, string apiVersion = "2021-06-01-preview") + { + this.endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint)); + this.instanceId = instanceId ?? throw new ArgumentNullException(nameof(instanceId)); + this.apiVersion = apiVersion ?? throw new ArgumentNullException(nameof(apiVersion)); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + } + + internal HttpMessage CreateListDeviceClassesRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/deviceclasses", false); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. + /// The cancellation token to use. + public async Task> ListDeviceClassesAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListDeviceClassesRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceClassesList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceClassesList.DeserializeDeviceClassesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. + /// The cancellation token to use. + public Response ListDeviceClasses(CancellationToken cancellationToken = default) + { + using var message = CreateListDeviceClassesRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceClassesList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceClassesList.DeserializeDeviceClassesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetDeviceClassRequest(string deviceClassId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/deviceclasses/", false); + uri.AppendPath(deviceClassId, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets the properties of a device class. + /// Device class identifier. + /// The cancellation token to use. + /// is null. + public async Task> GetDeviceClassAsync(string deviceClassId, CancellationToken cancellationToken = default) + { + if (deviceClassId == null) + { + throw new ArgumentNullException(nameof(deviceClassId)); + } + + using var message = CreateGetDeviceClassRequest(deviceClassId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceClass value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceClass.DeserializeDeviceClass(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the properties of a device class. + /// Device class identifier. + /// The cancellation token to use. + /// is null. + public Response GetDeviceClass(string deviceClassId, CancellationToken cancellationToken = default) + { + if (deviceClassId == null) + { + throw new ArgumentNullException(nameof(deviceClassId)); + } + + using var message = CreateGetDeviceClassRequest(deviceClassId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceClass value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceClass.DeserializeDeviceClass(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListInstallableUpdatesForDeviceClassRequest(string deviceClassId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/deviceclasses/", false); + uri.AppendPath(deviceClassId, true); + uri.AppendPath("/installableupdates", false); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of installable updates for a device class. + /// Device class identifier. + /// The cancellation token to use. + /// is null. + public async Task> ListInstallableUpdatesForDeviceClassAsync(string deviceClassId, CancellationToken cancellationToken = default) + { + if (deviceClassId == null) + { + throw new ArgumentNullException(nameof(deviceClassId)); + } + + using var message = CreateListInstallableUpdatesForDeviceClassRequest(deviceClassId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + UpdateIdsList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = UpdateIdsList.DeserializeUpdateIdsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of installable updates for a device class. + /// Device class identifier. + /// The cancellation token to use. + /// is null. + public Response ListInstallableUpdatesForDeviceClass(string deviceClassId, CancellationToken cancellationToken = default) + { + if (deviceClassId == null) + { + throw new ArgumentNullException(nameof(deviceClassId)); + } + + using var message = CreateListInstallableUpdatesForDeviceClassRequest(deviceClassId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + UpdateIdsList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = UpdateIdsList.DeserializeUpdateIdsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDevicesRequest(string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/devices", false); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of devices connected to Device Update for IoT Hub. + /// Restricts the set of devices returned. You can filter on device GroupId or DeviceClassId. + /// The cancellation token to use. + public async Task> ListDevicesAsync(string filter = null, CancellationToken cancellationToken = default) + { + using var message = CreateListDevicesRequest(filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DevicesList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DevicesList.DeserializeDevicesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of devices connected to Device Update for IoT Hub. + /// Restricts the set of devices returned. You can filter on device GroupId or DeviceClassId. + /// The cancellation token to use. + public Response ListDevices(string filter = null, CancellationToken cancellationToken = default) + { + using var message = CreateListDevicesRequest(filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DevicesList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DevicesList.DeserializeDevicesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateImportDevicesRequest(ImportAction action, ImportType importType) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/devices", false); + uri.AppendQuery("api-version", apiVersion, true); + uri.AppendQuery("action", action.ToString(), true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteStringValue(importType.ToString()); + request.Content = content; + return message; + } + + /// Import existing devices from IoT Hub. + /// Devices action. + /// The types of devices to import. + /// The cancellation token to use. + public async Task> ImportDevicesAsync(ImportAction action, ImportType importType, CancellationToken cancellationToken = default) + { + using var message = CreateImportDevicesRequest(action, importType); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + var headers = new DeviceManagementImportDevicesHeaders(message.Response); + switch (message.Response.Status) + { + case 202: + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Import existing devices from IoT Hub. + /// Devices action. + /// The types of devices to import. + /// The cancellation token to use. + public ResponseWithHeaders ImportDevices(ImportAction action, ImportType importType, CancellationToken cancellationToken = default) + { + using var message = CreateImportDevicesRequest(action, importType); + _pipeline.Send(message, cancellationToken); + var headers = new DeviceManagementImportDevicesHeaders(message.Response); + switch (message.Response.Status) + { + case 202: + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetDeviceRequest(string deviceId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/devices/", false); + uri.AppendPath(deviceId, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets the device properties and latest deployment status for a device connected to Device Update for IoT Hub. + /// Device identifier in Azure IoT Hub. + /// The cancellation token to use. + /// is null. + public async Task> GetDeviceAsync(string deviceId, CancellationToken cancellationToken = default) + { + if (deviceId == null) + { + throw new ArgumentNullException(nameof(deviceId)); + } + + using var message = CreateGetDeviceRequest(deviceId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + Device value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = Device.DeserializeDevice(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the device properties and latest deployment status for a device connected to Device Update for IoT Hub. + /// Device identifier in Azure IoT Hub. + /// The cancellation token to use. + /// is null. + public Response GetDevice(string deviceId, CancellationToken cancellationToken = default) + { + if (deviceId == null) + { + throw new ArgumentNullException(nameof(deviceId)); + } + + using var message = CreateGetDeviceRequest(deviceId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + Device value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = Device.DeserializeDevice(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetDeviceModuleRequest(string deviceId, string moduleId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/devices/", false); + uri.AppendPath(deviceId, true); + uri.AppendPath("/modules/", false); + uri.AppendPath(moduleId, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets the device module properties and latest deployment status for a device module connected to Device Update for IoT Hub. + /// Device identifier in Azure IoT Hub. + /// Device module identifier in Azure IoT Hub. + /// The cancellation token to use. + /// or is null. + public async Task> GetDeviceModuleAsync(string deviceId, string moduleId, CancellationToken cancellationToken = default) + { + if (deviceId == null) + { + throw new ArgumentNullException(nameof(deviceId)); + } + if (moduleId == null) + { + throw new ArgumentNullException(nameof(moduleId)); + } + + using var message = CreateGetDeviceModuleRequest(deviceId, moduleId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + Device value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = Device.DeserializeDevice(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the device module properties and latest deployment status for a device module connected to Device Update for IoT Hub. + /// Device identifier in Azure IoT Hub. + /// Device module identifier in Azure IoT Hub. + /// The cancellation token to use. + /// or is null. + public Response GetDeviceModule(string deviceId, string moduleId, CancellationToken cancellationToken = default) + { + if (deviceId == null) + { + throw new ArgumentNullException(nameof(deviceId)); + } + if (moduleId == null) + { + throw new ArgumentNullException(nameof(moduleId)); + } + + using var message = CreateGetDeviceModuleRequest(deviceId, moduleId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + Device value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = Device.DeserializeDevice(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetUpdateComplianceRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/updatecompliance", false); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets the breakdown of how many devices are on their latest update, have new updates available, or are in progress receiving new updates. + /// The cancellation token to use. + public async Task> GetUpdateComplianceAsync(CancellationToken cancellationToken = default) + { + using var message = CreateGetUpdateComplianceRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + UpdateCompliance value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = UpdateCompliance.DeserializeUpdateCompliance(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the breakdown of how many devices are on their latest update, have new updates available, or are in progress receiving new updates. + /// The cancellation token to use. + public Response GetUpdateCompliance(CancellationToken cancellationToken = default) + { + using var message = CreateGetUpdateComplianceRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + UpdateCompliance value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = UpdateCompliance.DeserializeUpdateCompliance(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeviceTagsRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/devicetags", false); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. + /// The cancellation token to use. + public async Task> ListDeviceTagsAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListDeviceTagsRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceTagsList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceTagsList.DeserializeDeviceTagsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. + /// The cancellation token to use. + public Response ListDeviceTags(CancellationToken cancellationToken = default) + { + using var message = CreateListDeviceTagsRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceTagsList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceTagsList.DeserializeDeviceTagsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetDeviceTagRequest(string tagName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/devicetags/", false); + uri.AppendPath(tagName, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a count of how many devices have a device tag. + /// Tag name. + /// The cancellation token to use. + /// is null. + public async Task> GetDeviceTagAsync(string tagName, CancellationToken cancellationToken = default) + { + if (tagName == null) + { + throw new ArgumentNullException(nameof(tagName)); + } + + using var message = CreateGetDeviceTagRequest(tagName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceTag value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceTag.DeserializeDeviceTag(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a count of how many devices have a device tag. + /// Tag name. + /// The cancellation token to use. + /// is null. + public Response GetDeviceTag(string tagName, CancellationToken cancellationToken = default) + { + if (tagName == null) + { + throw new ArgumentNullException(nameof(tagName)); + } + + using var message = CreateGetDeviceTagRequest(tagName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceTag value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceTag.DeserializeDeviceTag(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListGroupsRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups", false); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of all device groups. + /// The cancellation token to use. + public async Task> ListGroupsAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListGroupsRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupsList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupsList.DeserializeGroupsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of all device groups. + /// The cancellation token to use. + public Response ListGroups(CancellationToken cancellationToken = default) + { + using var message = CreateListGroupsRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupsList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupsList.DeserializeGroupsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetGroupRequest(string groupId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets the properties of a group. + /// Group identity. + /// The cancellation token to use. + /// is null. + public async Task> GetGroupAsync(string groupId, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateGetGroupRequest(groupId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + Group value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = Group.DeserializeGroup(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the properties of a group. + /// Group identity. + /// The cancellation token to use. + /// is null. + public Response GetGroup(string groupId, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateGetGroupRequest(groupId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + Group value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = Group.DeserializeGroup(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateGroupRequest(string groupId, Group group) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(group); + request.Content = content; + return message; + } + + /// Create or update a device group. + /// Group identity. + /// The group properties. + /// The cancellation token to use. + /// or is null. + public async Task> CreateOrUpdateGroupAsync(string groupId, Group group, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (group == null) + { + throw new ArgumentNullException(nameof(group)); + } + + using var message = CreateCreateOrUpdateGroupRequest(groupId, group); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + Group value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = Group.DeserializeGroup(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Create or update a device group. + /// Group identity. + /// The group properties. + /// The cancellation token to use. + /// or is null. + public Response CreateOrUpdateGroup(string groupId, Group group, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (group == null) + { + throw new ArgumentNullException(nameof(group)); + } + + using var message = CreateCreateOrUpdateGroupRequest(groupId, group); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + Group value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = Group.DeserializeGroup(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteGroupRequest(string groupId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Deletes a device group. + /// Group identity. + /// The cancellation token to use. + /// is null. + public async Task DeleteGroupAsync(string groupId, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateDeleteGroupRequest(groupId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Deletes a device group. + /// Group identity. + /// The cancellation token to use. + /// is null. + public Response DeleteGroup(string groupId, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateDeleteGroupRequest(groupId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetGroupUpdateComplianceRequest(string groupId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendPath("/updateCompliance", false); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Get group update compliance information such as how many devices are on their latest update, how many need new updates, and how many are in progress on receiving a new update. + /// Group identity. + /// The cancellation token to use. + /// is null. + public async Task> GetGroupUpdateComplianceAsync(string groupId, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateGetGroupUpdateComplianceRequest(groupId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + UpdateCompliance value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = UpdateCompliance.DeserializeUpdateCompliance(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get group update compliance information such as how many devices are on their latest update, how many need new updates, and how many are in progress on receiving a new update. + /// Group identity. + /// The cancellation token to use. + /// is null. + public Response GetGroupUpdateCompliance(string groupId, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateGetGroupUpdateComplianceRequest(groupId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + UpdateCompliance value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = UpdateCompliance.DeserializeUpdateCompliance(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListBestUpdatesForGroupRequest(string groupId, string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendPath("/bestUpdates", false); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Get the best available updates for a group and a count of how many devices need each update. + /// Group identity. + /// Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. + /// The cancellation token to use. + /// is null. + public async Task> ListBestUpdatesForGroupAsync(string groupId, string filter = null, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateListBestUpdatesForGroupRequest(groupId, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + UpdatableDevicesList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = UpdatableDevicesList.DeserializeUpdatableDevicesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get the best available updates for a group and a count of how many devices need each update. + /// Group identity. + /// Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. + /// The cancellation token to use. + /// is null. + public Response ListBestUpdatesForGroup(string groupId, string filter = null, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateListBestUpdatesForGroupRequest(groupId, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + UpdatableDevicesList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = UpdatableDevicesList.DeserializeUpdatableDevicesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeploymentsForGroupRequest(string groupId, string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendPath("/deployments", false); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of deployments for a group. + /// Group identity. + /// Restricts the set of deployments returned. You can filter on update Provider, Name and Version property. + /// The cancellation token to use. + /// is null. + public async Task> ListDeploymentsForGroupAsync(string groupId, string filter = null, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateListDeploymentsForGroupRequest(groupId, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeploymentsList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeploymentsList.DeserializeDeploymentsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of deployments for a group. + /// Group identity. + /// Restricts the set of deployments returned. You can filter on update Provider, Name and Version property. + /// The cancellation token to use. + /// is null. + public Response ListDeploymentsForGroup(string groupId, string filter = null, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateListDeploymentsForGroupRequest(groupId, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeploymentsList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeploymentsList.DeserializeDeploymentsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetDeploymentRequest(string groupId, string deploymentId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets the properties of a deployment. + /// Group identity. + /// Deployment identifier. + /// The cancellation token to use. + /// or is null. + public async Task> GetDeploymentAsync(string groupId, string deploymentId, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateGetDeploymentRequest(groupId, deploymentId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + Deployment value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = Deployment.DeserializeDeployment(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the properties of a deployment. + /// Group identity. + /// Deployment identifier. + /// The cancellation token to use. + /// or is null. + public Response GetDeployment(string groupId, string deploymentId, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateGetDeploymentRequest(groupId, deploymentId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + Deployment value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = Deployment.DeserializeDeployment(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateDeploymentRequest(string deploymentId, string groupId, Deployment deployment) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(deployment); + request.Content = content; + return message; + } + + /// Creates or updates a deployment. + /// Deployment identifier. + /// Group identity. + /// The deployment properties. + /// The cancellation token to use. + /// , , or is null. + public async Task> CreateOrUpdateDeploymentAsync(string deploymentId, string groupId, Deployment deployment, CancellationToken cancellationToken = default) + { + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deployment == null) + { + throw new ArgumentNullException(nameof(deployment)); + } + + using var message = CreateCreateOrUpdateDeploymentRequest(deploymentId, groupId, deployment); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + Deployment value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = Deployment.DeserializeDeployment(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Creates or updates a deployment. + /// Deployment identifier. + /// Group identity. + /// The deployment properties. + /// The cancellation token to use. + /// , , or is null. + public Response CreateOrUpdateDeployment(string deploymentId, string groupId, Deployment deployment, CancellationToken cancellationToken = default) + { + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deployment == null) + { + throw new ArgumentNullException(nameof(deployment)); + } + + using var message = CreateCreateOrUpdateDeploymentRequest(deploymentId, groupId, deployment); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + Deployment value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = Deployment.DeserializeDeployment(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteDeploymentRequest(string groupId, string deploymentId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Deletes a deployment. + /// Group identity. + /// Deployment identifier. + /// The cancellation token to use. + /// or is null. + public async Task DeleteDeploymentAsync(string groupId, string deploymentId, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateDeleteDeploymentRequest(groupId, deploymentId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Deletes a deployment. + /// Group identity. + /// Deployment identifier. + /// The cancellation token to use. + /// or is null. + public Response DeleteDeployment(string groupId, string deploymentId, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateDeleteDeploymentRequest(groupId, deploymentId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetDeploymentStatusRequest(string groupId, string deploymentId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendPath("/status", false); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets the status of a deployment including a breakdown of how many devices in the deployment are in progress, completed, or failed. + /// Group identity. + /// Deployment identifier. + /// The cancellation token to use. + /// or is null. + public async Task> GetDeploymentStatusAsync(string groupId, string deploymentId, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateGetDeploymentStatusRequest(groupId, deploymentId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeploymentStatus value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeploymentStatus.DeserializeDeploymentStatus(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets the status of a deployment including a breakdown of how many devices in the deployment are in progress, completed, or failed. + /// Group identity. + /// Deployment identifier. + /// The cancellation token to use. + /// or is null. + public Response GetDeploymentStatus(string groupId, string deploymentId, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateGetDeploymentStatusRequest(groupId, deploymentId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeploymentStatus value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeploymentStatus.DeserializeDeploymentStatus(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeploymentDevicesRequest(string groupId, string deploymentId, string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendPath("/devicestates", false); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. + /// Group identity. + /// Deployment identifier. + /// Restricts the set of deployment device states returned. You can filter on deviceId and moduleId and/or deviceState. + /// The cancellation token to use. + /// or is null. + public async Task> ListDeploymentDevicesAsync(string groupId, string deploymentId, string filter = null, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateListDeploymentDevicesRequest(groupId, deploymentId, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeploymentDeviceStatesList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeploymentDeviceStatesList.DeserializeDeploymentDeviceStatesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. + /// Group identity. + /// Deployment identifier. + /// Restricts the set of deployment device states returned. You can filter on deviceId and moduleId and/or deviceState. + /// The cancellation token to use. + /// or is null. + public Response ListDeploymentDevices(string groupId, string deploymentId, string filter = null, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateListDeploymentDevicesRequest(groupId, deploymentId, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeploymentDeviceStatesList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeploymentDeviceStatesList.DeserializeDeploymentDeviceStatesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetOperationRequest(string operationId, AccessCondition accessCondition) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/operations/", false); + uri.AppendPath(operationId, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + if (accessCondition?.IfNoneMatch != null) + { + request.Headers.Add("If-None-Match", accessCondition.IfNoneMatch); + } + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Retrieve operation status. + /// Operation identifier. + /// Parameter group. + /// The cancellation token to use. + /// is null. + public async Task> GetOperationAsync(string operationId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) + { + if (operationId == null) + { + throw new ArgumentNullException(nameof(operationId)); + } + + using var message = CreateGetOperationRequest(operationId, accessCondition); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + var headers = new DeviceManagementGetOperationHeaders(message.Response); + switch (message.Response.Status) + { + case 200: + { + DeviceOperation value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceOperation.DeserializeDeviceOperation(document.RootElement); + return ResponseWithHeaders.FromValue(value, headers, message.Response); + } + case 304: + return ResponseWithHeaders.FromValue((DeviceOperation)null, headers, message.Response); + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Retrieve operation status. + /// Operation identifier. + /// Parameter group. + /// The cancellation token to use. + /// is null. + public ResponseWithHeaders GetOperation(string operationId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) + { + if (operationId == null) + { + throw new ArgumentNullException(nameof(operationId)); + } + + using var message = CreateGetOperationRequest(operationId, accessCondition); + _pipeline.Send(message, cancellationToken); + var headers = new DeviceManagementGetOperationHeaders(message.Response); + switch (message.Response.Status) + { + case 200: + { + DeviceOperation value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceOperation.DeserializeDeviceOperation(document.RootElement); + return ResponseWithHeaders.FromValue(value, headers, message.Response); + } + case 304: + return ResponseWithHeaders.FromValue((DeviceOperation)null, headers, message.Response); + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListOperationsRequest(string filter, int? top) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/operations", false); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Get a list of all device import operations. Completed operations are kept for 7 days before auto-deleted. + /// Restricts the set of operations returned. Only one specific filter is supported: "status eq 'NotStarted' or status eq 'Running'". + /// Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n. + /// The cancellation token to use. + public async Task> ListOperationsAsync(string filter = null, int? top = null, CancellationToken cancellationToken = default) + { + using var message = CreateListOperationsRequest(filter, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceOperationsList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceOperationsList.DeserializeDeviceOperationsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get a list of all device import operations. Completed operations are kept for 7 days before auto-deleted. + /// Restricts the set of operations returned. Only one specific filter is supported: "status eq 'NotStarted' or status eq 'Running'". + /// Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n. + /// The cancellation token to use. + public Response ListOperations(string filter = null, int? top = null, CancellationToken cancellationToken = default) + { + using var message = CreateListOperationsRequest(filter, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceOperationsList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceOperationsList.DeserializeDeviceOperationsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCollectLogsRequest(string operationId, LogCollectionOperation logCollectionRequest) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/deviceDiagnostics/logCollections/", false); + uri.AppendPath(operationId, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(logCollectionRequest); + request.Content = content; + return message; + } + + /// Start the device diagnostics log collection operation on specified devices. + /// Operation identifier. + /// The deployment properties. + /// The cancellation token to use. + /// or is null. + public async Task> CollectLogsAsync(string operationId, LogCollectionOperation logCollectionRequest, CancellationToken cancellationToken = default) + { + if (operationId == null) + { + throw new ArgumentNullException(nameof(operationId)); + } + if (logCollectionRequest == null) + { + throw new ArgumentNullException(nameof(logCollectionRequest)); + } + + using var message = CreateCollectLogsRequest(operationId, logCollectionRequest); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 201: + { + LogCollectionOperation value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogCollectionOperation.DeserializeLogCollectionOperation(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Start the device diagnostics log collection operation on specified devices. + /// Operation identifier. + /// The deployment properties. + /// The cancellation token to use. + /// or is null. + public Response CollectLogs(string operationId, LogCollectionOperation logCollectionRequest, CancellationToken cancellationToken = default) + { + if (operationId == null) + { + throw new ArgumentNullException(nameof(operationId)); + } + if (logCollectionRequest == null) + { + throw new ArgumentNullException(nameof(logCollectionRequest)); + } + + using var message = CreateCollectLogsRequest(operationId, logCollectionRequest); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 201: + { + LogCollectionOperation value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogCollectionOperation.DeserializeLogCollectionOperation(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetLogCollectionOperationRequest(string operationId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/deviceDiagnostics/logCollections/", false); + uri.AppendPath(operationId, true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Get the device diagnostics log collection operation. + /// Operation identifier. + /// The cancellation token to use. + /// is null. + public async Task> GetLogCollectionOperationAsync(string operationId, CancellationToken cancellationToken = default) + { + if (operationId == null) + { + throw new ArgumentNullException(nameof(operationId)); + } + + using var message = CreateGetLogCollectionOperationRequest(operationId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LogCollectionOperation value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogCollectionOperation.DeserializeLogCollectionOperation(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get the device diagnostics log collection operation. + /// Operation identifier. + /// The cancellation token to use. + /// is null. + public Response GetLogCollectionOperation(string operationId, CancellationToken cancellationToken = default) + { + if (operationId == null) + { + throw new ArgumentNullException(nameof(operationId)); + } + + using var message = CreateGetLogCollectionOperationRequest(operationId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LogCollectionOperation value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogCollectionOperation.DeserializeLogCollectionOperation(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListLogCollectionOperationsRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/deviceDiagnostics/logCollections", false); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Get all device diagnostics log collection operations. + /// The cancellation token to use. + public async Task> ListLogCollectionOperationsAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListLogCollectionOperationsRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LogCollectionOperationList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogCollectionOperationList.DeserializeLogCollectionOperationList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get all device diagnostics log collection operations. + /// The cancellation token to use. + public Response ListLogCollectionOperations(CancellationToken cancellationToken = default) + { + using var message = CreateListLogCollectionOperationsRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LogCollectionOperationList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogCollectionOperationList.DeserializeLogCollectionOperationList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetLogCollectionOperationDetailedStatusRequest(string operationId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/deviceDiagnostics/logCollections/", false); + uri.AppendPath(operationId, true); + uri.AppendPath("/detailedStatus", false); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Get device diagnostics log collection operation with detailed status. + /// Operation identifier. + /// The cancellation token to use. + /// is null. + public async Task> GetLogCollectionOperationDetailedStatusAsync(string operationId, CancellationToken cancellationToken = default) + { + if (operationId == null) + { + throw new ArgumentNullException(nameof(operationId)); + } + + using var message = CreateGetLogCollectionOperationDetailedStatusRequest(operationId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LogCollectionOperationDetailedStatus value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogCollectionOperationDetailedStatus.DeserializeLogCollectionOperationDetailedStatus(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get device diagnostics log collection operation with detailed status. + /// Operation identifier. + /// The cancellation token to use. + /// is null. + public Response GetLogCollectionOperationDetailedStatus(string operationId, CancellationToken cancellationToken = default) + { + if (operationId == null) + { + throw new ArgumentNullException(nameof(operationId)); + } + + using var message = CreateGetLogCollectionOperationDetailedStatusRequest(operationId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LogCollectionOperationDetailedStatus value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogCollectionOperationDetailedStatus.DeserializeLogCollectionOperationDetailedStatus(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateStopDeploymentRequest(string groupId, string deploymentId, DeploymentCancelAction action) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendQuery("action", action.ToString(), true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Stops a deployment. + /// Group identity. + /// Deployment identifier. + /// Cancel deployment action. + /// The cancellation token to use. + /// or is null. + public async Task> StopDeploymentAsync(string groupId, string deploymentId, DeploymentCancelAction action, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateStopDeploymentRequest(groupId, deploymentId, action); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + Deployment value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = Deployment.DeserializeDeployment(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Stops a deployment. + /// Group identity. + /// Deployment identifier. + /// Cancel deployment action. + /// The cancellation token to use. + /// or is null. + public Response StopDeployment(string groupId, string deploymentId, DeploymentCancelAction action, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateStopDeploymentRequest(groupId, deploymentId, action); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + Deployment value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = Deployment.DeserializeDeployment(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateRetryDeploymentRequest(string groupId, string deploymentId, DeploymentRetryAction action) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/management/groups/", false); + uri.AppendPath(groupId, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendQuery("action", action.ToString(), true); + uri.AppendQuery("api-version", apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Retries a deployment with failed devices. + /// Group identity. + /// Deployment identifier. + /// Retry deployment action. + /// The cancellation token to use. + /// or is null. + public async Task> RetryDeploymentAsync(string groupId, string deploymentId, DeploymentRetryAction action, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateRetryDeploymentRequest(groupId, deploymentId, action); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + Deployment value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = Deployment.DeserializeDeployment(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Retries a deployment with failed devices. + /// Group identity. + /// Deployment identifier. + /// Retry deployment action. + /// The cancellation token to use. + /// or is null. + public Response RetryDeployment(string groupId, string deploymentId, DeploymentRetryAction action, CancellationToken cancellationToken = default) + { + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateRetryDeploymentRequest(groupId, deploymentId, action); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + Deployment value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = Deployment.DeserializeDeployment(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeviceClassesNextPageRequest(string nextLink) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public async Task> ListDeviceClassesNextPageAsync(string nextLink, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListDeviceClassesNextPageRequest(nextLink); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceClassesList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceClassesList.DeserializeDeviceClassesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public Response ListDeviceClassesNextPage(string nextLink, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListDeviceClassesNextPageRequest(nextLink); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceClassesList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceClassesList.DeserializeDeviceClassesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListInstallableUpdatesForDeviceClassNextPageRequest(string nextLink, string deviceClassId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of installable updates for a device class. + /// The URL to the next page of results. + /// Device class identifier. + /// The cancellation token to use. + /// or is null. + public async Task> ListInstallableUpdatesForDeviceClassNextPageAsync(string nextLink, string deviceClassId, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (deviceClassId == null) + { + throw new ArgumentNullException(nameof(deviceClassId)); + } + + using var message = CreateListInstallableUpdatesForDeviceClassNextPageRequest(nextLink, deviceClassId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + UpdateIdsList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = UpdateIdsList.DeserializeUpdateIdsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of installable updates for a device class. + /// The URL to the next page of results. + /// Device class identifier. + /// The cancellation token to use. + /// or is null. + public Response ListInstallableUpdatesForDeviceClassNextPage(string nextLink, string deviceClassId, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (deviceClassId == null) + { + throw new ArgumentNullException(nameof(deviceClassId)); + } + + using var message = CreateListInstallableUpdatesForDeviceClassNextPageRequest(nextLink, deviceClassId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + UpdateIdsList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = UpdateIdsList.DeserializeUpdateIdsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDevicesNextPageRequest(string nextLink, string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of devices connected to Device Update for IoT Hub. + /// The URL to the next page of results. + /// Restricts the set of devices returned. You can filter on device GroupId or DeviceClassId. + /// The cancellation token to use. + /// is null. + public async Task> ListDevicesNextPageAsync(string nextLink, string filter = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListDevicesNextPageRequest(nextLink, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DevicesList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DevicesList.DeserializeDevicesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of devices connected to Device Update for IoT Hub. + /// The URL to the next page of results. + /// Restricts the set of devices returned. You can filter on device GroupId or DeviceClassId. + /// The cancellation token to use. + /// is null. + public Response ListDevicesNextPage(string nextLink, string filter = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListDevicesNextPageRequest(nextLink, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DevicesList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DevicesList.DeserializeDevicesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeviceTagsNextPageRequest(string nextLink) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public async Task> ListDeviceTagsNextPageAsync(string nextLink, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListDeviceTagsNextPageRequest(nextLink); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceTagsList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceTagsList.DeserializeDeviceTagsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public Response ListDeviceTagsNextPage(string nextLink, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListDeviceTagsNextPageRequest(nextLink); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceTagsList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceTagsList.DeserializeDeviceTagsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListGroupsNextPageRequest(string nextLink) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of all device groups. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public async Task> ListGroupsNextPageAsync(string nextLink, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListGroupsNextPageRequest(nextLink); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GroupsList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GroupsList.DeserializeGroupsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of all device groups. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public Response ListGroupsNextPage(string nextLink, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListGroupsNextPageRequest(nextLink); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GroupsList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GroupsList.DeserializeGroupsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListBestUpdatesForGroupNextPageRequest(string nextLink, string groupId, string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Get the best available updates for a group and a count of how many devices need each update. + /// The URL to the next page of results. + /// Group identity. + /// Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. + /// The cancellation token to use. + /// or is null. + public async Task> ListBestUpdatesForGroupNextPageAsync(string nextLink, string groupId, string filter = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateListBestUpdatesForGroupNextPageRequest(nextLink, groupId, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + UpdatableDevicesList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = UpdatableDevicesList.DeserializeUpdatableDevicesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get the best available updates for a group and a count of how many devices need each update. + /// The URL to the next page of results. + /// Group identity. + /// Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. + /// The cancellation token to use. + /// or is null. + public Response ListBestUpdatesForGroupNextPage(string nextLink, string groupId, string filter = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateListBestUpdatesForGroupNextPageRequest(nextLink, groupId, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + UpdatableDevicesList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = UpdatableDevicesList.DeserializeUpdatableDevicesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeploymentsForGroupNextPageRequest(string nextLink, string groupId, string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of deployments for a group. + /// The URL to the next page of results. + /// Group identity. + /// Restricts the set of deployments returned. You can filter on update Provider, Name and Version property. + /// The cancellation token to use. + /// or is null. + public async Task> ListDeploymentsForGroupNextPageAsync(string nextLink, string groupId, string filter = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateListDeploymentsForGroupNextPageRequest(nextLink, groupId, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeploymentsList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeploymentsList.DeserializeDeploymentsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of deployments for a group. + /// The URL to the next page of results. + /// Group identity. + /// Restricts the set of deployments returned. You can filter on update Provider, Name and Version property. + /// The cancellation token to use. + /// or is null. + public Response ListDeploymentsForGroupNextPage(string nextLink, string groupId, string filter = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + + using var message = CreateListDeploymentsForGroupNextPageRequest(nextLink, groupId, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeploymentsList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeploymentsList.DeserializeDeploymentsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeploymentDevicesNextPageRequest(string nextLink, string groupId, string deploymentId, string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. + /// The URL to the next page of results. + /// Group identity. + /// Deployment identifier. + /// Restricts the set of deployment device states returned. You can filter on deviceId and moduleId and/or deviceState. + /// The cancellation token to use. + /// , , or is null. + public async Task> ListDeploymentDevicesNextPageAsync(string nextLink, string groupId, string deploymentId, string filter = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateListDeploymentDevicesNextPageRequest(nextLink, groupId, deploymentId, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeploymentDeviceStatesList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeploymentDeviceStatesList.DeserializeDeploymentDeviceStatesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. + /// The URL to the next page of results. + /// Group identity. + /// Deployment identifier. + /// Restricts the set of deployment device states returned. You can filter on deviceId and moduleId and/or deviceState. + /// The cancellation token to use. + /// , , or is null. + public Response ListDeploymentDevicesNextPage(string nextLink, string groupId, string deploymentId, string filter = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } + if (deploymentId == null) + { + throw new ArgumentNullException(nameof(deploymentId)); + } + + using var message = CreateListDeploymentDevicesNextPageRequest(nextLink, groupId, deploymentId, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeploymentDeviceStatesList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeploymentDeviceStatesList.DeserializeDeploymentDeviceStatesList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListOperationsNextPageRequest(string nextLink, string filter, int? top) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Get a list of all device import operations. Completed operations are kept for 7 days before auto-deleted. + /// The URL to the next page of results. + /// Restricts the set of operations returned. Only one specific filter is supported: "status eq 'NotStarted' or status eq 'Running'". + /// Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n. + /// The cancellation token to use. + /// is null. + public async Task> ListOperationsNextPageAsync(string nextLink, string filter = null, int? top = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListOperationsNextPageRequest(nextLink, filter, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceOperationsList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceOperationsList.DeserializeDeviceOperationsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get a list of all device import operations. Completed operations are kept for 7 days before auto-deleted. + /// The URL to the next page of results. + /// Restricts the set of operations returned. Only one specific filter is supported: "status eq 'NotStarted' or status eq 'Running'". + /// Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n. + /// The cancellation token to use. + /// is null. + public Response ListOperationsNextPage(string nextLink, string filter = null, int? top = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListOperationsNextPageRequest(nextLink, filter, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceOperationsList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceOperationsList.DeserializeDeviceOperationsList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListLogCollectionOperationsNextPageRequest(string nextLink) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Get all device diagnostics log collection operations. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public async Task> ListLogCollectionOperationsNextPageAsync(string nextLink, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListLogCollectionOperationsNextPageRequest(nextLink); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LogCollectionOperationList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LogCollectionOperationList.DeserializeLogCollectionOperationList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get all device diagnostics log collection operations. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public Response ListLogCollectionOperationsNextPage(string nextLink, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListLogCollectionOperationsNextPageRequest(nextLink); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LogCollectionOperationList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LogCollectionOperationList.DeserializeLogCollectionOperationList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesClient.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateClient.cs similarity index 57% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesClient.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateClient.cs index 2251fa745c1b3..c26790cdf6902 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesClient.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateClient.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Azure; @@ -15,21 +16,27 @@ namespace Azure.IoT.DeviceUpdate { - /// The Updates service client. - public partial class UpdatesClient + /// The DeviceUpdate service client. + public partial class DeviceUpdateClient { private readonly ClientDiagnostics _clientDiagnostics; private readonly HttpPipeline _pipeline; - internal UpdatesRestClient RestClient { get; } + internal DeviceUpdateRestClient RestClient { get; } - /// Initializes a new instance of UpdatesClient. + /// Initializes a new instance of DeviceUpdateClient for mocking. + protected DeviceUpdateClient() + { + } + + /// Initializes a new instance of DeviceUpdateClient. /// The handler for diagnostic messaging in the client. /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Account endpoint. + /// Account endpoint. /// Account instance identifier. - internal UpdatesClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string accountEndpoint, string instanceId) + /// Api Version. + internal DeviceUpdateClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string instanceId, string apiVersion = "2021-06-01-preview") { - RestClient = new UpdatesRestClient(clientDiagnostics, pipeline, accountEndpoint, instanceId); + RestClient = new DeviceUpdateRestClient(clientDiagnostics, pipeline, endpoint, instanceId, apiVersion); _clientDiagnostics = clientDiagnostics; _pipeline = pipeline; } @@ -42,7 +49,7 @@ internal UpdatesClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipelin /// The cancellation token to use. public virtual async Task> GetUpdateAsync(string provider, string name, string version, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetUpdate"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.GetUpdate"); scope.Start(); try { @@ -63,7 +70,7 @@ public virtual async Task> GetUpdateAsync(string provider, stri /// The cancellation token to use. public virtual Response GetUpdate(string provider, string name, string version, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetUpdate"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.GetUpdate"); scope.Start(); try { @@ -83,9 +90,9 @@ public virtual Response GetUpdate(string provider, string name, string v /// File identifier. /// Parameter group. /// The cancellation token to use. - public virtual async Task> GetFileAsync(string provider, string name, string version, string fileId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) + public virtual async Task> GetFileAsync(string provider, string name, string version, string fileId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetFile"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.GetFile"); scope.Start(); try { @@ -105,9 +112,9 @@ public virtual async Task> GetFileAsync(string provider, string n /// File identifier. /// Parameter group. /// The cancellation token to use. - public virtual Response GetFile(string provider, string name, string version, string fileId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) + public virtual Response GetFile(string provider, string name, string version, string fileId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetFile"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.GetFile"); scope.Start(); try { @@ -124,9 +131,9 @@ public virtual Response GetFile(string provider, string name, string versi /// Operation identifier. /// Parameter group. /// The cancellation token to use. - public virtual async Task> GetOperationAsync(string operationId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) + public virtual async Task> GetOperationAsync(string operationId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetOperation"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.GetOperation"); scope.Start(); try { @@ -143,9 +150,9 @@ public virtual Response GetFile(string provider, string name, string versi /// Operation identifier. /// Parameter group. /// The cancellation token to use. - public virtual Response GetOperation(string operationId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) + public virtual Response GetOperation(string operationId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetOperation"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.GetOperation"); scope.Start(); try { @@ -158,17 +165,95 @@ public virtual Response GetFile(string provider, string name, string versi } } + /// Get a list of all updates that have been imported to Device Update for IoT Hub. + /// Request updates matching a free-text search expression. + /// Filter updates by its properties. + /// The cancellation token to use. + public virtual AsyncPageable ListUpdatesAsync(string search = null, string filter = null, CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListUpdates"); + scope.Start(); + try + { + var response = await RestClient.ListUpdatesAsync(search, filter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListUpdates"); + scope.Start(); + try + { + var response = await RestClient.ListUpdatesNextPageAsync(nextLink, search, filter, cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// Get a list of all updates that have been imported to Device Update for IoT Hub. + /// Request updates matching a free-text search expression. + /// Filter updates by its properties. + /// The cancellation token to use. + public virtual Pageable ListUpdates(string search = null, string filter = null, CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListUpdates"); + scope.Start(); + try + { + var response = RestClient.ListUpdates(search, filter, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListUpdates"); + scope.Start(); + try + { + var response = RestClient.ListUpdatesNextPage(nextLink, search, filter, cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + /// Get a list of all update providers that have been imported to Device Update for IoT Hub. /// The cancellation token to use. - public virtual AsyncPageable GetProvidersAsync(CancellationToken cancellationToken = default) + public virtual AsyncPageable ListProvidersAsync(CancellationToken cancellationToken = default) { async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetProviders"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListProviders"); scope.Start(); try { - var response = await RestClient.GetProvidersAsync(cancellationToken).ConfigureAwait(false); + var response = await RestClient.ListProvidersAsync(cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -179,11 +264,11 @@ async Task> FirstPageFunc(int? pageSizeHint) } async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetProviders"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListProviders"); scope.Start(); try { - var response = await RestClient.GetProvidersNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false); + var response = await RestClient.ListProvidersNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -197,15 +282,15 @@ async Task> NextPageFunc(string nextLink, int? pageSizeHint) /// Get a list of all update providers that have been imported to Device Update for IoT Hub. /// The cancellation token to use. - public virtual Pageable GetProviders(CancellationToken cancellationToken = default) + public virtual Pageable ListProviders(CancellationToken cancellationToken = default) { Page FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetProviders"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListProviders"); scope.Start(); try { - var response = RestClient.GetProviders(cancellationToken); + var response = RestClient.ListProviders(cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -216,11 +301,11 @@ Page FirstPageFunc(int? pageSizeHint) } Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetProviders"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListProviders"); scope.Start(); try { - var response = RestClient.GetProvidersNextPage(nextLink, cancellationToken); + var response = RestClient.ListProvidersNextPage(nextLink, cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -236,7 +321,7 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) /// Update provider. /// The cancellation token to use. /// is null. - public virtual AsyncPageable GetNamesAsync(string provider, CancellationToken cancellationToken = default) + public virtual AsyncPageable ListNamesAsync(string provider, CancellationToken cancellationToken = default) { if (provider == null) { @@ -245,11 +330,11 @@ public virtual AsyncPageable GetNamesAsync(string provider, Cancellation async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetNames"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListNames"); scope.Start(); try { - var response = await RestClient.GetNamesAsync(provider, cancellationToken).ConfigureAwait(false); + var response = await RestClient.ListNamesAsync(provider, cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -260,11 +345,11 @@ async Task> FirstPageFunc(int? pageSizeHint) } async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetNames"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListNames"); scope.Start(); try { - var response = await RestClient.GetNamesNextPageAsync(nextLink, provider, cancellationToken).ConfigureAwait(false); + var response = await RestClient.ListNamesNextPageAsync(nextLink, provider, cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -280,7 +365,7 @@ async Task> NextPageFunc(string nextLink, int? pageSizeHint) /// Update provider. /// The cancellation token to use. /// is null. - public virtual Pageable GetNames(string provider, CancellationToken cancellationToken = default) + public virtual Pageable ListNames(string provider, CancellationToken cancellationToken = default) { if (provider == null) { @@ -289,11 +374,11 @@ public virtual Pageable GetNames(string provider, CancellationToken canc Page FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetNames"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListNames"); scope.Start(); try { - var response = RestClient.GetNames(provider, cancellationToken); + var response = RestClient.ListNames(provider, cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -304,11 +389,11 @@ Page FirstPageFunc(int? pageSizeHint) } Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetNames"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListNames"); scope.Start(); try { - var response = RestClient.GetNamesNextPage(nextLink, provider, cancellationToken); + var response = RestClient.ListNamesNextPage(nextLink, provider, cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -323,9 +408,10 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) /// Get a list of all update versions that match the specified provider and name. /// Update provider. /// Update name. + /// Filter updates by its properties. /// The cancellation token to use. /// or is null. - public virtual AsyncPageable GetVersionsAsync(string provider, string name, CancellationToken cancellationToken = default) + public virtual AsyncPageable ListVersionsAsync(string provider, string name, string filter = null, CancellationToken cancellationToken = default) { if (provider == null) { @@ -338,11 +424,11 @@ public virtual AsyncPageable GetVersionsAsync(string provider, string na async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetVersions"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListVersions"); scope.Start(); try { - var response = await RestClient.GetVersionsAsync(provider, name, cancellationToken).ConfigureAwait(false); + var response = await RestClient.ListVersionsAsync(provider, name, filter, cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -353,11 +439,11 @@ async Task> FirstPageFunc(int? pageSizeHint) } async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetVersions"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListVersions"); scope.Start(); try { - var response = await RestClient.GetVersionsNextPageAsync(nextLink, provider, name, cancellationToken).ConfigureAwait(false); + var response = await RestClient.ListVersionsNextPageAsync(nextLink, provider, name, filter, cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -372,9 +458,10 @@ async Task> NextPageFunc(string nextLink, int? pageSizeHint) /// Get a list of all update versions that match the specified provider and name. /// Update provider. /// Update name. + /// Filter updates by its properties. /// The cancellation token to use. /// or is null. - public virtual Pageable GetVersions(string provider, string name, CancellationToken cancellationToken = default) + public virtual Pageable ListVersions(string provider, string name, string filter = null, CancellationToken cancellationToken = default) { if (provider == null) { @@ -387,11 +474,11 @@ public virtual Pageable GetVersions(string provider, string name, Cancel Page FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetVersions"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListVersions"); scope.Start(); try { - var response = RestClient.GetVersions(provider, name, cancellationToken); + var response = RestClient.ListVersions(provider, name, filter, cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -402,11 +489,11 @@ Page FirstPageFunc(int? pageSizeHint) } Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetVersions"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListVersions"); scope.Start(); try { - var response = RestClient.GetVersionsNextPage(nextLink, provider, name, cancellationToken); + var response = RestClient.ListVersionsNextPage(nextLink, provider, name, filter, cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -424,7 +511,7 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) /// Update version. /// The cancellation token to use. /// , , or is null. - public virtual AsyncPageable GetFilesAsync(string provider, string name, string version, CancellationToken cancellationToken = default) + public virtual AsyncPageable ListFilesAsync(string provider, string name, string version, CancellationToken cancellationToken = default) { if (provider == null) { @@ -441,11 +528,11 @@ public virtual AsyncPageable GetFilesAsync(string provider, string name, async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetFiles"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListFiles"); scope.Start(); try { - var response = await RestClient.GetFilesAsync(provider, name, version, cancellationToken).ConfigureAwait(false); + var response = await RestClient.ListFilesAsync(provider, name, version, cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -456,11 +543,11 @@ async Task> FirstPageFunc(int? pageSizeHint) } async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetFiles"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListFiles"); scope.Start(); try { - var response = await RestClient.GetFilesNextPageAsync(nextLink, provider, name, version, cancellationToken).ConfigureAwait(false); + var response = await RestClient.ListFilesNextPageAsync(nextLink, provider, name, version, cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -478,7 +565,7 @@ async Task> NextPageFunc(string nextLink, int? pageSizeHint) /// Update version. /// The cancellation token to use. /// , , or is null. - public virtual Pageable GetFiles(string provider, string name, string version, CancellationToken cancellationToken = default) + public virtual Pageable ListFiles(string provider, string name, string version, CancellationToken cancellationToken = default) { if (provider == null) { @@ -495,11 +582,11 @@ public virtual Pageable GetFiles(string provider, string name, string ve Page FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetFiles"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListFiles"); scope.Start(); try { - var response = RestClient.GetFiles(provider, name, version, cancellationToken); + var response = RestClient.ListFiles(provider, name, version, cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -510,11 +597,11 @@ Page FirstPageFunc(int? pageSizeHint) } Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetFiles"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListFiles"); scope.Start(); try { - var response = RestClient.GetFilesNextPage(nextLink, provider, name, version, cancellationToken); + var response = RestClient.ListFilesNextPage(nextLink, provider, name, version, cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -530,15 +617,15 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) /// Restricts the set of operations returned. Only one specific filter is supported: "status eq 'NotStarted' or status eq 'Running'". /// Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n. /// The cancellation token to use. - public virtual AsyncPageable GetOperationsAsync(string filter = null, int? top = null, CancellationToken cancellationToken = default) + public virtual AsyncPageable ListOperationsAsync(string filter = null, int? top = null, CancellationToken cancellationToken = default) { - async Task> FirstPageFunc(int? pageSizeHint) + async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetOperations"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListOperations"); scope.Start(); try { - var response = await RestClient.GetOperationsAsync(filter, top, cancellationToken).ConfigureAwait(false); + var response = await RestClient.ListOperationsAsync(filter, top, cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -547,13 +634,13 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) throw; } } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetOperations"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListOperations"); scope.Start(); try { - var response = await RestClient.GetOperationsNextPageAsync(nextLink, filter, top, cancellationToken).ConfigureAwait(false); + var response = await RestClient.ListOperationsNextPageAsync(nextLink, filter, top, cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -569,15 +656,15 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) /// Restricts the set of operations returned. Only one specific filter is supported: "status eq 'NotStarted' or status eq 'Running'". /// Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n. /// The cancellation token to use. - public virtual Pageable GetOperations(string filter = null, int? top = null, CancellationToken cancellationToken = default) + public virtual Pageable ListOperations(string filter = null, int? top = null, CancellationToken cancellationToken = default) { - Page FirstPageFunc(int? pageSizeHint) + Page FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetOperations"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListOperations"); scope.Start(); try { - var response = RestClient.GetOperations(filter, top, cancellationToken); + var response = RestClient.ListOperations(filter, top, cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -586,13 +673,13 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) throw; } } - Page NextPageFunc(string nextLink, int? pageSizeHint) + Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("UpdatesClient.GetOperations"); + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.ListOperations"); scope.Start(); try { - var response = RestClient.GetOperationsNextPage(nextLink, filter, top, cancellationToken); + var response = RestClient.ListOperationsNextPage(nextLink, filter, top, cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -603,5 +690,127 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) } return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); } + + /// Import new update version. + /// Import update action. + /// The update to be imported. + /// The cancellation token to use. + /// is null. + public virtual async Task StartImportUpdateAsync(ImportAction action, IEnumerable updateToImport, CancellationToken cancellationToken = default) + { + if (updateToImport == null) + { + throw new ArgumentNullException(nameof(updateToImport)); + } + + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.StartImportUpdate"); + scope.Start(); + try + { + var originalResponse = await RestClient.ImportUpdateAsync(action, updateToImport, cancellationToken).ConfigureAwait(false); + return new DeviceUpdateImportUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateImportUpdateRequest(action, updateToImport).Request, originalResponse); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Import new update version. + /// Import update action. + /// The update to be imported. + /// The cancellation token to use. + /// is null. + public virtual DeviceUpdateImportUpdateOperation StartImportUpdate(ImportAction action, IEnumerable updateToImport, CancellationToken cancellationToken = default) + { + if (updateToImport == null) + { + throw new ArgumentNullException(nameof(updateToImport)); + } + + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.StartImportUpdate"); + scope.Start(); + try + { + var originalResponse = RestClient.ImportUpdate(action, updateToImport, cancellationToken); + return new DeviceUpdateImportUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateImportUpdateRequest(action, updateToImport).Request, originalResponse); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Delete a specific update version. + /// Update provider. + /// Update name. + /// Update version. + /// The cancellation token to use. + /// , , or is null. + public virtual async Task StartDeleteUpdateAsync(string provider, string name, string version, CancellationToken cancellationToken = default) + { + if (provider == null) + { + throw new ArgumentNullException(nameof(provider)); + } + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (version == null) + { + throw new ArgumentNullException(nameof(version)); + } + + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.StartDeleteUpdate"); + scope.Start(); + try + { + var originalResponse = await RestClient.DeleteUpdateAsync(provider, name, version, cancellationToken).ConfigureAwait(false); + return new DeviceUpdateDeleteUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteUpdateRequest(provider, name, version).Request, originalResponse); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Delete a specific update version. + /// Update provider. + /// Update name. + /// Update version. + /// The cancellation token to use. + /// , , or is null. + public virtual DeviceUpdateDeleteUpdateOperation StartDeleteUpdate(string provider, string name, string version, CancellationToken cancellationToken = default) + { + if (provider == null) + { + throw new ArgumentNullException(nameof(provider)); + } + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (version == null) + { + throw new ArgumentNullException(nameof(version)); + } + + using var scope = _clientDiagnostics.CreateScope("DeviceUpdateClient.StartDeleteUpdate"); + scope.Start(); + try + { + var originalResponse = RestClient.DeleteUpdate(provider, name, version, cancellationToken); + return new DeviceUpdateDeleteUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteUpdateRequest(provider, name, version).Request, originalResponse); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateClientOptions.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateClientOptions.cs index 360e5e963d03e..a5d84068331d8 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateClientOptions.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateClientOptions.cs @@ -13,13 +13,13 @@ namespace Azure.IoT.DeviceUpdate /// Client options for DeviceUpdateClient. public partial class DeviceUpdateClientOptions : ClientOptions { - private const ServiceVersion LatestVersion = ServiceVersion.V2020_09_01; + private const ServiceVersion LatestVersion = ServiceVersion.V2021_06_01_preview; /// The version of the service to use. public enum ServiceVersion { - /// Service version "2020-09-01". - V2020_09_01 = 1, + /// Service version "2021-06-01-preview". + V2021_06_01_preview = 1, } internal string Version { get; } @@ -29,7 +29,7 @@ public DeviceUpdateClientOptions(ServiceVersion version = LatestVersion) { Version = version switch { - ServiceVersion.V2020_09_01 => "2020-09-01", + ServiceVersion.V2021_06_01_preview => "2021-06-01-preview", _ => throw new NotSupportedException() }; } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesDeleteUpdateHeaders.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateDeleteUpdateHeaders.cs similarity index 63% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesDeleteUpdateHeaders.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateDeleteUpdateHeaders.cs index afd49ad001826..8fde6e5f24bfe 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesDeleteUpdateHeaders.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateDeleteUpdateHeaders.cs @@ -10,16 +10,14 @@ namespace Azure.IoT.DeviceUpdate { - internal partial class UpdatesDeleteUpdateHeaders + internal partial class DeviceUpdateDeleteUpdateHeaders { private readonly Response _response; - public UpdatesDeleteUpdateHeaders(Response response) + public DeviceUpdateDeleteUpdateHeaders(Response response) { _response = response; } /// Url to retrieve the operation status. - public string Location => _response.Headers.TryGetValue("Location", out string value) ? value : null; - /// Url to retrieve the operation status. public string OperationLocation => _response.Headers.TryGetValue("Operation-Location", out string value) ? value : null; } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateDeleteUpdateOperation.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateDeleteUpdateOperation.cs new file mode 100644 index 0000000000000..c7fbe2dba170e --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateDeleteUpdateOperation.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.IoT.DeviceUpdate +{ + /// Delete a specific update version. + public partial class DeviceUpdateDeleteUpdateOperation : Operation + { + private readonly OperationInternals _operation; + + /// Initializes a new instance of DeviceUpdateDeleteUpdateOperation for mocking. + protected DeviceUpdateDeleteUpdateOperation() + { + } + + internal DeviceUpdateDeleteUpdateOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response) + { + _operation = new OperationInternals(clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "DeviceUpdateDeleteUpdateOperation"); + } + + /// + public override string Id => _operation.Id; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.GetRawResponse(); + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesGetOperationHeaders.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateGetOperationHeaders.cs similarity index 81% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesGetOperationHeaders.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateGetOperationHeaders.cs index fc33723a9b71f..cf7c3019ed606 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesGetOperationHeaders.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateGetOperationHeaders.cs @@ -10,10 +10,10 @@ namespace Azure.IoT.DeviceUpdate { - internal partial class UpdatesGetOperationHeaders + internal partial class DeviceUpdateGetOperationHeaders { private readonly Response _response; - public UpdatesGetOperationHeaders(Response response) + public DeviceUpdateGetOperationHeaders(Response response) { _response = response; } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesImportUpdateHeaders.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateImportUpdateHeaders.cs similarity index 63% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesImportUpdateHeaders.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateImportUpdateHeaders.cs index 051f0038c85fc..4c25be1956c1c 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesImportUpdateHeaders.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateImportUpdateHeaders.cs @@ -10,16 +10,14 @@ namespace Azure.IoT.DeviceUpdate { - internal partial class UpdatesImportUpdateHeaders + internal partial class DeviceUpdateImportUpdateHeaders { private readonly Response _response; - public UpdatesImportUpdateHeaders(Response response) + public DeviceUpdateImportUpdateHeaders(Response response) { _response = response; } /// Url to retrieve the import operation status. - public string Location => _response.Headers.TryGetValue("Location", out string value) ? value : null; - /// Url to retrieve the import operation status. public string OperationLocation => _response.Headers.TryGetValue("Operation-Location", out string value) ? value : null; } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateImportUpdateOperation.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateImportUpdateOperation.cs new file mode 100644 index 0000000000000..046f65b8242f6 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateImportUpdateOperation.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.IoT.DeviceUpdate.Models; + +namespace Azure.IoT.DeviceUpdate +{ + /// Import new update version. + public partial class DeviceUpdateImportUpdateOperation : Operation, IOperationSource + { + private readonly OperationInternals _operation; + + /// Initializes a new instance of DeviceUpdateImportUpdateOperation for mocking. + protected DeviceUpdateImportUpdateOperation() + { + } + + internal DeviceUpdateImportUpdateOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response) + { + _operation = new OperationInternals(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "DeviceUpdateImportUpdateOperation"); + } + + /// + public override string Id => _operation.Id; + + /// + public override Update Value => _operation.Value; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override bool HasValue => _operation.HasValue; + + /// + public override Response GetRawResponse() => _operation.GetRawResponse(); + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + + Update IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + return Update.DeserializeUpdate(document.RootElement); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + return Update.DeserializeUpdate(document.RootElement); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateModelFactory.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateModelFactory.cs index 7f5a61aff683e..6c50ee70a114f 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateModelFactory.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateModelFactory.cs @@ -16,59 +16,51 @@ public static partial class DeviceUpdateModelFactory { /// Initializes a new instance of Update. /// Update identity. - /// Update type. - /// String interpreted by Device Update client to determine if the update is installed on the device. + /// Update description specified by creator. + /// Friendly update name specified by importer. + /// Whether the update can be deployed to a device on its own. + /// Update type. Deprecated in latest import manifest schema. + /// String interpreted by Device Update client to determine if the update is installed on the device. Deprecated in latest import manifest schema. /// List of update compatibility information. + /// Update install instructions. + /// List of update identities that reference this update. + /// Update aggregate scan result (calculated from payload file scan results). /// Schema version of manifest used to import the update. /// Date and time in UTC when the update was imported. /// Date and time in UTC when the update was created. /// Update ETag. /// A new instance for mocking. - public static Update Update(UpdateId updateId = null, string updateType = null, string installedCriteria = null, IEnumerable compatibility = null, string manifestVersion = null, DateTimeOffset importedDateTime = default, DateTimeOffset createdDateTime = default, string etag = null) + public static Update Update(UpdateId updateId = null, string description = null, string friendlyName = null, bool? isDeployable = null, string updateType = null, string installedCriteria = null, IEnumerable> compatibility = null, Instructions instructions = null, IEnumerable referencedBy = null, string scanResult = null, string manifestVersion = null, DateTimeOffset importedDateTime = default, DateTimeOffset createdDateTime = default, string etag = null) { - compatibility ??= new List(); + compatibility ??= new List>(); + referencedBy ??= new List(); - return new Update(updateId, updateType, installedCriteria, compatibility?.ToList(), manifestVersion, importedDateTime, createdDateTime, etag); + return new Update(updateId, description, friendlyName, isDeployable, updateType, installedCriteria, compatibility?.ToList(), instructions, referencedBy?.ToList(), scanResult, manifestVersion, importedDateTime, createdDateTime, etag); } - /// Initializes a new instance of Compatibility. - /// The manufacturer of device the update is compatible with. - /// The model of device the update is compatible with. - /// A new instance for mocking. - public static Compatibility Compatibility(string deviceManufacturer = null, string deviceModel = null) + /// Initializes a new instance of Instructions. + /// Collection of installation steps. + /// A new instance for mocking. + public static Instructions Instructions(IEnumerable steps = null) { - return new Compatibility(deviceManufacturer, deviceModel); - } - - /// Initializes a new instance of File. - /// File identity, generated by server at import time. - /// File name. - /// File size in number of bytes. - /// Mapping of hashing algorithm to base64 encoded hash values. - /// File MIME type. - /// File ETag. - /// A new instance for mocking. - public static File File(string fileId = null, string fileName = null, long sizeInBytes = default, IReadOnlyDictionary hashes = null, string mimeType = null, string etag = null) - { - hashes ??= new Dictionary(); + steps ??= new List(); - return new File(fileId, fileName, sizeInBytes, hashes, mimeType, etag); + return new Instructions(steps?.ToList()); } - /// Initializes a new instance of Operation. - /// Operation Id. - /// Operation status. - /// The identity of update being imported or deleted. For import, this property will only be populated after import manifest is processed successfully. - /// Location of the imported update when operation is successful. - /// Operation error encountered, if any. - /// Operation correlation identity that can used by Microsoft Support for troubleshooting. - /// Date and time in UTC when the operation status was last updated. - /// Date and time in UTC when the operation was created. - /// Operation ETag. - /// A new instance for mocking. - public static Operation Operation(string operationId = null, OperationStatus status = default, UpdateId updateId = null, string resourceLocation = null, Error error = null, string traceId = null, DateTimeOffset lastActionDateTime = default, DateTimeOffset createdDateTime = default, string etag = null) + /// Initializes a new instance of Step. + /// Step type. + /// Step description. + /// Identity of handler that will execute this step. Required if step type is inline. + /// Parameters to be passed to handler during execution. + /// Collection of file names to be passed to handler during execution. Required if step type is inline. + /// Referenced child update identity. Required if step type is reference. + /// A new instance for mocking. + public static Step Step(StepType? type = null, string description = null, string handler = null, object handlerProperties = null, IEnumerable files = null, UpdateId updateId = null) { - return new Operation(operationId, status, updateId, resourceLocation, error, traceId, lastActionDateTime, createdDateTime, etag); + files ??= new List(); + + return new Step(type, description, handler, handlerProperties, files?.ToList(), updateId); } /// Initializes a new instance of Error. @@ -97,19 +89,54 @@ public static InnerError InnerError(string code = null, string message = null, s return new InnerError(code, message, errorDetail, innerErrorValue); } + /// Initializes a new instance of UpdateFile. + /// File identity, generated by server at import time. + /// File name. + /// File size in number of bytes. + /// Mapping of hashing algorithm to base64 encoded hash values. + /// File MIME type. + /// Anti-malware scan result. + /// Anti-malware scan details. + /// File ETag. + /// A new instance for mocking. + public static UpdateFile UpdateFile(string fileId = null, string fileName = null, long sizeInBytes = default, IReadOnlyDictionary hashes = null, string mimeType = null, string scanResult = null, string scanDetails = null, string etag = null) + { + hashes ??= new Dictionary(); + + return new UpdateFile(fileId, fileName, sizeInBytes, hashes, mimeType, scanResult, scanDetails, etag); + } + + /// Initializes a new instance of UpdateOperation. + /// Operation Id. + /// Operation status. + /// The identity of update being imported or deleted. For import, this property will only be populated after import manifest is processed successfully. + /// Location of the imported update when operation is successful. + /// Operation error encountered, if any. + /// Operation correlation identity that can used by Microsoft Support for troubleshooting. + /// Date and time in UTC when the operation status was last updated. + /// Date and time in UTC when the operation was created. + /// Operation ETag. + /// A new instance for mocking. + public static UpdateOperation UpdateOperation(string operationId = null, OperationStatus status = default, UpdateId updateId = null, string resourceLocation = null, Error error = null, string traceId = null, DateTimeOffset lastActionDateTime = default, DateTimeOffset createdDateTime = default, string etag = null) + { + return new UpdateOperation(operationId, status, updateId, resourceLocation, error, traceId, lastActionDateTime, createdDateTime, etag); + } + /// Initializes a new instance of DeviceClass. /// The device class identifier. - /// Device manufacturer. - /// Device model. + /// The compat properties of the device class. This object can be thought of as a set of key-value pairs where the key is the name of the compatibility property and the value is the value of the compatibility property. There will always be at least 1 compat property. /// Update identity. /// A new instance for mocking. - public static DeviceClass DeviceClass(string deviceClassId = null, string manufacturer = null, string model = null, UpdateId bestCompatibleUpdateId = null) + public static DeviceClass DeviceClass(string deviceClassId = null, IReadOnlyDictionary compatProperties = null, UpdateId bestCompatibleUpdateId = null) { - return new DeviceClass(deviceClassId, manufacturer, model, bestCompatibleUpdateId); + compatProperties ??= new Dictionary(); + + return new DeviceClass(deviceClassId, compatProperties, bestCompatibleUpdateId); } /// Initializes a new instance of Device. /// Device identity. + /// Device module identity. /// Device class identity. /// Device manufacturer. /// Device model. @@ -119,10 +146,36 @@ public static DeviceClass DeviceClass(string deviceClassId = null, string manufa /// Update identity. /// Boolean flag indicating whether the latest update is installed on the device. /// The deployment identifier for the last deployment to the device. + /// Last install result. /// A new instance for mocking. - public static Device Device(string deviceId = null, string deviceClassId = null, string manufacturer = null, string model = null, string groupId = null, UpdateId lastAttemptedUpdateId = null, DeviceDeploymentState? deploymentStatus = null, UpdateId installedUpdateId = null, bool onLatestUpdate = default, string lastDeploymentId = null) + public static Device Device(string deviceId = null, string moduleId = null, string deviceClassId = null, string manufacturer = null, string model = null, string groupId = null, UpdateId lastAttemptedUpdateId = null, DeviceDeploymentState? deploymentStatus = null, UpdateId installedUpdateId = null, bool onLatestUpdate = default, string lastDeploymentId = null, InstallResult lastInstallResult = null) { - return new Device(deviceId, deviceClassId, manufacturer, model, groupId, lastAttemptedUpdateId, deploymentStatus, installedUpdateId, onLatestUpdate, lastDeploymentId); + return new Device(deviceId, moduleId, deviceClassId, manufacturer, model, groupId, lastAttemptedUpdateId, deploymentStatus, installedUpdateId, onLatestUpdate, lastDeploymentId, lastInstallResult); + } + + /// Initializes a new instance of InstallResult. + /// Install result code. + /// Install extended result code. + /// A string containing further details about the install result. + /// Array of step results. + /// A new instance for mocking. + public static InstallResult InstallResult(int resultCode = default, int extendedResultCode = default, string resultDetails = null, IEnumerable stepResults = null) + { + stepResults ??= new List(); + + return new InstallResult(resultCode, extendedResultCode, resultDetails, stepResults?.ToList()); + } + + /// Initializes a new instance of StepResult. + /// It is update id for update steps; otherwise it is null. + /// Step description. It might be null for update steps. + /// Install result code. + /// Install extended result code. + /// A string containing further details about the install result. + /// A new instance for mocking. + public static StepResult StepResult(UpdateId updateId = null, string description = null, int resultCode = default, int extendedResultCode = default, string resultDetails = null) + { + return new StepResult(updateId, description, resultCode, extendedResultCode, resultDetails); } /// Initializes a new instance of UpdateCompliance. @@ -155,28 +208,85 @@ public static UpdatableDevices UpdatableDevices(UpdateId updateId = null, int de } /// Initializes a new instance of DeploymentStatus. - /// Gets or sets the state of the deployment. - /// Gets or sets the total number of devices in the deployment. - /// Gets or sets the number of incompatible devices in the deployment. - /// Gets or sets the number of devices that are currently in deployment. - /// Gets or sets the number of devices that have completed deployment with a failure. - /// Gets or sets the number of devices which have successfully completed deployment. - /// Gets or sets the number of devices which have had their deployment canceled. + /// The state of the deployment. + /// The total number of devices in the deployment. + /// The number of devices that are currently in deployment. + /// The number of devices that have completed deployment with a failure. + /// The number of devices which have successfully completed deployment. + /// The number of devices which have had their deployment canceled. /// A new instance for mocking. - public static DeploymentStatus DeploymentStatus(DeploymentState deploymentState = default, int? totalDevices = null, int? devicesIncompatibleCount = null, int? devicesInProgressCount = null, int? devicesCompletedFailedCount = null, int? devicesCompletedSucceededCount = null, int? devicesCanceledCount = null) + public static DeploymentStatus DeploymentStatus(DeploymentState deploymentState = default, int? totalDevices = null, int? devicesInProgressCount = null, int? devicesCompletedFailedCount = null, int? devicesCompletedSucceededCount = null, int? devicesCanceledCount = null) { - return new DeploymentStatus(deploymentState, totalDevices, devicesIncompatibleCount, devicesInProgressCount, devicesCompletedFailedCount, devicesCompletedSucceededCount, devicesCanceledCount); + return new DeploymentStatus(deploymentState, totalDevices, devicesInProgressCount, devicesCompletedFailedCount, devicesCompletedSucceededCount, devicesCanceledCount); } /// Initializes a new instance of DeploymentDeviceState. /// Device identity. + /// Device module identity. /// The number of times this deployment has been retried on this device. /// Boolean flag indicating whether this device is in a newer deployment and can no longer retry this deployment. /// Deployment device state. /// A new instance for mocking. - public static DeploymentDeviceState DeploymentDeviceState(string deviceId = null, int retryCount = default, bool movedOnToNewDeployment = default, DeviceDeploymentState deviceState = default) + public static DeploymentDeviceState DeploymentDeviceState(string deviceId = null, string moduleId = null, int retryCount = default, bool movedOnToNewDeployment = default, DeviceDeploymentState deviceState = default) + { + return new DeploymentDeviceState(deviceId, moduleId, retryCount, movedOnToNewDeployment, deviceState); + } + + /// Initializes a new instance of DeviceOperation. + /// Operation Id. + /// Operation status. + /// Operation error encountered, if any. + /// Operation correlation identity that can used by Microsoft Support for troubleshooting. + /// Date and time in UTC when the operation status was last updated. + /// Date and time in UTC when the operation was created. + /// Operation ETag. + /// A new instance for mocking. + public static DeviceOperation DeviceOperation(string operationId = null, OperationStatus status = default, Error error = null, string traceId = null, DateTimeOffset lastActionDateTime = default, DateTimeOffset createdDateTime = default, string etag = null) + { + return new DeviceOperation(operationId, status, error, traceId, lastActionDateTime, createdDateTime, etag); + } + + /// Initializes a new instance of LogCollectionOperation. + /// The diagnostics operation id. + /// Array of Device Update agent ids. + /// Description of the diagnostics operation. + /// The timestamp when the operation was created. + /// A timestamp for when the current state was entered. + /// Operation status. + /// A new instance for mocking. + public static LogCollectionOperation LogCollectionOperation(string operationId = null, IEnumerable deviceList = null, string description = null, string createdDateTime = null, string lastActionDateTime = null, OperationStatus? status = null) + { + deviceList ??= new List(); + + return new LogCollectionOperation(operationId, deviceList?.ToList(), description, createdDateTime, lastActionDateTime, status); + } + + /// Initializes a new instance of LogCollectionOperationDetailedStatus. + /// The device diagnostics operation id. + /// The timestamp when the operation was created. + /// A timestamp for when the current state was entered. + /// Operation status. + /// Status of the devices in the operation. + /// Device diagnostics operation description. + /// A new instance for mocking. + public static LogCollectionOperationDetailedStatus LogCollectionOperationDetailedStatus(string operationId = null, string createdDateTime = null, string lastActionDateTime = null, OperationStatus? status = null, IEnumerable deviceStatus = null, string description = null) + { + deviceStatus ??= new List(); + + return new LogCollectionOperationDetailedStatus(operationId, createdDateTime, lastActionDateTime, status, deviceStatus?.ToList(), description); + } + + /// Initializes a new instance of LogCollectionOperationDeviceStatus. + /// Device id. + /// Module id. + /// Log upload status. + /// Log upload result code. + /// Log upload extended result code. + /// Log upload location. + /// A new instance for mocking. + public static LogCollectionOperationDeviceStatus LogCollectionOperationDeviceStatus(string deviceId = null, string moduleId = null, OperationStatus status = default, string resultCode = null, string extendedResultCode = null, string logLocation = null) { - return new DeploymentDeviceState(deviceId, retryCount, movedOnToNewDeployment, deviceState); + return new LogCollectionOperationDeviceStatus(deviceId, moduleId, status, resultCode, extendedResultCode, logLocation); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesRestClient.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateRestClient.cs similarity index 69% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesRestClient.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateRestClient.cs index b4019d288b70d..3f45fc4ee2d5e 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/UpdatesRestClient.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DeviceUpdateRestClient.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -16,61 +17,72 @@ namespace Azure.IoT.DeviceUpdate { - internal partial class UpdatesRestClient + internal partial class DeviceUpdateRestClient { - private string accountEndpoint; + private string endpoint; private string instanceId; + private string apiVersion; private ClientDiagnostics _clientDiagnostics; private HttpPipeline _pipeline; - /// Initializes a new instance of UpdatesRestClient. + /// Initializes a new instance of DeviceUpdateRestClient. /// The handler for diagnostic messaging in the client. /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Account endpoint. + /// Account endpoint. /// Account instance identifier. - /// or is null. - public UpdatesRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string accountEndpoint, string instanceId) + /// Api Version. + /// , , or is null. + public DeviceUpdateRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string instanceId, string apiVersion = "2021-06-01-preview") { - this.accountEndpoint = accountEndpoint ?? throw new ArgumentNullException(nameof(accountEndpoint)); + this.endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint)); this.instanceId = instanceId ?? throw new ArgumentNullException(nameof(instanceId)); + this.apiVersion = apiVersion ?? throw new ArgumentNullException(nameof(apiVersion)); _clientDiagnostics = clientDiagnostics; _pipeline = pipeline; } - internal HttpMessage CreateImportUpdateRequest(ImportUpdateInput updateToImport) + internal HttpMessage CreateImportUpdateRequest(ImportAction action, IEnumerable updateToImport) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendPath("/deviceupdate/", false); uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/updates", false); - uri.AppendQuery("action", "import", true); + uri.AppendPath("/updates", false); + uri.AppendQuery("action", action.ToString(), true); + uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; + request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(updateToImport); + content.JsonWriter.WriteStartArray(); + foreach (var item in updateToImport) + { + content.JsonWriter.WriteObjectValue(item); + } + content.JsonWriter.WriteEndArray(); request.Content = content; return message; } /// Import new update version. + /// Import update action. /// The update to be imported. /// The cancellation token to use. /// is null. - public async Task> ImportUpdateAsync(ImportUpdateInput updateToImport, CancellationToken cancellationToken = default) + public async Task> ImportUpdateAsync(ImportAction action, IEnumerable updateToImport, CancellationToken cancellationToken = default) { if (updateToImport == null) { throw new ArgumentNullException(nameof(updateToImport)); } - using var message = CreateImportUpdateRequest(updateToImport); + using var message = CreateImportUpdateRequest(action, updateToImport); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - var headers = new UpdatesImportUpdateHeaders(message.Response); + var headers = new DeviceUpdateImportUpdateHeaders(message.Response); switch (message.Response.Status) { case 202: @@ -81,19 +93,20 @@ public async Task> ImportUpdateA } /// Import new update version. + /// Import update action. /// The update to be imported. /// The cancellation token to use. /// is null. - public ResponseWithHeaders ImportUpdate(ImportUpdateInput updateToImport, CancellationToken cancellationToken = default) + public ResponseWithHeaders ImportUpdate(ImportAction action, IEnumerable updateToImport, CancellationToken cancellationToken = default) { if (updateToImport == null) { throw new ArgumentNullException(nameof(updateToImport)); } - using var message = CreateImportUpdateRequest(updateToImport); + using var message = CreateImportUpdateRequest(action, updateToImport); _pipeline.Send(message, cancellationToken); - var headers = new UpdatesImportUpdateHeaders(message.Response); + var headers = new DeviceUpdateImportUpdateHeaders(message.Response); switch (message.Response.Status) { case 202: @@ -103,6 +116,75 @@ public ResponseWithHeaders ImportUpdate(ImportUpdate } } + internal HttpMessage CreateListUpdatesRequest(string search, string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendPath("/deviceupdate/", false); + uri.AppendPath(instanceId, false); + uri.AppendPath("/updates", false); + uri.AppendQuery("api-version", apiVersion, true); + if (search != null) + { + uri.AppendQuery("$search", search, true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Get a list of all updates that have been imported to Device Update for IoT Hub. + /// Request updates matching a free-text search expression. + /// Filter updates by its properties. + /// The cancellation token to use. + public async Task> ListUpdatesAsync(string search = null, string filter = null, CancellationToken cancellationToken = default) + { + using var message = CreateListUpdatesRequest(search, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + UpdateList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = UpdateList.DeserializeUpdateList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get a list of all updates that have been imported to Device Update for IoT Hub. + /// Request updates matching a free-text search expression. + /// Filter updates by its properties. + /// The cancellation token to use. + public Response ListUpdates(string search = null, string filter = null, CancellationToken cancellationToken = default) + { + using var message = CreateListUpdatesRequest(search, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + UpdateList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = UpdateList.DeserializeUpdateList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + internal HttpMessage CreateGetUpdateRequest(string provider, string name, string version, AccessCondition accessCondition) { var message = _pipeline.CreateMessage(); @@ -110,15 +192,16 @@ internal HttpMessage CreateGetUpdateRequest(string provider, string name, string request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendPath("/deviceupdate/", false); uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/updates/providers/", false); + uri.AppendPath("/updates/providers/", false); uri.AppendPath(provider, true); uri.AppendPath("/names/", false); uri.AppendPath(name, true); uri.AppendPath("/versions/", false); uri.AppendPath(version, true); + uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; if (accessCondition?.IfNoneMatch != null) { @@ -215,16 +298,18 @@ internal HttpMessage CreateDeleteUpdateRequest(string provider, string name, str request.Method = RequestMethod.Delete; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendPath("/deviceupdate/", false); uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/updates/providers/", false); + uri.AppendPath("/updates/providers/", false); uri.AppendPath(provider, true); uri.AppendPath("/names/", false); uri.AppendPath(name, true); uri.AppendPath("/versions/", false); uri.AppendPath(version, true); + uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; + request.Headers.Add("Accept", "application/json"); return message; } @@ -234,7 +319,7 @@ internal HttpMessage CreateDeleteUpdateRequest(string provider, string name, str /// Update version. /// The cancellation token to use. /// , , or is null. - public async Task> DeleteUpdateAsync(string provider, string name, string version, CancellationToken cancellationToken = default) + public async Task> DeleteUpdateAsync(string provider, string name, string version, CancellationToken cancellationToken = default) { if (provider == null) { @@ -251,7 +336,7 @@ public async Task> DeleteUpdateA using var message = CreateDeleteUpdateRequest(provider, name, version); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - var headers = new UpdatesDeleteUpdateHeaders(message.Response); + var headers = new DeviceUpdateDeleteUpdateHeaders(message.Response); switch (message.Response.Status) { case 202: @@ -267,7 +352,7 @@ public async Task> DeleteUpdateA /// Update version. /// The cancellation token to use. /// , , or is null. - public ResponseWithHeaders DeleteUpdate(string provider, string name, string version, CancellationToken cancellationToken = default) + public ResponseWithHeaders DeleteUpdate(string provider, string name, string version, CancellationToken cancellationToken = default) { if (provider == null) { @@ -284,7 +369,7 @@ public ResponseWithHeaders DeleteUpdate(string provi using var message = CreateDeleteUpdateRequest(provider, name, version); _pipeline.Send(message, cancellationToken); - var headers = new UpdatesDeleteUpdateHeaders(message.Response); + var headers = new DeviceUpdateDeleteUpdateHeaders(message.Response); switch (message.Response.Status) { case 202: @@ -294,17 +379,18 @@ public ResponseWithHeaders DeleteUpdate(string provi } } - internal HttpMessage CreateGetProvidersRequest() + internal HttpMessage CreateListProvidersRequest() { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendPath("/deviceupdate/", false); uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/updates/providers", false); + uri.AppendPath("/updates/providers", false); + uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; @@ -312,17 +398,17 @@ internal HttpMessage CreateGetProvidersRequest() /// Get a list of all update providers that have been imported to Device Update for IoT Hub. /// The cancellation token to use. - public async Task> GetProvidersAsync(CancellationToken cancellationToken = default) + public async Task> ListProvidersAsync(CancellationToken cancellationToken = default) { - using var message = CreateGetProvidersRequest(); + using var message = CreateListProvidersRequest(); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -332,17 +418,17 @@ public async Task> GetProvidersAsync(Cancellatio /// Get a list of all update providers that have been imported to Device Update for IoT Hub. /// The cancellation token to use. - public Response GetProviders(CancellationToken cancellationToken = default) + public Response ListProviders(CancellationToken cancellationToken = default) { - using var message = CreateGetProvidersRequest(); + using var message = CreateListProvidersRequest(); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -350,19 +436,20 @@ public Response GetProviders(CancellationToken cancellati } } - internal HttpMessage CreateGetNamesRequest(string provider) + internal HttpMessage CreateListNamesRequest(string provider) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendPath("/deviceupdate/", false); uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/updates/providers/", false); + uri.AppendPath("/updates/providers/", false); uri.AppendPath(provider, true); uri.AppendPath("/names", false); + uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; @@ -372,22 +459,22 @@ internal HttpMessage CreateGetNamesRequest(string provider) /// Update provider. /// The cancellation token to use. /// is null. - public async Task> GetNamesAsync(string provider, CancellationToken cancellationToken = default) + public async Task> ListNamesAsync(string provider, CancellationToken cancellationToken = default) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } - using var message = CreateGetNamesRequest(provider); + using var message = CreateListNamesRequest(provider); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -399,22 +486,22 @@ public async Task> GetNamesAsync(string provider /// Update provider. /// The cancellation token to use. /// is null. - public Response GetNames(string provider, CancellationToken cancellationToken = default) + public Response ListNames(string provider, CancellationToken cancellationToken = default) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } - using var message = CreateGetNamesRequest(provider); + using var message = CreateListNamesRequest(provider); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -422,21 +509,26 @@ public Response GetNames(string provider, CancellationTok } } - internal HttpMessage CreateGetVersionsRequest(string provider, string name) + internal HttpMessage CreateListVersionsRequest(string provider, string name, string filter) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendPath("/deviceupdate/", false); uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/updates/providers/", false); + uri.AppendPath("/updates/providers/", false); uri.AppendPath(provider, true); uri.AppendPath("/names/", false); uri.AppendPath(name, true); uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", apiVersion, true); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; @@ -445,9 +537,10 @@ internal HttpMessage CreateGetVersionsRequest(string provider, string name) /// Get a list of all update versions that match the specified provider and name. /// Update provider. /// Update name. + /// Filter updates by its properties. /// The cancellation token to use. /// or is null. - public async Task> GetVersionsAsync(string provider, string name, CancellationToken cancellationToken = default) + public async Task> ListVersionsAsync(string provider, string name, string filter = null, CancellationToken cancellationToken = default) { if (provider == null) { @@ -458,15 +551,15 @@ public async Task> GetVersionsAsync(string provi throw new ArgumentNullException(nameof(name)); } - using var message = CreateGetVersionsRequest(provider, name); + using var message = CreateListVersionsRequest(provider, name, filter); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -477,9 +570,10 @@ public async Task> GetVersionsAsync(string provi /// Get a list of all update versions that match the specified provider and name. /// Update provider. /// Update name. + /// Filter updates by its properties. /// The cancellation token to use. /// or is null. - public Response GetVersions(string provider, string name, CancellationToken cancellationToken = default) + public Response ListVersions(string provider, string name, string filter = null, CancellationToken cancellationToken = default) { if (provider == null) { @@ -490,15 +584,15 @@ public Response GetVersions(string provider, string name, throw new ArgumentNullException(nameof(name)); } - using var message = CreateGetVersionsRequest(provider, name); + using var message = CreateListVersionsRequest(provider, name, filter); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -506,23 +600,24 @@ public Response GetVersions(string provider, string name, } } - internal HttpMessage CreateGetFilesRequest(string provider, string name, string version) + internal HttpMessage CreateListFilesRequest(string provider, string name, string version) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendPath("/deviceupdate/", false); uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/updates/providers/", false); + uri.AppendPath("/updates/providers/", false); uri.AppendPath(provider, true); uri.AppendPath("/names/", false); uri.AppendPath(name, true); uri.AppendPath("/versions/", false); uri.AppendPath(version, true); uri.AppendPath("/files", false); + uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; @@ -534,7 +629,7 @@ internal HttpMessage CreateGetFilesRequest(string provider, string name, string /// Update version. /// The cancellation token to use. /// , , or is null. - public async Task> GetFilesAsync(string provider, string name, string version, CancellationToken cancellationToken = default) + public async Task> ListFilesAsync(string provider, string name, string version, CancellationToken cancellationToken = default) { if (provider == null) { @@ -549,15 +644,15 @@ public async Task> GetFilesAsync(string provider throw new ArgumentNullException(nameof(version)); } - using var message = CreateGetFilesRequest(provider, name, version); + using var message = CreateListFilesRequest(provider, name, version); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -571,7 +666,7 @@ public async Task> GetFilesAsync(string provider /// Update version. /// The cancellation token to use. /// , , or is null. - public Response GetFiles(string provider, string name, string version, CancellationToken cancellationToken = default) + public Response ListFiles(string provider, string name, string version, CancellationToken cancellationToken = default) { if (provider == null) { @@ -586,15 +681,15 @@ public Response GetFiles(string provider, string name, st throw new ArgumentNullException(nameof(version)); } - using var message = CreateGetFilesRequest(provider, name, version); + using var message = CreateListFilesRequest(provider, name, version); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -609,10 +704,10 @@ internal HttpMessage CreateGetFileRequest(string provider, string name, string v request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendPath("/deviceupdate/", false); uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/updates/providers/", false); + uri.AppendPath("/updates/providers/", false); uri.AppendPath(provider, true); uri.AppendPath("/names/", false); uri.AppendPath(name, true); @@ -620,6 +715,7 @@ internal HttpMessage CreateGetFileRequest(string provider, string name, string v uri.AppendPath(version, true); uri.AppendPath("/files/", false); uri.AppendPath(fileId, true); + uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; if (accessCondition?.IfNoneMatch != null) { @@ -637,7 +733,7 @@ internal HttpMessage CreateGetFileRequest(string provider, string name, string v /// Parameter group. /// The cancellation token to use. /// , , , or is null. - public async Task> GetFileAsync(string provider, string name, string version, string fileId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) + public async Task> GetFileAsync(string provider, string name, string version, string fileId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) { if (provider == null) { @@ -662,13 +758,13 @@ public async Task> GetFileAsync(string provider, string name, str { case 200: { - File value = default; + UpdateFile value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = File.DeserializeFile(document.RootElement); + value = UpdateFile.DeserializeUpdateFile(document.RootElement); return Response.FromValue(value, message.Response); } case 304: - return Response.FromValue((File)null, message.Response); + return Response.FromValue((UpdateFile)null, message.Response); default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } @@ -682,7 +778,7 @@ public async Task> GetFileAsync(string provider, string name, str /// Parameter group. /// The cancellation token to use. /// , , , or is null. - public Response GetFile(string provider, string name, string version, string fileId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) + public Response GetFile(string provider, string name, string version, string fileId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) { if (provider == null) { @@ -707,29 +803,29 @@ public Response GetFile(string provider, string name, string version, stri { case 200: { - File value = default; + UpdateFile value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = File.DeserializeFile(document.RootElement); + value = UpdateFile.DeserializeUpdateFile(document.RootElement); return Response.FromValue(value, message.Response); } case 304: - return Response.FromValue((File)null, message.Response); + return Response.FromValue((UpdateFile)null, message.Response); default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateGetOperationsRequest(string filter, int? top) + internal HttpMessage CreateListOperationsRequest(string filter, int? top) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendPath("/deviceupdate/", false); uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/updates/operations", false); + uri.AppendPath("/updates/operations", false); if (filter != null) { uri.AppendQuery("$filter", filter, true); @@ -738,6 +834,7 @@ internal HttpMessage CreateGetOperationsRequest(string filter, int? top) { uri.AppendQuery("$top", top.Value, true); } + uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; @@ -747,17 +844,17 @@ internal HttpMessage CreateGetOperationsRequest(string filter, int? top) /// Restricts the set of operations returned. Only one specific filter is supported: "status eq 'NotStarted' or status eq 'Running'". /// Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n. /// The cancellation token to use. - public async Task> GetOperationsAsync(string filter = null, int? top = null, CancellationToken cancellationToken = default) + public async Task> ListOperationsAsync(string filter = null, int? top = null, CancellationToken cancellationToken = default) { - using var message = CreateGetOperationsRequest(filter, top); + using var message = CreateListOperationsRequest(filter, top); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - PageableListOfOperations value = default; + UpdateOperationsList value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfOperations.DeserializePageableListOfOperations(document.RootElement); + value = UpdateOperationsList.DeserializeUpdateOperationsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -769,17 +866,17 @@ public async Task> GetOperationsAsync(string /// Restricts the set of operations returned. Only one specific filter is supported: "status eq 'NotStarted' or status eq 'Running'". /// Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n. /// The cancellation token to use. - public Response GetOperations(string filter = null, int? top = null, CancellationToken cancellationToken = default) + public Response ListOperations(string filter = null, int? top = null, CancellationToken cancellationToken = default) { - using var message = CreateGetOperationsRequest(filter, top); + using var message = CreateListOperationsRequest(filter, top); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - PageableListOfOperations value = default; + UpdateOperationsList value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfOperations.DeserializePageableListOfOperations(document.RootElement); + value = UpdateOperationsList.DeserializeUpdateOperationsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -794,11 +891,12 @@ internal HttpMessage CreateGetOperationRequest(string operationId, AccessConditi request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendPath("/deviceupdate/", false); uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/updates/operations/", false); + uri.AppendPath("/updates/operations/", false); uri.AppendPath(operationId, true); + uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; if (accessCondition?.IfNoneMatch != null) { @@ -813,7 +911,7 @@ internal HttpMessage CreateGetOperationRequest(string operationId, AccessConditi /// Parameter group. /// The cancellation token to use. /// is null. - public async Task> GetOperationAsync(string operationId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) + public async Task> GetOperationAsync(string operationId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) { if (operationId == null) { @@ -822,18 +920,18 @@ internal HttpMessage CreateGetOperationRequest(string operationId, AccessConditi using var message = CreateGetOperationRequest(operationId, accessCondition); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - var headers = new UpdatesGetOperationHeaders(message.Response); + var headers = new DeviceUpdateGetOperationHeaders(message.Response); switch (message.Response.Status) { case 200: { - Models.Operation value = default; + UpdateOperation value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = Models.Operation.DeserializeOperation(document.RootElement); + value = UpdateOperation.DeserializeUpdateOperation(document.RootElement); return ResponseWithHeaders.FromValue(value, headers, message.Response); } case 304: - return ResponseWithHeaders.FromValue((Models.Operation)null, headers, message.Response); + return ResponseWithHeaders.FromValue((UpdateOperation)null, headers, message.Response); default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } @@ -844,7 +942,7 @@ internal HttpMessage CreateGetOperationRequest(string operationId, AccessConditi /// Parameter group. /// The cancellation token to use. /// is null. - public ResponseWithHeaders GetOperation(string operationId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) + public ResponseWithHeaders GetOperation(string operationId, AccessCondition accessCondition = null, CancellationToken cancellationToken = default) { if (operationId == null) { @@ -853,31 +951,103 @@ internal HttpMessage CreateGetOperationRequest(string operationId, AccessConditi using var message = CreateGetOperationRequest(operationId, accessCondition); _pipeline.Send(message, cancellationToken); - var headers = new UpdatesGetOperationHeaders(message.Response); + var headers = new DeviceUpdateGetOperationHeaders(message.Response); switch (message.Response.Status) { case 200: { - Models.Operation value = default; + UpdateOperation value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = Models.Operation.DeserializeOperation(document.RootElement); + value = UpdateOperation.DeserializeUpdateOperation(document.RootElement); return ResponseWithHeaders.FromValue(value, headers, message.Response); } case 304: - return ResponseWithHeaders.FromValue((Models.Operation)null, headers, message.Response); + return ResponseWithHeaders.FromValue((UpdateOperation)null, headers, message.Response); + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListUpdatesNextPageRequest(string nextLink, string search, string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.AppendRaw(endpoint, false); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + /// Get a list of all updates that have been imported to Device Update for IoT Hub. + /// The URL to the next page of results. + /// Request updates matching a free-text search expression. + /// Filter updates by its properties. + /// The cancellation token to use. + /// is null. + public async Task> ListUpdatesNextPageAsync(string nextLink, string search = null, string filter = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListUpdatesNextPageRequest(nextLink, search, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + UpdateList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = UpdateList.DeserializeUpdateList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Get a list of all updates that have been imported to Device Update for IoT Hub. + /// The URL to the next page of results. + /// Request updates matching a free-text search expression. + /// Filter updates by its properties. + /// The cancellation token to use. + /// is null. + public Response ListUpdatesNextPage(string nextLink, string search = null, string filter = null, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + + using var message = CreateListUpdatesNextPageRequest(nextLink, search, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + UpdateList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = UpdateList.DeserializeUpdateList(document.RootElement); + return Response.FromValue(value, message.Response); + } default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateGetProvidersNextPageRequest(string nextLink) + internal HttpMessage CreateListProvidersNextPageRequest(string nextLink) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendRawNextLink(nextLink, false); request.Uri = uri; request.Headers.Add("Accept", "application/json"); @@ -888,22 +1058,22 @@ internal HttpMessage CreateGetProvidersNextPageRequest(string nextLink) /// The URL to the next page of results. /// The cancellation token to use. /// is null. - public async Task> GetProvidersNextPageAsync(string nextLink, CancellationToken cancellationToken = default) + public async Task> ListProvidersNextPageAsync(string nextLink, CancellationToken cancellationToken = default) { if (nextLink == null) { throw new ArgumentNullException(nameof(nextLink)); } - using var message = CreateGetProvidersNextPageRequest(nextLink); + using var message = CreateListProvidersNextPageRequest(nextLink); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -915,22 +1085,22 @@ public async Task> GetProvidersNextPageAsync(str /// The URL to the next page of results. /// The cancellation token to use. /// is null. - public Response GetProvidersNextPage(string nextLink, CancellationToken cancellationToken = default) + public Response ListProvidersNextPage(string nextLink, CancellationToken cancellationToken = default) { if (nextLink == null) { throw new ArgumentNullException(nameof(nextLink)); } - using var message = CreateGetProvidersNextPageRequest(nextLink); + using var message = CreateListProvidersNextPageRequest(nextLink); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -938,14 +1108,14 @@ public Response GetProvidersNextPage(string nextLink, Can } } - internal HttpMessage CreateGetNamesNextPageRequest(string nextLink, string provider) + internal HttpMessage CreateListNamesNextPageRequest(string nextLink, string provider) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendRawNextLink(nextLink, false); request.Uri = uri; request.Headers.Add("Accept", "application/json"); @@ -957,7 +1127,7 @@ internal HttpMessage CreateGetNamesNextPageRequest(string nextLink, string provi /// Update provider. /// The cancellation token to use. /// or is null. - public async Task> GetNamesNextPageAsync(string nextLink, string provider, CancellationToken cancellationToken = default) + public async Task> ListNamesNextPageAsync(string nextLink, string provider, CancellationToken cancellationToken = default) { if (nextLink == null) { @@ -968,15 +1138,15 @@ public async Task> GetNamesNextPageAsync(string throw new ArgumentNullException(nameof(provider)); } - using var message = CreateGetNamesNextPageRequest(nextLink, provider); + using var message = CreateListNamesNextPageRequest(nextLink, provider); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -989,7 +1159,7 @@ public async Task> GetNamesNextPageAsync(string /// Update provider. /// The cancellation token to use. /// or is null. - public Response GetNamesNextPage(string nextLink, string provider, CancellationToken cancellationToken = default) + public Response ListNamesNextPage(string nextLink, string provider, CancellationToken cancellationToken = default) { if (nextLink == null) { @@ -1000,15 +1170,15 @@ public Response GetNamesNextPage(string nextLink, string throw new ArgumentNullException(nameof(provider)); } - using var message = CreateGetNamesNextPageRequest(nextLink, provider); + using var message = CreateListNamesNextPageRequest(nextLink, provider); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -1016,14 +1186,14 @@ public Response GetNamesNextPage(string nextLink, string } } - internal HttpMessage CreateGetVersionsNextPageRequest(string nextLink, string provider, string name) + internal HttpMessage CreateListVersionsNextPageRequest(string nextLink, string provider, string name, string filter) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendRawNextLink(nextLink, false); request.Uri = uri; request.Headers.Add("Accept", "application/json"); @@ -1034,9 +1204,10 @@ internal HttpMessage CreateGetVersionsNextPageRequest(string nextLink, string pr /// The URL to the next page of results. /// Update provider. /// Update name. + /// Filter updates by its properties. /// The cancellation token to use. /// , , or is null. - public async Task> GetVersionsNextPageAsync(string nextLink, string provider, string name, CancellationToken cancellationToken = default) + public async Task> ListVersionsNextPageAsync(string nextLink, string provider, string name, string filter = null, CancellationToken cancellationToken = default) { if (nextLink == null) { @@ -1051,15 +1222,15 @@ public async Task> GetVersionsNextPageAsync(stri throw new ArgumentNullException(nameof(name)); } - using var message = CreateGetVersionsNextPageRequest(nextLink, provider, name); + using var message = CreateListVersionsNextPageRequest(nextLink, provider, name, filter); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -1071,9 +1242,10 @@ public async Task> GetVersionsNextPageAsync(stri /// The URL to the next page of results. /// Update provider. /// Update name. + /// Filter updates by its properties. /// The cancellation token to use. /// , , or is null. - public Response GetVersionsNextPage(string nextLink, string provider, string name, CancellationToken cancellationToken = default) + public Response ListVersionsNextPage(string nextLink, string provider, string name, string filter = null, CancellationToken cancellationToken = default) { if (nextLink == null) { @@ -1088,15 +1260,15 @@ public Response GetVersionsNextPage(string nextLink, stri throw new ArgumentNullException(nameof(name)); } - using var message = CreateGetVersionsNextPageRequest(nextLink, provider, name); + using var message = CreateListVersionsNextPageRequest(nextLink, provider, name, filter); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -1104,14 +1276,14 @@ public Response GetVersionsNextPage(string nextLink, stri } } - internal HttpMessage CreateGetFilesNextPageRequest(string nextLink, string provider, string name, string version) + internal HttpMessage CreateListFilesNextPageRequest(string nextLink, string provider, string name, string version) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendRawNextLink(nextLink, false); request.Uri = uri; request.Headers.Add("Accept", "application/json"); @@ -1125,7 +1297,7 @@ internal HttpMessage CreateGetFilesNextPageRequest(string nextLink, string provi /// Update version. /// The cancellation token to use. /// , , , or is null. - public async Task> GetFilesNextPageAsync(string nextLink, string provider, string name, string version, CancellationToken cancellationToken = default) + public async Task> ListFilesNextPageAsync(string nextLink, string provider, string name, string version, CancellationToken cancellationToken = default) { if (nextLink == null) { @@ -1144,15 +1316,15 @@ public async Task> GetFilesNextPageAsync(string throw new ArgumentNullException(nameof(version)); } - using var message = CreateGetFilesNextPageRequest(nextLink, provider, name, version); + using var message = CreateListFilesNextPageRequest(nextLink, provider, name, version); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -1167,7 +1339,7 @@ public async Task> GetFilesNextPageAsync(string /// Update version. /// The cancellation token to use. /// , , , or is null. - public Response GetFilesNextPage(string nextLink, string provider, string name, string version, CancellationToken cancellationToken = default) + public Response ListFilesNextPage(string nextLink, string provider, string name, string version, CancellationToken cancellationToken = default) { if (nextLink == null) { @@ -1186,15 +1358,15 @@ public Response GetFilesNextPage(string nextLink, string throw new ArgumentNullException(nameof(version)); } - using var message = CreateGetFilesNextPageRequest(nextLink, provider, name, version); + using var message = CreateListFilesNextPageRequest(nextLink, provider, name, version); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - PageableListOfStrings value = default; + StringsList value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); + value = StringsList.DeserializeStringsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -1202,14 +1374,14 @@ public Response GetFilesNextPage(string nextLink, string } } - internal HttpMessage CreateGetOperationsNextPageRequest(string nextLink, string filter, int? top) + internal HttpMessage CreateListOperationsNextPageRequest(string nextLink, string filter, int? top) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); + uri.AppendRaw(endpoint, false); uri.AppendRawNextLink(nextLink, false); request.Uri = uri; request.Headers.Add("Accept", "application/json"); @@ -1222,22 +1394,22 @@ internal HttpMessage CreateGetOperationsNextPageRequest(string nextLink, string /// Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n. /// The cancellation token to use. /// is null. - public async Task> GetOperationsNextPageAsync(string nextLink, string filter = null, int? top = null, CancellationToken cancellationToken = default) + public async Task> ListOperationsNextPageAsync(string nextLink, string filter = null, int? top = null, CancellationToken cancellationToken = default) { if (nextLink == null) { throw new ArgumentNullException(nameof(nextLink)); } - using var message = CreateGetOperationsNextPageRequest(nextLink, filter, top); + using var message = CreateListOperationsNextPageRequest(nextLink, filter, top); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - PageableListOfOperations value = default; + UpdateOperationsList value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfOperations.DeserializePageableListOfOperations(document.RootElement); + value = UpdateOperationsList.DeserializeUpdateOperationsList(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -1251,22 +1423,22 @@ public async Task> GetOperationsNextPageAsync /// Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the specified value n. /// The cancellation token to use. /// is null. - public Response GetOperationsNextPage(string nextLink, string filter = null, int? top = null, CancellationToken cancellationToken = default) + public Response ListOperationsNextPage(string nextLink, string filter = null, int? top = null, CancellationToken cancellationToken = default) { if (nextLink == null) { throw new ArgumentNullException(nameof(nextLink)); } - using var message = CreateGetOperationsNextPageRequest(nextLink, filter, top); + using var message = CreateListOperationsNextPageRequest(nextLink, filter, top); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - PageableListOfOperations value = default; + UpdateOperationsList value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfOperations.DeserializePageableListOfOperations(document.RootElement); + value = UpdateOperationsList.DeserializeUpdateOperationsList(document.RootElement); return Response.FromValue(value, message.Response); } default: diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DevicesClient.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DevicesClient.cs deleted file mode 100644 index c99c7038a5d4d..0000000000000 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DevicesClient.cs +++ /dev/null @@ -1,889 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.IoT.DeviceUpdate.Models; - -namespace Azure.IoT.DeviceUpdate -{ - /// The Devices service client. - public partial class DevicesClient - { - private readonly ClientDiagnostics _clientDiagnostics; - private readonly HttpPipeline _pipeline; - internal DevicesRestClient RestClient { get; } - - /// Initializes a new instance of DevicesClient. - /// The handler for diagnostic messaging in the client. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Account endpoint. - /// Account instance identifier. - internal DevicesClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string accountEndpoint, string instanceId) - { - RestClient = new DevicesRestClient(clientDiagnostics, pipeline, accountEndpoint, instanceId); - _clientDiagnostics = clientDiagnostics; - _pipeline = pipeline; - } - - /// Gets the properties of a device class. - /// Device class identifier. - /// The cancellation token to use. - public virtual async Task> GetDeviceClassAsync(string deviceClassId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDeviceClass"); - scope.Start(); - try - { - return await RestClient.GetDeviceClassAsync(deviceClassId, cancellationToken).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets the properties of a device class. - /// Device class identifier. - /// The cancellation token to use. - public virtual Response GetDeviceClass(string deviceClassId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDeviceClass"); - scope.Start(); - try - { - return RestClient.GetDeviceClass(deviceClassId, cancellationToken); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets the device properties and latest deployment status for a device connected to Device Update for IoT Hub. - /// Device identifier in Azure IOT Hub. - /// The cancellation token to use. - public virtual async Task> GetDeviceAsync(string deviceId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDevice"); - scope.Start(); - try - { - return await RestClient.GetDeviceAsync(deviceId, cancellationToken).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets the device properties and latest deployment status for a device connected to Device Update for IoT Hub. - /// Device identifier in Azure IOT Hub. - /// The cancellation token to use. - public virtual Response GetDevice(string deviceId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDevice"); - scope.Start(); - try - { - return RestClient.GetDevice(deviceId, cancellationToken); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets the breakdown of how many devices are on their latest update, have new updates available, or are in progress receiving new updates. - /// The cancellation token to use. - public virtual async Task> GetUpdateComplianceAsync(CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetUpdateCompliance"); - scope.Start(); - try - { - return await RestClient.GetUpdateComplianceAsync(cancellationToken).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets the breakdown of how many devices are on their latest update, have new updates available, or are in progress receiving new updates. - /// The cancellation token to use. - public virtual Response GetUpdateCompliance(CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetUpdateCompliance"); - scope.Start(); - try - { - return RestClient.GetUpdateCompliance(cancellationToken); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets a count of how many devices have a device tag. - /// Tag name. - /// The cancellation token to use. - public virtual async Task> GetDeviceTagAsync(string tagName, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDeviceTag"); - scope.Start(); - try - { - return await RestClient.GetDeviceTagAsync(tagName, cancellationToken).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets a count of how many devices have a device tag. - /// Tag name. - /// The cancellation token to use. - public virtual Response GetDeviceTag(string tagName, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDeviceTag"); - scope.Start(); - try - { - return RestClient.GetDeviceTag(tagName, cancellationToken); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets the properties of a group. - /// Group identifier. - /// The cancellation token to use. - public virtual async Task> GetGroupAsync(string groupId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetGroup"); - scope.Start(); - try - { - return await RestClient.GetGroupAsync(groupId, cancellationToken).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets the properties of a group. - /// Group identifier. - /// The cancellation token to use. - public virtual Response GetGroup(string groupId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetGroup"); - scope.Start(); - try - { - return RestClient.GetGroup(groupId, cancellationToken); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Create or update a device group. - /// Group identifier. - /// The group properties. - /// The cancellation token to use. - public virtual async Task> CreateOrUpdateGroupAsync(string groupId, Group group, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.CreateOrUpdateGroup"); - scope.Start(); - try - { - return await RestClient.CreateOrUpdateGroupAsync(groupId, group, cancellationToken).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Create or update a device group. - /// Group identifier. - /// The group properties. - /// The cancellation token to use. - public virtual Response CreateOrUpdateGroup(string groupId, Group group, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.CreateOrUpdateGroup"); - scope.Start(); - try - { - return RestClient.CreateOrUpdateGroup(groupId, group, cancellationToken); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Deletes a device group. - /// Group identifier. - /// The cancellation token to use. - public virtual async Task DeleteGroupAsync(string groupId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.DeleteGroup"); - scope.Start(); - try - { - return await RestClient.DeleteGroupAsync(groupId, cancellationToken).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Deletes a device group. - /// Group identifier. - /// The cancellation token to use. - public virtual Response DeleteGroup(string groupId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.DeleteGroup"); - scope.Start(); - try - { - return RestClient.DeleteGroup(groupId, cancellationToken); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Get group update compliance information such as how many devices are on their latest update, how many need new updates, and how many are in progress on receiving a new update. - /// Group identifier. - /// The cancellation token to use. - public virtual async Task> GetGroupUpdateComplianceAsync(string groupId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetGroupUpdateCompliance"); - scope.Start(); - try - { - return await RestClient.GetGroupUpdateComplianceAsync(groupId, cancellationToken).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Get group update compliance information such as how many devices are on their latest update, how many need new updates, and how many are in progress on receiving a new update. - /// Group identifier. - /// The cancellation token to use. - public virtual Response GetGroupUpdateCompliance(string groupId, CancellationToken cancellationToken = default) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetGroupUpdateCompliance"); - scope.Start(); - try - { - return RestClient.GetGroupUpdateCompliance(groupId, cancellationToken); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. - /// The cancellation token to use. - public virtual AsyncPageable GetAllDeviceClassesAsync(CancellationToken cancellationToken = default) - { - async Task> FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllDeviceClasses"); - scope.Start(); - try - { - var response = await RestClient.GetAllDeviceClassesAsync(cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllDeviceClasses"); - scope.Start(); - try - { - var response = await RestClient.GetAllDeviceClassesNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. - /// The cancellation token to use. - public virtual Pageable GetAllDeviceClasses(CancellationToken cancellationToken = default) - { - Page FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllDeviceClasses"); - scope.Start(); - try - { - var response = RestClient.GetAllDeviceClasses(cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - Page NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllDeviceClasses"); - scope.Start(); - try - { - var response = RestClient.GetAllDeviceClassesNextPage(nextLink, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of device identifiers in a device class. - /// Device class identifier. - /// The cancellation token to use. - /// is null. - public virtual AsyncPageable GetDeviceClassDeviceIdsAsync(string deviceClassId, CancellationToken cancellationToken = default) - { - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - async Task> FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDeviceClassDeviceIds"); - scope.Start(); - try - { - var response = await RestClient.GetDeviceClassDeviceIdsAsync(deviceClassId, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDeviceClassDeviceIds"); - scope.Start(); - try - { - var response = await RestClient.GetDeviceClassDeviceIdsNextPageAsync(nextLink, deviceClassId, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of device identifiers in a device class. - /// Device class identifier. - /// The cancellation token to use. - /// is null. - public virtual Pageable GetDeviceClassDeviceIds(string deviceClassId, CancellationToken cancellationToken = default) - { - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - Page FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDeviceClassDeviceIds"); - scope.Start(); - try - { - var response = RestClient.GetDeviceClassDeviceIds(deviceClassId, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - Page NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDeviceClassDeviceIds"); - scope.Start(); - try - { - var response = RestClient.GetDeviceClassDeviceIdsNextPage(nextLink, deviceClassId, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of installable updates for a device class. - /// Device class identifier. - /// The cancellation token to use. - /// is null. - public virtual AsyncPageable GetDeviceClassInstallableUpdatesAsync(string deviceClassId, CancellationToken cancellationToken = default) - { - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - async Task> FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDeviceClassInstallableUpdates"); - scope.Start(); - try - { - var response = await RestClient.GetDeviceClassInstallableUpdatesAsync(deviceClassId, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDeviceClassInstallableUpdates"); - scope.Start(); - try - { - var response = await RestClient.GetDeviceClassInstallableUpdatesNextPageAsync(nextLink, deviceClassId, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of installable updates for a device class. - /// Device class identifier. - /// The cancellation token to use. - /// is null. - public virtual Pageable GetDeviceClassInstallableUpdates(string deviceClassId, CancellationToken cancellationToken = default) - { - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - Page FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDeviceClassInstallableUpdates"); - scope.Start(); - try - { - var response = RestClient.GetDeviceClassInstallableUpdates(deviceClassId, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - Page NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetDeviceClassInstallableUpdates"); - scope.Start(); - try - { - var response = RestClient.GetDeviceClassInstallableUpdatesNextPage(nextLink, deviceClassId, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of devices connected to Device Update for IoT Hub. - /// Restricts the set of devices returned. You can only filter on device GroupId. - /// The cancellation token to use. - public virtual AsyncPageable GetAllDevicesAsync(string filter = null, CancellationToken cancellationToken = default) - { - async Task> FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllDevices"); - scope.Start(); - try - { - var response = await RestClient.GetAllDevicesAsync(filter, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllDevices"); - scope.Start(); - try - { - var response = await RestClient.GetAllDevicesNextPageAsync(nextLink, filter, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of devices connected to Device Update for IoT Hub. - /// Restricts the set of devices returned. You can only filter on device GroupId. - /// The cancellation token to use. - public virtual Pageable GetAllDevices(string filter = null, CancellationToken cancellationToken = default) - { - Page FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllDevices"); - scope.Start(); - try - { - var response = RestClient.GetAllDevices(filter, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - Page NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllDevices"); - scope.Start(); - try - { - var response = RestClient.GetAllDevicesNextPage(nextLink, filter, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. - /// The cancellation token to use. - public virtual AsyncPageable GetAllDeviceTagsAsync(CancellationToken cancellationToken = default) - { - async Task> FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllDeviceTags"); - scope.Start(); - try - { - var response = await RestClient.GetAllDeviceTagsAsync(cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllDeviceTags"); - scope.Start(); - try - { - var response = await RestClient.GetAllDeviceTagsNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. - /// The cancellation token to use. - public virtual Pageable GetAllDeviceTags(CancellationToken cancellationToken = default) - { - Page FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllDeviceTags"); - scope.Start(); - try - { - var response = RestClient.GetAllDeviceTags(cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - Page NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllDeviceTags"); - scope.Start(); - try - { - var response = RestClient.GetAllDeviceTagsNextPage(nextLink, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of all device groups. - /// The cancellation token to use. - public virtual AsyncPageable GetAllGroupsAsync(CancellationToken cancellationToken = default) - { - async Task> FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllGroups"); - scope.Start(); - try - { - var response = await RestClient.GetAllGroupsAsync(cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllGroups"); - scope.Start(); - try - { - var response = await RestClient.GetAllGroupsNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Gets a list of all device groups. - /// The cancellation token to use. - public virtual Pageable GetAllGroups(CancellationToken cancellationToken = default) - { - Page FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllGroups"); - scope.Start(); - try - { - var response = RestClient.GetAllGroups(cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - Page NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetAllGroups"); - scope.Start(); - try - { - var response = RestClient.GetAllGroupsNextPage(nextLink, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Get the best available updates for a group and a count of how many devices need each update. - /// Group identifier. - /// Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. - /// The cancellation token to use. - /// is null. - public virtual AsyncPageable GetGroupBestUpdatesAsync(string groupId, string filter = null, CancellationToken cancellationToken = default) - { - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - - async Task> FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetGroupBestUpdates"); - scope.Start(); - try - { - var response = await RestClient.GetGroupBestUpdatesAsync(groupId, filter, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetGroupBestUpdates"); - scope.Start(); - try - { - var response = await RestClient.GetGroupBestUpdatesNextPageAsync(nextLink, groupId, filter, cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); - } - - /// Get the best available updates for a group and a count of how many devices need each update. - /// Group identifier. - /// Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. - /// The cancellation token to use. - /// is null. - public virtual Pageable GetGroupBestUpdates(string groupId, string filter = null, CancellationToken cancellationToken = default) - { - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - - Page FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetGroupBestUpdates"); - scope.Start(); - try - { - var response = RestClient.GetGroupBestUpdates(groupId, filter, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - Page NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("DevicesClient.GetGroupBestUpdates"); - scope.Start(); - try - { - var response = RestClient.GetGroupBestUpdatesNextPage(nextLink, groupId, filter, cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); - } - } -} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DevicesRestClient.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DevicesRestClient.cs deleted file mode 100644 index eed7f4b66a05b..0000000000000 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/DevicesRestClient.cs +++ /dev/null @@ -1,1561 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.IoT.DeviceUpdate.Models; - -namespace Azure.IoT.DeviceUpdate -{ - internal partial class DevicesRestClient - { - private string accountEndpoint; - private string instanceId; - private ClientDiagnostics _clientDiagnostics; - private HttpPipeline _pipeline; - - /// Initializes a new instance of DevicesRestClient. - /// The handler for diagnostic messaging in the client. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Account endpoint. - /// Account instance identifier. - /// or is null. - public DevicesRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string accountEndpoint, string instanceId) - { - this.accountEndpoint = accountEndpoint ?? throw new ArgumentNullException(nameof(accountEndpoint)); - this.instanceId = instanceId ?? throw new ArgumentNullException(nameof(instanceId)); - _clientDiagnostics = clientDiagnostics; - _pipeline = pipeline; - } - - internal HttpMessage CreateGetAllDeviceClassesRequest() - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/deviceclasses", false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. - /// The cancellation token to use. - public async Task> GetAllDeviceClassesAsync(CancellationToken cancellationToken = default) - { - using var message = CreateGetAllDeviceClassesRequest(); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeviceClasses value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfDeviceClasses.DeserializePageableListOfDeviceClasses(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. - /// The cancellation token to use. - public Response GetAllDeviceClasses(CancellationToken cancellationToken = default) - { - using var message = CreateGetAllDeviceClassesRequest(); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeviceClasses value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfDeviceClasses.DeserializePageableListOfDeviceClasses(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetDeviceClassRequest(string deviceClassId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/deviceclasses/", false); - uri.AppendPath(deviceClassId, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets the properties of a device class. - /// Device class identifier. - /// The cancellation token to use. - /// is null. - public async Task> GetDeviceClassAsync(string deviceClassId, CancellationToken cancellationToken = default) - { - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - using var message = CreateGetDeviceClassRequest(deviceClassId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DeviceClass value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = DeviceClass.DeserializeDeviceClass(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets the properties of a device class. - /// Device class identifier. - /// The cancellation token to use. - /// is null. - public Response GetDeviceClass(string deviceClassId, CancellationToken cancellationToken = default) - { - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - using var message = CreateGetDeviceClassRequest(deviceClassId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DeviceClass value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = DeviceClass.DeserializeDeviceClass(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetDeviceClassDeviceIdsRequest(string deviceClassId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/deviceclasses/", false); - uri.AppendPath(deviceClassId, true); - uri.AppendPath("/deviceids", false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of device identifiers in a device class. - /// Device class identifier. - /// The cancellation token to use. - /// is null. - public async Task> GetDeviceClassDeviceIdsAsync(string deviceClassId, CancellationToken cancellationToken = default) - { - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - using var message = CreateGetDeviceClassDeviceIdsRequest(deviceClassId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfStrings value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of device identifiers in a device class. - /// Device class identifier. - /// The cancellation token to use. - /// is null. - public Response GetDeviceClassDeviceIds(string deviceClassId, CancellationToken cancellationToken = default) - { - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - using var message = CreateGetDeviceClassDeviceIdsRequest(deviceClassId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfStrings value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetDeviceClassInstallableUpdatesRequest(string deviceClassId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/deviceclasses/", false); - uri.AppendPath(deviceClassId, true); - uri.AppendPath("/installableupdates", false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of installable updates for a device class. - /// Device class identifier. - /// The cancellation token to use. - /// is null. - public async Task> GetDeviceClassInstallableUpdatesAsync(string deviceClassId, CancellationToken cancellationToken = default) - { - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - using var message = CreateGetDeviceClassInstallableUpdatesRequest(deviceClassId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfUpdateIds value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfUpdateIds.DeserializePageableListOfUpdateIds(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of installable updates for a device class. - /// Device class identifier. - /// The cancellation token to use. - /// is null. - public Response GetDeviceClassInstallableUpdates(string deviceClassId, CancellationToken cancellationToken = default) - { - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - using var message = CreateGetDeviceClassInstallableUpdatesRequest(deviceClassId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfUpdateIds value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfUpdateIds.DeserializePageableListOfUpdateIds(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetAllDevicesRequest(string filter) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/devices", false); - if (filter != null) - { - uri.AppendQuery("$filter", filter, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of devices connected to Device Update for IoT Hub. - /// Restricts the set of devices returned. You can only filter on device GroupId. - /// The cancellation token to use. - public async Task> GetAllDevicesAsync(string filter = null, CancellationToken cancellationToken = default) - { - using var message = CreateGetAllDevicesRequest(filter); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDevices value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfDevices.DeserializePageableListOfDevices(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of devices connected to Device Update for IoT Hub. - /// Restricts the set of devices returned. You can only filter on device GroupId. - /// The cancellation token to use. - public Response GetAllDevices(string filter = null, CancellationToken cancellationToken = default) - { - using var message = CreateGetAllDevicesRequest(filter); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDevices value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfDevices.DeserializePageableListOfDevices(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetDeviceRequest(string deviceId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/devices/", false); - uri.AppendPath(deviceId, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets the device properties and latest deployment status for a device connected to Device Update for IoT Hub. - /// Device identifier in Azure IOT Hub. - /// The cancellation token to use. - /// is null. - public async Task> GetDeviceAsync(string deviceId, CancellationToken cancellationToken = default) - { - if (deviceId == null) - { - throw new ArgumentNullException(nameof(deviceId)); - } - - using var message = CreateGetDeviceRequest(deviceId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - Device value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = Device.DeserializeDevice(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets the device properties and latest deployment status for a device connected to Device Update for IoT Hub. - /// Device identifier in Azure IOT Hub. - /// The cancellation token to use. - /// is null. - public Response GetDevice(string deviceId, CancellationToken cancellationToken = default) - { - if (deviceId == null) - { - throw new ArgumentNullException(nameof(deviceId)); - } - - using var message = CreateGetDeviceRequest(deviceId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - Device value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = Device.DeserializeDevice(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetUpdateComplianceRequest() - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/updatecompliance", false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets the breakdown of how many devices are on their latest update, have new updates available, or are in progress receiving new updates. - /// The cancellation token to use. - public async Task> GetUpdateComplianceAsync(CancellationToken cancellationToken = default) - { - using var message = CreateGetUpdateComplianceRequest(); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - UpdateCompliance value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = UpdateCompliance.DeserializeUpdateCompliance(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets the breakdown of how many devices are on their latest update, have new updates available, or are in progress receiving new updates. - /// The cancellation token to use. - public Response GetUpdateCompliance(CancellationToken cancellationToken = default) - { - using var message = CreateGetUpdateComplianceRequest(); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - UpdateCompliance value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = UpdateCompliance.DeserializeUpdateCompliance(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetAllDeviceTagsRequest() - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/devicetags", false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. - /// The cancellation token to use. - public async Task> GetAllDeviceTagsAsync(CancellationToken cancellationToken = default) - { - using var message = CreateGetAllDeviceTagsRequest(); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeviceTags value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfDeviceTags.DeserializePageableListOfDeviceTags(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. - /// The cancellation token to use. - public Response GetAllDeviceTags(CancellationToken cancellationToken = default) - { - using var message = CreateGetAllDeviceTagsRequest(); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeviceTags value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfDeviceTags.DeserializePageableListOfDeviceTags(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetDeviceTagRequest(string tagName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/devicetags/", false); - uri.AppendPath(tagName, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a count of how many devices have a device tag. - /// Tag name. - /// The cancellation token to use. - /// is null. - public async Task> GetDeviceTagAsync(string tagName, CancellationToken cancellationToken = default) - { - if (tagName == null) - { - throw new ArgumentNullException(nameof(tagName)); - } - - using var message = CreateGetDeviceTagRequest(tagName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DeviceTag value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = DeviceTag.DeserializeDeviceTag(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a count of how many devices have a device tag. - /// Tag name. - /// The cancellation token to use. - /// is null. - public Response GetDeviceTag(string tagName, CancellationToken cancellationToken = default) - { - if (tagName == null) - { - throw new ArgumentNullException(nameof(tagName)); - } - - using var message = CreateGetDeviceTagRequest(tagName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DeviceTag value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = DeviceTag.DeserializeDeviceTag(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetAllGroupsRequest() - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/groups", false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of all device groups. - /// The cancellation token to use. - public async Task> GetAllGroupsAsync(CancellationToken cancellationToken = default) - { - using var message = CreateGetAllGroupsRequest(); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfGroups value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfGroups.DeserializePageableListOfGroups(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of all device groups. - /// The cancellation token to use. - public Response GetAllGroups(CancellationToken cancellationToken = default) - { - using var message = CreateGetAllGroupsRequest(); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfGroups value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfGroups.DeserializePageableListOfGroups(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetGroupRequest(string groupId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/groups/", false); - uri.AppendPath(groupId, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets the properties of a group. - /// Group identifier. - /// The cancellation token to use. - /// is null. - public async Task> GetGroupAsync(string groupId, CancellationToken cancellationToken = default) - { - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - - using var message = CreateGetGroupRequest(groupId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - Group value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = Group.DeserializeGroup(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets the properties of a group. - /// Group identifier. - /// The cancellation token to use. - /// is null. - public Response GetGroup(string groupId, CancellationToken cancellationToken = default) - { - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - - using var message = CreateGetGroupRequest(groupId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - Group value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = Group.DeserializeGroup(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateCreateOrUpdateGroupRequest(string groupId, Group group) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/groups/", false); - uri.AppendPath(groupId, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(group); - request.Content = content; - return message; - } - - /// Create or update a device group. - /// Group identifier. - /// The group properties. - /// The cancellation token to use. - /// or is null. - public async Task> CreateOrUpdateGroupAsync(string groupId, Group group, CancellationToken cancellationToken = default) - { - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - if (group == null) - { - throw new ArgumentNullException(nameof(group)); - } - - using var message = CreateCreateOrUpdateGroupRequest(groupId, group); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - Group value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = Group.DeserializeGroup(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Create or update a device group. - /// Group identifier. - /// The group properties. - /// The cancellation token to use. - /// or is null. - public Response CreateOrUpdateGroup(string groupId, Group group, CancellationToken cancellationToken = default) - { - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - if (group == null) - { - throw new ArgumentNullException(nameof(group)); - } - - using var message = CreateCreateOrUpdateGroupRequest(groupId, group); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - Group value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = Group.DeserializeGroup(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateDeleteGroupRequest(string groupId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/groups/", false); - uri.AppendPath(groupId, true); - request.Uri = uri; - return message; - } - - /// Deletes a device group. - /// Group identifier. - /// The cancellation token to use. - /// is null. - public async Task DeleteGroupAsync(string groupId, CancellationToken cancellationToken = default) - { - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - - using var message = CreateDeleteGroupRequest(groupId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Deletes a device group. - /// Group identifier. - /// The cancellation token to use. - /// is null. - public Response DeleteGroup(string groupId, CancellationToken cancellationToken = default) - { - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - - using var message = CreateDeleteGroupRequest(groupId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetGroupUpdateComplianceRequest(string groupId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/groups/", false); - uri.AppendPath(groupId, true); - uri.AppendPath("/updateCompliance", false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Get group update compliance information such as how many devices are on their latest update, how many need new updates, and how many are in progress on receiving a new update. - /// Group identifier. - /// The cancellation token to use. - /// is null. - public async Task> GetGroupUpdateComplianceAsync(string groupId, CancellationToken cancellationToken = default) - { - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - - using var message = CreateGetGroupUpdateComplianceRequest(groupId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - UpdateCompliance value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = UpdateCompliance.DeserializeUpdateCompliance(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Get group update compliance information such as how many devices are on their latest update, how many need new updates, and how many are in progress on receiving a new update. - /// Group identifier. - /// The cancellation token to use. - /// is null. - public Response GetGroupUpdateCompliance(string groupId, CancellationToken cancellationToken = default) - { - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - - using var message = CreateGetGroupUpdateComplianceRequest(groupId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - UpdateCompliance value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = UpdateCompliance.DeserializeUpdateCompliance(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetGroupBestUpdatesRequest(string groupId, string filter) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendPath("/deviceupdate/", false); - uri.AppendPath(instanceId, false); - uri.AppendPath("/v2/management/groups/", false); - uri.AppendPath(groupId, true); - uri.AppendPath("/bestUpdates", false); - if (filter != null) - { - uri.AppendQuery("$filter", filter, true); - } - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Get the best available updates for a group and a count of how many devices need each update. - /// Group identifier. - /// Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. - /// The cancellation token to use. - /// is null. - public async Task> GetGroupBestUpdatesAsync(string groupId, string filter = null, CancellationToken cancellationToken = default) - { - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - - using var message = CreateGetGroupBestUpdatesRequest(groupId, filter); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfUpdatableDevices value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfUpdatableDevices.DeserializePageableListOfUpdatableDevices(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Get the best available updates for a group and a count of how many devices need each update. - /// Group identifier. - /// Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. - /// The cancellation token to use. - /// is null. - public Response GetGroupBestUpdates(string groupId, string filter = null, CancellationToken cancellationToken = default) - { - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - - using var message = CreateGetGroupBestUpdatesRequest(groupId, filter); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfUpdatableDevices value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfUpdatableDevices.DeserializePageableListOfUpdatableDevices(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetAllDeviceClassesNextPageRequest(string nextLink) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. - /// The URL to the next page of results. - /// The cancellation token to use. - /// is null. - public async Task> GetAllDeviceClassesNextPageAsync(string nextLink, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - - using var message = CreateGetAllDeviceClassesNextPageRequest(nextLink); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeviceClasses value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfDeviceClasses.DeserializePageableListOfDeviceClasses(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. - /// The URL to the next page of results. - /// The cancellation token to use. - /// is null. - public Response GetAllDeviceClassesNextPage(string nextLink, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - - using var message = CreateGetAllDeviceClassesNextPageRequest(nextLink); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeviceClasses value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfDeviceClasses.DeserializePageableListOfDeviceClasses(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetDeviceClassDeviceIdsNextPageRequest(string nextLink, string deviceClassId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of device identifiers in a device class. - /// The URL to the next page of results. - /// Device class identifier. - /// The cancellation token to use. - /// or is null. - public async Task> GetDeviceClassDeviceIdsNextPageAsync(string nextLink, string deviceClassId, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - using var message = CreateGetDeviceClassDeviceIdsNextPageRequest(nextLink, deviceClassId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfStrings value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of device identifiers in a device class. - /// The URL to the next page of results. - /// Device class identifier. - /// The cancellation token to use. - /// or is null. - public Response GetDeviceClassDeviceIdsNextPage(string nextLink, string deviceClassId, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - using var message = CreateGetDeviceClassDeviceIdsNextPageRequest(nextLink, deviceClassId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfStrings value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfStrings.DeserializePageableListOfStrings(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetDeviceClassInstallableUpdatesNextPageRequest(string nextLink, string deviceClassId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of installable updates for a device class. - /// The URL to the next page of results. - /// Device class identifier. - /// The cancellation token to use. - /// or is null. - public async Task> GetDeviceClassInstallableUpdatesNextPageAsync(string nextLink, string deviceClassId, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - using var message = CreateGetDeviceClassInstallableUpdatesNextPageRequest(nextLink, deviceClassId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfUpdateIds value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfUpdateIds.DeserializePageableListOfUpdateIds(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of installable updates for a device class. - /// The URL to the next page of results. - /// Device class identifier. - /// The cancellation token to use. - /// or is null. - public Response GetDeviceClassInstallableUpdatesNextPage(string nextLink, string deviceClassId, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - if (deviceClassId == null) - { - throw new ArgumentNullException(nameof(deviceClassId)); - } - - using var message = CreateGetDeviceClassInstallableUpdatesNextPageRequest(nextLink, deviceClassId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfUpdateIds value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfUpdateIds.DeserializePageableListOfUpdateIds(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetAllDevicesNextPageRequest(string nextLink, string filter) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of devices connected to Device Update for IoT Hub. - /// The URL to the next page of results. - /// Restricts the set of devices returned. You can only filter on device GroupId. - /// The cancellation token to use. - /// is null. - public async Task> GetAllDevicesNextPageAsync(string nextLink, string filter = null, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - - using var message = CreateGetAllDevicesNextPageRequest(nextLink, filter); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDevices value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfDevices.DeserializePageableListOfDevices(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of devices connected to Device Update for IoT Hub. - /// The URL to the next page of results. - /// Restricts the set of devices returned. You can only filter on device GroupId. - /// The cancellation token to use. - /// is null. - public Response GetAllDevicesNextPage(string nextLink, string filter = null, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - - using var message = CreateGetAllDevicesNextPageRequest(nextLink, filter); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDevices value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfDevices.DeserializePageableListOfDevices(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetAllDeviceTagsNextPageRequest(string nextLink) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. - /// The URL to the next page of results. - /// The cancellation token to use. - /// is null. - public async Task> GetAllDeviceTagsNextPageAsync(string nextLink, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - - using var message = CreateGetAllDeviceTagsNextPageRequest(nextLink); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeviceTags value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfDeviceTags.DeserializePageableListOfDeviceTags(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. - /// The URL to the next page of results. - /// The cancellation token to use. - /// is null. - public Response GetAllDeviceTagsNextPage(string nextLink, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - - using var message = CreateGetAllDeviceTagsNextPageRequest(nextLink); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfDeviceTags value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfDeviceTags.DeserializePageableListOfDeviceTags(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetAllGroupsNextPageRequest(string nextLink) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Gets a list of all device groups. - /// The URL to the next page of results. - /// The cancellation token to use. - /// is null. - public async Task> GetAllGroupsNextPageAsync(string nextLink, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - - using var message = CreateGetAllGroupsNextPageRequest(nextLink); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfGroups value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfGroups.DeserializePageableListOfGroups(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a list of all device groups. - /// The URL to the next page of results. - /// The cancellation token to use. - /// is null. - public Response GetAllGroupsNextPage(string nextLink, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - - using var message = CreateGetAllGroupsNextPageRequest(nextLink); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfGroups value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfGroups.DeserializePageableListOfGroups(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetGroupBestUpdatesNextPageRequest(string nextLink, string groupId, string filter) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw("https://", false); - uri.AppendRaw(accountEndpoint, false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Get the best available updates for a group and a count of how many devices need each update. - /// The URL to the next page of results. - /// Group identifier. - /// Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. - /// The cancellation token to use. - /// or is null. - public async Task> GetGroupBestUpdatesNextPageAsync(string nextLink, string groupId, string filter = null, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - - using var message = CreateGetGroupBestUpdatesNextPageRequest(nextLink, groupId, filter); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PageableListOfUpdatableDevices value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PageableListOfUpdatableDevices.DeserializePageableListOfUpdatableDevices(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Get the best available updates for a group and a count of how many devices need each update. - /// The URL to the next page of results. - /// Group identifier. - /// Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. - /// The cancellation token to use. - /// or is null. - public Response GetGroupBestUpdatesNextPage(string nextLink, string groupId, string filter = null, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - if (groupId == null) - { - throw new ArgumentNullException(nameof(groupId)); - } - - using var message = CreateGetGroupBestUpdatesNextPageRequest(nextLink, groupId, filter); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PageableListOfUpdatableDevices value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PageableListOfUpdatableDevices.DeserializePageableListOfUpdatableDevices(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - } -} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Compatibility.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Compatibility.Serialization.cs deleted file mode 100644 index 3cba66223c8fb..0000000000000 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Compatibility.Serialization.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.IoT.DeviceUpdate.Models -{ - public partial class Compatibility - { - internal static Compatibility DeserializeCompatibility(JsonElement element) - { - string deviceManufacturer = default; - string deviceModel = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("deviceManufacturer")) - { - deviceManufacturer = property.Value.GetString(); - continue; - } - if (property.NameEquals("deviceModel")) - { - deviceModel = property.Value.GetString(); - continue; - } - } - return new Compatibility(deviceManufacturer, deviceModel); - } - } -} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Compatibility.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Compatibility.cs deleted file mode 100644 index e2c1faddaf1a0..0000000000000 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Compatibility.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; - -namespace Azure.IoT.DeviceUpdate.Models -{ - /// Update compatibility information. - public partial class Compatibility - { - /// Initializes a new instance of Compatibility. - /// The manufacturer of device the update is compatible with. - /// The model of device the update is compatible with. - /// or is null. - internal Compatibility(string deviceManufacturer, string deviceModel) - { - if (deviceManufacturer == null) - { - throw new ArgumentNullException(nameof(deviceManufacturer)); - } - if (deviceModel == null) - { - throw new ArgumentNullException(nameof(deviceModel)); - } - - DeviceManufacturer = deviceManufacturer; - DeviceModel = deviceModel; - } - - /// The manufacturer of device the update is compatible with. - public string DeviceManufacturer { get; } - /// The model of device the update is compatible with. - public string DeviceModel { get; } - } -} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Deployment.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Deployment.Serialization.cs index 87a1b735c1993..216b8c71d64f3 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Deployment.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Deployment.Serialization.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Text.Json; using Azure.Core; @@ -19,26 +18,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartObject(); writer.WritePropertyName("deploymentId"); writer.WriteStringValue(DeploymentId); - writer.WritePropertyName("deploymentType"); - writer.WriteStringValue(DeploymentType.ToString()); - if (Optional.IsDefined(DeviceClassId)) - { - writer.WritePropertyName("deviceClassId"); - writer.WriteStringValue(DeviceClassId); - } writer.WritePropertyName("startDateTime"); writer.WriteStringValue(StartDateTime, "O"); - writer.WritePropertyName("deviceGroupType"); - writer.WriteStringValue(DeviceGroupType.ToString()); - writer.WritePropertyName("deviceGroupDefinition"); - writer.WriteStartArray(); - foreach (var item in DeviceGroupDefinition) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); writer.WritePropertyName("updateId"); writer.WriteObjectValue(UpdateId); + writer.WritePropertyName("groupId"); + writer.WriteStringValue(GroupId); if (Optional.IsDefined(IsCanceled)) { writer.WritePropertyName("isCanceled"); @@ -49,26 +34,17 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("isRetried"); writer.WriteBooleanValue(IsRetried.Value); } - if (Optional.IsDefined(IsCompleted)) - { - writer.WritePropertyName("isCompleted"); - writer.WriteBooleanValue(IsCompleted.Value); - } writer.WriteEndObject(); } internal static Deployment DeserializeDeployment(JsonElement element) { string deploymentId = default; - DeploymentType deploymentType = default; - Optional deviceClassId = default; DateTimeOffset startDateTime = default; - DeviceGroupType deviceGroupType = default; - IList deviceGroupDefinition = default; UpdateId updateId = default; + string groupId = default; Optional isCanceled = default; Optional isRetried = default; - Optional isCompleted = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("deploymentId")) @@ -76,39 +52,19 @@ internal static Deployment DeserializeDeployment(JsonElement element) deploymentId = property.Value.GetString(); continue; } - if (property.NameEquals("deploymentType")) - { - deploymentType = new DeploymentType(property.Value.GetString()); - continue; - } - if (property.NameEquals("deviceClassId")) - { - deviceClassId = property.Value.GetString(); - continue; - } if (property.NameEquals("startDateTime")) { startDateTime = property.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("deviceGroupType")) - { - deviceGroupType = new DeviceGroupType(property.Value.GetString()); - continue; - } - if (property.NameEquals("deviceGroupDefinition")) + if (property.NameEquals("updateId")) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - deviceGroupDefinition = array; + updateId = UpdateId.DeserializeUpdateId(property.Value); continue; } - if (property.NameEquals("updateId")) + if (property.NameEquals("groupId")) { - updateId = UpdateId.DeserializeUpdateId(property.Value); + groupId = property.Value.GetString(); continue; } if (property.NameEquals("isCanceled")) @@ -131,18 +87,8 @@ internal static Deployment DeserializeDeployment(JsonElement element) isRetried = property.Value.GetBoolean(); continue; } - if (property.NameEquals("isCompleted")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } - isCompleted = property.Value.GetBoolean(); - continue; - } } - return new Deployment(deploymentId, deploymentType, deviceClassId.Value, startDateTime, deviceGroupType, deviceGroupDefinition, updateId, Optional.ToNullable(isCanceled), Optional.ToNullable(isRetried), Optional.ToNullable(isCompleted)); + return new Deployment(deploymentId, startDateTime, updateId, groupId, Optional.ToNullable(isCanceled), Optional.ToNullable(isRetried)); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Deployment.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Deployment.cs index 09b7b7f38a7e9..5b728b99d01e6 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Deployment.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Deployment.cs @@ -6,8 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; -using System.Linq; namespace Azure.IoT.DeviceUpdate.Models { @@ -15,80 +13,60 @@ namespace Azure.IoT.DeviceUpdate.Models public partial class Deployment { /// Initializes a new instance of Deployment. - /// Gets or sets the deployment identifier. - /// Gets or sets the deployment type. - /// Gets or sets the Deployment start datetime. - /// Gets or sets the device group type. - /// Gets or sets the device group definition. + /// The deployment identifier. + /// The deployment start datetime. /// Update identity. - /// , , or is null. - public Deployment(string deploymentId, DeploymentType deploymentType, DateTimeOffset startDateTime, DeviceGroupType deviceGroupType, IEnumerable deviceGroupDefinition, UpdateId updateId) + /// The group identity. + /// , , or is null. + public Deployment(string deploymentId, DateTimeOffset startDateTime, UpdateId updateId, string groupId) { if (deploymentId == null) { throw new ArgumentNullException(nameof(deploymentId)); } - if (deviceGroupDefinition == null) - { - throw new ArgumentNullException(nameof(deviceGroupDefinition)); - } if (updateId == null) { throw new ArgumentNullException(nameof(updateId)); } + if (groupId == null) + { + throw new ArgumentNullException(nameof(groupId)); + } DeploymentId = deploymentId; - DeploymentType = deploymentType; StartDateTime = startDateTime; - DeviceGroupType = deviceGroupType; - DeviceGroupDefinition = deviceGroupDefinition.ToList(); UpdateId = updateId; + GroupId = groupId; } /// Initializes a new instance of Deployment. - /// Gets or sets the deployment identifier. - /// Gets or sets the deployment type. - /// Gets or sets the device class identifier. - /// Gets or sets the Deployment start datetime. - /// Gets or sets the device group type. - /// Gets or sets the device group definition. + /// The deployment identifier. + /// The deployment start datetime. /// Update identity. + /// The group identity. /// Boolean flag indicating whether the deployment was canceled. /// Boolean flag indicating whether the deployment has been retried. - /// Boolean flag indicating whether the deployment was completed. - internal Deployment(string deploymentId, DeploymentType deploymentType, string deviceClassId, DateTimeOffset startDateTime, DeviceGroupType deviceGroupType, IList deviceGroupDefinition, UpdateId updateId, bool? isCanceled, bool? isRetried, bool? isCompleted) + internal Deployment(string deploymentId, DateTimeOffset startDateTime, UpdateId updateId, string groupId, bool? isCanceled, bool? isRetried) { DeploymentId = deploymentId; - DeploymentType = deploymentType; - DeviceClassId = deviceClassId; StartDateTime = startDateTime; - DeviceGroupType = deviceGroupType; - DeviceGroupDefinition = deviceGroupDefinition; UpdateId = updateId; + GroupId = groupId; IsCanceled = isCanceled; IsRetried = isRetried; - IsCompleted = isCompleted; } - /// Gets or sets the deployment identifier. + /// The deployment identifier. public string DeploymentId { get; set; } - /// Gets or sets the deployment type. - public DeploymentType DeploymentType { get; set; } - /// Gets or sets the device class identifier. - public string DeviceClassId { get; set; } - /// Gets or sets the Deployment start datetime. + /// The deployment start datetime. public DateTimeOffset StartDateTime { get; set; } - /// Gets or sets the device group type. - public DeviceGroupType DeviceGroupType { get; set; } - /// Gets or sets the device group definition. - public IList DeviceGroupDefinition { get; } /// Update identity. public UpdateId UpdateId { get; set; } + /// The group identity. + public string GroupId { get; set; } /// Boolean flag indicating whether the deployment was canceled. public bool? IsCanceled { get; set; } /// Boolean flag indicating whether the deployment has been retried. public bool? IsRetried { get; set; } - /// Boolean flag indicating whether the deployment was completed. - public bool? IsCompleted { get; set; } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentCancelAction.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentCancelAction.cs new file mode 100644 index 0000000000000..d8a847b8aeebf --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentCancelAction.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// The DeploymentCancelAction. + public readonly partial struct DeploymentCancelAction : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DeploymentCancelAction(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CancelValue = "cancel"; + + /// Cancel action. + public static DeploymentCancelAction Cancel { get; } = new DeploymentCancelAction(CancelValue); + /// Determines if two values are the same. + public static bool operator ==(DeploymentCancelAction left, DeploymentCancelAction right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DeploymentCancelAction left, DeploymentCancelAction right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DeploymentCancelAction(string value) => new DeploymentCancelAction(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DeploymentCancelAction other && Equals(other); + /// + public bool Equals(DeploymentCancelAction other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceState.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceState.Serialization.cs index ee98e9a085b5b..364a790d3c8cf 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceState.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceState.Serialization.cs @@ -15,6 +15,7 @@ public partial class DeploymentDeviceState internal static DeploymentDeviceState DeserializeDeploymentDeviceState(JsonElement element) { string deviceId = default; + Optional moduleId = default; int retryCount = default; bool movedOnToNewDeployment = default; DeviceDeploymentState deviceState = default; @@ -25,6 +26,11 @@ internal static DeploymentDeviceState DeserializeDeploymentDeviceState(JsonEleme deviceId = property.Value.GetString(); continue; } + if (property.NameEquals("moduleId")) + { + moduleId = property.Value.GetString(); + continue; + } if (property.NameEquals("retryCount")) { retryCount = property.Value.GetInt32(); @@ -41,7 +47,7 @@ internal static DeploymentDeviceState DeserializeDeploymentDeviceState(JsonEleme continue; } } - return new DeploymentDeviceState(deviceId, retryCount, movedOnToNewDeployment, deviceState); + return new DeploymentDeviceState(deviceId, moduleId.Value, retryCount, movedOnToNewDeployment, deviceState); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceState.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceState.cs index c8bd09ffebf62..14cb9090ede9d 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceState.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceState.cs @@ -31,8 +31,25 @@ internal DeploymentDeviceState(string deviceId, int retryCount, bool movedOnToNe DeviceState = deviceState; } + /// Initializes a new instance of DeploymentDeviceState. + /// Device identity. + /// Device module identity. + /// The number of times this deployment has been retried on this device. + /// Boolean flag indicating whether this device is in a newer deployment and can no longer retry this deployment. + /// Deployment device state. + internal DeploymentDeviceState(string deviceId, string moduleId, int retryCount, bool movedOnToNewDeployment, DeviceDeploymentState deviceState) + { + DeviceId = deviceId; + ModuleId = moduleId; + RetryCount = retryCount; + MovedOnToNewDeployment = movedOnToNewDeployment; + DeviceState = deviceState; + } + /// Device identity. public string DeviceId { get; } + /// Device module identity. + public string ModuleId { get; } /// The number of times this deployment has been retried on this device. public int RetryCount { get; } /// Boolean flag indicating whether this device is in a newer deployment and can no longer retry this deployment. diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceStatesFilter.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceStatesFilter.cs index b2969013bc920..84ec00881d0c6 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceStatesFilter.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceStatesFilter.cs @@ -17,6 +17,8 @@ internal DeploymentDeviceStatesFilter() /// Device Identifier. public string DeviceId { get; } + /// Device module Identifier. + public string ModuleId { get; } /// The deployment device state. public DeviceState? DeviceState { get; } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeploymentDeviceStates.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceStatesList.Serialization.cs similarity index 64% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeploymentDeviceStates.Serialization.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceStatesList.Serialization.cs index f3054503f47eb..77013c82b7699 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeploymentDeviceStates.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceStatesList.Serialization.cs @@ -11,21 +11,16 @@ namespace Azure.IoT.DeviceUpdate.Models { - internal partial class PageableListOfDeploymentDeviceStates + internal partial class DeploymentDeviceStatesList { - internal static PageableListOfDeploymentDeviceStates DeserializePageableListOfDeploymentDeviceStates(JsonElement element) + internal static DeploymentDeviceStatesList DeserializeDeploymentDeviceStatesList(JsonElement element) { - Optional> value = default; + IReadOnlyList value = default; Optional nextLink = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -40,7 +35,7 @@ internal static PageableListOfDeploymentDeviceStates DeserializePageableListOfDe continue; } } - return new PageableListOfDeploymentDeviceStates(Optional.ToList(value), nextLink.Value); + return new DeploymentDeviceStatesList(value, nextLink.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeploymentDeviceStates.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceStatesList.cs similarity index 50% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeploymentDeviceStates.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceStatesList.cs index fcaf3e5210448..d158436565d61 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeploymentDeviceStates.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentDeviceStatesList.cs @@ -5,24 +5,32 @@ #nullable disable +using System; using System.Collections.Generic; -using Azure.Core; +using System.Linq; namespace Azure.IoT.DeviceUpdate.Models { /// The list of deployment device states. - internal partial class PageableListOfDeploymentDeviceStates + internal partial class DeploymentDeviceStatesList { - /// Initializes a new instance of PageableListOfDeploymentDeviceStates. - internal PageableListOfDeploymentDeviceStates() + /// Initializes a new instance of DeploymentDeviceStatesList. + /// The collection of pageable items. + /// is null. + internal DeploymentDeviceStatesList(IEnumerable value) { - Value = new ChangeTrackingList(); + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); } - /// Initializes a new instance of PageableListOfDeploymentDeviceStates. + /// Initializes a new instance of DeploymentDeviceStatesList. /// The collection of pageable items. /// The link to the next page of items. - internal PageableListOfDeploymentDeviceStates(IReadOnlyList value, string nextLink) + internal DeploymentDeviceStatesList(IReadOnlyList value, string nextLink) { Value = value; NextLink = nextLink; diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentRetryAction.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentRetryAction.cs new file mode 100644 index 0000000000000..ae2e309c63b77 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentRetryAction.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// The DeploymentRetryAction. + public readonly partial struct DeploymentRetryAction : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DeploymentRetryAction(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string RetryValue = "retry"; + + /// Retry action. + public static DeploymentRetryAction Retry { get; } = new DeploymentRetryAction(RetryValue); + /// Determines if two values are the same. + public static bool operator ==(DeploymentRetryAction left, DeploymentRetryAction right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DeploymentRetryAction left, DeploymentRetryAction right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DeploymentRetryAction(string value) => new DeploymentRetryAction(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DeploymentRetryAction other && Equals(other); + /// + public bool Equals(DeploymentRetryAction other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentState.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentState.cs index 4bba270aac2f9..00f82c32275ce 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentState.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentState.cs @@ -23,13 +23,13 @@ public DeploymentState(string value) } private const string ActiveValue = "Active"; - private const string SupersededValue = "Superseded"; + private const string InactiveValue = "Inactive"; private const string CanceledValue = "Canceled"; /// The deployment can be sent to devices targeted in the deployment. public static DeploymentState Active { get; } = new DeploymentState(ActiveValue); - /// A newer deployment with the same targeting exists and no devices will receive this deployment. - public static DeploymentState Superseded { get; } = new DeploymentState(SupersededValue); + /// A newer deployment for this group has been created and no devices in the group will receive this deployment. + public static DeploymentState Inactive { get; } = new DeploymentState(InactiveValue); /// The deployment has been canceled and no devices will receive it. public static DeploymentState Canceled { get; } = new DeploymentState(CanceledValue); /// Determines if two values are the same. diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentStatus.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentStatus.Serialization.cs index b3fa65f8c0f0a..83dcca9a97d85 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentStatus.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentStatus.Serialization.cs @@ -16,7 +16,6 @@ internal static DeploymentStatus DeserializeDeploymentStatus(JsonElement element { DeploymentState deploymentState = default; Optional totalDevices = default; - Optional devicesIncompatibleCount = default; Optional devicesInProgressCount = default; Optional devicesCompletedFailedCount = default; Optional devicesCompletedSucceededCount = default; @@ -38,16 +37,6 @@ internal static DeploymentStatus DeserializeDeploymentStatus(JsonElement element totalDevices = property.Value.GetInt32(); continue; } - if (property.NameEquals("devicesIncompatibleCount")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } - devicesIncompatibleCount = property.Value.GetInt32(); - continue; - } if (property.NameEquals("devicesInProgressCount")) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -89,7 +78,7 @@ internal static DeploymentStatus DeserializeDeploymentStatus(JsonElement element continue; } } - return new DeploymentStatus(deploymentState, Optional.ToNullable(totalDevices), Optional.ToNullable(devicesIncompatibleCount), Optional.ToNullable(devicesInProgressCount), Optional.ToNullable(devicesCompletedFailedCount), Optional.ToNullable(devicesCompletedSucceededCount), Optional.ToNullable(devicesCanceledCount)); + return new DeploymentStatus(deploymentState, Optional.ToNullable(totalDevices), Optional.ToNullable(devicesInProgressCount), Optional.ToNullable(devicesCompletedFailedCount), Optional.ToNullable(devicesCompletedSucceededCount), Optional.ToNullable(devicesCanceledCount)); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentStatus.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentStatus.cs index 29b1f3c2a87d0..c91a0dd274e37 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentStatus.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentStatus.cs @@ -11,44 +11,40 @@ namespace Azure.IoT.DeviceUpdate.Models public partial class DeploymentStatus { /// Initializes a new instance of DeploymentStatus. - /// Gets or sets the state of the deployment. + /// The state of the deployment. internal DeploymentStatus(DeploymentState deploymentState) { DeploymentState = deploymentState; } /// Initializes a new instance of DeploymentStatus. - /// Gets or sets the state of the deployment. - /// Gets or sets the total number of devices in the deployment. - /// Gets or sets the number of incompatible devices in the deployment. - /// Gets or sets the number of devices that are currently in deployment. - /// Gets or sets the number of devices that have completed deployment with a failure. - /// Gets or sets the number of devices which have successfully completed deployment. - /// Gets or sets the number of devices which have had their deployment canceled. - internal DeploymentStatus(DeploymentState deploymentState, int? totalDevices, int? devicesIncompatibleCount, int? devicesInProgressCount, int? devicesCompletedFailedCount, int? devicesCompletedSucceededCount, int? devicesCanceledCount) + /// The state of the deployment. + /// The total number of devices in the deployment. + /// The number of devices that are currently in deployment. + /// The number of devices that have completed deployment with a failure. + /// The number of devices which have successfully completed deployment. + /// The number of devices which have had their deployment canceled. + internal DeploymentStatus(DeploymentState deploymentState, int? totalDevices, int? devicesInProgressCount, int? devicesCompletedFailedCount, int? devicesCompletedSucceededCount, int? devicesCanceledCount) { DeploymentState = deploymentState; TotalDevices = totalDevices; - DevicesIncompatibleCount = devicesIncompatibleCount; DevicesInProgressCount = devicesInProgressCount; DevicesCompletedFailedCount = devicesCompletedFailedCount; DevicesCompletedSucceededCount = devicesCompletedSucceededCount; DevicesCanceledCount = devicesCanceledCount; } - /// Gets or sets the state of the deployment. + /// The state of the deployment. public DeploymentState DeploymentState { get; } - /// Gets or sets the total number of devices in the deployment. + /// The total number of devices in the deployment. public int? TotalDevices { get; } - /// Gets or sets the number of incompatible devices in the deployment. - public int? DevicesIncompatibleCount { get; } - /// Gets or sets the number of devices that are currently in deployment. + /// The number of devices that are currently in deployment. public int? DevicesInProgressCount { get; } - /// Gets or sets the number of devices that have completed deployment with a failure. + /// The number of devices that have completed deployment with a failure. public int? DevicesCompletedFailedCount { get; } - /// Gets or sets the number of devices which have successfully completed deployment. + /// The number of devices which have successfully completed deployment. public int? DevicesCompletedSucceededCount { get; } - /// Gets or sets the number of devices which have had their deployment canceled. + /// The number of devices which have had their deployment canceled. public int? DevicesCanceledCount { get; } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentType.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentType.cs deleted file mode 100644 index 8eb727074f62f..0000000000000 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentType.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.IoT.DeviceUpdate.Models -{ - /// Supported deployment types. - public readonly partial struct DeploymentType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public DeploymentType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string CompleteValue = "Complete"; - private const string DownloadValue = "Download"; - private const string InstallValue = "Install"; - - /// A complete deployment including download, install, and apply actions. - public static DeploymentType Complete { get; } = new DeploymentType(CompleteValue); - /// A download-only deployment that does not include any install or apply actions. Not currently supported. - public static DeploymentType Download { get; } = new DeploymentType(DownloadValue); - /// An install-only rollout that does not include any download actions, only install and complete. Not currently supported. - public static DeploymentType Install { get; } = new DeploymentType(InstallValue); - /// Determines if two values are the same. - public static bool operator ==(DeploymentType left, DeploymentType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(DeploymentType left, DeploymentType right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator DeploymentType(string value) => new DeploymentType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is DeploymentType other && Equals(other); - /// - public bool Equals(DeploymentType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeployments.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentsList.Serialization.cs similarity index 65% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeployments.Serialization.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentsList.Serialization.cs index ed6e513cb60f8..b45ceb6fe4c98 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeployments.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentsList.Serialization.cs @@ -11,21 +11,16 @@ namespace Azure.IoT.DeviceUpdate.Models { - internal partial class PageableListOfDeployments + internal partial class DeploymentsList { - internal static PageableListOfDeployments DeserializePageableListOfDeployments(JsonElement element) + internal static DeploymentsList DeserializeDeploymentsList(JsonElement element) { - Optional> value = default; + IReadOnlyList value = default; Optional nextLink = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -40,7 +35,7 @@ internal static PageableListOfDeployments DeserializePageableListOfDeployments(J continue; } } - return new PageableListOfDeployments(Optional.ToList(value), nextLink.Value); + return new DeploymentsList(value, nextLink.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeployments.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentsList.cs similarity index 51% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeployments.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentsList.cs index cf5695384e1f8..d05faff05ed60 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeployments.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeploymentsList.cs @@ -5,24 +5,32 @@ #nullable disable +using System; using System.Collections.Generic; -using Azure.Core; +using System.Linq; namespace Azure.IoT.DeviceUpdate.Models { /// The list of deployments. - internal partial class PageableListOfDeployments + internal partial class DeploymentsList { - /// Initializes a new instance of PageableListOfDeployments. - internal PageableListOfDeployments() + /// Initializes a new instance of DeploymentsList. + /// The collection of pageable items. + /// is null. + internal DeploymentsList(IEnumerable value) { - Value = new ChangeTrackingList(); + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); } - /// Initializes a new instance of PageableListOfDeployments. + /// Initializes a new instance of DeploymentsList. /// The collection of pageable items. /// The link to the next page of items. - internal PageableListOfDeployments(IReadOnlyList value, string nextLink) + internal DeploymentsList(IReadOnlyList value, string nextLink) { Value = value; NextLink = nextLink; diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Device.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Device.Serialization.cs index 8188432caf84f..fcc0118fbeda6 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Device.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Device.Serialization.cs @@ -15,6 +15,7 @@ public partial class Device internal static Device DeserializeDevice(JsonElement element) { string deviceId = default; + Optional moduleId = default; string deviceClassId = default; string manufacturer = default; string model = default; @@ -24,6 +25,7 @@ internal static Device DeserializeDevice(JsonElement element) Optional installedUpdateId = default; bool onLatestUpdate = default; Optional lastDeploymentId = default; + Optional lastInstallResult = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("deviceId")) @@ -31,6 +33,11 @@ internal static Device DeserializeDevice(JsonElement element) deviceId = property.Value.GetString(); continue; } + if (property.NameEquals("moduleId")) + { + moduleId = property.Value.GetString(); + continue; + } if (property.NameEquals("deviceClassId")) { deviceClassId = property.Value.GetString(); @@ -91,8 +98,18 @@ internal static Device DeserializeDevice(JsonElement element) lastDeploymentId = property.Value.GetString(); continue; } + if (property.NameEquals("lastInstallResult")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + lastInstallResult = null; + continue; + } + lastInstallResult = InstallResult.DeserializeInstallResult(property.Value); + continue; + } } - return new Device(deviceId, deviceClassId, manufacturer, model, groupId.Value, lastAttemptedUpdateId.Value, Optional.ToNullable(deploymentStatus), installedUpdateId.Value, onLatestUpdate, lastDeploymentId.Value); + return new Device(deviceId, moduleId.Value, deviceClassId, manufacturer, model, groupId.Value, lastAttemptedUpdateId.Value, Optional.ToNullable(deploymentStatus), installedUpdateId.Value, onLatestUpdate, lastDeploymentId.Value, lastInstallResult.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Device.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Device.cs index 913fea161f8b8..f662bc624105f 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Device.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Device.cs @@ -47,6 +47,7 @@ internal Device(string deviceId, string deviceClassId, string manufacturer, stri /// Initializes a new instance of Device. /// Device identity. + /// Device module identity. /// Device class identity. /// Device manufacturer. /// Device model. @@ -56,9 +57,11 @@ internal Device(string deviceId, string deviceClassId, string manufacturer, stri /// Update identity. /// Boolean flag indicating whether the latest update is installed on the device. /// The deployment identifier for the last deployment to the device. - internal Device(string deviceId, string deviceClassId, string manufacturer, string model, string groupId, UpdateId lastAttemptedUpdateId, DeviceDeploymentState? deploymentStatus, UpdateId installedUpdateId, bool onLatestUpdate, string lastDeploymentId) + /// Last install result. + internal Device(string deviceId, string moduleId, string deviceClassId, string manufacturer, string model, string groupId, UpdateId lastAttemptedUpdateId, DeviceDeploymentState? deploymentStatus, UpdateId installedUpdateId, bool onLatestUpdate, string lastDeploymentId, InstallResult lastInstallResult) { DeviceId = deviceId; + ModuleId = moduleId; DeviceClassId = deviceClassId; Manufacturer = manufacturer; Model = model; @@ -68,10 +71,13 @@ internal Device(string deviceId, string deviceClassId, string manufacturer, stri InstalledUpdateId = installedUpdateId; OnLatestUpdate = onLatestUpdate; LastDeploymentId = lastDeploymentId; + LastInstallResult = lastInstallResult; } /// Device identity. public string DeviceId { get; } + /// Device module identity. + public string ModuleId { get; } /// Device class identity. public string DeviceClassId { get; } /// Device manufacturer. @@ -90,5 +96,7 @@ internal Device(string deviceId, string deviceClassId, string manufacturer, stri public bool OnLatestUpdate { get; } /// The deployment identifier for the last deployment to the device. public string LastDeploymentId { get; } + /// Last install result. + public InstallResult LastInstallResult { get; } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClass.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClass.Serialization.cs index 9c0eba708133c..d67ed433fe7e6 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClass.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClass.Serialization.cs @@ -5,6 +5,7 @@ #nullable disable +using System.Collections.Generic; using System.Text.Json; using Azure.Core; @@ -15,8 +16,7 @@ public partial class DeviceClass internal static DeviceClass DeserializeDeviceClass(JsonElement element) { string deviceClassId = default; - string manufacturer = default; - string model = default; + IReadOnlyDictionary compatProperties = default; UpdateId bestCompatibleUpdateId = default; foreach (var property in element.EnumerateObject()) { @@ -25,14 +25,14 @@ internal static DeviceClass DeserializeDeviceClass(JsonElement element) deviceClassId = property.Value.GetString(); continue; } - if (property.NameEquals("manufacturer")) + if (property.NameEquals("compatProperties")) { - manufacturer = property.Value.GetString(); - continue; - } - if (property.NameEquals("model")) - { - model = property.Value.GetString(); + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + compatProperties = dictionary; continue; } if (property.NameEquals("bestCompatibleUpdateId")) @@ -46,7 +46,7 @@ internal static DeviceClass DeserializeDeviceClass(JsonElement element) continue; } } - return new DeviceClass(deviceClassId, manufacturer, model, bestCompatibleUpdateId); + return new DeviceClass(deviceClassId, compatProperties, bestCompatibleUpdateId); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClass.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClass.cs index 3e9bc5af71b5a..ca0a0f70ec355 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClass.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClass.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.IoT.DeviceUpdate.Models { @@ -14,37 +15,29 @@ public partial class DeviceClass { /// Initializes a new instance of DeviceClass. /// The device class identifier. - /// Device manufacturer. - /// Device model. + /// The compat properties of the device class. This object can be thought of as a set of key-value pairs where the key is the name of the compatibility property and the value is the value of the compatibility property. There will always be at least 1 compat property. /// Update identity. - /// , , or is null. - internal DeviceClass(string deviceClassId, string manufacturer, string model, UpdateId bestCompatibleUpdateId) + /// or is null. + internal DeviceClass(string deviceClassId, IReadOnlyDictionary compatProperties, UpdateId bestCompatibleUpdateId) { if (deviceClassId == null) { throw new ArgumentNullException(nameof(deviceClassId)); } - if (manufacturer == null) + if (compatProperties == null) { - throw new ArgumentNullException(nameof(manufacturer)); - } - if (model == null) - { - throw new ArgumentNullException(nameof(model)); + throw new ArgumentNullException(nameof(compatProperties)); } DeviceClassId = deviceClassId; - Manufacturer = manufacturer; - Model = model; + CompatProperties = compatProperties; BestCompatibleUpdateId = bestCompatibleUpdateId; } /// The device class identifier. public string DeviceClassId { get; } - /// Device manufacturer. - public string Manufacturer { get; } - /// Device model. - public string Model { get; } + /// The compat properties of the device class. This object can be thought of as a set of key-value pairs where the key is the name of the compatibility property and the value is the value of the compatibility property. There will always be at least 1 compat property. + public IReadOnlyDictionary CompatProperties { get; } /// Update identity. public UpdateId BestCompatibleUpdateId { get; } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeviceClasses.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClassesList.Serialization.cs similarity index 65% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeviceClasses.Serialization.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClassesList.Serialization.cs index cd23777c338d7..1df0d766985bd 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeviceClasses.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClassesList.Serialization.cs @@ -11,21 +11,16 @@ namespace Azure.IoT.DeviceUpdate.Models { - internal partial class PageableListOfDeviceClasses + internal partial class DeviceClassesList { - internal static PageableListOfDeviceClasses DeserializePageableListOfDeviceClasses(JsonElement element) + internal static DeviceClassesList DeserializeDeviceClassesList(JsonElement element) { - Optional> value = default; + IReadOnlyList value = default; Optional nextLink = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -40,7 +35,7 @@ internal static PageableListOfDeviceClasses DeserializePageableListOfDeviceClass continue; } } - return new PageableListOfDeviceClasses(Optional.ToList(value), nextLink.Value); + return new DeviceClassesList(value, nextLink.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeviceClasses.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClassesList.cs similarity index 51% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeviceClasses.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClassesList.cs index acfb66848259a..ac5e83e767dc8 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeviceClasses.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceClassesList.cs @@ -5,24 +5,32 @@ #nullable disable +using System; using System.Collections.Generic; -using Azure.Core; +using System.Linq; namespace Azure.IoT.DeviceUpdate.Models { /// The list of device classes. - internal partial class PageableListOfDeviceClasses + internal partial class DeviceClassesList { - /// Initializes a new instance of PageableListOfDeviceClasses. - internal PageableListOfDeviceClasses() + /// Initializes a new instance of DeviceClassesList. + /// The collection of pageable items. + /// is null. + internal DeviceClassesList(IEnumerable value) { - Value = new ChangeTrackingList(); + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); } - /// Initializes a new instance of PageableListOfDeviceClasses. + /// Initializes a new instance of DeviceClassesList. /// The collection of pageable items. /// The link to the next page of items. - internal PageableListOfDeviceClasses(IReadOnlyList value, string nextLink) + internal DeviceClassesList(IReadOnlyList value, string nextLink) { Value = value; NextLink = nextLink; diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceFilter.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceFilter.cs index f1ae13842475e..b0b8ed9b7001a 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceFilter.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceFilter.cs @@ -15,7 +15,7 @@ internal DeviceFilter() { } - /// Device group identifier. + /// Device group identity. public string GroupId { get; } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceGroupType.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceGroupType.cs deleted file mode 100644 index 30daf59b2bc47..0000000000000 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceGroupType.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.IoT.DeviceUpdate.Models -{ - /// Supported deployment group types. - public readonly partial struct DeviceGroupType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public DeviceGroupType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AllValue = "All"; - private const string DevicesValue = "Devices"; - private const string DeviceGroupDefinitionsValue = "DeviceGroupDefinitions"; - - /// The deployment should be sent to all devices in the device class. - public static DeviceGroupType All { get; } = new DeviceGroupType(AllValue); - /// The deployment should be sent to the list of devices in the device group definition. - public static DeviceGroupType Devices { get; } = new DeviceGroupType(DevicesValue); - /// The deployment should be sent to the list of devices returned by the union of all the device group definition queries. - public static DeviceGroupType DeviceGroupDefinitions { get; } = new DeviceGroupType(DeviceGroupDefinitionsValue); - /// Determines if two values are the same. - public static bool operator ==(DeviceGroupType left, DeviceGroupType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(DeviceGroupType left, DeviceGroupType right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator DeviceGroupType(string value) => new DeviceGroupType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is DeviceGroupType other && Equals(other); - /// - public bool Equals(DeviceGroupType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperation.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperation.Serialization.cs new file mode 100644 index 0000000000000..c1b04e099c938 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperation.Serialization.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + public partial class DeviceOperation + { + internal static DeviceOperation DeserializeDeviceOperation(JsonElement element) + { + string operationId = default; + OperationStatus status = default; + Optional error = default; + Optional traceId = default; + DateTimeOffset lastActionDateTime = default; + DateTimeOffset createdDateTime = default; + Optional etag = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operationId")) + { + operationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = new OperationStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("error")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + error = Error.DeserializeError(property.Value); + continue; + } + if (property.NameEquals("traceId")) + { + traceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastActionDateTime")) + { + lastActionDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdDateTime")) + { + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("etag")) + { + etag = property.Value.GetString(); + continue; + } + } + return new DeviceOperation(operationId, status, error.Value, traceId.Value, lastActionDateTime, createdDateTime, etag.Value); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperation.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperation.cs new file mode 100644 index 0000000000000..c5a84eaf08672 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperation.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// Operation metadata. + public partial class DeviceOperation + { + /// Initializes a new instance of DeviceOperation. + /// Operation Id. + /// Operation status. + /// Date and time in UTC when the operation status was last updated. + /// Date and time in UTC when the operation was created. + /// is null. + internal DeviceOperation(string operationId, OperationStatus status, DateTimeOffset lastActionDateTime, DateTimeOffset createdDateTime) + { + if (operationId == null) + { + throw new ArgumentNullException(nameof(operationId)); + } + + OperationId = operationId; + Status = status; + LastActionDateTime = lastActionDateTime; + CreatedDateTime = createdDateTime; + } + + /// Initializes a new instance of DeviceOperation. + /// Operation Id. + /// Operation status. + /// Operation error encountered, if any. + /// Operation correlation identity that can used by Microsoft Support for troubleshooting. + /// Date and time in UTC when the operation status was last updated. + /// Date and time in UTC when the operation was created. + /// Operation ETag. + internal DeviceOperation(string operationId, OperationStatus status, Error error, string traceId, DateTimeOffset lastActionDateTime, DateTimeOffset createdDateTime, string etag) + { + OperationId = operationId; + Status = status; + Error = error; + TraceId = traceId; + LastActionDateTime = lastActionDateTime; + CreatedDateTime = createdDateTime; + Etag = etag; + } + + /// Operation Id. + public string OperationId { get; } + /// Operation status. + public OperationStatus Status { get; } + /// Operation error encountered, if any. + public Error Error { get; } + /// Operation correlation identity that can used by Microsoft Support for troubleshooting. + public string TraceId { get; } + /// Date and time in UTC when the operation status was last updated. + public DateTimeOffset LastActionDateTime { get; } + /// Date and time in UTC when the operation was created. + public DateTimeOffset CreatedDateTime { get; } + /// Operation ETag. + public string Etag { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperationsList.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperationsList.Serialization.cs new file mode 100644 index 0000000000000..655e778b7173b --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperationsList.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + internal partial class DeviceOperationsList + { + internal static DeviceOperationsList DeserializeDeviceOperationsList(JsonElement element) + { + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DeviceOperation.DeserializeDeviceOperation(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new DeviceOperationsList(value, nextLink.Value); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperationsList.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperationsList.cs new file mode 100644 index 0000000000000..e1bd6149bb86a --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceOperationsList.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// The list of device operations with server paging support. + internal partial class DeviceOperationsList + { + /// Initializes a new instance of DeviceOperationsList. + /// The collection of pageable items. + /// is null. + internal DeviceOperationsList(IEnumerable value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); + } + + /// Initializes a new instance of DeviceOperationsList. + /// The collection of pageable items. + /// The link to the next page of items. + internal DeviceOperationsList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The collection of pageable items. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public string NextLink { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeviceTags.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceTagsList.Serialization.cs similarity index 65% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeviceTags.Serialization.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceTagsList.Serialization.cs index 6ed6aaad4231b..5068ef4e8d763 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeviceTags.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceTagsList.Serialization.cs @@ -11,21 +11,16 @@ namespace Azure.IoT.DeviceUpdate.Models { - internal partial class PageableListOfDeviceTags + internal partial class DeviceTagsList { - internal static PageableListOfDeviceTags DeserializePageableListOfDeviceTags(JsonElement element) + internal static DeviceTagsList DeserializeDeviceTagsList(JsonElement element) { - Optional> value = default; + IReadOnlyList value = default; Optional nextLink = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -40,7 +35,7 @@ internal static PageableListOfDeviceTags DeserializePageableListOfDeviceTags(Jso continue; } } - return new PageableListOfDeviceTags(Optional.ToList(value), nextLink.Value); + return new DeviceTagsList(value, nextLink.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeviceTags.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceTagsList.cs similarity index 52% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeviceTags.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceTagsList.cs index 4793655c2ac53..afe6691647dda 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDeviceTags.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceTagsList.cs @@ -5,24 +5,32 @@ #nullable disable +using System; using System.Collections.Generic; -using Azure.Core; +using System.Linq; namespace Azure.IoT.DeviceUpdate.Models { /// The list of device tags. - internal partial class PageableListOfDeviceTags + internal partial class DeviceTagsList { - /// Initializes a new instance of PageableListOfDeviceTags. - internal PageableListOfDeviceTags() + /// Initializes a new instance of DeviceTagsList. + /// The collection of pageable items. + /// is null. + internal DeviceTagsList(IEnumerable value) { - Value = new ChangeTrackingList(); + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); } - /// Initializes a new instance of PageableListOfDeviceTags. + /// Initializes a new instance of DeviceTagsList. /// The collection of pageable items. /// The link to the next page of items. - internal PageableListOfDeviceTags(IReadOnlyList value, string nextLink) + internal DeviceTagsList(IReadOnlyList value, string nextLink) { Value = value; NextLink = nextLink; diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceUpdateAgentId.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceUpdateAgentId.Serialization.cs new file mode 100644 index 0000000000000..11c1b984fd6a0 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceUpdateAgentId.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + public partial class DeviceUpdateAgentId : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("deviceId"); + writer.WriteStringValue(DeviceId); + if (Optional.IsDefined(ModuleId)) + { + writer.WritePropertyName("moduleId"); + writer.WriteStringValue(ModuleId); + } + writer.WriteEndObject(); + } + + internal static DeviceUpdateAgentId DeserializeDeviceUpdateAgentId(JsonElement element) + { + string deviceId = default; + Optional moduleId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("deviceId")) + { + deviceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("moduleId")) + { + moduleId = property.Value.GetString(); + continue; + } + } + return new DeviceUpdateAgentId(deviceId, moduleId.Value); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceUpdateAgentId.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceUpdateAgentId.cs new file mode 100644 index 0000000000000..51b380bd0f17f --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DeviceUpdateAgentId.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// Device Update agent id. + public partial class DeviceUpdateAgentId + { + /// Initializes a new instance of DeviceUpdateAgentId. + /// Device Id. + /// is null. + public DeviceUpdateAgentId(string deviceId) + { + if (deviceId == null) + { + throw new ArgumentNullException(nameof(deviceId)); + } + + DeviceId = deviceId; + } + + /// Initializes a new instance of DeviceUpdateAgentId. + /// Device Id. + /// Module Id. + internal DeviceUpdateAgentId(string deviceId, string moduleId) + { + DeviceId = deviceId; + ModuleId = moduleId; + } + + /// Device Id. + public string DeviceId { get; set; } + /// Module Id. + public string ModuleId { get; set; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDevices.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DevicesList.Serialization.cs similarity index 66% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDevices.Serialization.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DevicesList.Serialization.cs index 36ab464886731..cc24ea695589c 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDevices.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DevicesList.Serialization.cs @@ -11,21 +11,16 @@ namespace Azure.IoT.DeviceUpdate.Models { - internal partial class PageableListOfDevices + internal partial class DevicesList { - internal static PageableListOfDevices DeserializePageableListOfDevices(JsonElement element) + internal static DevicesList DeserializeDevicesList(JsonElement element) { - Optional> value = default; + IReadOnlyList value = default; Optional nextLink = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -40,7 +35,7 @@ internal static PageableListOfDevices DeserializePageableListOfDevices(JsonEleme continue; } } - return new PageableListOfDevices(Optional.ToList(value), nextLink.Value); + return new DevicesList(value, nextLink.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDevices.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DevicesList.cs similarity index 52% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDevices.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DevicesList.cs index 242ae8c8d3770..c8235a9912c43 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfDevices.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/DevicesList.cs @@ -5,24 +5,32 @@ #nullable disable +using System; using System.Collections.Generic; -using Azure.Core; +using System.Linq; namespace Azure.IoT.DeviceUpdate.Models { /// The list of devices. - internal partial class PageableListOfDevices + internal partial class DevicesList { - /// Initializes a new instance of PageableListOfDevices. - internal PageableListOfDevices() + /// Initializes a new instance of DevicesList. + /// The collection of pageable items. + /// is null. + internal DevicesList(IEnumerable value) { - Value = new ChangeTrackingList(); + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); } - /// Initializes a new instance of PageableListOfDevices. + /// Initializes a new instance of DevicesList. /// The collection of pageable items. /// The link to the next page of items. - internal PageableListOfDevices(IReadOnlyList value, string nextLink) + internal DevicesList(IReadOnlyList value, string nextLink) { Value = value; NextLink = nextLink; diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ErrorResponse.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ErrorResponse.Serialization.cs new file mode 100644 index 0000000000000..a9a746b151705 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ErrorResponse.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + internal partial class ErrorResponse + { + internal static ErrorResponse DeserializeErrorResponse(JsonElement element) + { + Error error = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("error")) + { + error = Error.DeserializeError(property.Value); + continue; + } + } + return new ErrorResponse(error); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ErrorResponse.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ErrorResponse.cs new file mode 100644 index 0000000000000..b411613aeb7a2 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ErrorResponse.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// Common error response. + internal partial class ErrorResponse + { + /// Initializes a new instance of ErrorResponse. + /// The error details. + /// is null. + internal ErrorResponse(Error error) + { + if (error == null) + { + throw new ArgumentNullException(nameof(error)); + } + + Error = error; + } + + /// The error details. + public Error Error { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Group.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Group.Serialization.cs index 0f0048613cd17..d99b58f42bcec 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Group.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Group.Serialization.cs @@ -34,6 +34,16 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("deviceCount"); writer.WriteNumberValue(DeviceCount.Value); } + if (Optional.IsDefined(DeploymentId)) + { + writer.WritePropertyName("deploymentId"); + writer.WriteStringValue(DeploymentId); + } + if (Optional.IsDefined(DeviceClassId)) + { + writer.WritePropertyName("deviceClassId"); + writer.WriteStringValue(DeviceClassId); + } writer.WriteEndObject(); } @@ -44,6 +54,8 @@ internal static Group DeserializeGroup(JsonElement element) IList tags = default; string createdDateTime = default; Optional deviceCount = default; + Optional deploymentId = default; + Optional deviceClassId = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("groupId")) @@ -81,8 +93,18 @@ internal static Group DeserializeGroup(JsonElement element) deviceCount = property.Value.GetInt32(); continue; } + if (property.NameEquals("deploymentId")) + { + deploymentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("deviceClassId")) + { + deviceClassId = property.Value.GetString(); + continue; + } } - return new Group(groupId, groupType, tags, createdDateTime, Optional.ToNullable(deviceCount)); + return new Group(groupId, groupType, tags, createdDateTime, Optional.ToNullable(deviceCount), deploymentId.Value, deviceClassId.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Group.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Group.cs index 131d8c29ffac6..d23c5451c94b8 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Group.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Group.cs @@ -47,13 +47,17 @@ public Group(string groupId, GroupType groupType, IEnumerable tags, stri /// IoT Hub tags. /// Date and time when the update was created. /// The number of devices in the group. - internal Group(string groupId, GroupType groupType, IList tags, string createdDateTime, int? deviceCount) + /// The deployment Id for the group. + /// The device class Id for the group. + internal Group(string groupId, GroupType groupType, IList tags, string createdDateTime, int? deviceCount, string deploymentId, string deviceClassId) { GroupId = groupId; GroupType = groupType; Tags = tags; CreatedDateTime = createdDateTime; DeviceCount = deviceCount; + DeploymentId = deploymentId; + DeviceClassId = deviceClassId; } /// Group identity. @@ -66,5 +70,9 @@ internal Group(string groupId, GroupType groupType, IList tags, string c public string CreatedDateTime { get; set; } /// The number of devices in the group. public int? DeviceCount { get; set; } + /// The deployment Id for the group. + public string DeploymentId { get; set; } + /// The device class Id for the group. + public string DeviceClassId { get; set; } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/GroupType.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/GroupType.cs index 73d2f6bd2086e..bb49593cba87d 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/GroupType.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/GroupType.cs @@ -22,10 +22,16 @@ public GroupType(string value) _value = value ?? throw new ArgumentNullException(nameof(value)); } - private const string IoTHubTagValue = "IoTHubTag"; - - /// IoT Hub tag based group. - public static GroupType IoTHubTag { get; } = new GroupType(IoTHubTagValue); + private const string DeviceClassIdAndIoTHubTagValue = "DeviceClassIdAndIoTHubTag"; + private const string InvalidDeviceClassIdAndIoTHubTagValue = "InvalidDeviceClassIdAndIoTHubTag"; + private const string DefaultDeviceClassIdValue = "DefaultDeviceClassId"; + + /// DeviceClassId IoT Hub tag based group, all devices in the group are compatible with the same updates and share a tag and deviceClassId. + public static GroupType DeviceClassIdAndIoTHubTag { get; } = new GroupType(DeviceClassIdAndIoTHubTagValue); + /// Invalid deviceClassId IoT Hub tag based group, all devices in the group do not match the deviceClassId of the valid group they were tagged to join. + public static GroupType InvalidDeviceClassIdAndIoTHubTag { get; } = new GroupType(InvalidDeviceClassIdAndIoTHubTagValue); + /// Default deviceClassId based group, all devices in the group have no tags but are part of the same deviceClassId. All devices will be part of one of these groups until a user tags them to join another group. + public static GroupType DefaultDeviceClassId { get; } = new GroupType(DefaultDeviceClassIdValue); /// Determines if two values are the same. public static bool operator ==(GroupType left, GroupType right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfGroups.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/GroupsList.Serialization.cs similarity index 66% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfGroups.Serialization.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/GroupsList.Serialization.cs index d34da20c86438..3c60016ee07c3 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfGroups.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/GroupsList.Serialization.cs @@ -11,21 +11,16 @@ namespace Azure.IoT.DeviceUpdate.Models { - internal partial class PageableListOfGroups + internal partial class GroupsList { - internal static PageableListOfGroups DeserializePageableListOfGroups(JsonElement element) + internal static GroupsList DeserializeGroupsList(JsonElement element) { - Optional> value = default; + IReadOnlyList value = default; Optional nextLink = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -40,7 +35,7 @@ internal static PageableListOfGroups DeserializePageableListOfGroups(JsonElement continue; } } - return new PageableListOfGroups(Optional.ToList(value), nextLink.Value); + return new GroupsList(value, nextLink.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfGroups.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/GroupsList.cs similarity index 52% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfGroups.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/GroupsList.cs index 9469dc1efeb4c..17eb5f0c90d1c 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfGroups.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/GroupsList.cs @@ -5,24 +5,32 @@ #nullable disable +using System; using System.Collections.Generic; -using Azure.Core; +using System.Linq; namespace Azure.IoT.DeviceUpdate.Models { /// The list of groups. - internal partial class PageableListOfGroups + internal partial class GroupsList { - /// Initializes a new instance of PageableListOfGroups. - internal PageableListOfGroups() + /// Initializes a new instance of GroupsList. + /// The collection of pageable items. + /// is null. + internal GroupsList(IEnumerable value) { - Value = new ChangeTrackingList(); + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); } - /// Initializes a new instance of PageableListOfGroups. + /// Initializes a new instance of GroupsList. /// The collection of pageable items. /// The link to the next page of items. - internal PageableListOfGroups(IReadOnlyList value, string nextLink) + internal GroupsList(IReadOnlyList value, string nextLink) { Value = value; NextLink = nextLink; diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportAction.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportAction.cs new file mode 100644 index 0000000000000..14073e10f6970 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportAction.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// The ImportAction. + public readonly partial struct ImportAction : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ImportAction(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ImportValue = "import"; + + /// Import action. + public static ImportAction Import { get; } = new ImportAction(ImportValue); + /// Determines if two values are the same. + public static bool operator ==(ImportAction left, ImportAction right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ImportAction left, ImportAction right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ImportAction(string value) => new ImportAction(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImportAction other && Equals(other); + /// + public bool Equals(ImportAction other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportType.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportType.cs new file mode 100644 index 0000000000000..fcab5c40814e3 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// The device import type. + public readonly partial struct ImportType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ImportType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DevicesValue = "Devices"; + private const string ModulesValue = "Modules"; + private const string AllValue = "All"; + + /// Import only devices but not modules. + public static ImportType Devices { get; } = new ImportType(DevicesValue); + /// Import only modules but not devices. + public static ImportType Modules { get; } = new ImportType(ModulesValue); + /// Import both devices and modules. + public static ImportType All { get; } = new ImportType(AllValue); + /// Determines if two values are the same. + public static bool operator ==(ImportType left, ImportType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ImportType left, ImportType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ImportType(string value) => new ImportType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImportType other && Equals(other); + /// + public bool Equals(ImportType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInput.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInput.Serialization.cs deleted file mode 100644 index 7695bc4930fd3..0000000000000 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInput.Serialization.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.IoT.DeviceUpdate.Models -{ - public partial class ImportUpdateInput : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - writer.WritePropertyName("importManifest"); - writer.WriteObjectValue(ImportManifest); - writer.WritePropertyName("files"); - writer.WriteStartArray(); - foreach (var item in Files) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WriteEndObject(); - } - } -} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInputItem.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInputItem.Serialization.cs new file mode 100644 index 0000000000000..226809272d61d --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInputItem.Serialization.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + public partial class ImportUpdateInputItem : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("importManifest"); + writer.WriteObjectValue(ImportManifest); + if (Optional.IsDefined(FriendlyName)) + { + writer.WritePropertyName("friendlyName"); + writer.WriteStringValue(FriendlyName); + } + if (Optional.IsCollectionDefined(Files)) + { + writer.WritePropertyName("files"); + writer.WriteStartArray(); + foreach (var item in Files) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInput.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInputItem.cs similarity index 63% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInput.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInputItem.cs index 492d4eebf95f8..efa96260360fb 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInput.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/ImportUpdateInputItem.cs @@ -7,34 +7,31 @@ using System; using System.Collections.Generic; -using System.Linq; +using Azure.Core; namespace Azure.IoT.DeviceUpdate.Models { - /// Import update input metadata. - public partial class ImportUpdateInput + /// Import update input item metadata. + public partial class ImportUpdateInputItem { - /// Initializes a new instance of ImportUpdateInput. + /// Initializes a new instance of ImportUpdateInputItem. /// Import manifest metadata like source URL, file size/hashes, etc. - /// One or more update file properties like filename and source URL. - /// or is null. - public ImportUpdateInput(ImportManifestMetadata importManifest, IEnumerable files) + /// is null. + public ImportUpdateInputItem(ImportManifestMetadata importManifest) { if (importManifest == null) { throw new ArgumentNullException(nameof(importManifest)); } - if (files == null) - { - throw new ArgumentNullException(nameof(files)); - } ImportManifest = importManifest; - Files = files.ToList(); + Files = new ChangeTrackingList(); } /// Import manifest metadata like source URL, file size/hashes, etc. public ImportManifestMetadata ImportManifest { get; } + /// Friendly update name. + public string FriendlyName { get; set; } /// One or more update file properties like filename and source URL. public IList Files { get; } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/InstallResult.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/InstallResult.Serialization.cs new file mode 100644 index 0000000000000..53777e91d8716 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/InstallResult.Serialization.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + public partial class InstallResult + { + internal static InstallResult DeserializeInstallResult(JsonElement element) + { + int resultCode = default; + int extendedResultCode = default; + Optional resultDetails = default; + Optional> stepResults = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resultCode")) + { + resultCode = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("extendedResultCode")) + { + extendedResultCode = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("resultDetails")) + { + resultDetails = property.Value.GetString(); + continue; + } + if (property.NameEquals("stepResults")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(StepResult.DeserializeStepResult(item)); + } + stepResults = array; + continue; + } + } + return new InstallResult(resultCode, extendedResultCode, resultDetails.Value, Optional.ToList(stepResults)); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/InstallResult.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/InstallResult.cs new file mode 100644 index 0000000000000..3989526e494df --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/InstallResult.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// The install result of an update and any step results under it. + public partial class InstallResult + { + /// Initializes a new instance of InstallResult. + /// Install result code. + /// Install extended result code. + internal InstallResult(int resultCode, int extendedResultCode) + { + ResultCode = resultCode; + ExtendedResultCode = extendedResultCode; + StepResults = new ChangeTrackingList(); + } + + /// Initializes a new instance of InstallResult. + /// Install result code. + /// Install extended result code. + /// A string containing further details about the install result. + /// Array of step results. + internal InstallResult(int resultCode, int extendedResultCode, string resultDetails, IReadOnlyList stepResults) + { + ResultCode = resultCode; + ExtendedResultCode = extendedResultCode; + ResultDetails = resultDetails; + StepResults = stepResults; + } + + /// Install result code. + public int ResultCode { get; } + /// Install extended result code. + public int ExtendedResultCode { get; } + /// A string containing further details about the install result. + public string ResultDetails { get; } + /// Array of step results. + public IReadOnlyList StepResults { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Instructions.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Instructions.Serialization.cs new file mode 100644 index 0000000000000..e75d7c69cb1be --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Instructions.Serialization.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + public partial class Instructions + { + internal static Instructions DeserializeInstructions(JsonElement element) + { + IReadOnlyList steps = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("steps")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Step.DeserializeStep(item)); + } + steps = array; + continue; + } + } + return new Instructions(steps); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Instructions.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Instructions.cs new file mode 100644 index 0000000000000..4997f55ff241d --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Instructions.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// The Instructions. + public partial class Instructions + { + /// Initializes a new instance of Instructions. + /// Collection of installation steps. + /// is null. + internal Instructions(IEnumerable steps) + { + if (steps == null) + { + throw new ArgumentNullException(nameof(steps)); + } + + Steps = steps.ToList(); + } + + /// Initializes a new instance of Instructions. + /// Collection of installation steps. + internal Instructions(IReadOnlyList steps) + { + Steps = steps; + } + + /// Collection of installation steps. + public IReadOnlyList Steps { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperation.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperation.Serialization.cs new file mode 100644 index 0000000000000..ef5253a0f7442 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperation.Serialization.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + public partial class LogCollectionOperation : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(OperationId)) + { + writer.WritePropertyName("operationId"); + writer.WriteStringValue(OperationId); + } + writer.WritePropertyName("deviceList"); + writer.WriteStartArray(); + foreach (var item in DeviceList) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"); + writer.WriteStringValue(Description); + } + writer.WriteEndObject(); + } + + internal static LogCollectionOperation DeserializeLogCollectionOperation(JsonElement element) + { + Optional operationId = default; + IList deviceList = default; + Optional description = default; + Optional createdDateTime = default; + Optional lastActionDateTime = default; + Optional status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operationId")) + { + operationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("deviceList")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DeviceUpdateAgentId.DeserializeDeviceUpdateAgentId(item)); + } + deviceList = array; + continue; + } + if (property.NameEquals("description")) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime")) + { + createdDateTime = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastActionDateTime")) + { + lastActionDateTime = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + status = new OperationStatus(property.Value.GetString()); + continue; + } + } + return new LogCollectionOperation(operationId.Value, deviceList, description.Value, createdDateTime.Value, lastActionDateTime.Value, Optional.ToNullable(status)); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperation.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperation.cs new file mode 100644 index 0000000000000..0219fc8511ed5 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperation.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// Diagnostics request body. + public partial class LogCollectionOperation + { + /// Initializes a new instance of LogCollectionOperation. + /// Array of Device Update agent ids. + /// is null. + public LogCollectionOperation(IEnumerable deviceList) + { + if (deviceList == null) + { + throw new ArgumentNullException(nameof(deviceList)); + } + + DeviceList = deviceList.ToList(); + } + + /// Initializes a new instance of LogCollectionOperation. + /// The diagnostics operation id. + /// Array of Device Update agent ids. + /// Description of the diagnostics operation. + /// The timestamp when the operation was created. + /// A timestamp for when the current state was entered. + /// Operation status. + internal LogCollectionOperation(string operationId, IList deviceList, string description, string createdDateTime, string lastActionDateTime, OperationStatus? status) + { + OperationId = operationId; + DeviceList = deviceList; + Description = description; + CreatedDateTime = createdDateTime; + LastActionDateTime = lastActionDateTime; + Status = status; + } + + /// The diagnostics operation id. + public string OperationId { get; set; } + /// Array of Device Update agent ids. + public IList DeviceList { get; } + /// Description of the diagnostics operation. + public string Description { get; set; } + /// The timestamp when the operation was created. + public string CreatedDateTime { get; } + /// A timestamp for when the current state was entered. + public string LastActionDateTime { get; } + /// Operation status. + public OperationStatus? Status { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDetailedStatus.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDetailedStatus.Serialization.cs new file mode 100644 index 0000000000000..d308d1a3a71e4 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDetailedStatus.Serialization.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + public partial class LogCollectionOperationDetailedStatus + { + internal static LogCollectionOperationDetailedStatus DeserializeLogCollectionOperationDetailedStatus(JsonElement element) + { + Optional operationId = default; + Optional createdDateTime = default; + Optional lastActionDateTime = default; + Optional status = default; + Optional> deviceStatus = default; + Optional description = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operationId")) + { + operationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime")) + { + createdDateTime = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastActionDateTime")) + { + lastActionDateTime = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + status = new OperationStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("deviceStatus")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(LogCollectionOperationDeviceStatus.DeserializeLogCollectionOperationDeviceStatus(item)); + } + deviceStatus = array; + continue; + } + if (property.NameEquals("description")) + { + description = property.Value.GetString(); + continue; + } + } + return new LogCollectionOperationDetailedStatus(operationId.Value, createdDateTime.Value, lastActionDateTime.Value, Optional.ToNullable(status), Optional.ToList(deviceStatus), description.Value); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDetailedStatus.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDetailedStatus.cs new file mode 100644 index 0000000000000..d867a85d01ddb --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDetailedStatus.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// Device diagnostics operation detailed status. + public partial class LogCollectionOperationDetailedStatus + { + /// Initializes a new instance of LogCollectionOperationDetailedStatus. + internal LogCollectionOperationDetailedStatus() + { + DeviceStatus = new ChangeTrackingList(); + } + + /// Initializes a new instance of LogCollectionOperationDetailedStatus. + /// The device diagnostics operation id. + /// The timestamp when the operation was created. + /// A timestamp for when the current state was entered. + /// Operation status. + /// Status of the devices in the operation. + /// Device diagnostics operation description. + internal LogCollectionOperationDetailedStatus(string operationId, string createdDateTime, string lastActionDateTime, OperationStatus? status, IReadOnlyList deviceStatus, string description) + { + OperationId = operationId; + CreatedDateTime = createdDateTime; + LastActionDateTime = lastActionDateTime; + Status = status; + DeviceStatus = deviceStatus; + Description = description; + } + + /// The device diagnostics operation id. + public string OperationId { get; } + /// The timestamp when the operation was created. + public string CreatedDateTime { get; } + /// A timestamp for when the current state was entered. + public string LastActionDateTime { get; } + /// Operation status. + public OperationStatus? Status { get; } + /// Status of the devices in the operation. + public IReadOnlyList DeviceStatus { get; } + /// Device diagnostics operation description. + public string Description { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDetailedStatusList.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDetailedStatusList.cs new file mode 100644 index 0000000000000..6e9803955ec2d --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDetailedStatusList.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// The list of diagnostics operations with detailed status, with server paging support. + internal partial class LogCollectionOperationDetailedStatusList + { + /// Initializes a new instance of LogCollectionOperationDetailedStatusList. + /// The collection of pageable items. + /// is null. + internal LogCollectionOperationDetailedStatusList(IEnumerable value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); + } + + /// The collection of pageable items. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public string NextLink { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDeviceStatus.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDeviceStatus.Serialization.cs new file mode 100644 index 0000000000000..5d0c895893193 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDeviceStatus.Serialization.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + public partial class LogCollectionOperationDeviceStatus + { + internal static LogCollectionOperationDeviceStatus DeserializeLogCollectionOperationDeviceStatus(JsonElement element) + { + string deviceId = default; + Optional moduleId = default; + OperationStatus status = default; + Optional resultCode = default; + Optional extendedResultCode = default; + Optional logLocation = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("deviceId")) + { + deviceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("moduleId")) + { + moduleId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = new OperationStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("resultCode")) + { + resultCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("extendedResultCode")) + { + extendedResultCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("logLocation")) + { + logLocation = property.Value.GetString(); + continue; + } + } + return new LogCollectionOperationDeviceStatus(deviceId, moduleId.Value, status, resultCode.Value, extendedResultCode.Value, logLocation.Value); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDeviceStatus.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDeviceStatus.cs new file mode 100644 index 0000000000000..4cfa32596abe5 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationDeviceStatus.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// Diagnostics operation device status. + public partial class LogCollectionOperationDeviceStatus + { + /// Initializes a new instance of LogCollectionOperationDeviceStatus. + /// Device id. + /// Log upload status. + /// is null. + internal LogCollectionOperationDeviceStatus(string deviceId, OperationStatus status) + { + if (deviceId == null) + { + throw new ArgumentNullException(nameof(deviceId)); + } + + DeviceId = deviceId; + Status = status; + } + + /// Initializes a new instance of LogCollectionOperationDeviceStatus. + /// Device id. + /// Module id. + /// Log upload status. + /// Log upload result code. + /// Log upload extended result code. + /// Log upload location. + internal LogCollectionOperationDeviceStatus(string deviceId, string moduleId, OperationStatus status, string resultCode, string extendedResultCode, string logLocation) + { + DeviceId = deviceId; + ModuleId = moduleId; + Status = status; + ResultCode = resultCode; + ExtendedResultCode = extendedResultCode; + LogLocation = logLocation; + } + + /// Device id. + public string DeviceId { get; } + /// Module id. + public string ModuleId { get; } + /// Log upload status. + public OperationStatus Status { get; } + /// Log upload result code. + public string ResultCode { get; } + /// Log upload extended result code. + public string ExtendedResultCode { get; } + /// Log upload location. + public string LogLocation { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationList.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationList.Serialization.cs new file mode 100644 index 0000000000000..1db9e45e0d245 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationList.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + internal partial class LogCollectionOperationList + { + internal static LogCollectionOperationList DeserializeLogCollectionOperationList(JsonElement element) + { + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(LogCollectionOperation.DeserializeLogCollectionOperation(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new LogCollectionOperationList(value, nextLink.Value); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationList.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationList.cs new file mode 100644 index 0000000000000..aec1f8ea0693d --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/LogCollectionOperationList.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// The list of diagnostics operations with server paging support. + internal partial class LogCollectionOperationList + { + /// Initializes a new instance of LogCollectionOperationList. + /// The collection of pageable items. + /// is null. + internal LogCollectionOperationList(IEnumerable value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); + } + + /// Initializes a new instance of LogCollectionOperationList. + /// The collection of pageable items. + /// The link to the next page of items. + internal LogCollectionOperationList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The collection of pageable items. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public string NextLink { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfOperations.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfOperations.Serialization.cs deleted file mode 100644 index 9bd45c11205a7..0000000000000 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfOperations.Serialization.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.IoT.DeviceUpdate.Models -{ - internal partial class PageableListOfOperations - { - internal static PageableListOfOperations DeserializePageableListOfOperations(JsonElement element) - { - Optional> value = default; - Optional nextLink = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("value")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(Operation.DeserializeOperation(item)); - } - value = array; - continue; - } - if (property.NameEquals("nextLink")) - { - nextLink = property.Value.GetString(); - continue; - } - } - return new PageableListOfOperations(Optional.ToList(value), nextLink.Value); - } - } -} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfOperations.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfOperations.cs deleted file mode 100644 index 34b7d045f8d50..0000000000000 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfOperations.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; -using Azure.Core; - -namespace Azure.IoT.DeviceUpdate.Models -{ - /// The list of operations with server paging support. - internal partial class PageableListOfOperations - { - /// Initializes a new instance of PageableListOfOperations. - internal PageableListOfOperations() - { - Value = new ChangeTrackingList(); - } - - /// Initializes a new instance of PageableListOfOperations. - /// The collection of pageable items. - /// The link to the next page of items. - internal PageableListOfOperations(IReadOnlyList value, string nextLink) - { - Value = value; - NextLink = nextLink; - } - - /// The collection of pageable items. - public IReadOnlyList Value { get; } - /// The link to the next page of items. - public string NextLink { get; } - } -} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Step.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Step.Serialization.cs new file mode 100644 index 0000000000000..5a7f7be0a6164 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Step.Serialization.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + public partial class Step + { + internal static Step DeserializeStep(JsonElement element) + { + Optional type = default; + Optional description = default; + Optional handler = default; + Optional handlerProperties = default; + Optional> files = default; + Optional updateId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + type = new StepType(property.Value.GetString()); + continue; + } + if (property.NameEquals("description")) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("handler")) + { + handler = property.Value.GetString(); + continue; + } + if (property.NameEquals("handlerProperties")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + handlerProperties = property.Value.GetObject(); + continue; + } + if (property.NameEquals("files")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + files = array; + continue; + } + if (property.NameEquals("updateId")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + updateId = UpdateId.DeserializeUpdateId(property.Value); + continue; + } + } + return new Step(Optional.ToNullable(type), description.Value, handler.Value, handlerProperties.Value, Optional.ToList(files), updateId.Value); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Step.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Step.cs new file mode 100644 index 0000000000000..c87e951dc1bd2 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Step.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// Update install instruction step. + public partial class Step + { + /// Initializes a new instance of Step. + internal Step() + { + Files = new ChangeTrackingList(); + } + + /// Initializes a new instance of Step. + /// Step type. + /// Step description. + /// Identity of handler that will execute this step. Required if step type is inline. + /// Parameters to be passed to handler during execution. + /// Collection of file names to be passed to handler during execution. Required if step type is inline. + /// Referenced child update identity. Required if step type is reference. + internal Step(StepType? type, string description, string handler, object handlerProperties, IReadOnlyList files, UpdateId updateId) + { + Type = type; + Description = description; + Handler = handler; + HandlerProperties = handlerProperties; + Files = files; + UpdateId = updateId; + } + + /// Step type. + public StepType? Type { get; } + /// Step description. + public string Description { get; } + /// Identity of handler that will execute this step. Required if step type is inline. + public string Handler { get; } + /// Parameters to be passed to handler during execution. + public object HandlerProperties { get; } + /// Collection of file names to be passed to handler during execution. Required if step type is inline. + public IReadOnlyList Files { get; } + /// Referenced child update identity. Required if step type is reference. + public UpdateId UpdateId { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StepResult.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StepResult.Serialization.cs new file mode 100644 index 0000000000000..d37be576144dc --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StepResult.Serialization.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + public partial class StepResult + { + internal static StepResult DeserializeStepResult(JsonElement element) + { + Optional updateId = default; + Optional description = default; + int resultCode = default; + int extendedResultCode = default; + Optional resultDetails = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("updateId")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + updateId = UpdateId.DeserializeUpdateId(property.Value); + continue; + } + if (property.NameEquals("description")) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("resultCode")) + { + resultCode = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("extendedResultCode")) + { + extendedResultCode = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("resultDetails")) + { + resultDetails = property.Value.GetString(); + continue; + } + } + return new StepResult(updateId.Value, description.Value, resultCode, extendedResultCode, resultDetails.Value); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StepResult.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StepResult.cs new file mode 100644 index 0000000000000..6cd2c6da2024e --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StepResult.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// The step result under an update. + public partial class StepResult + { + /// Initializes a new instance of StepResult. + /// Install result code. + /// Install extended result code. + internal StepResult(int resultCode, int extendedResultCode) + { + ResultCode = resultCode; + ExtendedResultCode = extendedResultCode; + } + + /// Initializes a new instance of StepResult. + /// It is update id for update steps; otherwise it is null. + /// Step description. It might be null for update steps. + /// Install result code. + /// Install extended result code. + /// A string containing further details about the install result. + internal StepResult(UpdateId updateId, string description, int resultCode, int extendedResultCode, string resultDetails) + { + UpdateId = updateId; + Description = description; + ResultCode = resultCode; + ExtendedResultCode = extendedResultCode; + ResultDetails = resultDetails; + } + + /// It is update id for update steps; otherwise it is null. + public UpdateId UpdateId { get; } + /// Step description. It might be null for update steps. + public string Description { get; } + /// Install result code. + public int ResultCode { get; } + /// Install extended result code. + public int ExtendedResultCode { get; } + /// A string containing further details about the install result. + public string ResultDetails { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StepType.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StepType.cs new file mode 100644 index 0000000000000..fb47983b6f5cb --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StepType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// Step type. + public readonly partial struct StepType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public StepType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InlineValue = "Inline"; + private const string ReferenceValue = "Reference"; + + /// Step type that performs code execution. + public static StepType Inline { get; } = new StepType(InlineValue); + /// Step type that installs another update. + public static StepType Reference { get; } = new StepType(ReferenceValue); + /// Determines if two values are the same. + public static bool operator ==(StepType left, StepType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(StepType left, StepType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator StepType(string value) => new StepType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is StepType other && Equals(other); + /// + public bool Equals(StepType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfStrings.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StringsList.Serialization.cs similarity index 65% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfStrings.Serialization.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StringsList.Serialization.cs index 81dd2a5b3df44..86632356a78a7 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfStrings.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StringsList.Serialization.cs @@ -11,21 +11,16 @@ namespace Azure.IoT.DeviceUpdate.Models { - internal partial class PageableListOfStrings + internal partial class StringsList { - internal static PageableListOfStrings DeserializePageableListOfStrings(JsonElement element) + internal static StringsList DeserializeStringsList(JsonElement element) { - Optional> value = default; + IReadOnlyList value = default; Optional nextLink = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -40,7 +35,7 @@ internal static PageableListOfStrings DeserializePageableListOfStrings(JsonEleme continue; } } - return new PageableListOfStrings(Optional.ToList(value), nextLink.Value); + return new StringsList(value, nextLink.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfStrings.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StringsList.cs similarity index 53% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfStrings.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StringsList.cs index f91a00f27f2fd..a2625668ec63d 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfStrings.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/StringsList.cs @@ -5,24 +5,32 @@ #nullable disable +using System; using System.Collections.Generic; -using Azure.Core; +using System.Linq; namespace Azure.IoT.DeviceUpdate.Models { /// The list of strings with server paging support. - internal partial class PageableListOfStrings + internal partial class StringsList { - /// Initializes a new instance of PageableListOfStrings. - internal PageableListOfStrings() + /// Initializes a new instance of StringsList. + /// The collection of pageable items. + /// is null. + internal StringsList(IEnumerable value) { - Value = new ChangeTrackingList(); + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); } - /// Initializes a new instance of PageableListOfStrings. + /// Initializes a new instance of StringsList. /// The collection of pageable items. /// The link to the next page of items. - internal PageableListOfStrings(IReadOnlyList value, string nextLink) + internal StringsList(IReadOnlyList value, string nextLink) { Value = value; NextLink = nextLink; diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfUpdatableDevices.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdatableDevicesList.Serialization.cs similarity index 65% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfUpdatableDevices.Serialization.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdatableDevicesList.Serialization.cs index 2bbec6d51ee85..da5114151c0cc 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfUpdatableDevices.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdatableDevicesList.Serialization.cs @@ -11,21 +11,16 @@ namespace Azure.IoT.DeviceUpdate.Models { - internal partial class PageableListOfUpdatableDevices + internal partial class UpdatableDevicesList { - internal static PageableListOfUpdatableDevices DeserializePageableListOfUpdatableDevices(JsonElement element) + internal static UpdatableDevicesList DeserializeUpdatableDevicesList(JsonElement element) { - Optional> value = default; + IReadOnlyList value = default; Optional nextLink = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -40,7 +35,7 @@ internal static PageableListOfUpdatableDevices DeserializePageableListOfUpdatabl continue; } } - return new PageableListOfUpdatableDevices(Optional.ToList(value), nextLink.Value); + return new UpdatableDevicesList(value, nextLink.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfUpdatableDevices.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdatableDevicesList.cs similarity index 50% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfUpdatableDevices.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdatableDevicesList.cs index 23b749b0ce005..9e4f0b7a66df3 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfUpdatableDevices.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdatableDevicesList.cs @@ -5,24 +5,32 @@ #nullable disable +using System; using System.Collections.Generic; -using Azure.Core; +using System.Linq; namespace Azure.IoT.DeviceUpdate.Models { /// The list of updatable devices. - internal partial class PageableListOfUpdatableDevices + internal partial class UpdatableDevicesList { - /// Initializes a new instance of PageableListOfUpdatableDevices. - internal PageableListOfUpdatableDevices() + /// Initializes a new instance of UpdatableDevicesList. + /// The collection of pageable items. + /// is null. + internal UpdatableDevicesList(IEnumerable value) { - Value = new ChangeTrackingList(); + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); } - /// Initializes a new instance of PageableListOfUpdatableDevices. + /// Initializes a new instance of UpdatableDevicesList. /// The collection of pageable items. /// The link to the next page of items. - internal PageableListOfUpdatableDevices(IReadOnlyList value, string nextLink) + internal UpdatableDevicesList(IReadOnlyList value, string nextLink) { Value = value; NextLink = nextLink; diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Update.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Update.Serialization.cs index 46bde42ecb008..a848673c49ea8 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Update.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Update.Serialization.cs @@ -17,9 +17,15 @@ public partial class Update internal static Update DeserializeUpdate(JsonElement element) { UpdateId updateId = default; - string updateType = default; - string installedCriteria = default; - IReadOnlyList compatibility = default; + Optional description = default; + Optional friendlyName = default; + Optional isDeployable = default; + Optional updateType = default; + Optional installedCriteria = default; + IReadOnlyList> compatibility = default; + Optional instructions = default; + Optional> referencedBy = default; + Optional scanResult = default; string manifestVersion = default; DateTimeOffset importedDateTime = default; DateTimeOffset createdDateTime = default; @@ -31,6 +37,26 @@ internal static Update DeserializeUpdate(JsonElement element) updateId = UpdateId.DeserializeUpdateId(property.Value); continue; } + if (property.NameEquals("description")) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("friendlyName")) + { + friendlyName = property.Value.GetString(); + continue; + } + if (property.NameEquals("isDeployable")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + isDeployable = property.Value.GetBoolean(); + continue; + } if (property.NameEquals("updateType")) { updateType = property.Value.GetString(); @@ -43,14 +69,49 @@ internal static Update DeserializeUpdate(JsonElement element) } if (property.NameEquals("compatibility")) { - List array = new List(); + List> array = new List>(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(Models.Compatibility.DeserializeCompatibility(item)); + Dictionary dictionary = new Dictionary(); + foreach (var property0 in item.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + array.Add(dictionary); } compatibility = array; continue; } + if (property.NameEquals("instructions")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + instructions = Instructions.DeserializeInstructions(property.Value); + continue; + } + if (property.NameEquals("referencedBy")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(UpdateId.DeserializeUpdateId(item)); + } + referencedBy = array; + continue; + } + if (property.NameEquals("scanResult")) + { + scanResult = property.Value.GetString(); + continue; + } if (property.NameEquals("manifestVersion")) { manifestVersion = property.Value.GetString(); @@ -72,7 +133,7 @@ internal static Update DeserializeUpdate(JsonElement element) continue; } } - return new Update(updateId, updateType, installedCriteria, compatibility, manifestVersion, importedDateTime, createdDateTime, etag.Value); + return new Update(updateId, description.Value, friendlyName.Value, Optional.ToNullable(isDeployable), updateType.Value, installedCriteria.Value, compatibility, instructions.Value, Optional.ToList(referencedBy), scanResult.Value, manifestVersion, importedDateTime, createdDateTime, etag.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Update.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Update.cs index 1a4b6e4704d92..e307f30d3dae5 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Update.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Update.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.Core; namespace Azure.IoT.DeviceUpdate.Models { @@ -16,27 +17,17 @@ public partial class Update { /// Initializes a new instance of Update. /// Update identity. - /// Update type. - /// String interpreted by Device Update client to determine if the update is installed on the device. /// List of update compatibility information. /// Schema version of manifest used to import the update. /// Date and time in UTC when the update was imported. /// Date and time in UTC when the update was created. - /// , , , , or is null. - internal Update(UpdateId updateId, string updateType, string installedCriteria, IEnumerable compatibility, string manifestVersion, DateTimeOffset importedDateTime, DateTimeOffset createdDateTime) + /// , , or is null. + internal Update(UpdateId updateId, IEnumerable> compatibility, string manifestVersion, DateTimeOffset importedDateTime, DateTimeOffset createdDateTime) { if (updateId == null) { throw new ArgumentNullException(nameof(updateId)); } - if (updateType == null) - { - throw new ArgumentNullException(nameof(updateType)); - } - if (installedCriteria == null) - { - throw new ArgumentNullException(nameof(installedCriteria)); - } if (compatibility == null) { throw new ArgumentNullException(nameof(compatibility)); @@ -47,9 +38,8 @@ internal Update(UpdateId updateId, string updateType, string installedCriteria, } UpdateId = updateId; - UpdateType = updateType; - InstalledCriteria = installedCriteria; Compatibility = compatibility.ToList(); + ReferencedBy = new ChangeTrackingList(); ManifestVersion = manifestVersion; ImportedDateTime = importedDateTime; CreatedDateTime = createdDateTime; @@ -57,19 +47,31 @@ internal Update(UpdateId updateId, string updateType, string installedCriteria, /// Initializes a new instance of Update. /// Update identity. - /// Update type. - /// String interpreted by Device Update client to determine if the update is installed on the device. + /// Update description specified by creator. + /// Friendly update name specified by importer. + /// Whether the update can be deployed to a device on its own. + /// Update type. Deprecated in latest import manifest schema. + /// String interpreted by Device Update client to determine if the update is installed on the device. Deprecated in latest import manifest schema. /// List of update compatibility information. + /// Update install instructions. + /// List of update identities that reference this update. + /// Update aggregate scan result (calculated from payload file scan results). /// Schema version of manifest used to import the update. /// Date and time in UTC when the update was imported. /// Date and time in UTC when the update was created. /// Update ETag. - internal Update(UpdateId updateId, string updateType, string installedCriteria, IReadOnlyList compatibility, string manifestVersion, DateTimeOffset importedDateTime, DateTimeOffset createdDateTime, string etag) + internal Update(UpdateId updateId, string description, string friendlyName, bool? isDeployable, string updateType, string installedCriteria, IReadOnlyList> compatibility, Instructions instructions, IReadOnlyList referencedBy, string scanResult, string manifestVersion, DateTimeOffset importedDateTime, DateTimeOffset createdDateTime, string etag) { UpdateId = updateId; + Description = description; + FriendlyName = friendlyName; + IsDeployable = isDeployable; UpdateType = updateType; InstalledCriteria = installedCriteria; Compatibility = compatibility; + Instructions = instructions; + ReferencedBy = referencedBy; + ScanResult = scanResult; ManifestVersion = manifestVersion; ImportedDateTime = importedDateTime; CreatedDateTime = createdDateTime; @@ -78,12 +80,24 @@ internal Update(UpdateId updateId, string updateType, string installedCriteria, /// Update identity. public UpdateId UpdateId { get; } - /// Update type. + /// Update description specified by creator. + public string Description { get; } + /// Friendly update name specified by importer. + public string FriendlyName { get; } + /// Whether the update can be deployed to a device on its own. + public bool? IsDeployable { get; } + /// Update type. Deprecated in latest import manifest schema. public string UpdateType { get; } - /// String interpreted by Device Update client to determine if the update is installed on the device. + /// String interpreted by Device Update client to determine if the update is installed on the device. Deprecated in latest import manifest schema. public string InstalledCriteria { get; } /// List of update compatibility information. - public IReadOnlyList Compatibility { get; } + public IReadOnlyList> Compatibility { get; } + /// Update install instructions. + public Instructions Instructions { get; } + /// List of update identities that reference this update. + public IReadOnlyList ReferencedBy { get; } + /// Update aggregate scan result (calculated from payload file scan results). + public string ScanResult { get; } /// Schema version of manifest used to import the update. public string ManifestVersion { get; } /// Date and time in UTC when the update was imported. diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/File.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateFile.Serialization.cs similarity index 73% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/File.Serialization.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateFile.Serialization.cs index a714d8b623fff..334e5668e7793 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/File.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateFile.Serialization.cs @@ -11,15 +11,17 @@ namespace Azure.IoT.DeviceUpdate.Models { - public partial class File + public partial class UpdateFile { - internal static File DeserializeFile(JsonElement element) + internal static UpdateFile DeserializeUpdateFile(JsonElement element) { string fileId = default; string fileName = default; long sizeInBytes = default; IReadOnlyDictionary hashes = default; Optional mimeType = default; + Optional scanResult = default; + Optional scanDetails = default; Optional etag = default; foreach (var property in element.EnumerateObject()) { @@ -53,13 +55,23 @@ internal static File DeserializeFile(JsonElement element) mimeType = property.Value.GetString(); continue; } + if (property.NameEquals("scanResult")) + { + scanResult = property.Value.GetString(); + continue; + } + if (property.NameEquals("scanDetails")) + { + scanDetails = property.Value.GetString(); + continue; + } if (property.NameEquals("etag")) { etag = property.Value.GetString(); continue; } } - return new File(fileId, fileName, sizeInBytes, hashes, mimeType.Value, etag.Value); + return new UpdateFile(fileId, fileName, sizeInBytes, hashes, mimeType.Value, scanResult.Value, scanDetails.Value, etag.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/File.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateFile.cs similarity index 73% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/File.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateFile.cs index f95a6434caedc..1c4435e328450 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/File.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateFile.cs @@ -11,15 +11,15 @@ namespace Azure.IoT.DeviceUpdate.Models { /// Update file metadata. - public partial class File + public partial class UpdateFile { - /// Initializes a new instance of File. + /// Initializes a new instance of UpdateFile. /// File identity, generated by server at import time. /// File name. /// File size in number of bytes. /// Mapping of hashing algorithm to base64 encoded hash values. /// , , or is null. - internal File(string fileId, string fileName, long sizeInBytes, IReadOnlyDictionary hashes) + internal UpdateFile(string fileId, string fileName, long sizeInBytes, IReadOnlyDictionary hashes) { if (fileId == null) { @@ -40,20 +40,24 @@ internal File(string fileId, string fileName, long sizeInBytes, IReadOnlyDiction Hashes = hashes; } - /// Initializes a new instance of File. + /// Initializes a new instance of UpdateFile. /// File identity, generated by server at import time. /// File name. /// File size in number of bytes. /// Mapping of hashing algorithm to base64 encoded hash values. /// File MIME type. + /// Anti-malware scan result. + /// Anti-malware scan details. /// File ETag. - internal File(string fileId, string fileName, long sizeInBytes, IReadOnlyDictionary hashes, string mimeType, string etag) + internal UpdateFile(string fileId, string fileName, long sizeInBytes, IReadOnlyDictionary hashes, string mimeType, string scanResult, string scanDetails, string etag) { FileId = fileId; FileName = fileName; SizeInBytes = sizeInBytes; Hashes = hashes; MimeType = mimeType; + ScanResult = scanResult; + ScanDetails = scanDetails; Etag = etag; } @@ -67,6 +71,10 @@ internal File(string fileId, string fileName, long sizeInBytes, IReadOnlyDiction public IReadOnlyDictionary Hashes { get; } /// File MIME type. public string MimeType { get; } + /// Anti-malware scan result. + public string ScanResult { get; } + /// Anti-malware scan details. + public string ScanDetails { get; } /// File ETag. public string Etag { get; } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateFilter.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateFilter.cs new file mode 100644 index 0000000000000..65abc7eae004d --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateFilter.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// Update filter. + internal partial class UpdateFilter + { + /// Initializes a new instance of UpdateFilter. + internal UpdateFilter() + { + } + + /// Update isDeployable property. + public bool? IsDeployable { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfUpdateIds.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateIdsList.Serialization.cs similarity index 65% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfUpdateIds.Serialization.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateIdsList.Serialization.cs index dbe32336a218c..bdcefd39061a3 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfUpdateIds.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateIdsList.Serialization.cs @@ -11,21 +11,16 @@ namespace Azure.IoT.DeviceUpdate.Models { - internal partial class PageableListOfUpdateIds + internal partial class UpdateIdsList { - internal static PageableListOfUpdateIds DeserializePageableListOfUpdateIds(JsonElement element) + internal static UpdateIdsList DeserializeUpdateIdsList(JsonElement element) { - Optional> value = default; + IReadOnlyList value = default; Optional nextLink = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -40,7 +35,7 @@ internal static PageableListOfUpdateIds DeserializePageableListOfUpdateIds(JsonE continue; } } - return new PageableListOfUpdateIds(Optional.ToList(value), nextLink.Value); + return new UpdateIdsList(value, nextLink.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfUpdateIds.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateIdsList.cs similarity index 52% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfUpdateIds.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateIdsList.cs index 275528816a5d3..581322026847c 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/PageableListOfUpdateIds.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateIdsList.cs @@ -5,24 +5,32 @@ #nullable disable +using System; using System.Collections.Generic; -using Azure.Core; +using System.Linq; namespace Azure.IoT.DeviceUpdate.Models { /// The list of update identities. - internal partial class PageableListOfUpdateIds + internal partial class UpdateIdsList { - /// Initializes a new instance of PageableListOfUpdateIds. - internal PageableListOfUpdateIds() + /// Initializes a new instance of UpdateIdsList. + /// The collection of pageable items. + /// is null. + internal UpdateIdsList(IEnumerable value) { - Value = new ChangeTrackingList(); + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); } - /// Initializes a new instance of PageableListOfUpdateIds. + /// Initializes a new instance of UpdateIdsList. /// The collection of pageable items. /// The link to the next page of items. - internal PageableListOfUpdateIds(IReadOnlyList value, string nextLink) + internal UpdateIdsList(IReadOnlyList value, string nextLink) { Value = value; NextLink = nextLink; diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateList.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateList.Serialization.cs new file mode 100644 index 0000000000000..5dd1d9896e480 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateList.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + internal partial class UpdateList + { + internal static UpdateList DeserializeUpdateList(JsonElement element) + { + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Update.DeserializeUpdate(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new UpdateList(value, nextLink.Value); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateList.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateList.cs new file mode 100644 index 0000000000000..5e3c53e7f7e30 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateList.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// The list of updates. + internal partial class UpdateList + { + /// Initializes a new instance of UpdateList. + /// The collection of pageable items. + /// is null. + internal UpdateList(IEnumerable value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); + } + + /// Initializes a new instance of UpdateList. + /// The collection of pageable items. + /// The link to the next page of items. + internal UpdateList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The collection of pageable items. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public string NextLink { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Operation.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperation.Serialization.cs similarity index 90% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Operation.Serialization.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperation.Serialization.cs index a3f640b58c4d9..634aba1c35930 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Operation.Serialization.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperation.Serialization.cs @@ -11,9 +11,9 @@ namespace Azure.IoT.DeviceUpdate.Models { - public partial class Operation + public partial class UpdateOperation { - internal static Operation DeserializeOperation(JsonElement element) + internal static UpdateOperation DeserializeUpdateOperation(JsonElement element) { string operationId = default; OperationStatus status = default; @@ -82,7 +82,7 @@ internal static Operation DeserializeOperation(JsonElement element) continue; } } - return new Operation(operationId, status, updateId.Value, resourceLocation.Value, error.Value, traceId.Value, lastActionDateTime, createdDateTime, etag.Value); + return new UpdateOperation(operationId, status, updateId.Value, resourceLocation.Value, error.Value, traceId.Value, lastActionDateTime, createdDateTime, etag.Value); } } } diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Operation.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperation.cs similarity index 85% rename from sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Operation.cs rename to sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperation.cs index 22063934ae71e..845b998dd9763 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/Operation.cs +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperation.cs @@ -10,15 +10,15 @@ namespace Azure.IoT.DeviceUpdate.Models { /// Operation metadata. - public partial class Operation + public partial class UpdateOperation { - /// Initializes a new instance of Operation. + /// Initializes a new instance of UpdateOperation. /// Operation Id. /// Operation status. /// Date and time in UTC when the operation status was last updated. /// Date and time in UTC when the operation was created. /// is null. - internal Operation(string operationId, OperationStatus status, DateTimeOffset lastActionDateTime, DateTimeOffset createdDateTime) + internal UpdateOperation(string operationId, OperationStatus status, DateTimeOffset lastActionDateTime, DateTimeOffset createdDateTime) { if (operationId == null) { @@ -31,7 +31,7 @@ internal Operation(string operationId, OperationStatus status, DateTimeOffset la CreatedDateTime = createdDateTime; } - /// Initializes a new instance of Operation. + /// Initializes a new instance of UpdateOperation. /// Operation Id. /// Operation status. /// The identity of update being imported or deleted. For import, this property will only be populated after import manifest is processed successfully. @@ -41,7 +41,7 @@ internal Operation(string operationId, OperationStatus status, DateTimeOffset la /// Date and time in UTC when the operation status was last updated. /// Date and time in UTC when the operation was created. /// Operation ETag. - internal Operation(string operationId, OperationStatus status, UpdateId updateId, string resourceLocation, Error error, string traceId, DateTimeOffset lastActionDateTime, DateTimeOffset createdDateTime, string etag) + internal UpdateOperation(string operationId, OperationStatus status, UpdateId updateId, string resourceLocation, Error error, string traceId, DateTimeOffset lastActionDateTime, DateTimeOffset createdDateTime, string etag) { OperationId = operationId; Status = status; diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperationsList.Serialization.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperationsList.Serialization.cs new file mode 100644 index 0000000000000..7e68041923b2c --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperationsList.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.IoT.DeviceUpdate.Models +{ + internal partial class UpdateOperationsList + { + internal static UpdateOperationsList DeserializeUpdateOperationsList(JsonElement element) + { + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value")) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(UpdateOperation.DeserializeUpdateOperation(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new UpdateOperationsList(value, nextLink.Value); + } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperationsList.cs b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperationsList.cs new file mode 100644 index 0000000000000..48c86cecf1026 --- /dev/null +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/Generated/Models/UpdateOperationsList.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.IoT.DeviceUpdate.Models +{ + /// The list of operations with server paging support. + internal partial class UpdateOperationsList + { + /// Initializes a new instance of UpdateOperationsList. + /// The collection of pageable items. + /// is null. + internal UpdateOperationsList(IEnumerable value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + Value = value.ToList(); + } + + /// Initializes a new instance of UpdateOperationsList. + /// The collection of pageable items. + /// The link to the next page of items. + internal UpdateOperationsList(IReadOnlyList value, string nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The collection of pageable items. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public string NextLink { get; } + } +} diff --git a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/autorest.md b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/autorest.md index 325816e63b38b..a04bbc964967d 100644 --- a/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/autorest.md +++ b/sdk/deviceupdate/Azure.IoT.DeviceUpdate/src/autorest.md @@ -8,5 +8,5 @@ Run `generate.ps1` or `dotnet msbuild /t:GenerateCode` to generate code. ``` yaml public-clients: true require: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/53574efb3c9199b9dcec21bd8e7ca5b9e8d4f9b9/specification/deviceupdate/data-plane/readme.md + - https://github.com/Azure/azure-rest-api-specs/blob/d73e2aef15b4670fef9ba7b1cbce825205547212/specification/deviceupdate/data-plane/readme.md ```