From e6b4939f895ebeaa4a8a11e20be8fc8b8ca4444a Mon Sep 17 00:00:00 2001 From: Sindhu Nagesh Date: Tue, 12 May 2020 12:10:44 -0700 Subject: [PATCH] swagger(iothub): Adding overrides for type names --- .../Azure.Iot.Hub.Service/src/API Design.md | 14 + .../src/Customized/Models/DeviceIdentity.cs | 15 + .../src/Customized/Models/ModuleIdentity.cs | 15 + .../src/Customized/Models/PnPDesired.cs | 15 + .../src/Customized/Models/PnpInterface.cs | 15 + .../src/Customized/Models/PnpProperty.cs | 15 + .../src/Customized/Models/PnpReported.cs | 15 + .../Customized/Models/TwinConfiguration.cs | 15 + .../src/Customized/Models/TwinData.cs | 15 + .../{Operations => }/ConfigurationClient.cs | 157 ++- .../ConfigurationRestClient.cs | 550 +++----- .../{Operations => }/DeviceMethodClient.cs | 49 +- .../DeviceMethodRestClient.cs | 178 +-- .../{Operations => }/DigitalTwinClient.cs | 121 +- .../DigitalTwinGetDigitalTwinModelHeaders.cs | 0 ...igitalTwinInvokeComponentCommandHeaders.cs | 0 .../{Operations => }/DigitalTwinRestClient.cs | 476 +++---- .../{Operations => }/FaultInjectionClient.cs | 49 +- .../FaultInjectionRestClient.cs | 136 +- .../{Operations => }/HttpRuntimeClient.cs | 73 +- .../{Operations => }/HttpRuntimeRestClient.cs | 148 +- .../Generated/{Operations => }/JobClient.cs | 193 ++- .../{Operations => }/JobRestClient.cs | 764 ++++------- ...ion.cs => DeviceIdentity.Serialization.cs} | 18 +- .../Models/{Device.cs => DeviceIdentity.cs} | 10 +- .../Models/DeviceRegistryOperationWarning.cs | 1 + .../DigitalTwinInterfaces.Serialization.cs | 6 +- .../Generated/Models/DigitalTwinInterfaces.cs | 4 +- .../FaultInjectionProperties.Serialization.cs | 4 +- .../Models/JobProperties.Serialization.cs | 8 +- .../Models/JobRequest.Serialization.cs | 2 +- .../src/Generated/Models/JobRequest.cs | 4 +- .../Models/JobResponse.Serialization.cs | 10 +- .../src/Generated/Models/JobResponse.cs | 4 +- ...ion.cs => ModuleIdentity.Serialization.cs} | 14 +- .../Models/{Module.cs => ModuleIdentity.cs} | 10 +- ...ization.cs => PnPDesired.Serialization.cs} | 6 +- .../Models/{Desired.cs => PnPDesired.cs} | 10 +- ...ation.cs => PnpInterface.Serialization.cs} | 12 +- .../Models/{Interface.cs => PnpInterface.cs} | 12 +- ...zation.cs => PnpProperty.Serialization.cs} | 14 +- .../Models/{Property.cs => PnpProperty.cs} | 14 +- ...zation.cs => PnpReported.Serialization.cs} | 6 +- .../Models/{Reported.cs => PnpReported.cs} | 10 +- ....cs => TwinConfiguration.Serialization.cs} | 14 +- ...{Configuration.cs => TwinConfiguration.cs} | 10 +- ...alization.cs => TwinData.Serialization.cs} | 14 +- .../Generated/Models/{Twin.cs => TwinData.cs} | 10 +- .../{Operations => }/RegistryManagerClient.cs | 341 ++++- .../RegistryManagerQueryIotHubHeaders.cs | 0 .../RegistryManagerRestClient.cs | 1216 +++++++---------- .../Generated/{Operations => }/TwinClient.cs | 169 ++- .../{Operations => }/TwinRestClient.cs | 560 +++----- 53 files changed, 2842 insertions(+), 2699 deletions(-) create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/DeviceIdentity.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/ModuleIdentity.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnPDesired.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnpInterface.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnpProperty.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnpReported.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/TwinConfiguration.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/TwinData.cs rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/ConfigurationClient.cs (66%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/ConfigurationRestClient.cs (51%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/DeviceMethodClient.cs (69%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/DeviceMethodRestClient.cs (57%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/DigitalTwinClient.cs (72%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/DigitalTwinGetDigitalTwinModelHeaders.cs (100%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/DigitalTwinInvokeComponentCommandHeaders.cs (100%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/DigitalTwinRestClient.cs (57%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/FaultInjectionClient.cs (74%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/FaultInjectionRestClient.cs (59%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/HttpRuntimeClient.cs (75%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/HttpRuntimeRestClient.cs (69%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/JobClient.cs (74%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/JobRestClient.cs (53%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Device.Serialization.cs => DeviceIdentity.Serialization.cs} (95%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Device.cs => DeviceIdentity.cs} (79%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Module.Serialization.cs => ModuleIdentity.Serialization.cs} (93%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Module.cs => ModuleIdentity.cs} (77%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Desired.Serialization.cs => PnPDesired.Serialization.cs} (81%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Desired.cs => PnPDesired.cs} (68%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Interface.Serialization.cs => PnpInterface.Serialization.cs} (75%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Interface.cs => PnpInterface.cs} (64%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Property.Serialization.cs => PnpProperty.Serialization.cs} (67%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Property.cs => PnpProperty.cs} (53%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Reported.Serialization.cs => PnpReported.Serialization.cs} (86%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Reported.cs => PnpReported.cs} (69%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Configuration.Serialization.cs => TwinConfiguration.Serialization.cs} (94%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Configuration.cs => TwinConfiguration.cs} (84%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Twin.Serialization.cs => TwinData.Serialization.cs} (96%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/{Twin.cs => TwinData.cs} (89%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/RegistryManagerClient.cs (66%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/RegistryManagerQueryIotHubHeaders.cs (100%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/RegistryManagerRestClient.cs (51%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/TwinClient.cs (64%) rename sdk/iot/Azure.Iot.Hub.Service/src/Generated/{Operations => }/TwinRestClient.cs (54%) diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/API Design.md b/sdk/iot/Azure.Iot.Hub.Service/src/API Design.md index 0988e80dad816..358932893a51d 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/API Design.md +++ b/sdk/iot/Azure.Iot.Hub.Service/src/API Design.md @@ -1,6 +1,20 @@ # Azure Iot Hub Service API Design Doc This document outlines the APIs for the Azure Iot Hub Service SDK +
Type definition names + +``` +Configuration - TwinConfiguration +Module - ModuleIdentity +Device - DeviceIdentity +Twin - TwinData +Interface - PnpInterface +Property - PnpProperty +Reported - PnpReported +Desired - PnpDesired +``` +
+
Constructors ```csharp diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/DeviceIdentity.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/DeviceIdentity.cs new file mode 100644 index 0000000000000..714a5e7b35a6b --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/DeviceIdentity.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Iot.Hub.Service.Models +{ + /// + /// Device identity. + /// + [CodeGenModel("Device")] + public partial class DeviceIdentity + { + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/ModuleIdentity.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/ModuleIdentity.cs new file mode 100644 index 0000000000000..ea8c7bd4f67d1 --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/ModuleIdentity.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Iot.Hub.Service.Models +{ + /// + /// Module identity. + /// + [CodeGenModel("Module")] + public partial class ModuleIdentity + { + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnPDesired.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnPDesired.cs new file mode 100644 index 0000000000000..3c3ccfdb078ee --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnPDesired.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Iot.Hub.Service.Models +{ + /// + /// The desired property of a digital twin. + /// + [CodeGenModel("Desired")] + internal partial class PnpDesired + { + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnpInterface.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnpInterface.cs new file mode 100644 index 0000000000000..fa5fa3ca9e46e --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnpInterface.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Iot.Hub.Service.Models +{ + /// + /// The digital twin interface which defines all the properties. + /// + [CodeGenModel("Interface")] + internal partial class PnpInterface + { + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnpProperty.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnpProperty.cs new file mode 100644 index 0000000000000..bffcf7997b0f6 --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnpProperty.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Iot.Hub.Service.Models +{ + /// + /// The property of a digital twin. This consists of both the Desired and Reported property. + /// + [CodeGenModel("Property")] + internal partial class PnpProperty + { + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnpReported.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnpReported.cs new file mode 100644 index 0000000000000..66e0565b24a1e --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/PnpReported.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Iot.Hub.Service.Models +{ + /// + /// The reported property of a digital twin. + /// + [CodeGenModel("Reported")] + internal partial class PnpReported + { + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/TwinConfiguration.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/TwinConfiguration.cs new file mode 100644 index 0000000000000..35eefc931e2ee --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/TwinConfiguration.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Iot.Hub.Service.Models +{ + /// + /// Configuration for automatic device and module management. + /// + [CodeGenModel("Configuration")] + public partial class TwinConfiguration + { + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/TwinData.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/TwinData.cs new file mode 100644 index 0000000000000..eb4f3a9489c06 --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Customized/Models/TwinData.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Iot.Hub.Service.Models +{ + /// + /// Twin data. + /// + [CodeGenModel("Twin")] + public partial class TwinData + { + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/ConfigurationClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/ConfigurationClient.cs similarity index 66% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/ConfigurationClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/ConfigurationClient.cs index 5618e5b8ecd41..b8300aa00deca 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/ConfigurationClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/ConfigurationClient.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -35,17 +36,37 @@ internal ConfigurationClient(ClientDiagnostics clientDiagnostics, HttpPipeline p /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The String to use. /// The cancellation token to use. - public virtual async Task> GetAsync(string id, CancellationToken cancellationToken = default) + public virtual async Task> GetAsync(string id, CancellationToken cancellationToken = default) { - return await RestClient.GetAsync(id, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(id, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The String to use. /// The cancellation token to use. - public virtual Response Get(string id, CancellationToken cancellationToken = default) + public virtual Response Get(string id, CancellationToken cancellationToken = default) { - return RestClient.Get(id, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.Get"); + scope.Start(); + try + { + return RestClient.Get(id, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -53,9 +74,19 @@ public virtual Response Get(string id, CancellationToken cancella /// The Configuration to use. /// The String to use. /// The cancellation token to use. - public virtual async Task> CreateOrUpdateAsync(string id, Configuration configuration, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual async Task> CreateOrUpdateAsync(string id, TwinConfiguration configuration, string ifMatch = null, CancellationToken cancellationToken = default) { - return await RestClient.CreateOrUpdateAsync(id, configuration, ifMatch, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.CreateOrUpdate"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateAsync(id, configuration, ifMatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -63,9 +94,19 @@ public virtual async Task> CreateOrUpdateAsync(string id /// The Configuration to use. /// The String to use. /// The cancellation token to use. - public virtual Response CreateOrUpdate(string id, Configuration configuration, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual Response CreateOrUpdate(string id, TwinConfiguration configuration, string ifMatch = null, CancellationToken cancellationToken = default) { - return RestClient.CreateOrUpdate(id, configuration, ifMatch, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.CreateOrUpdate"); + scope.Start(); + try + { + return RestClient.CreateOrUpdate(id, configuration, ifMatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -74,7 +115,17 @@ public virtual Response CreateOrUpdate(string id, Configuration c /// The cancellation token to use. public virtual async Task DeleteAsync(string id, string ifMatch = null, CancellationToken cancellationToken = default) { - return await RestClient.DeleteAsync(id, ifMatch, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.Delete"); + scope.Start(); + try + { + return await RestClient.DeleteAsync(id, ifMatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -83,23 +134,53 @@ public virtual async Task DeleteAsync(string id, string ifMatch = null /// The cancellation token to use. public virtual Response Delete(string id, string ifMatch = null, CancellationToken cancellationToken = default) { - return RestClient.Delete(id, ifMatch, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.Delete"); + scope.Start(); + try + { + return RestClient.Delete(id, ifMatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The Integer to use. /// The cancellation token to use. - public virtual async Task>> GetConfigurationsAsync(int? top = null, CancellationToken cancellationToken = default) + public virtual async Task>> GetConfigurationsAsync(int? top = null, CancellationToken cancellationToken = default) { - return await RestClient.GetConfigurationsAsync(top, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.GetConfigurations"); + scope.Start(); + try + { + return await RestClient.GetConfigurationsAsync(top, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The Integer to use. /// The cancellation token to use. - public virtual Response> GetConfigurations(int? top = null, CancellationToken cancellationToken = default) + public virtual Response> GetConfigurations(int? top = null, CancellationToken cancellationToken = default) { - return RestClient.GetConfigurations(top, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.GetConfigurations"); + scope.Start(); + try + { + return RestClient.GetConfigurations(top, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Validates the target condition query and custom metric queries for a configuration. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -107,7 +188,17 @@ public virtual Response> GetConfigurations(int? top /// The cancellation token to use. public virtual async Task> TestQueriesAsync(ConfigurationQueriesTestInput input, CancellationToken cancellationToken = default) { - return await RestClient.TestQueriesAsync(input, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.TestQueries"); + scope.Start(); + try + { + return await RestClient.TestQueriesAsync(input, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Validates the target condition query and custom metric queries for a configuration. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -115,7 +206,17 @@ public virtual async Task> TestQuerie /// The cancellation token to use. public virtual Response TestQueries(ConfigurationQueriesTestInput input, CancellationToken cancellationToken = default) { - return RestClient.TestQueries(input, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.TestQueries"); + scope.Start(); + try + { + return RestClient.TestQueries(input, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Applies the provided configuration content to the specified edge device. Configuration content must have modules content For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -124,7 +225,17 @@ public virtual Response TestQueries(Configurat /// The cancellation token to use. public virtual async Task> ApplyOnEdgeDeviceAsync(string id, ConfigurationContent content, CancellationToken cancellationToken = default) { - return await RestClient.ApplyOnEdgeDeviceAsync(id, content, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.ApplyOnEdgeDevice"); + scope.Start(); + try + { + return await RestClient.ApplyOnEdgeDeviceAsync(id, content, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Applies the provided configuration content to the specified edge device. Configuration content must have modules content For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -133,7 +244,17 @@ public virtual async Task> ApplyOnEdgeDeviceAsync(string id, Co /// The cancellation token to use. public virtual Response ApplyOnEdgeDevice(string id, ConfigurationContent content, CancellationToken cancellationToken = default) { - return RestClient.ApplyOnEdgeDevice(id, content, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.ApplyOnEdgeDevice"); + scope.Start(); + try + { + return RestClient.ApplyOnEdgeDevice(id, content, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/ConfigurationRestClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/ConfigurationRestClient.cs similarity index 51% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/ConfigurationRestClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/ConfigurationRestClient.cs index a4305dda39f2d..344b957a34d02 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/ConfigurationRestClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/ConfigurationRestClient.cs @@ -59,90 +59,70 @@ internal HttpMessage CreateGetRequest(string id) /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The String to use. /// The cancellation token to use. - public async ValueTask> GetAsync(string id, CancellationToken cancellationToken = default) + public async ValueTask> GetAsync(string id, CancellationToken cancellationToken = default) { if (id == null) { throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.Get"); - scope.Start(); - try + using var message = CreateGetRequest(id); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateGetRequest(id); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinConfiguration value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Configuration value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Configuration.DeserializeConfiguration(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinConfiguration.DeserializeTwinConfiguration(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The String to use. /// The cancellation token to use. - public Response Get(string id, CancellationToken cancellationToken = default) + public Response Get(string id, CancellationToken cancellationToken = default) { if (id == null) { throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.Get"); - scope.Start(); - try + using var message = CreateGetRequest(id); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateGetRequest(id); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinConfiguration value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Configuration value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Configuration.DeserializeConfiguration(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinConfiguration.DeserializeTwinConfiguration(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateCreateOrUpdateRequest(string id, Configuration configuration, string ifMatch) + internal HttpMessage CreateCreateOrUpdateRequest(string id, TwinConfiguration configuration, string ifMatch) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -169,7 +149,7 @@ internal HttpMessage CreateCreateOrUpdateRequest(string id, Configuration config /// The Configuration to use. /// The String to use. /// The cancellation token to use. - public async ValueTask> CreateOrUpdateAsync(string id, Configuration configuration, string ifMatch = null, CancellationToken cancellationToken = default) + public async ValueTask> CreateOrUpdateAsync(string id, TwinConfiguration configuration, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -180,37 +160,27 @@ public async ValueTask> CreateOrUpdateAsync(string id, C throw new ArgumentNullException(nameof(configuration)); } - using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.CreateOrUpdate"); - scope.Start(); - try + using var message = CreateCreateOrUpdateRequest(id, configuration, ifMatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateCreateOrUpdateRequest(id, configuration, ifMatch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: + case 200: + case 201: + { + TwinConfiguration value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Configuration value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Configuration.DeserializeConfiguration(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinConfiguration.DeserializeTwinConfiguration(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -219,7 +189,7 @@ public async ValueTask> CreateOrUpdateAsync(string id, C /// The Configuration to use. /// The String to use. /// The cancellation token to use. - public Response CreateOrUpdate(string id, Configuration configuration, string ifMatch = null, CancellationToken cancellationToken = default) + public Response CreateOrUpdate(string id, TwinConfiguration configuration, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -230,37 +200,27 @@ public Response CreateOrUpdate(string id, Configuration configura throw new ArgumentNullException(nameof(configuration)); } - using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.CreateOrUpdate"); - scope.Start(); - try + using var message = CreateCreateOrUpdateRequest(id, configuration, ifMatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateCreateOrUpdateRequest(id, configuration, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: + case 200: + case 201: + { + TwinConfiguration value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Configuration value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Configuration.DeserializeConfiguration(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinConfiguration.DeserializeTwinConfiguration(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -293,24 +253,14 @@ public async ValueTask DeleteAsync(string id, string ifMatch = null, C throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.Delete"); - scope.Start(); - try + using var message = CreateDeleteRequest(id, ifMatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateDeleteRequest(id, ifMatch); - 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); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -325,24 +275,14 @@ public Response Delete(string id, string ifMatch = null, CancellationToken cance throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.Delete"); - scope.Start(); - try - { - using var message = CreateDeleteRequest(id, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) + using var message = CreateDeleteRequest(id, ifMatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - scope.Failed(e); - throw; + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -366,100 +306,80 @@ internal HttpMessage CreateGetConfigurationsRequest(int? top) /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The Integer to use. /// The cancellation token to use. - public async ValueTask>> GetConfigurationsAsync(int? top = null, CancellationToken cancellationToken = default) + public async ValueTask>> GetConfigurationsAsync(int? top = null, CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.GetConfigurations"); - scope.Start(); - try - { - using var message = CreateGetConfigurationsRequest(top); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetConfigurationsRequest(top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + IReadOnlyList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - IReadOnlyList value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else + value = null; + } + else + { + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) { - List array = new List(); - foreach (var item in document.RootElement.EnumerateArray()) + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(Configuration.DeserializeConfiguration(item)); - } + array.Add(TwinConfiguration.DeserializeTwinConfiguration(item)); } - value = array; } - return Response.FromValue(value, message.Response); + value = array; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The Integer to use. /// The cancellation token to use. - public Response> GetConfigurations(int? top = null, CancellationToken cancellationToken = default) + public Response> GetConfigurations(int? top = null, CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.GetConfigurations"); - scope.Start(); - try - { - using var message = CreateGetConfigurationsRequest(top); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetConfigurationsRequest(top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + IReadOnlyList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - IReadOnlyList value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else + value = null; + } + else + { + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) { - List array = new List(); - foreach (var item in document.RootElement.EnumerateArray()) + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(Configuration.DeserializeConfiguration(item)); - } + array.Add(TwinConfiguration.DeserializeTwinConfiguration(item)); } - value = array; } - return Response.FromValue(value, message.Response); + value = array; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -490,36 +410,26 @@ public async ValueTask> TestQueriesAs throw new ArgumentNullException(nameof(input)); } - using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.TestQueries"); - scope.Start(); - try + using var message = CreateTestQueriesRequest(input); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateTestQueriesRequest(input); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + ConfigurationQueriesTestResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - ConfigurationQueriesTestResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = ConfigurationQueriesTestResponse.DeserializeConfigurationQueriesTestResponse(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = ConfigurationQueriesTestResponse.DeserializeConfigurationQueriesTestResponse(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -533,36 +443,26 @@ public Response TestQueries(ConfigurationQueri throw new ArgumentNullException(nameof(input)); } - using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.TestQueries"); - scope.Start(); - try + using var message = CreateTestQueriesRequest(input); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateTestQueriesRequest(input); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + ConfigurationQueriesTestResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - ConfigurationQueriesTestResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = ConfigurationQueriesTestResponse.DeserializeConfigurationQueriesTestResponse(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = ConfigurationQueriesTestResponse.DeserializeConfigurationQueriesTestResponse(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -600,38 +500,28 @@ public async ValueTask> ApplyOnEdgeDeviceAsync(string id, Confi throw new ArgumentNullException(nameof(content)); } - using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.ApplyOnEdgeDevice"); - scope.Start(); - try + using var message = CreateApplyOnEdgeDeviceRequest(id, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateApplyOnEdgeDeviceRequest(id, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + object value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - object value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = document.RootElement.GetObject(); - } - return Response.FromValue(value, message.Response); + value = null; } - case 204: - return Response.FromValue(null, message.Response); - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = document.RootElement.GetObject(); + } + return Response.FromValue(value, message.Response); + } + case 204: + return Response.FromValue(null, message.Response); + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -650,38 +540,28 @@ public Response ApplyOnEdgeDevice(string id, ConfigurationContent conten throw new ArgumentNullException(nameof(content)); } - using var scope = _clientDiagnostics.CreateScope("ConfigurationClient.ApplyOnEdgeDevice"); - scope.Start(); - try + using var message = CreateApplyOnEdgeDeviceRequest(id, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateApplyOnEdgeDeviceRequest(id, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + object value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - object value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = document.RootElement.GetObject(); - } - return Response.FromValue(value, message.Response); + value = null; } - case 204: - return Response.FromValue(null, message.Response); - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = document.RootElement.GetObject(); + } + return Response.FromValue(value, message.Response); + } + case 204: + return Response.FromValue(null, message.Response); + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DeviceMethodClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/DeviceMethodClient.cs similarity index 69% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DeviceMethodClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/DeviceMethodClient.cs index c5d264436a05c..74d4498fad595 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DeviceMethodClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/DeviceMethodClient.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Threading; using System.Threading.Tasks; using Azure; @@ -37,7 +38,17 @@ internal DeviceMethodClient(ClientDiagnostics clientDiagnostics, HttpPipeline pi /// The cancellation token to use. public virtual async Task> InvokeDeviceMethodAsync(string deviceId, CloudToDeviceMethod directMethodRequest, CancellationToken cancellationToken = default) { - return await RestClient.InvokeDeviceMethodAsync(deviceId, directMethodRequest, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("DeviceMethodClient.InvokeDeviceMethod"); + scope.Start(); + try + { + return await RestClient.InvokeDeviceMethodAsync(deviceId, directMethodRequest, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Invoke a direct method on a device. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-direct-methods for more information. @@ -46,7 +57,17 @@ public virtual async Task> InvokeDeviceMetho /// The cancellation token to use. public virtual Response InvokeDeviceMethod(string deviceId, CloudToDeviceMethod directMethodRequest, CancellationToken cancellationToken = default) { - return RestClient.InvokeDeviceMethod(deviceId, directMethodRequest, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("DeviceMethodClient.InvokeDeviceMethod"); + scope.Start(); + try + { + return RestClient.InvokeDeviceMethod(deviceId, directMethodRequest, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Invoke a direct method on a module of a device. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-direct-methods for more information. @@ -56,7 +77,17 @@ public virtual Response InvokeDeviceMethod(string dev /// The cancellation token to use. public virtual async Task> InvokeModuleMethodAsync(string deviceId, string moduleId, CloudToDeviceMethod directMethodRequest, CancellationToken cancellationToken = default) { - return await RestClient.InvokeModuleMethodAsync(deviceId, moduleId, directMethodRequest, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("DeviceMethodClient.InvokeModuleMethod"); + scope.Start(); + try + { + return await RestClient.InvokeModuleMethodAsync(deviceId, moduleId, directMethodRequest, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Invoke a direct method on a module of a device. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-direct-methods for more information. @@ -66,7 +97,17 @@ public virtual async Task> InvokeModuleMetho /// The cancellation token to use. public virtual Response InvokeModuleMethod(string deviceId, string moduleId, CloudToDeviceMethod directMethodRequest, CancellationToken cancellationToken = default) { - return RestClient.InvokeModuleMethod(deviceId, moduleId, directMethodRequest, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("DeviceMethodClient.InvokeModuleMethod"); + scope.Start(); + try + { + return RestClient.InvokeModuleMethod(deviceId, moduleId, directMethodRequest, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DeviceMethodRestClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/DeviceMethodRestClient.cs similarity index 57% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DeviceMethodRestClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/DeviceMethodRestClient.cs index ba65fa852c76c..339bff491ff63 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DeviceMethodRestClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/DeviceMethodRestClient.cs @@ -75,36 +75,26 @@ public async ValueTask> InvokeDeviceMethodAs throw new ArgumentNullException(nameof(directMethodRequest)); } - using var scope = _clientDiagnostics.CreateScope("DeviceMethodClient.InvokeDeviceMethod"); - scope.Start(); - try - { - using var message = CreateInvokeDeviceMethodRequest(deviceId, directMethodRequest); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + using var message = CreateInvokeDeviceMethodRequest(deviceId, directMethodRequest); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CloudToDeviceMethodResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - CloudToDeviceMethodResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = CloudToDeviceMethodResult.DeserializeCloudToDeviceMethodResult(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = CloudToDeviceMethodResult.DeserializeCloudToDeviceMethodResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -123,36 +113,26 @@ public Response InvokeDeviceMethod(string deviceId, C throw new ArgumentNullException(nameof(directMethodRequest)); } - using var scope = _clientDiagnostics.CreateScope("DeviceMethodClient.InvokeDeviceMethod"); - scope.Start(); - try + using var message = CreateInvokeDeviceMethodRequest(deviceId, directMethodRequest); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateInvokeDeviceMethodRequest(deviceId, directMethodRequest); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + CloudToDeviceMethodResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - CloudToDeviceMethodResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = CloudToDeviceMethodResult.DeserializeCloudToDeviceMethodResult(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = CloudToDeviceMethodResult.DeserializeCloudToDeviceMethodResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -197,36 +177,26 @@ public async ValueTask> InvokeModuleMethodAs throw new ArgumentNullException(nameof(directMethodRequest)); } - using var scope = _clientDiagnostics.CreateScope("DeviceMethodClient.InvokeModuleMethod"); - scope.Start(); - try + using var message = CreateInvokeModuleMethodRequest(deviceId, moduleId, directMethodRequest); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateInvokeModuleMethodRequest(deviceId, moduleId, directMethodRequest); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + CloudToDeviceMethodResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - CloudToDeviceMethodResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = CloudToDeviceMethodResult.DeserializeCloudToDeviceMethodResult(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = CloudToDeviceMethodResult.DeserializeCloudToDeviceMethodResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -250,36 +220,26 @@ public Response InvokeModuleMethod(string deviceId, s throw new ArgumentNullException(nameof(directMethodRequest)); } - using var scope = _clientDiagnostics.CreateScope("DeviceMethodClient.InvokeModuleMethod"); - scope.Start(); - try + using var message = CreateInvokeModuleMethodRequest(deviceId, moduleId, directMethodRequest); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateInvokeModuleMethodRequest(deviceId, moduleId, directMethodRequest); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + CloudToDeviceMethodResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - CloudToDeviceMethodResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = CloudToDeviceMethodResult.DeserializeCloudToDeviceMethodResult(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = CloudToDeviceMethodResult.DeserializeCloudToDeviceMethodResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DigitalTwinClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/DigitalTwinClient.cs similarity index 72% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DigitalTwinClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/DigitalTwinClient.cs index ffc6fc3efe833..efe4ec677e259 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DigitalTwinClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/DigitalTwinClient.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Threading; using System.Threading.Tasks; using Azure; @@ -36,7 +37,17 @@ internal DigitalTwinClient(ClientDiagnostics clientDiagnostics, HttpPipeline pip /// The cancellation token to use. public virtual async Task> GetComponentsAsync(string digitalTwinId, CancellationToken cancellationToken = default) { - return await RestClient.GetComponentsAsync(digitalTwinId, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.GetComponents"); + scope.Start(); + try + { + return await RestClient.GetComponentsAsync(digitalTwinId, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -44,7 +55,17 @@ public virtual async Task> GetComponentsAsync(st /// The cancellation token to use. public virtual Response GetComponents(string digitalTwinId, CancellationToken cancellationToken = default) { - return RestClient.GetComponents(digitalTwinId, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.GetComponents"); + scope.Start(); + try + { + return RestClient.GetComponents(digitalTwinId, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -54,7 +75,17 @@ public virtual Response GetComponents(string digitalTwinI /// The cancellation token to use. public virtual async Task> UpdateComponentAsync(string digitalTwinId, DigitalTwinInterfacesPatch interfacesPatchInfo, string ifMatch = null, CancellationToken cancellationToken = default) { - return await RestClient.UpdateComponentAsync(digitalTwinId, interfacesPatchInfo, ifMatch, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.UpdateComponent"); + scope.Start(); + try + { + return await RestClient.UpdateComponentAsync(digitalTwinId, interfacesPatchInfo, ifMatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -64,7 +95,17 @@ public virtual async Task> UpdateComponentAsync( /// The cancellation token to use. public virtual Response UpdateComponent(string digitalTwinId, DigitalTwinInterfacesPatch interfacesPatchInfo, string ifMatch = null, CancellationToken cancellationToken = default) { - return RestClient.UpdateComponent(digitalTwinId, interfacesPatchInfo, ifMatch, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.UpdateComponent"); + scope.Start(); + try + { + return RestClient.UpdateComponent(digitalTwinId, interfacesPatchInfo, ifMatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -73,7 +114,17 @@ public virtual Response UpdateComponent(string digitalTwi /// The cancellation token to use. public virtual async Task> GetComponentAsync(string digitalTwinId, string interfaceName, CancellationToken cancellationToken = default) { - return await RestClient.GetComponentAsync(digitalTwinId, interfaceName, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.GetComponent"); + scope.Start(); + try + { + return await RestClient.GetComponentAsync(digitalTwinId, interfaceName, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -82,7 +133,17 @@ public virtual async Task> GetComponentAsync(str /// The cancellation token to use. public virtual Response GetComponent(string digitalTwinId, string interfaceName, CancellationToken cancellationToken = default) { - return RestClient.GetComponent(digitalTwinId, interfaceName, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.GetComponent"); + scope.Start(); + try + { + return RestClient.GetComponent(digitalTwinId, interfaceName, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -95,7 +156,17 @@ public virtual Response GetComponent(string digitalTwinId /// The cancellation token to use. public virtual async Task> GetDigitalTwinModelAsync(string modelId, bool? expand = null, CancellationToken cancellationToken = default) { - return await RestClient.GetDigitalTwinModelAsync(modelId, expand, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.GetDigitalTwinModel"); + scope.Start(); + try + { + return await RestClient.GetDigitalTwinModelAsync(modelId, expand, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -108,7 +179,17 @@ public virtual async Task> GetDigitalTwinModelAsync(string mode /// The cancellation token to use. public virtual Response GetDigitalTwinModel(string modelId, bool? expand = null, CancellationToken cancellationToken = default) { - return RestClient.GetDigitalTwinModel(modelId, expand, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.GetDigitalTwinModel"); + scope.Start(); + try + { + return RestClient.GetDigitalTwinModel(modelId, expand, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Invoke a digital twin interface command. @@ -121,7 +202,17 @@ public virtual Response GetDigitalTwinModel(string modelId, bool? expand /// The cancellation token to use. public virtual async Task> InvokeComponentCommandAsync(string digitalTwinId, string interfaceName, string commandName, object payload, int? connectTimeoutInSeconds = null, int? responseTimeoutInSeconds = null, CancellationToken cancellationToken = default) { - return await RestClient.InvokeComponentCommandAsync(digitalTwinId, interfaceName, commandName, payload, connectTimeoutInSeconds, responseTimeoutInSeconds, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.InvokeComponentCommand"); + scope.Start(); + try + { + return await RestClient.InvokeComponentCommandAsync(digitalTwinId, interfaceName, commandName, payload, connectTimeoutInSeconds, responseTimeoutInSeconds, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Invoke a digital twin interface command. @@ -134,7 +225,17 @@ public virtual async Task> InvokeComponentCommandAsync(string d /// The cancellation token to use. public virtual Response InvokeComponentCommand(string digitalTwinId, string interfaceName, string commandName, object payload, int? connectTimeoutInSeconds = null, int? responseTimeoutInSeconds = null, CancellationToken cancellationToken = default) { - return RestClient.InvokeComponentCommand(digitalTwinId, interfaceName, commandName, payload, connectTimeoutInSeconds, responseTimeoutInSeconds, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.InvokeComponentCommand"); + scope.Start(); + try + { + return RestClient.InvokeComponentCommand(digitalTwinId, interfaceName, commandName, payload, connectTimeoutInSeconds, responseTimeoutInSeconds, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DigitalTwinGetDigitalTwinModelHeaders.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/DigitalTwinGetDigitalTwinModelHeaders.cs similarity index 100% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DigitalTwinGetDigitalTwinModelHeaders.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/DigitalTwinGetDigitalTwinModelHeaders.cs diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DigitalTwinInvokeComponentCommandHeaders.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/DigitalTwinInvokeComponentCommandHeaders.cs similarity index 100% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DigitalTwinInvokeComponentCommandHeaders.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/DigitalTwinInvokeComponentCommandHeaders.cs diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DigitalTwinRestClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/DigitalTwinRestClient.cs similarity index 57% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DigitalTwinRestClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/DigitalTwinRestClient.cs index a3db22bd1b846..221b573cb19db 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/DigitalTwinRestClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/DigitalTwinRestClient.cs @@ -66,36 +66,26 @@ public async ValueTask> GetComponentsAsync(strin throw new ArgumentNullException(nameof(digitalTwinId)); } - using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.GetComponents"); - scope.Start(); - try - { - using var message = CreateGetComponentsRequest(digitalTwinId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetComponentsRequest(digitalTwinId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DigitalTwinInterfaces value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - DigitalTwinInterfaces value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = DigitalTwinInterfaces.DeserializeDigitalTwinInterfaces(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = DigitalTwinInterfaces.DeserializeDigitalTwinInterfaces(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -109,36 +99,26 @@ public Response GetComponents(string digitalTwinId, Cance throw new ArgumentNullException(nameof(digitalTwinId)); } - using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.GetComponents"); - scope.Start(); - try - { - using var message = CreateGetComponentsRequest(digitalTwinId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetComponentsRequest(digitalTwinId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DigitalTwinInterfaces value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - DigitalTwinInterfaces value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = DigitalTwinInterfaces.DeserializeDigitalTwinInterfaces(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = DigitalTwinInterfaces.DeserializeDigitalTwinInterfaces(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -181,36 +161,26 @@ public async ValueTask> UpdateComponentAsync(str throw new ArgumentNullException(nameof(interfacesPatchInfo)); } - using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.UpdateComponent"); - scope.Start(); - try - { - using var message = CreateUpdateComponentRequest(digitalTwinId, interfacesPatchInfo, ifMatch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + using var message = CreateUpdateComponentRequest(digitalTwinId, interfacesPatchInfo, ifMatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DigitalTwinInterfaces value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - DigitalTwinInterfaces value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = DigitalTwinInterfaces.DeserializeDigitalTwinInterfaces(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = DigitalTwinInterfaces.DeserializeDigitalTwinInterfaces(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -230,36 +200,26 @@ public Response UpdateComponent(string digitalTwinId, Dig throw new ArgumentNullException(nameof(interfacesPatchInfo)); } - using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.UpdateComponent"); - scope.Start(); - try - { - using var message = CreateUpdateComponentRequest(digitalTwinId, interfacesPatchInfo, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + using var message = CreateUpdateComponentRequest(digitalTwinId, interfacesPatchInfo, ifMatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DigitalTwinInterfaces value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - DigitalTwinInterfaces value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = DigitalTwinInterfaces.DeserializeDigitalTwinInterfaces(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = DigitalTwinInterfaces.DeserializeDigitalTwinInterfaces(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -294,36 +254,26 @@ public async ValueTask> GetComponentAsync(string throw new ArgumentNullException(nameof(interfaceName)); } - using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.GetComponent"); - scope.Start(); - try - { - using var message = CreateGetComponentRequest(digitalTwinId, interfaceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetComponentRequest(digitalTwinId, interfaceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DigitalTwinInterfaces value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - DigitalTwinInterfaces value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = DigitalTwinInterfaces.DeserializeDigitalTwinInterfaces(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = DigitalTwinInterfaces.DeserializeDigitalTwinInterfaces(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -342,36 +292,26 @@ public Response GetComponent(string digitalTwinId, string throw new ArgumentNullException(nameof(interfaceName)); } - using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.GetComponent"); - scope.Start(); - try - { - using var message = CreateGetComponentRequest(digitalTwinId, interfaceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetComponentRequest(digitalTwinId, interfaceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DigitalTwinInterfaces value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - DigitalTwinInterfaces value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = DigitalTwinInterfaces.DeserializeDigitalTwinInterfaces(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = DigitalTwinInterfaces.DeserializeDigitalTwinInterfaces(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -408,39 +348,29 @@ public async ValueTask(null, headers, message.Response); - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = document.RootElement.GetObject(); + } + return ResponseWithHeaders.FromValue(value, headers, message.Response); + } + case 204: + return ResponseWithHeaders.FromValue(null, headers, message.Response); + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -459,39 +389,29 @@ public ResponseWithHeaders GetDig throw new ArgumentNullException(nameof(modelId)); } - using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.GetDigitalTwinModel"); - scope.Start(); - try - { - using var message = CreateGetDigitalTwinModelRequest(modelId, expand); - _pipeline.Send(message, cancellationToken); - var headers = new DigitalTwinGetDigitalTwinModelHeaders(message.Response); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetDigitalTwinModelRequest(modelId, expand); + _pipeline.Send(message, cancellationToken); + var headers = new DigitalTwinGetDigitalTwinModelHeaders(message.Response); + switch (message.Response.Status) + { + case 200: + { + object value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - object value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = document.RootElement.GetObject(); - } - return ResponseWithHeaders.FromValue(value, headers, message.Response); + value = null; } - case 204: - return ResponseWithHeaders.FromValue(null, headers, message.Response); - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = document.RootElement.GetObject(); + } + return ResponseWithHeaders.FromValue(value, headers, message.Response); + } + case 204: + return ResponseWithHeaders.FromValue(null, headers, message.Response); + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -552,37 +472,27 @@ public async ValueTask Inv throw new ArgumentNullException(nameof(payload)); } - using var scope = _clientDiagnostics.CreateScope("DigitalTwinClient.InvokeComponentCommand"); - scope.Start(); - try - { - using var message = CreateInvokeComponentCommandRequest(digitalTwinId, interfaceName, commandName, payload, connectTimeoutInSeconds, responseTimeoutInSeconds); - _pipeline.Send(message, cancellationToken); - var headers = new DigitalTwinInvokeComponentCommandHeaders(message.Response); - switch (message.Response.Status) - { - case 200: + using var message = CreateInvokeComponentCommandRequest(digitalTwinId, interfaceName, commandName, payload, connectTimeoutInSeconds, responseTimeoutInSeconds); + _pipeline.Send(message, cancellationToken); + var headers = new DigitalTwinInvokeComponentCommandHeaders(message.Response); + switch (message.Response.Status) + { + case 200: + { + object value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - object value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = document.RootElement.GetObject(); - } - return ResponseWithHeaders.FromValue(value, headers, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = document.RootElement.GetObject(); + } + return ResponseWithHeaders.FromValue(value, headers, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/FaultInjectionClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/FaultInjectionClient.cs similarity index 74% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/FaultInjectionClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/FaultInjectionClient.cs index 11aa51d752a54..c381f9b7b00e9 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/FaultInjectionClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/FaultInjectionClient.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Threading; using System.Threading.Tasks; using Azure; @@ -35,14 +36,34 @@ internal FaultInjectionClient(ClientDiagnostics clientDiagnostics, HttpPipeline /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - return await RestClient.GetAsync(cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("FaultInjectionClient.Get"); + scope.Start(); + try + { + return await RestClient.GetAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - return RestClient.Get(cancellationToken); + using var scope = _clientDiagnostics.CreateScope("FaultInjectionClient.Get"); + scope.Start(); + try + { + return RestClient.Get(cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -50,7 +71,17 @@ public virtual Response Get(CancellationToken cancella /// The cancellation token to use. public virtual async Task SetAsync(FaultInjectionProperties value, CancellationToken cancellationToken = default) { - return await RestClient.SetAsync(value, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("FaultInjectionClient.Set"); + scope.Start(); + try + { + return await RestClient.SetAsync(value, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -58,7 +89,17 @@ public virtual async Task SetAsync(FaultInjectionProperties value, Can /// The cancellation token to use. public virtual Response Set(FaultInjectionProperties value, CancellationToken cancellationToken = default) { - return RestClient.Set(value, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("FaultInjectionClient.Set"); + scope.Start(); + try + { + return RestClient.Set(value, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/FaultInjectionRestClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/FaultInjectionRestClient.cs similarity index 59% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/FaultInjectionRestClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/FaultInjectionRestClient.cs index 118987f8d657e..1cb29e0a048ae 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/FaultInjectionRestClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/FaultInjectionRestClient.cs @@ -58,36 +58,26 @@ internal HttpMessage CreateGetRequest() /// The cancellation token to use. public async ValueTask> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("FaultInjectionClient.Get"); - scope.Start(); - try + using var message = CreateGetRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateGetRequest(); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + FaultInjectionProperties value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - FaultInjectionProperties value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = FaultInjectionProperties.DeserializeFaultInjectionProperties(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = FaultInjectionProperties.DeserializeFaultInjectionProperties(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -95,36 +85,26 @@ public async ValueTask> GetAsync(Cancellation /// The cancellation token to use. public Response Get(CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("FaultInjectionClient.Get"); - scope.Start(); - try + using var message = CreateGetRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateGetRequest(); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + FaultInjectionProperties value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - FaultInjectionProperties value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = FaultInjectionProperties.DeserializeFaultInjectionProperties(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = FaultInjectionProperties.DeserializeFaultInjectionProperties(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -155,24 +135,14 @@ public async ValueTask SetAsync(FaultInjectionProperties value, Cancel throw new ArgumentNullException(nameof(value)); } - using var scope = _clientDiagnostics.CreateScope("FaultInjectionClient.Set"); - scope.Start(); - try - { - using var message = CreateSetRequest(value); - 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); - } - } - catch (Exception e) + using var message = CreateSetRequest(value); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - scope.Failed(e); - throw; + case 200: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -186,24 +156,14 @@ public Response Set(FaultInjectionProperties value, CancellationToken cancellati throw new ArgumentNullException(nameof(value)); } - using var scope = _clientDiagnostics.CreateScope("FaultInjectionClient.Set"); - scope.Start(); - try - { - using var message = CreateSetRequest(value); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - return message.Response; - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) + using var message = CreateSetRequest(value); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - scope.Failed(e); - throw; + case 200: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/HttpRuntimeClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/HttpRuntimeClient.cs similarity index 75% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/HttpRuntimeClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/HttpRuntimeClient.cs index 69c29dbb8d242..5b46adfa8172f 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/HttpRuntimeClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/HttpRuntimeClient.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Threading; using System.Threading.Tasks; using Azure; @@ -34,14 +35,34 @@ internal HttpRuntimeClient(ClientDiagnostics clientDiagnostics, HttpPipeline pip /// The cancellation token to use. public virtual async Task ReceiveFeedbackNotificationAsync(CancellationToken cancellationToken = default) { - return await RestClient.ReceiveFeedbackNotificationAsync(cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("HttpRuntimeClient.ReceiveFeedbackNotification"); + scope.Start(); + try + { + return await RestClient.ReceiveFeedbackNotificationAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// This method is used to retrieve feedback of a cloud-to-device message See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging for more information. This capability is only available in the standard tier IoT Hub. For more information, see [Choose the right IoT Hub tier](https://aka.ms/scaleyouriotsolution). For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The cancellation token to use. public virtual Response ReceiveFeedbackNotification(CancellationToken cancellationToken = default) { - return RestClient.ReceiveFeedbackNotification(cancellationToken); + using var scope = _clientDiagnostics.CreateScope("HttpRuntimeClient.ReceiveFeedbackNotification"); + scope.Start(); + try + { + return RestClient.ReceiveFeedbackNotification(cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// This method completes a feedback message. The lockToken obtained when the message was received must be provided to resolve race conditions when completing, a feedback message. A completed message is deleted from the feedback queue. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -49,7 +70,17 @@ public virtual Response ReceiveFeedbackNotification(CancellationToken cancellati /// The cancellation token to use. public virtual async Task CompleteFeedbackNotificationAsync(string lockToken, CancellationToken cancellationToken = default) { - return await RestClient.CompleteFeedbackNotificationAsync(lockToken, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("HttpRuntimeClient.CompleteFeedbackNotification"); + scope.Start(); + try + { + return await RestClient.CompleteFeedbackNotificationAsync(lockToken, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// This method completes a feedback message. The lockToken obtained when the message was received must be provided to resolve race conditions when completing, a feedback message. A completed message is deleted from the feedback queue. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -57,7 +88,17 @@ public virtual async Task CompleteFeedbackNotificationAsync(string loc /// The cancellation token to use. public virtual Response CompleteFeedbackNotification(string lockToken, CancellationToken cancellationToken = default) { - return RestClient.CompleteFeedbackNotification(lockToken, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("HttpRuntimeClient.CompleteFeedbackNotification"); + scope.Start(); + try + { + return RestClient.CompleteFeedbackNotification(lockToken, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// This method abandons a feedback message. The lockToken obtained when the message was received must be provided to resolve race conditions when abandoning, a feedback message. A abandoned message is deleted from the feedback queue. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -65,7 +106,17 @@ public virtual Response CompleteFeedbackNotification(string lockToken, Cancellat /// The cancellation token to use. public virtual async Task AbandonFeedbackNotificationAsync(string lockToken, CancellationToken cancellationToken = default) { - return await RestClient.AbandonFeedbackNotificationAsync(lockToken, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("HttpRuntimeClient.AbandonFeedbackNotification"); + scope.Start(); + try + { + return await RestClient.AbandonFeedbackNotificationAsync(lockToken, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// This method abandons a feedback message. The lockToken obtained when the message was received must be provided to resolve race conditions when abandoning, a feedback message. A abandoned message is deleted from the feedback queue. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -73,7 +124,17 @@ public virtual async Task AbandonFeedbackNotificationAsync(string lock /// The cancellation token to use. public virtual Response AbandonFeedbackNotification(string lockToken, CancellationToken cancellationToken = default) { - return RestClient.AbandonFeedbackNotification(lockToken, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("HttpRuntimeClient.AbandonFeedbackNotification"); + scope.Start(); + try + { + return RestClient.AbandonFeedbackNotification(lockToken, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/HttpRuntimeRestClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/HttpRuntimeRestClient.cs similarity index 69% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/HttpRuntimeRestClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/HttpRuntimeRestClient.cs index 0879caed988a9..09f2529f35f6a 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/HttpRuntimeRestClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/HttpRuntimeRestClient.cs @@ -56,25 +56,15 @@ internal HttpMessage CreateReceiveFeedbackNotificationRequest() /// The cancellation token to use. public async ValueTask ReceiveFeedbackNotificationAsync(CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("HttpRuntimeClient.ReceiveFeedbackNotification"); - scope.Start(); - try + using var message = CreateReceiveFeedbackNotificationRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateReceiveFeedbackNotificationRequest(); - 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); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + case 200: + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -82,25 +72,15 @@ public async ValueTask ReceiveFeedbackNotificationAsync(CancellationTo /// The cancellation token to use. public Response ReceiveFeedbackNotification(CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("HttpRuntimeClient.ReceiveFeedbackNotification"); - scope.Start(); - try - { - using var message = CreateReceiveFeedbackNotificationRequest(); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) + using var message = CreateReceiveFeedbackNotificationRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - scope.Failed(e); - throw; + case 200: + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -128,24 +108,14 @@ public async ValueTask CompleteFeedbackNotificationAsync(string lockTo throw new ArgumentNullException(nameof(lockToken)); } - using var scope = _clientDiagnostics.CreateScope("HttpRuntimeClient.CompleteFeedbackNotification"); - scope.Start(); - try - { - using var message = CreateCompleteFeedbackNotificationRequest(lockToken); - 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); - } - } - catch (Exception e) + using var message = CreateCompleteFeedbackNotificationRequest(lockToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - scope.Failed(e); - throw; + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -159,24 +129,14 @@ public Response CompleteFeedbackNotification(string lockToken, CancellationToken throw new ArgumentNullException(nameof(lockToken)); } - using var scope = _clientDiagnostics.CreateScope("HttpRuntimeClient.CompleteFeedbackNotification"); - scope.Start(); - try + using var message = CreateCompleteFeedbackNotificationRequest(lockToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateCompleteFeedbackNotificationRequest(lockToken); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -205,24 +165,14 @@ public async ValueTask AbandonFeedbackNotificationAsync(string lockTok throw new ArgumentNullException(nameof(lockToken)); } - using var scope = _clientDiagnostics.CreateScope("HttpRuntimeClient.AbandonFeedbackNotification"); - scope.Start(); - try - { - using var message = CreateAbandonFeedbackNotificationRequest(lockToken); - 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); - } - } - catch (Exception e) + using var message = CreateAbandonFeedbackNotificationRequest(lockToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - scope.Failed(e); - throw; + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -236,24 +186,14 @@ public Response AbandonFeedbackNotification(string lockToken, CancellationToken throw new ArgumentNullException(nameof(lockToken)); } - using var scope = _clientDiagnostics.CreateScope("HttpRuntimeClient.AbandonFeedbackNotification"); - scope.Start(); - try - { - using var message = CreateAbandonFeedbackNotificationRequest(lockToken); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) + using var message = CreateAbandonFeedbackNotificationRequest(lockToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - scope.Failed(e); - throw; + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/JobClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/JobClient.cs similarity index 74% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/JobClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/JobClient.cs index d798be5bae4e3..b85007ca28e65 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/JobClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/JobClient.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -37,7 +38,17 @@ internal JobClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, s /// The cancellation token to use. public virtual async Task> CreateImportExportJobAsync(JobProperties jobProperties, CancellationToken cancellationToken = default) { - return await RestClient.CreateImportExportJobAsync(jobProperties, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("JobClient.CreateImportExportJob"); + scope.Start(); + try + { + return await RestClient.CreateImportExportJobAsync(jobProperties, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Create a new import/export job on an IoT hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -45,21 +56,51 @@ public virtual async Task> CreateImportExportJobAsync(Jo /// The cancellation token to use. public virtual Response CreateImportExportJob(JobProperties jobProperties, CancellationToken cancellationToken = default) { - return RestClient.CreateImportExportJob(jobProperties, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("JobClient.CreateImportExportJob"); + scope.Start(); + try + { + return RestClient.CreateImportExportJob(jobProperties, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Gets the status of all import/export jobs in an iot hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The cancellation token to use. public virtual async Task>> GetImportExportJobsAsync(CancellationToken cancellationToken = default) { - return await RestClient.GetImportExportJobsAsync(cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("JobClient.GetImportExportJobs"); + scope.Start(); + try + { + return await RestClient.GetImportExportJobsAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Gets the status of all import/export jobs in an iot hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The cancellation token to use. public virtual Response> GetImportExportJobs(CancellationToken cancellationToken = default) { - return RestClient.GetImportExportJobs(cancellationToken); + using var scope = _clientDiagnostics.CreateScope("JobClient.GetImportExportJobs"); + scope.Start(); + try + { + return RestClient.GetImportExportJobs(cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Gets the status of an import or export job in an iot hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -67,7 +108,17 @@ public virtual Response> GetImportExportJobs(Cancel /// The cancellation token to use. public virtual async Task> GetImportExportJobAsync(string id, CancellationToken cancellationToken = default) { - return await RestClient.GetImportExportJobAsync(id, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("JobClient.GetImportExportJob"); + scope.Start(); + try + { + return await RestClient.GetImportExportJobAsync(id, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Gets the status of an import or export job in an iot hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -75,7 +126,17 @@ public virtual async Task> GetImportExportJobAsync(strin /// The cancellation token to use. public virtual Response GetImportExportJob(string id, CancellationToken cancellationToken = default) { - return RestClient.GetImportExportJob(id, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("JobClient.GetImportExportJob"); + scope.Start(); + try + { + return RestClient.GetImportExportJob(id, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Cancels an import or export job in an IoT hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -83,7 +144,17 @@ public virtual Response GetImportExportJob(string id, Cancellatio /// The cancellation token to use. public virtual async Task> CancelImportExportJobAsync(string id, CancellationToken cancellationToken = default) { - return await RestClient.CancelImportExportJobAsync(id, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("JobClient.CancelImportExportJob"); + scope.Start(); + try + { + return await RestClient.CancelImportExportJobAsync(id, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Cancels an import or export job in an IoT hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -91,7 +162,17 @@ public virtual async Task> CancelImportExportJobAsync(string id /// The cancellation token to use. public virtual Response CancelImportExportJob(string id, CancellationToken cancellationToken = default) { - return RestClient.CancelImportExportJob(id, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("JobClient.CancelImportExportJob"); + scope.Start(); + try + { + return RestClient.CancelImportExportJob(id, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Retrieves details of a scheduled job from an IoT hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-jobs for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -99,7 +180,17 @@ public virtual Response CancelImportExportJob(string id, CancellationTok /// The cancellation token to use. public virtual async Task> GetJobAsync(string id, CancellationToken cancellationToken = default) { - return await RestClient.GetJobAsync(id, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("JobClient.GetJob"); + scope.Start(); + try + { + return await RestClient.GetJobAsync(id, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Retrieves details of a scheduled job from an IoT hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-jobs for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -107,7 +198,17 @@ public virtual async Task> GetJobAsync(string id, Cancella /// The cancellation token to use. public virtual Response GetJob(string id, CancellationToken cancellationToken = default) { - return RestClient.GetJob(id, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("JobClient.GetJob"); + scope.Start(); + try + { + return RestClient.GetJob(id, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Creates a new job to schedule update twins or device direct methods on an IoT hub at a scheduled time. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-jobs for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -116,7 +217,17 @@ public virtual Response GetJob(string id, CancellationToken cancell /// The cancellation token to use. public virtual async Task> CreateJobAsync(string id, JobRequest jobRequest, CancellationToken cancellationToken = default) { - return await RestClient.CreateJobAsync(id, jobRequest, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("JobClient.CreateJob"); + scope.Start(); + try + { + return await RestClient.CreateJobAsync(id, jobRequest, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Creates a new job to schedule update twins or device direct methods on an IoT hub at a scheduled time. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-jobs for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -125,7 +236,17 @@ public virtual async Task> CreateJobAsync(string id, JobRe /// The cancellation token to use. public virtual Response CreateJob(string id, JobRequest jobRequest, CancellationToken cancellationToken = default) { - return RestClient.CreateJob(id, jobRequest, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("JobClient.CreateJob"); + scope.Start(); + try + { + return RestClient.CreateJob(id, jobRequest, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Cancels a scheduled job on an IoT hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-jobs for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -133,7 +254,17 @@ public virtual Response CreateJob(string id, JobRequest jobRequest, /// The cancellation token to use. public virtual async Task> CancelJobAsync(string id, CancellationToken cancellationToken = default) { - return await RestClient.CancelJobAsync(id, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("JobClient.CancelJob"); + scope.Start(); + try + { + return await RestClient.CancelJobAsync(id, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Cancels a scheduled job on an IoT hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-jobs for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -141,7 +272,17 @@ public virtual async Task> CancelJobAsync(string id, Cance /// The cancellation token to use. public virtual Response CancelJob(string id, CancellationToken cancellationToken = default) { - return RestClient.CancelJob(id, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("JobClient.CancelJob"); + scope.Start(); + try + { + return RestClient.CancelJob(id, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Query an IoT hub to retrieve information regarding jobs using the IoT Hub query language. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language for more information. Pagination of results is supported. This returns information about jobs only. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -150,7 +291,17 @@ public virtual Response CancelJob(string id, CancellationToken canc /// The cancellation token to use. public virtual async Task> QueryJobsAsync(string jobType = null, string jobStatus = null, CancellationToken cancellationToken = default) { - return await RestClient.QueryJobsAsync(jobType, jobStatus, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("JobClient.QueryJobs"); + scope.Start(); + try + { + return await RestClient.QueryJobsAsync(jobType, jobStatus, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Query an IoT hub to retrieve information regarding jobs using the IoT Hub query language. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language for more information. Pagination of results is supported. This returns information about jobs only. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -159,7 +310,17 @@ public virtual async Task> QueryJobsAsync(string jobType = /// The cancellation token to use. public virtual Response QueryJobs(string jobType = null, string jobStatus = null, CancellationToken cancellationToken = default) { - return RestClient.QueryJobs(jobType, jobStatus, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("JobClient.QueryJobs"); + scope.Start(); + try + { + return RestClient.QueryJobs(jobType, jobStatus, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/JobRestClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/JobRestClient.cs similarity index 53% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/JobRestClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/JobRestClient.cs index 18e5e08acb636..ffe433881e219 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/JobRestClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/JobRestClient.cs @@ -69,36 +69,26 @@ public async ValueTask> CreateImportExportJobAsync(JobPr throw new ArgumentNullException(nameof(jobProperties)); } - using var scope = _clientDiagnostics.CreateScope("JobClient.CreateImportExportJob"); - scope.Start(); - try - { - using var message = CreateCreateImportExportJobRequest(jobProperties); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - JobProperties value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = JobProperties.DeserializeJobProperties(document.RootElement); - } - return Response.FromValue(value, message.Response); + using var message = CreateCreateImportExportJobRequest(jobProperties); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + JobProperties value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) + { + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = JobProperties.DeserializeJobProperties(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -112,36 +102,26 @@ public Response CreateImportExportJob(JobProperties jobProperties throw new ArgumentNullException(nameof(jobProperties)); } - using var scope = _clientDiagnostics.CreateScope("JobClient.CreateImportExportJob"); - scope.Start(); - try + using var message = CreateCreateImportExportJobRequest(jobProperties); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateCreateImportExportJobRequest(jobProperties); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + JobProperties value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - JobProperties value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = JobProperties.DeserializeJobProperties(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = JobProperties.DeserializeJobProperties(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -162,48 +142,38 @@ internal HttpMessage CreateGetImportExportJobsRequest() /// The cancellation token to use. public async ValueTask>> GetImportExportJobsAsync(CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("JobClient.GetImportExportJobs"); - scope.Start(); - try - { - using var message = CreateGetImportExportJobsRequest(); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - IReadOnlyList value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else + using var message = CreateGetImportExportJobsRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + IReadOnlyList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) + { + value = null; + } + else + { + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) { - List array = new List(); - foreach (var item in document.RootElement.EnumerateArray()) + if (item.ValueKind == JsonValueKind.Null) { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(JobProperties.DeserializeJobProperties(item)); - } + array.Add(null); + } + else + { + array.Add(JobProperties.DeserializeJobProperties(item)); } - value = array; } - return Response.FromValue(value, message.Response); + value = array; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -211,48 +181,38 @@ public async ValueTask>> GetImportExportJo /// The cancellation token to use. public Response> GetImportExportJobs(CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("JobClient.GetImportExportJobs"); - scope.Start(); - try - { - using var message = CreateGetImportExportJobsRequest(); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - IReadOnlyList value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else + using var message = CreateGetImportExportJobsRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + IReadOnlyList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) + { + value = null; + } + else + { + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) { - List array = new List(); - foreach (var item in document.RootElement.EnumerateArray()) + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(JobProperties.DeserializeJobProperties(item)); - } + array.Add(JobProperties.DeserializeJobProperties(item)); } - value = array; } - return Response.FromValue(value, message.Response); + value = array; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -280,36 +240,26 @@ public async ValueTask> GetImportExportJobAsync(string i throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("JobClient.GetImportExportJob"); - scope.Start(); - try + using var message = CreateGetImportExportJobRequest(id); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateGetImportExportJobRequest(id); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + JobProperties value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - JobProperties value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = JobProperties.DeserializeJobProperties(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = JobProperties.DeserializeJobProperties(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -323,36 +273,26 @@ public Response GetImportExportJob(string id, CancellationToken c throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("JobClient.GetImportExportJob"); - scope.Start(); - try + using var message = CreateGetImportExportJobRequest(id); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateGetImportExportJobRequest(id); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + JobProperties value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - JobProperties value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = JobProperties.DeserializeJobProperties(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = JobProperties.DeserializeJobProperties(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -380,38 +320,28 @@ public async ValueTask> CancelImportExportJobAsync(string id, C throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("JobClient.CancelImportExportJob"); - scope.Start(); - try + using var message = CreateCancelImportExportJobRequest(id); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateCancelImportExportJobRequest(id); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + object value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - object value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = document.RootElement.GetObject(); - } - return Response.FromValue(value, message.Response); + value = null; } - case 204: - return Response.FromValue(null, message.Response); - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = document.RootElement.GetObject(); + } + return Response.FromValue(value, message.Response); + } + case 204: + return Response.FromValue(null, message.Response); + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -425,38 +355,28 @@ public Response CancelImportExportJob(string id, CancellationToken cance throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("JobClient.CancelImportExportJob"); - scope.Start(); - try + using var message = CreateCancelImportExportJobRequest(id); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateCancelImportExportJobRequest(id); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + object value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - object value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = document.RootElement.GetObject(); - } - return Response.FromValue(value, message.Response); + value = null; } - case 204: - return Response.FromValue(null, message.Response); - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = document.RootElement.GetObject(); + } + return Response.FromValue(value, message.Response); + } + case 204: + return Response.FromValue(null, message.Response); + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -484,36 +404,26 @@ public async ValueTask> GetJobAsync(string id, Cancellatio throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("JobClient.GetJob"); - scope.Start(); - try + using var message = CreateGetJobRequest(id); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateGetJobRequest(id); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + JobResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - JobResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = JobResponse.DeserializeJobResponse(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = JobResponse.DeserializeJobResponse(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -527,36 +437,26 @@ public Response GetJob(string id, CancellationToken cancellationTok throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("JobClient.GetJob"); - scope.Start(); - try + using var message = CreateGetJobRequest(id); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateGetJobRequest(id); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + JobResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - JobResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = JobResponse.DeserializeJobResponse(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = JobResponse.DeserializeJobResponse(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -593,36 +493,26 @@ public async ValueTask> CreateJobAsync(string id, JobReque throw new ArgumentNullException(nameof(jobRequest)); } - using var scope = _clientDiagnostics.CreateScope("JobClient.CreateJob"); - scope.Start(); - try + using var message = CreateCreateJobRequest(id, jobRequest); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateCreateJobRequest(id, jobRequest); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + JobResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - JobResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = JobResponse.DeserializeJobResponse(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = JobResponse.DeserializeJobResponse(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -641,36 +531,26 @@ public Response CreateJob(string id, JobRequest jobRequest, Cancell throw new ArgumentNullException(nameof(jobRequest)); } - using var scope = _clientDiagnostics.CreateScope("JobClient.CreateJob"); - scope.Start(); - try + using var message = CreateCreateJobRequest(id, jobRequest); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateCreateJobRequest(id, jobRequest); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + JobResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - JobResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = JobResponse.DeserializeJobResponse(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = JobResponse.DeserializeJobResponse(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -699,36 +579,26 @@ public async ValueTask> CancelJobAsync(string id, Cancella throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("JobClient.CancelJob"); - scope.Start(); - try + using var message = CreateCancelJobRequest(id); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateCancelJobRequest(id); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + JobResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - JobResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = JobResponse.DeserializeJobResponse(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = JobResponse.DeserializeJobResponse(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -742,36 +612,26 @@ public Response CancelJob(string id, CancellationToken cancellation throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("JobClient.CancelJob"); - scope.Start(); - try + using var message = CreateCancelJobRequest(id); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateCancelJobRequest(id); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + JobResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - JobResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = JobResponse.DeserializeJobResponse(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = JobResponse.DeserializeJobResponse(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -802,36 +662,26 @@ internal HttpMessage CreateQueryJobsRequest(string jobType, string jobStatus) /// The cancellation token to use. public async ValueTask> QueryJobsAsync(string jobType = null, string jobStatus = null, CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("JobClient.QueryJobs"); - scope.Start(); - try - { - using var message = CreateQueryJobsRequest(jobType, jobStatus); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - QueryResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = QueryResult.DeserializeQueryResult(document.RootElement); - } - return Response.FromValue(value, message.Response); + using var message = CreateQueryJobsRequest(jobType, jobStatus); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + QueryResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) + { + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = QueryResult.DeserializeQueryResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -841,36 +691,26 @@ public async ValueTask> QueryJobsAsync(string jobType = nu /// The cancellation token to use. public Response QueryJobs(string jobType = null, string jobStatus = null, CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("JobClient.QueryJobs"); - scope.Start(); - try - { - using var message = CreateQueryJobsRequest(jobType, jobStatus); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - QueryResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = QueryResult.DeserializeQueryResult(document.RootElement); - } - return Response.FromValue(value, message.Response); + using var message = CreateQueryJobsRequest(jobType, jobStatus); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + QueryResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) + { + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = QueryResult.DeserializeQueryResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Device.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DeviceIdentity.Serialization.cs similarity index 95% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Device.Serialization.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DeviceIdentity.Serialization.cs index a206d2db8cf26..1c6f8030dc78d 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Device.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DeviceIdentity.Serialization.cs @@ -12,7 +12,7 @@ namespace Azure.Iot.Hub.Service.Models { - public partial class Device : IUtf8JsonSerializable + public partial class DeviceIdentity : IUtf8JsonSerializable { void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { @@ -50,17 +50,17 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (ConnectionStateUpdatedTime != null) { writer.WritePropertyName("connectionStateUpdatedTime"); - writer.WriteStringValue(ConnectionStateUpdatedTime.Value, "S"); + writer.WriteStringValue(ConnectionStateUpdatedTime.Value, "O"); } if (StatusUpdatedTime != null) { writer.WritePropertyName("statusUpdatedTime"); - writer.WriteStringValue(StatusUpdatedTime.Value, "S"); + writer.WriteStringValue(StatusUpdatedTime.Value, "O"); } if (LastActivityTime != null) { writer.WritePropertyName("lastActivityTime"); - writer.WriteStringValue(LastActivityTime.Value, "S"); + writer.WriteStringValue(LastActivityTime.Value, "O"); } if (CloudToDeviceMessageCount != null) { @@ -95,7 +95,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } - internal static Device DeserializeDevice(JsonElement element) + internal static DeviceIdentity DeserializeDeviceIdentity(JsonElement element) { string deviceId = default; string generationId = default; @@ -173,7 +173,7 @@ internal static Device DeserializeDevice(JsonElement element) { continue; } - connectionStateUpdatedTime = property.Value.GetDateTimeOffset("S"); + connectionStateUpdatedTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("statusUpdatedTime")) @@ -182,7 +182,7 @@ internal static Device DeserializeDevice(JsonElement element) { continue; } - statusUpdatedTime = property.Value.GetDateTimeOffset("S"); + statusUpdatedTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("lastActivityTime")) @@ -191,7 +191,7 @@ internal static Device DeserializeDevice(JsonElement element) { continue; } - lastActivityTime = property.Value.GetDateTimeOffset("S"); + lastActivityTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("cloudToDeviceMessageCount")) @@ -252,7 +252,7 @@ internal static Device DeserializeDevice(JsonElement element) continue; } } - return new Device(deviceId, generationId, etag, connectionState, status, statusReason, connectionStateUpdatedTime, statusUpdatedTime, lastActivityTime, cloudToDeviceMessageCount, authentication, capabilities, deviceScope, parentScopes); + return new DeviceIdentity(deviceId, generationId, etag, connectionState, status, statusReason, connectionStateUpdatedTime, statusUpdatedTime, lastActivityTime, cloudToDeviceMessageCount, authentication, capabilities, deviceScope, parentScopes); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Device.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DeviceIdentity.cs similarity index 79% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Device.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DeviceIdentity.cs index 2f28ef34401c1..68f179a39d159 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Device.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DeviceIdentity.cs @@ -11,14 +11,14 @@ namespace Azure.Iot.Hub.Service.Models { /// The Device. - public partial class Device + public partial class DeviceIdentity { - /// Initializes a new instance of Device. - public Device() + /// Initializes a new instance of DeviceIdentity. + public DeviceIdentity() { } - /// Initializes a new instance of Device. + /// Initializes a new instance of DeviceIdentity. /// . /// . /// . @@ -33,7 +33,7 @@ public Device() /// Status of Capabilities enabled on the device. /// . /// . - internal Device(string deviceId, string generationId, string etag, DeviceConnectionState? connectionState, DeviceStatus? status, string statusReason, DateTimeOffset? connectionStateUpdatedTime, DateTimeOffset? statusUpdatedTime, DateTimeOffset? lastActivityTime, int? cloudToDeviceMessageCount, AuthenticationMechanism authentication, DeviceCapabilities capabilities, string deviceScope, IList parentScopes) + internal DeviceIdentity(string deviceId, string generationId, string etag, DeviceConnectionState? connectionState, DeviceStatus? status, string statusReason, DateTimeOffset? connectionStateUpdatedTime, DateTimeOffset? statusUpdatedTime, DateTimeOffset? lastActivityTime, int? cloudToDeviceMessageCount, AuthenticationMechanism authentication, DeviceCapabilities capabilities, string deviceScope, IList parentScopes) { DeviceId = deviceId; GenerationId = generationId; diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DeviceRegistryOperationWarning.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DeviceRegistryOperationWarning.cs index 890c2461277ea..e9f354eed096e 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DeviceRegistryOperationWarning.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DeviceRegistryOperationWarning.cs @@ -13,6 +13,7 @@ public partial class DeviceRegistryOperationWarning /// Initializes a new instance of DeviceRegistryOperationWarning. internal DeviceRegistryOperationWarning() { + WarningCode = "DeviceRegisteredWithoutTwin"; } /// Initializes a new instance of DeviceRegistryOperationWarning. diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DigitalTwinInterfaces.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DigitalTwinInterfaces.Serialization.cs index f0d775a2af342..179c15f8659b9 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DigitalTwinInterfaces.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DigitalTwinInterfaces.Serialization.cs @@ -15,7 +15,7 @@ public partial class DigitalTwinInterfaces { internal static DigitalTwinInterfaces DeserializeDigitalTwinInterfaces(JsonElement element) { - IReadOnlyDictionary interfaces = default; + IReadOnlyDictionary interfaces = default; long? version = default; foreach (var property in element.EnumerateObject()) { @@ -25,7 +25,7 @@ internal static DigitalTwinInterfaces DeserializeDigitalTwinInterfaces(JsonEleme { continue; } - Dictionary dictionary = new Dictionary(); + Dictionary dictionary = new Dictionary(); foreach (var property0 in property.Value.EnumerateObject()) { if (property0.Value.ValueKind == JsonValueKind.Null) @@ -34,7 +34,7 @@ internal static DigitalTwinInterfaces DeserializeDigitalTwinInterfaces(JsonEleme } else { - dictionary.Add(property0.Name, Interface.DeserializeInterface(property0.Value)); + dictionary.Add(property0.Name, PnpInterface.DeserializePnpInterface(property0.Value)); } } interfaces = dictionary; diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DigitalTwinInterfaces.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DigitalTwinInterfaces.cs index 96649aafd04d4..c24ab37093ddc 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DigitalTwinInterfaces.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/DigitalTwinInterfaces.cs @@ -20,14 +20,14 @@ internal DigitalTwinInterfaces() /// Initializes a new instance of DigitalTwinInterfaces. /// Interface(s) data on the digital twin. /// Version of digital twin. - internal DigitalTwinInterfaces(IReadOnlyDictionary interfaces, long? version) + internal DigitalTwinInterfaces(IReadOnlyDictionary interfaces, long? version) { Interfaces = interfaces; Version = version; } /// Interface(s) data on the digital twin. - public IReadOnlyDictionary Interfaces { get; } + public IReadOnlyDictionary Interfaces { get; } /// Version of digital twin. public long? Version { get; } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/FaultInjectionProperties.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/FaultInjectionProperties.Serialization.cs index b85ff482e4ca8..598d0d432b813 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/FaultInjectionProperties.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/FaultInjectionProperties.Serialization.cs @@ -29,7 +29,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (LastUpdatedTimeUtc != null) { writer.WritePropertyName("lastUpdatedTimeUtc"); - writer.WriteStringValue(LastUpdatedTimeUtc.Value, "S"); + writer.WriteStringValue(LastUpdatedTimeUtc.Value, "O"); } writer.WriteEndObject(); } @@ -65,7 +65,7 @@ internal static FaultInjectionProperties DeserializeFaultInjectionProperties(Jso { continue; } - lastUpdatedTimeUtc = property.Value.GetDateTimeOffset("S"); + lastUpdatedTimeUtc = property.Value.GetDateTimeOffset("O"); continue; } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobProperties.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobProperties.Serialization.cs index ebe0a557effe6..cc05e6e9f02ad 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobProperties.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobProperties.Serialization.cs @@ -24,12 +24,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (StartTimeUtc != null) { writer.WritePropertyName("startTimeUtc"); - writer.WriteStringValue(StartTimeUtc.Value, "S"); + writer.WriteStringValue(StartTimeUtc.Value, "O"); } if (EndTimeUtc != null) { writer.WritePropertyName("endTimeUtc"); - writer.WriteStringValue(EndTimeUtc.Value, "S"); + writer.WriteStringValue(EndTimeUtc.Value, "O"); } if (Type != null) { @@ -116,7 +116,7 @@ internal static JobProperties DeserializeJobProperties(JsonElement element) { continue; } - startTimeUtc = property.Value.GetDateTimeOffset("S"); + startTimeUtc = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("endTimeUtc")) @@ -125,7 +125,7 @@ internal static JobProperties DeserializeJobProperties(JsonElement element) { continue; } - endTimeUtc = property.Value.GetDateTimeOffset("S"); + endTimeUtc = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("type")) diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobRequest.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobRequest.Serialization.cs index 01b0bc49bbddb..ddb7f0b165ce6 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobRequest.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobRequest.Serialization.cs @@ -43,7 +43,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (StartTime != null) { writer.WritePropertyName("startTime"); - writer.WriteStringValue(StartTime.Value, "S"); + writer.WriteStringValue(StartTime.Value, "O"); } if (MaxExecutionTimeInSeconds != null) { diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobRequest.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobRequest.cs index 4501850f2cd41..03918194d7b0d 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobRequest.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobRequest.cs @@ -37,7 +37,7 @@ public JobRequest() /// /// ISO 8601 date time to start the job. /// Max execution time in secounds (ttl duration). - internal JobRequest(string jobId, JobRequestType? type, CloudToDeviceMethod cloudToDeviceMethod, Twin updateTwin, string queryCondition, DateTimeOffset? startTime, long? maxExecutionTimeInSeconds) + internal JobRequest(string jobId, JobRequestType? type, CloudToDeviceMethod cloudToDeviceMethod, TwinData updateTwin, string queryCondition, DateTimeOffset? startTime, long? maxExecutionTimeInSeconds) { JobId = jobId; Type = type; @@ -63,7 +63,7 @@ internal JobRequest(string jobId, JobRequestType? type, CloudToDeviceMethod clou /// public CloudToDeviceMethod CloudToDeviceMethod { get; set; } /// Twin Representation. - public Twin UpdateTwin { get; set; } + public TwinData UpdateTwin { get; set; } /// /// Required if jobType is updateTwin or cloudToDeviceMethod. /// diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobResponse.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobResponse.Serialization.cs index ab3583d64042c..fc2acd7dc1762 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobResponse.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobResponse.Serialization.cs @@ -23,7 +23,7 @@ internal static JobResponse DeserializeJobResponse(JsonElement element) long? maxExecutionTimeInSeconds = default; JobResponseType? type = default; CloudToDeviceMethod cloudToDeviceMethod = default; - Twin updateTwin = default; + TwinData updateTwin = default; JobResponseStatus? status = default; string failureReason = default; string statusMessage = default; @@ -54,7 +54,7 @@ internal static JobResponse DeserializeJobResponse(JsonElement element) { continue; } - createdTime = property.Value.GetDateTimeOffset("S"); + createdTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("startTime")) @@ -63,7 +63,7 @@ internal static JobResponse DeserializeJobResponse(JsonElement element) { continue; } - startTime = property.Value.GetDateTimeOffset("S"); + startTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("endTime")) @@ -72,7 +72,7 @@ internal static JobResponse DeserializeJobResponse(JsonElement element) { continue; } - endTime = property.Value.GetDateTimeOffset("S"); + endTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("maxExecutionTimeInSeconds")) @@ -108,7 +108,7 @@ internal static JobResponse DeserializeJobResponse(JsonElement element) { continue; } - updateTwin = Twin.DeserializeTwin(property.Value); + updateTwin = TwinData.DeserializeTwinData(property.Value); continue; } if (property.NameEquals("status")) diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobResponse.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobResponse.cs index d165f7e73ecd5..8413ccfe5f138 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobResponse.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/JobResponse.cs @@ -47,7 +47,7 @@ internal JobResponse() /// /// Status message for the job. /// Job details. - internal JobResponse(string jobId, string queryCondition, DateTimeOffset? createdTime, DateTimeOffset? startTime, DateTimeOffset? endTime, long? maxExecutionTimeInSeconds, JobResponseType? type, CloudToDeviceMethod cloudToDeviceMethod, Twin updateTwin, JobResponseStatus? status, string failureReason, string statusMessage, DeviceJobStatistics deviceJobStatistics) + internal JobResponse(string jobId, string queryCondition, DateTimeOffset? createdTime, DateTimeOffset? startTime, DateTimeOffset? endTime, long? maxExecutionTimeInSeconds, JobResponseType? type, CloudToDeviceMethod cloudToDeviceMethod, TwinData updateTwin, JobResponseStatus? status, string failureReason, string statusMessage, DeviceJobStatistics deviceJobStatistics) { JobId = jobId; QueryCondition = queryCondition; @@ -93,7 +93,7 @@ internal JobResponse(string jobId, string queryCondition, DateTimeOffset? create /// public CloudToDeviceMethod CloudToDeviceMethod { get; } /// Twin Representation. - public Twin UpdateTwin { get; } + public TwinData UpdateTwin { get; } /// System generated. Ignored at creation. public JobResponseStatus? Status { get; } /// diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Module.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/ModuleIdentity.Serialization.cs similarity index 93% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Module.Serialization.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/ModuleIdentity.Serialization.cs index f32d5f1fd612f..825f991cafae1 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Module.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/ModuleIdentity.Serialization.cs @@ -11,7 +11,7 @@ namespace Azure.Iot.Hub.Service.Models { - public partial class Module : IUtf8JsonSerializable + public partial class ModuleIdentity : IUtf8JsonSerializable { void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { @@ -49,12 +49,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (ConnectionStateUpdatedTime != null) { writer.WritePropertyName("connectionStateUpdatedTime"); - writer.WriteStringValue(ConnectionStateUpdatedTime.Value, "S"); + writer.WriteStringValue(ConnectionStateUpdatedTime.Value, "O"); } if (LastActivityTime != null) { writer.WritePropertyName("lastActivityTime"); - writer.WriteStringValue(LastActivityTime.Value, "S"); + writer.WriteStringValue(LastActivityTime.Value, "O"); } if (CloudToDeviceMessageCount != null) { @@ -69,7 +69,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } - internal static Module DeserializeModule(JsonElement element) + internal static ModuleIdentity DeserializeModuleIdentity(JsonElement element) { string moduleId = default; string managedBy = default; @@ -143,7 +143,7 @@ internal static Module DeserializeModule(JsonElement element) { continue; } - connectionStateUpdatedTime = property.Value.GetDateTimeOffset("S"); + connectionStateUpdatedTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("lastActivityTime")) @@ -152,7 +152,7 @@ internal static Module DeserializeModule(JsonElement element) { continue; } - lastActivityTime = property.Value.GetDateTimeOffset("S"); + lastActivityTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("cloudToDeviceMessageCount")) @@ -174,7 +174,7 @@ internal static Module DeserializeModule(JsonElement element) continue; } } - return new Module(moduleId, managedBy, deviceId, generationId, etag, connectionState, connectionStateUpdatedTime, lastActivityTime, cloudToDeviceMessageCount, authentication); + return new ModuleIdentity(moduleId, managedBy, deviceId, generationId, etag, connectionState, connectionStateUpdatedTime, lastActivityTime, cloudToDeviceMessageCount, authentication); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Module.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/ModuleIdentity.cs similarity index 77% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Module.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/ModuleIdentity.cs index 90ad9354b4846..f59c8a4656e62 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Module.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/ModuleIdentity.cs @@ -10,14 +10,14 @@ namespace Azure.Iot.Hub.Service.Models { /// Module identity on a device. - public partial class Module + public partial class ModuleIdentity { - /// Initializes a new instance of Module. - public Module() + /// Initializes a new instance of ModuleIdentity. + public ModuleIdentity() { } - /// Initializes a new instance of Module. + /// Initializes a new instance of ModuleIdentity. /// . /// . /// . @@ -28,7 +28,7 @@ public Module() /// . /// . /// . - internal Module(string moduleId, string managedBy, string deviceId, string generationId, string etag, ModuleConnectionState? connectionState, DateTimeOffset? connectionStateUpdatedTime, DateTimeOffset? lastActivityTime, int? cloudToDeviceMessageCount, AuthenticationMechanism authentication) + internal ModuleIdentity(string moduleId, string managedBy, string deviceId, string generationId, string etag, ModuleConnectionState? connectionState, DateTimeOffset? connectionStateUpdatedTime, DateTimeOffset? lastActivityTime, int? cloudToDeviceMessageCount, AuthenticationMechanism authentication) { ModuleId = moduleId; ManagedBy = managedBy; diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Desired.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnPDesired.Serialization.cs similarity index 81% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Desired.Serialization.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnPDesired.Serialization.cs index 031720ee8bf3a..9a092eeeb7103 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Desired.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnPDesired.Serialization.cs @@ -10,9 +10,9 @@ namespace Azure.Iot.Hub.Service.Models { - public partial class Desired + internal partial class PnpDesired { - internal static Desired DeserializeDesired(JsonElement element) + internal static PnpDesired DeserializePnpDesired(JsonElement element) { object value = default; foreach (var property in element.EnumerateObject()) @@ -27,7 +27,7 @@ internal static Desired DeserializeDesired(JsonElement element) continue; } } - return new Desired(value); + return new PnpDesired(value); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Desired.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnPDesired.cs similarity index 68% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Desired.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnPDesired.cs index d606dc01e5c9a..451cd442e97e6 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Desired.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnPDesired.cs @@ -8,16 +8,16 @@ namespace Azure.Iot.Hub.Service.Models { /// The Desired. - public partial class Desired + internal partial class PnpDesired { - /// Initializes a new instance of Desired. - internal Desired() + /// Initializes a new instance of PnpDesired. + internal PnpDesired() { } - /// Initializes a new instance of Desired. + /// Initializes a new instance of PnpDesired. /// The desired value of the interface property to set in a digitalTwin. - internal Desired(object value) + internal PnpDesired(object value) { Value = value; } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Interface.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpInterface.Serialization.cs similarity index 75% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Interface.Serialization.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpInterface.Serialization.cs index e524b73fd63b6..22e8225a1002f 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Interface.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpInterface.Serialization.cs @@ -11,12 +11,12 @@ namespace Azure.Iot.Hub.Service.Models { - public partial class Interface + internal partial class PnpInterface { - internal static Interface DeserializeInterface(JsonElement element) + internal static PnpInterface DeserializePnpInterface(JsonElement element) { string name = default; - IReadOnlyDictionary properties = default; + IReadOnlyDictionary properties = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) @@ -34,7 +34,7 @@ internal static Interface DeserializeInterface(JsonElement element) { continue; } - Dictionary dictionary = new Dictionary(); + Dictionary dictionary = new Dictionary(); foreach (var property0 in property.Value.EnumerateObject()) { if (property0.Value.ValueKind == JsonValueKind.Null) @@ -43,14 +43,14 @@ internal static Interface DeserializeInterface(JsonElement element) } else { - dictionary.Add(property0.Name, Property.DeserializeProperty(property0.Value)); + dictionary.Add(property0.Name, PnpProperty.DeserializePnpProperty(property0.Value)); } } properties = dictionary; continue; } } - return new Interface(name, properties); + return new PnpInterface(name, properties); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Interface.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpInterface.cs similarity index 64% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Interface.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpInterface.cs index 175d8c5d52c6d..12d84ac58d749 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Interface.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpInterface.cs @@ -10,17 +10,17 @@ namespace Azure.Iot.Hub.Service.Models { /// The Interface. - public partial class Interface + internal partial class PnpInterface { - /// Initializes a new instance of Interface. - internal Interface() + /// Initializes a new instance of PnpInterface. + internal PnpInterface() { } - /// Initializes a new instance of Interface. + /// Initializes a new instance of PnpInterface. /// Full name of digital twin interface. /// List of all properties in an interface. - internal Interface(string name, IReadOnlyDictionary properties) + internal PnpInterface(string name, IReadOnlyDictionary properties) { Name = name; Properties = properties; @@ -29,6 +29,6 @@ internal Interface(string name, IReadOnlyDictionary properties /// Full name of digital twin interface. public string Name { get; } /// List of all properties in an interface. - public IReadOnlyDictionary Properties { get; } + public IReadOnlyDictionary Properties { get; } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Property.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpProperty.Serialization.cs similarity index 67% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Property.Serialization.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpProperty.Serialization.cs index d3f15692efc38..6f6ffbda0eeca 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Property.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpProperty.Serialization.cs @@ -10,12 +10,12 @@ namespace Azure.Iot.Hub.Service.Models { - public partial class Property + internal partial class PnpProperty { - internal static Property DeserializeProperty(JsonElement element) + internal static PnpProperty DeserializePnpProperty(JsonElement element) { - Reported reported = default; - Desired desired = default; + PnpReported reported = default; + PnpDesired desired = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("reported")) @@ -24,7 +24,7 @@ internal static Property DeserializeProperty(JsonElement element) { continue; } - reported = Reported.DeserializeReported(property.Value); + reported = PnpReported.DeserializePnpReported(property.Value); continue; } if (property.NameEquals("desired")) @@ -33,11 +33,11 @@ internal static Property DeserializeProperty(JsonElement element) { continue; } - desired = Desired.DeserializeDesired(property.Value); + desired = PnpDesired.DeserializePnpDesired(property.Value); continue; } } - return new Property(reported, desired); + return new PnpProperty(reported, desired); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Property.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpProperty.cs similarity index 53% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Property.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpProperty.cs index 8182d0add2afa..6f71ce1fd824d 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Property.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpProperty.cs @@ -8,23 +8,23 @@ namespace Azure.Iot.Hub.Service.Models { /// The Property. - public partial class Property + internal partial class PnpProperty { - /// Initializes a new instance of Property. - internal Property() + /// Initializes a new instance of PnpProperty. + internal PnpProperty() { } - /// Initializes a new instance of Property. + /// Initializes a new instance of PnpProperty. /// . /// . - internal Property(Reported reported, Desired desired) + internal PnpProperty(PnpReported reported, PnpDesired desired) { Reported = reported; Desired = desired; } - public Reported Reported { get; } - public Desired Desired { get; } + public PnpReported Reported { get; } + public PnpDesired Desired { get; } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Reported.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpReported.Serialization.cs similarity index 86% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Reported.Serialization.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpReported.Serialization.cs index 37a941de478fc..13a240a52fd4f 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Reported.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpReported.Serialization.cs @@ -10,9 +10,9 @@ namespace Azure.Iot.Hub.Service.Models { - public partial class Reported + internal partial class PnpReported { - internal static Reported DeserializeReported(JsonElement element) + internal static PnpReported DeserializePnpReported(JsonElement element) { object value = default; DesiredState desiredState = default; @@ -37,7 +37,7 @@ internal static Reported DeserializeReported(JsonElement element) continue; } } - return new Reported(value, desiredState); + return new PnpReported(value, desiredState); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Reported.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpReported.cs similarity index 69% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Reported.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpReported.cs index 62537cd38fb79..0c9ef3720d63b 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Reported.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/PnpReported.cs @@ -8,17 +8,17 @@ namespace Azure.Iot.Hub.Service.Models { /// The Reported. - public partial class Reported + internal partial class PnpReported { - /// Initializes a new instance of Reported. - internal Reported() + /// Initializes a new instance of PnpReported. + internal PnpReported() { } - /// Initializes a new instance of Reported. + /// Initializes a new instance of PnpReported. /// The current interface property value in a digitalTwin. /// . - internal Reported(object value, DesiredState desiredState) + internal PnpReported(object value, DesiredState desiredState) { Value = value; DesiredState = desiredState; diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Configuration.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/TwinConfiguration.Serialization.cs similarity index 94% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Configuration.Serialization.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/TwinConfiguration.Serialization.cs index 679f96773f192..5ef032d373a80 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Configuration.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/TwinConfiguration.Serialization.cs @@ -12,7 +12,7 @@ namespace Azure.Iot.Hub.Service.Models { - public partial class Configuration : IUtf8JsonSerializable + public partial class TwinConfiguration : IUtf8JsonSerializable { void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { @@ -51,12 +51,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (CreatedTimeUtc != null) { writer.WritePropertyName("createdTimeUtc"); - writer.WriteStringValue(CreatedTimeUtc.Value, "S"); + writer.WriteStringValue(CreatedTimeUtc.Value, "O"); } if (LastUpdatedTimeUtc != null) { writer.WritePropertyName("lastUpdatedTimeUtc"); - writer.WriteStringValue(LastUpdatedTimeUtc.Value, "S"); + writer.WriteStringValue(LastUpdatedTimeUtc.Value, "O"); } if (Priority != null) { @@ -81,7 +81,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } - internal static Configuration DeserializeConfiguration(JsonElement element) + internal static TwinConfiguration DeserializeTwinConfiguration(JsonElement element) { string id = default; string schemaVersion = default; @@ -159,7 +159,7 @@ internal static Configuration DeserializeConfiguration(JsonElement element) { continue; } - createdTimeUtc = property.Value.GetDateTimeOffset("S"); + createdTimeUtc = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("lastUpdatedTimeUtc")) @@ -168,7 +168,7 @@ internal static Configuration DeserializeConfiguration(JsonElement element) { continue; } - lastUpdatedTimeUtc = property.Value.GetDateTimeOffset("S"); + lastUpdatedTimeUtc = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("priority")) @@ -208,7 +208,7 @@ internal static Configuration DeserializeConfiguration(JsonElement element) continue; } } - return new Configuration(id, schemaVersion, labels, content, targetCondition, createdTimeUtc, lastUpdatedTimeUtc, priority, systemMetrics, metrics, etag); + return new TwinConfiguration(id, schemaVersion, labels, content, targetCondition, createdTimeUtc, lastUpdatedTimeUtc, priority, systemMetrics, metrics, etag); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Configuration.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/TwinConfiguration.cs similarity index 84% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Configuration.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/TwinConfiguration.cs index 1ddfc942e605c..1b1c42ad873c3 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Configuration.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/TwinConfiguration.cs @@ -11,14 +11,14 @@ namespace Azure.Iot.Hub.Service.Models { /// Configuration for IotHub devices and modules. - public partial class Configuration + public partial class TwinConfiguration { - /// Initializes a new instance of Configuration. - public Configuration() + /// Initializes a new instance of TwinConfiguration. + public TwinConfiguration() { } - /// Initializes a new instance of Configuration. + /// Initializes a new instance of TwinConfiguration. /// Gets Identifier for the configuration. /// Gets Schema version for the configuration. /// Gets or sets labels for the configuration. @@ -30,7 +30,7 @@ public Configuration() /// System Configuration Metrics. /// Custom Configuration Metrics. /// Gets or sets configuration's ETag. - internal Configuration(string id, string schemaVersion, IDictionary labels, ConfigurationContent content, string targetCondition, DateTimeOffset? createdTimeUtc, DateTimeOffset? lastUpdatedTimeUtc, int? priority, ConfigurationMetrics systemMetrics, ConfigurationMetrics metrics, string etag) + internal TwinConfiguration(string id, string schemaVersion, IDictionary labels, ConfigurationContent content, string targetCondition, DateTimeOffset? createdTimeUtc, DateTimeOffset? lastUpdatedTimeUtc, int? priority, ConfigurationMetrics systemMetrics, ConfigurationMetrics metrics, string etag) { Id = id; SchemaVersion = schemaVersion; diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Twin.Serialization.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/TwinData.Serialization.cs similarity index 96% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Twin.Serialization.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/TwinData.Serialization.cs index 043879358b6d3..6d2b444087013 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Twin.Serialization.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/TwinData.Serialization.cs @@ -12,7 +12,7 @@ namespace Azure.Iot.Hub.Service.Models { - public partial class Twin : IUtf8JsonSerializable + public partial class TwinData : IUtf8JsonSerializable { void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { @@ -71,7 +71,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (StatusUpdateTime != null) { writer.WritePropertyName("statusUpdateTime"); - writer.WriteStringValue(StatusUpdateTime.Value, "S"); + writer.WriteStringValue(StatusUpdateTime.Value, "O"); } if (ConnectionState != null) { @@ -81,7 +81,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (LastActivityTime != null) { writer.WritePropertyName("lastActivityTime"); - writer.WriteStringValue(LastActivityTime.Value, "S"); + writer.WriteStringValue(LastActivityTime.Value, "O"); } if (CloudToDeviceMessageCount != null) { @@ -121,7 +121,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } - internal static Twin DeserializeTwin(JsonElement element) + internal static TwinData DeserializeTwinData(JsonElement element) { string deviceId = default; string moduleId = default; @@ -242,7 +242,7 @@ internal static Twin DeserializeTwin(JsonElement element) { continue; } - statusUpdateTime = property.Value.GetDateTimeOffset("S"); + statusUpdateTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("connectionState")) @@ -260,7 +260,7 @@ internal static Twin DeserializeTwin(JsonElement element) { continue; } - lastActivityTime = property.Value.GetDateTimeOffset("S"); + lastActivityTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("cloudToDeviceMessageCount")) @@ -330,7 +330,7 @@ internal static Twin DeserializeTwin(JsonElement element) continue; } } - return new Twin(deviceId, moduleId, tags, properties, etag, version, deviceEtag, status, statusReason, statusUpdateTime, connectionState, lastActivityTime, cloudToDeviceMessageCount, authenticationType, x509Thumbprint, capabilities, deviceScope, parentScopes); + return new TwinData(deviceId, moduleId, tags, properties, etag, version, deviceEtag, status, statusReason, statusUpdateTime, connectionState, lastActivityTime, cloudToDeviceMessageCount, authenticationType, x509Thumbprint, capabilities, deviceScope, parentScopes); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Twin.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/TwinData.cs similarity index 89% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Twin.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/TwinData.cs index 60836f5bb81e5..8fb846997704b 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/Twin.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Models/TwinData.cs @@ -11,14 +11,14 @@ namespace Azure.Iot.Hub.Service.Models { /// Twin Representation. - public partial class Twin + public partial class TwinData { - /// Initializes a new instance of Twin. - public Twin() + /// Initializes a new instance of TwinData. + public TwinData() { } - /// Initializes a new instance of Twin. + /// Initializes a new instance of TwinData. /// The deviceId uniquely identifies the device in the IoT hub's identity registry. A case-sensitive string (up to 128 char long) of ASCII 7-bit alphanumeric chars + {'-', ':', '.', '+', '%', '_', '#', '*', '?', '!', '(', ')', ',', '=', '@', ';', '$', '''}. /// Gets and sets the Module Id. /// A JSON document read and written by the solution back end. Tags are not visible to device apps. @@ -37,7 +37,7 @@ public Twin() /// Status of Capabilities enabled on the device. /// . /// . - internal Twin(string deviceId, string moduleId, IDictionary tags, TwinProperties properties, string etag, long? version, string deviceEtag, TwinStatus? status, string statusReason, DateTimeOffset? statusUpdateTime, TwinConnectionState? connectionState, DateTimeOffset? lastActivityTime, int? cloudToDeviceMessageCount, TwinAuthenticationType? authenticationType, X509Thumbprint x509Thumbprint, DeviceCapabilities capabilities, string deviceScope, IList parentScopes) + internal TwinData(string deviceId, string moduleId, IDictionary tags, TwinProperties properties, string etag, long? version, string deviceEtag, TwinStatus? status, string statusReason, DateTimeOffset? statusUpdateTime, TwinConnectionState? connectionState, DateTimeOffset? lastActivityTime, int? cloudToDeviceMessageCount, TwinAuthenticationType? authenticationType, X509Thumbprint x509Thumbprint, DeviceCapabilities capabilities, string deviceScope, IList parentScopes) { DeviceId = deviceId; ModuleId = moduleId; diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/RegistryManagerClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/RegistryManagerClient.cs similarity index 66% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/RegistryManagerClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/RegistryManagerClient.cs index 662f0b6272417..96eac83eb39dc 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/RegistryManagerClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/RegistryManagerClient.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -36,44 +37,104 @@ internal RegistryManagerClient(ClientDiagnostics clientDiagnostics, HttpPipeline /// The cancellation token to use. public virtual async Task> GetDeviceStatisticsAsync(CancellationToken cancellationToken = default) { - return await RestClient.GetDeviceStatisticsAsync(cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetDeviceStatistics"); + scope.Start(); + try + { + return await RestClient.GetDeviceStatisticsAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The cancellation token to use. public virtual Response GetDeviceStatistics(CancellationToken cancellationToken = default) { - return RestClient.GetDeviceStatistics(cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetDeviceStatistics"); + scope.Start(); + try + { + return RestClient.GetDeviceStatistics(cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The cancellation token to use. public virtual async Task> GetServiceStatisticsAsync(CancellationToken cancellationToken = default) { - return await RestClient.GetServiceStatisticsAsync(cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetServiceStatistics"); + scope.Start(); + try + { + return await RestClient.GetServiceStatisticsAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// The cancellation token to use. public virtual Response GetServiceStatistics(CancellationToken cancellationToken = default) { - return RestClient.GetServiceStatistics(cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetServiceStatistics"); + scope.Start(); + try + { + return RestClient.GetServiceStatistics(cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// This parameter when specified, defines the maximum number of device identities that are returned. Any value outside the range of 1-1000 is considered to be 1000. /// The cancellation token to use. - public virtual async Task>> GetDevicesAsync(int? top = null, CancellationToken cancellationToken = default) + public virtual async Task>> GetDevicesAsync(int? top = null, CancellationToken cancellationToken = default) { - return await RestClient.GetDevicesAsync(top, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetDevices"); + scope.Start(); + try + { + return await RestClient.GetDevicesAsync(top, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// This parameter when specified, defines the maximum number of device identities that are returned. Any value outside the range of 1-1000 is considered to be 1000. /// The cancellation token to use. - public virtual Response> GetDevices(int? top = null, CancellationToken cancellationToken = default) + public virtual Response> GetDevices(int? top = null, CancellationToken cancellationToken = default) { - return RestClient.GetDevices(top, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetDevices"); + scope.Start(); + try + { + return RestClient.GetDevices(top, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Create, update, or delete the identiies of multiple devices from the IoT hub identity registry. A device identity can be specified only once in the list. Different operations (create, update, delete) on different devices are allowed. A maximum of 100 devices can be specified per invocation. For large scale operations, consider using the import feature using blob storage(https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities). For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -81,7 +142,17 @@ public virtual Response> GetDevices(int? top = null, Cance /// The cancellation token to use. public virtual async Task> BulkDeviceCrudAsync(IEnumerable devices, CancellationToken cancellationToken = default) { - return await RestClient.BulkDeviceCrudAsync(devices, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.BulkDeviceCrud"); + scope.Start(); + try + { + return await RestClient.BulkDeviceCrudAsync(devices, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Create, update, or delete the identiies of multiple devices from the IoT hub identity registry. A device identity can be specified only once in the list. Different operations (create, update, delete) on different devices are allowed. A maximum of 100 devices can be specified per invocation. For large scale operations, consider using the import feature using blob storage(https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities). For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -89,7 +160,17 @@ public virtual async Task> BulkDeviceCrudA /// The cancellation token to use. public virtual Response BulkDeviceCrud(IEnumerable devices, CancellationToken cancellationToken = default) { - return RestClient.BulkDeviceCrud(devices, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.BulkDeviceCrud"); + scope.Start(); + try + { + return RestClient.BulkDeviceCrud(devices, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Query an IoT hub to retrieve information regarding device twins using a SQL-like language. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language for more information. Pagination of results is supported. This returns information about device twins only. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -97,9 +178,19 @@ public virtual Response BulkDeviceCrud(IEnumerable< /// The String to use. /// The String to use. /// The cancellation token to use. - public virtual async Task>> QueryIotHubAsync(QuerySpecification querySpecification, string xMsContinuation = null, string xMsMaxItemCount = null, CancellationToken cancellationToken = default) + public virtual async Task>> QueryIotHubAsync(QuerySpecification querySpecification, string xMsContinuation = null, string xMsMaxItemCount = null, CancellationToken cancellationToken = default) { - return await RestClient.QueryIotHubAsync(querySpecification, xMsContinuation, xMsMaxItemCount, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.QueryIotHub"); + scope.Start(); + try + { + return await RestClient.QueryIotHubAsync(querySpecification, xMsContinuation, xMsMaxItemCount, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Query an IoT hub to retrieve information regarding device twins using a SQL-like language. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language for more information. Pagination of results is supported. This returns information about device twins only. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -107,25 +198,55 @@ public virtual async Task>> QueryIotHubAsync(QueryS /// The String to use. /// The String to use. /// The cancellation token to use. - public virtual Response> QueryIotHub(QuerySpecification querySpecification, string xMsContinuation = null, string xMsMaxItemCount = null, CancellationToken cancellationToken = default) + public virtual Response> QueryIotHub(QuerySpecification querySpecification, string xMsContinuation = null, string xMsMaxItemCount = null, CancellationToken cancellationToken = default) { - return RestClient.QueryIotHub(querySpecification, xMsContinuation, xMsMaxItemCount, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.QueryIotHub"); + scope.Start(); + try + { + return RestClient.QueryIotHub(querySpecification, xMsContinuation, xMsMaxItemCount, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Retrieve a device from the identity registry of an IoT hub. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// The cancellation token to use. - public virtual async Task> GetDeviceAsync(string id, CancellationToken cancellationToken = default) + public virtual async Task> GetDeviceAsync(string id, CancellationToken cancellationToken = default) { - return await RestClient.GetDeviceAsync(id, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetDevice"); + scope.Start(); + try + { + return await RestClient.GetDeviceAsync(id, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Retrieve a device from the identity registry of an IoT hub. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// The cancellation token to use. - public virtual Response GetDevice(string id, CancellationToken cancellationToken = default) + public virtual Response GetDevice(string id, CancellationToken cancellationToken = default) { - return RestClient.GetDevice(id, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetDevice"); + scope.Start(); + try + { + return RestClient.GetDevice(id, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Create or update the identity of a device in the identity registry of an IoT hub. An ETag must not be specified for the create operation. An ETag must be specified for the update operation. Note that generationId and deviceId cannot be updated by the user. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -133,9 +254,19 @@ public virtual Response GetDevice(string id, CancellationToken cancellat /// The Device to use. /// The String to use. /// The cancellation token to use. - public virtual async Task> CreateOrUpdateDeviceAsync(string id, Device device, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual async Task> CreateOrUpdateDeviceAsync(string id, DeviceIdentity device, string ifMatch = null, CancellationToken cancellationToken = default) { - return await RestClient.CreateOrUpdateDeviceAsync(id, device, ifMatch, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.CreateOrUpdateDevice"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateDeviceAsync(id, device, ifMatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Create or update the identity of a device in the identity registry of an IoT hub. An ETag must not be specified for the create operation. An ETag must be specified for the update operation. Note that generationId and deviceId cannot be updated by the user. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -143,9 +274,19 @@ public virtual async Task> CreateOrUpdateDeviceAsync(string id, /// The Device to use. /// The String to use. /// The cancellation token to use. - public virtual Response CreateOrUpdateDevice(string id, Device device, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual Response CreateOrUpdateDevice(string id, DeviceIdentity device, string ifMatch = null, CancellationToken cancellationToken = default) { - return RestClient.CreateOrUpdateDevice(id, device, ifMatch, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.CreateOrUpdateDevice"); + scope.Start(); + try + { + return RestClient.CreateOrUpdateDevice(id, device, ifMatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Delete the identity of a device from the identity registry of an IoT hub. This request requires the If-Match header. The client may specify the ETag for the device identity on the request in order to compare to the ETag maintained by the service for the purpose of optimistic concurrency. The delete operation is performed only if the ETag sent by the client matches the value maintained by the server, indicating that the device identity has not been modified since it was retrieved by the client. To force an unconditional delete, set If-Match to the wildcard character (*). For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -154,7 +295,17 @@ public virtual Response CreateOrUpdateDevice(string id, Device device, s /// The cancellation token to use. public virtual async Task DeleteDeviceAsync(string id, string ifMatch = null, CancellationToken cancellationToken = default) { - return await RestClient.DeleteDeviceAsync(id, ifMatch, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.DeleteDevice"); + scope.Start(); + try + { + return await RestClient.DeleteDeviceAsync(id, ifMatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Delete the identity of a device from the identity registry of an IoT hub. This request requires the If-Match header. The client may specify the ETag for the device identity on the request in order to compare to the ETag maintained by the service for the purpose of optimistic concurrency. The delete operation is performed only if the ETag sent by the client matches the value maintained by the server, indicating that the device identity has not been modified since it was retrieved by the client. To force an unconditional delete, set If-Match to the wildcard character (*). For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -163,7 +314,17 @@ public virtual async Task DeleteDeviceAsync(string id, string ifMatch /// The cancellation token to use. public virtual Response DeleteDevice(string id, string ifMatch = null, CancellationToken cancellationToken = default) { - return RestClient.DeleteDevice(id, ifMatch, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.DeleteDevice"); + scope.Start(); + try + { + return RestClient.DeleteDevice(id, ifMatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Deletes all the pending commands for this device from the IoT hub For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -171,7 +332,17 @@ public virtual Response DeleteDevice(string id, string ifMatch = null, Cancellat /// The cancellation token to use. public virtual async Task> PurgeCommandQueueAsync(string id, CancellationToken cancellationToken = default) { - return await RestClient.PurgeCommandQueueAsync(id, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.PurgeCommandQueue"); + scope.Start(); + try + { + return await RestClient.PurgeCommandQueueAsync(id, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Deletes all the pending commands for this device from the IoT hub For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -179,41 +350,91 @@ public virtual async Task> PurgeCommandQueueAs /// The cancellation token to use. public virtual Response PurgeCommandQueue(string id, CancellationToken cancellationToken = default) { - return RestClient.PurgeCommandQueue(id, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.PurgeCommandQueue"); + scope.Start(); + try + { + return RestClient.PurgeCommandQueue(id, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// The cancellation token to use. - public virtual async Task>> GetModulesOnDeviceAsync(string id, CancellationToken cancellationToken = default) + public virtual async Task>> GetModulesOnDeviceAsync(string id, CancellationToken cancellationToken = default) { - return await RestClient.GetModulesOnDeviceAsync(id, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetModulesOnDevice"); + scope.Start(); + try + { + return await RestClient.GetModulesOnDeviceAsync(id, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// The cancellation token to use. - public virtual Response> GetModulesOnDevice(string id, CancellationToken cancellationToken = default) + public virtual Response> GetModulesOnDevice(string id, CancellationToken cancellationToken = default) { - return RestClient.GetModulesOnDevice(id, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetModulesOnDevice"); + scope.Start(); + try + { + return RestClient.GetModulesOnDevice(id, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// Module ID. /// The cancellation token to use. - public virtual async Task> GetModuleAsync(string id, string mid, CancellationToken cancellationToken = default) + public virtual async Task> GetModuleAsync(string id, string mid, CancellationToken cancellationToken = default) { - return await RestClient.GetModuleAsync(id, mid, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetModule"); + scope.Start(); + try + { + return await RestClient.GetModuleAsync(id, mid, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// Module ID. /// The cancellation token to use. - public virtual Response GetModule(string id, string mid, CancellationToken cancellationToken = default) + public virtual Response GetModule(string id, string mid, CancellationToken cancellationToken = default) { - return RestClient.GetModule(id, mid, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetModule"); + scope.Start(); + try + { + return RestClient.GetModule(id, mid, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -222,9 +443,19 @@ public virtual Response GetModule(string id, string mid, CancellationTok /// The Module to use. /// The String to use. /// The cancellation token to use. - public virtual async Task> CreateOrUpdateModuleAsync(string id, string mid, Module module, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual async Task> CreateOrUpdateModuleAsync(string id, string mid, ModuleIdentity module, string ifMatch = null, CancellationToken cancellationToken = default) { - return await RestClient.CreateOrUpdateModuleAsync(id, mid, module, ifMatch, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.CreateOrUpdateModule"); + scope.Start(); + try + { + return await RestClient.CreateOrUpdateModuleAsync(id, mid, module, ifMatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -233,9 +464,19 @@ public virtual async Task> CreateOrUpdateModuleAsync(string id, /// The Module to use. /// The String to use. /// The cancellation token to use. - public virtual Response CreateOrUpdateModule(string id, string mid, Module module, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual Response CreateOrUpdateModule(string id, string mid, ModuleIdentity module, string ifMatch = null, CancellationToken cancellationToken = default) { - return RestClient.CreateOrUpdateModule(id, mid, module, ifMatch, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.CreateOrUpdateModule"); + scope.Start(); + try + { + return RestClient.CreateOrUpdateModule(id, mid, module, ifMatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -245,7 +486,17 @@ public virtual Response CreateOrUpdateModule(string id, string mid, Modu /// The cancellation token to use. public virtual async Task DeleteModuleAsync(string id, string mid, string ifMatch = null, CancellationToken cancellationToken = default) { - return await RestClient.DeleteModuleAsync(id, mid, ifMatch, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.DeleteModule"); + scope.Start(); + try + { + return await RestClient.DeleteModuleAsync(id, mid, ifMatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -255,7 +506,17 @@ public virtual async Task DeleteModuleAsync(string id, string mid, str /// The cancellation token to use. public virtual Response DeleteModule(string id, string mid, string ifMatch = null, CancellationToken cancellationToken = default) { - return RestClient.DeleteModule(id, mid, ifMatch, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.DeleteModule"); + scope.Start(); + try + { + return RestClient.DeleteModule(id, mid, ifMatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/RegistryManagerQueryIotHubHeaders.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/RegistryManagerQueryIotHubHeaders.cs similarity index 100% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/RegistryManagerQueryIotHubHeaders.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/RegistryManagerQueryIotHubHeaders.cs diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/RegistryManagerRestClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/RegistryManagerRestClient.cs similarity index 51% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/RegistryManagerRestClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/RegistryManagerRestClient.cs index d5f9528cd21f9..82297cd61b157 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/RegistryManagerRestClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/RegistryManagerRestClient.cs @@ -59,36 +59,26 @@ internal HttpMessage CreateGetDeviceStatisticsRequest() /// The cancellation token to use. public async ValueTask> GetDeviceStatisticsAsync(CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetDeviceStatistics"); - scope.Start(); - try - { - using var message = CreateGetDeviceStatisticsRequest(); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetDeviceStatisticsRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RegistryStatistics value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - RegistryStatistics value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = RegistryStatistics.DeserializeRegistryStatistics(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = RegistryStatistics.DeserializeRegistryStatistics(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -96,36 +86,26 @@ public async ValueTask> GetDeviceStatisticsAsync(Ca /// The cancellation token to use. public Response GetDeviceStatistics(CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetDeviceStatistics"); - scope.Start(); - try - { - using var message = CreateGetDeviceStatisticsRequest(); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetDeviceStatisticsRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RegistryStatistics value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - RegistryStatistics value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = RegistryStatistics.DeserializeRegistryStatistics(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = RegistryStatistics.DeserializeRegistryStatistics(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -146,36 +126,26 @@ internal HttpMessage CreateGetServiceStatisticsRequest() /// The cancellation token to use. public async ValueTask> GetServiceStatisticsAsync(CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetServiceStatistics"); - scope.Start(); - try - { - using var message = CreateGetServiceStatisticsRequest(); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetServiceStatisticsRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ServiceStatistics value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - ServiceStatistics value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = ServiceStatistics.DeserializeServiceStatistics(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = ServiceStatistics.DeserializeServiceStatistics(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -183,36 +153,26 @@ public async ValueTask> GetServiceStatisticsAsync(Ca /// The cancellation token to use. public Response GetServiceStatistics(CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetServiceStatistics"); - scope.Start(); - try - { - using var message = CreateGetServiceStatisticsRequest(); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetServiceStatisticsRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ServiceStatistics value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - ServiceStatistics value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = ServiceStatistics.DeserializeServiceStatistics(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = ServiceStatistics.DeserializeServiceStatistics(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -236,100 +196,80 @@ internal HttpMessage CreateGetDevicesRequest(int? top) /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// This parameter when specified, defines the maximum number of device identities that are returned. Any value outside the range of 1-1000 is considered to be 1000. /// The cancellation token to use. - public async ValueTask>> GetDevicesAsync(int? top = null, CancellationToken cancellationToken = default) + public async ValueTask>> GetDevicesAsync(int? top = null, CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetDevices"); - scope.Start(); - try - { - using var message = CreateGetDevicesRequest(top); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetDevicesRequest(top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + IReadOnlyList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - IReadOnlyList value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else + value = null; + } + else + { + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) { - List array = new List(); - foreach (var item in document.RootElement.EnumerateArray()) + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(Device.DeserializeDevice(item)); - } + array.Add(DeviceIdentity.DeserializeDeviceIdentity(item)); } - value = array; } - return Response.FromValue(value, message.Response); + value = array; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// This parameter when specified, defines the maximum number of device identities that are returned. Any value outside the range of 1-1000 is considered to be 1000. /// The cancellation token to use. - public Response> GetDevices(int? top = null, CancellationToken cancellationToken = default) + public Response> GetDevices(int? top = null, CancellationToken cancellationToken = default) { - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetDevices"); - scope.Start(); - try - { - using var message = CreateGetDevicesRequest(top); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + using var message = CreateGetDevicesRequest(top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + IReadOnlyList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - IReadOnlyList value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else + value = null; + } + else + { + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) { - List array = new List(); - foreach (var item in document.RootElement.EnumerateArray()) + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(Device.DeserializeDevice(item)); - } + array.Add(DeviceIdentity.DeserializeDeviceIdentity(item)); } - value = array; } - return Response.FromValue(value, message.Response); + value = array; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -365,37 +305,27 @@ public async ValueTask> BulkDeviceCrudAsyn throw new ArgumentNullException(nameof(devices)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.BulkDeviceCrud"); - scope.Start(); - try + using var message = CreateBulkDeviceCrudRequest(devices); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateBulkDeviceCrudRequest(devices); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 400: + case 200: + case 400: + { + BulkRegistryOperationResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - BulkRegistryOperationResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = BulkRegistryOperationResult.DeserializeBulkRegistryOperationResult(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = BulkRegistryOperationResult.DeserializeBulkRegistryOperationResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -409,37 +339,27 @@ public Response BulkDeviceCrud(IEnumerable The String to use. /// The String to use. /// The cancellation token to use. - public async ValueTask, RegistryManagerQueryIotHubHeaders>> QueryIotHubAsync(QuerySpecification querySpecification, string xMsContinuation = null, string xMsMaxItemCount = null, CancellationToken cancellationToken = default) + public async ValueTask, RegistryManagerQueryIotHubHeaders>> QueryIotHubAsync(QuerySpecification querySpecification, string xMsContinuation = null, string xMsMaxItemCount = null, CancellationToken cancellationToken = default) { if (querySpecification == null) { throw new ArgumentNullException(nameof(querySpecification)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.QueryIotHub"); - scope.Start(); - try + using var message = CreateQueryIotHubRequest(querySpecification, xMsContinuation, xMsMaxItemCount); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + var headers = new RegistryManagerQueryIotHubHeaders(message.Response); + switch (message.Response.Status) { - using var message = CreateQueryIotHubRequest(querySpecification, xMsContinuation, xMsMaxItemCount); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - var headers = new RegistryManagerQueryIotHubHeaders(message.Response); - switch (message.Response.Status) - { - case 200: + case 200: + { + IReadOnlyList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - IReadOnlyList value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else + value = null; + } + else + { + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) { - List array = new List(); - foreach (var item in document.RootElement.EnumerateArray()) + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(Twin.DeserializeTwin(item)); - } + array.Add(TwinData.DeserializeTwinData(item)); } - value = array; } - return ResponseWithHeaders.FromValue(value, headers, message.Response); + value = array; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + return ResponseWithHeaders.FromValue(value, headers, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -531,56 +441,46 @@ public async ValueTask, RegistryManagerQ /// The String to use. /// The String to use. /// The cancellation token to use. - public ResponseWithHeaders, RegistryManagerQueryIotHubHeaders> QueryIotHub(QuerySpecification querySpecification, string xMsContinuation = null, string xMsMaxItemCount = null, CancellationToken cancellationToken = default) + public ResponseWithHeaders, RegistryManagerQueryIotHubHeaders> QueryIotHub(QuerySpecification querySpecification, string xMsContinuation = null, string xMsMaxItemCount = null, CancellationToken cancellationToken = default) { if (querySpecification == null) { throw new ArgumentNullException(nameof(querySpecification)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.QueryIotHub"); - scope.Start(); - try + using var message = CreateQueryIotHubRequest(querySpecification, xMsContinuation, xMsMaxItemCount); + _pipeline.Send(message, cancellationToken); + var headers = new RegistryManagerQueryIotHubHeaders(message.Response); + switch (message.Response.Status) { - using var message = CreateQueryIotHubRequest(querySpecification, xMsContinuation, xMsMaxItemCount); - _pipeline.Send(message, cancellationToken); - var headers = new RegistryManagerQueryIotHubHeaders(message.Response); - switch (message.Response.Status) - { - case 200: + case 200: + { + IReadOnlyList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - IReadOnlyList value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else + value = null; + } + else + { + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) { - List array = new List(); - foreach (var item in document.RootElement.EnumerateArray()) + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(Twin.DeserializeTwin(item)); - } + array.Add(TwinData.DeserializeTwinData(item)); } - value = array; } - return ResponseWithHeaders.FromValue(value, headers, message.Response); + value = array; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + return ResponseWithHeaders.FromValue(value, headers, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -601,90 +501,70 @@ internal HttpMessage CreateGetDeviceRequest(string id) /// Retrieve a device from the identity registry of an IoT hub. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// The cancellation token to use. - public async ValueTask> GetDeviceAsync(string id, CancellationToken cancellationToken = default) + public async ValueTask> GetDeviceAsync(string id, CancellationToken cancellationToken = default) { if (id == null) { throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetDevice"); - scope.Start(); - try + using var message = CreateGetDeviceRequest(id); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateGetDeviceRequest(id); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + DeviceIdentity value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Device value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Device.DeserializeDevice(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = DeviceIdentity.DeserializeDeviceIdentity(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } /// Retrieve a device from the identity registry of an IoT hub. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// The cancellation token to use. - public Response GetDevice(string id, CancellationToken cancellationToken = default) + public Response GetDevice(string id, CancellationToken cancellationToken = default) { if (id == null) { throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetDevice"); - scope.Start(); - try + using var message = CreateGetDeviceRequest(id); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateGetDeviceRequest(id); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + DeviceIdentity value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Device value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Device.DeserializeDevice(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = DeviceIdentity.DeserializeDeviceIdentity(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateCreateOrUpdateDeviceRequest(string id, Device device, string ifMatch) + internal HttpMessage CreateCreateOrUpdateDeviceRequest(string id, DeviceIdentity device, string ifMatch) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -711,7 +591,7 @@ internal HttpMessage CreateCreateOrUpdateDeviceRequest(string id, Device device, /// The Device to use. /// The String to use. /// The cancellation token to use. - public async ValueTask> CreateOrUpdateDeviceAsync(string id, Device device, string ifMatch = null, CancellationToken cancellationToken = default) + public async ValueTask> CreateOrUpdateDeviceAsync(string id, DeviceIdentity device, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -722,36 +602,26 @@ public async ValueTask> CreateOrUpdateDeviceAsync(string id, De throw new ArgumentNullException(nameof(device)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.CreateOrUpdateDevice"); - scope.Start(); - try + using var message = CreateCreateOrUpdateDeviceRequest(id, device, ifMatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateCreateOrUpdateDeviceRequest(id, device, ifMatch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + DeviceIdentity value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Device value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Device.DeserializeDevice(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = DeviceIdentity.DeserializeDeviceIdentity(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -760,7 +630,7 @@ public async ValueTask> CreateOrUpdateDeviceAsync(string id, De /// The Device to use. /// The String to use. /// The cancellation token to use. - public Response CreateOrUpdateDevice(string id, Device device, string ifMatch = null, CancellationToken cancellationToken = default) + public Response CreateOrUpdateDevice(string id, DeviceIdentity device, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -771,36 +641,26 @@ public Response CreateOrUpdateDevice(string id, Device device, string if throw new ArgumentNullException(nameof(device)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.CreateOrUpdateDevice"); - scope.Start(); - try + using var message = CreateCreateOrUpdateDeviceRequest(id, device, ifMatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateCreateOrUpdateDeviceRequest(id, device, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + DeviceIdentity value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Device value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Device.DeserializeDevice(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = DeviceIdentity.DeserializeDeviceIdentity(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -833,24 +693,14 @@ public async ValueTask DeleteDeviceAsync(string id, string ifMatch = n throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.DeleteDevice"); - scope.Start(); - try + using var message = CreateDeleteDeviceRequest(id, ifMatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateDeleteDeviceRequest(id, ifMatch); - 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); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -865,24 +715,14 @@ public Response DeleteDevice(string id, string ifMatch = null, CancellationToken throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.DeleteDevice"); - scope.Start(); - try - { - using var message = CreateDeleteDeviceRequest(id, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) + using var message = CreateDeleteDeviceRequest(id, ifMatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - scope.Failed(e); - throw; + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -911,36 +751,26 @@ public async ValueTask> PurgeCommandQueueAsync throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.PurgeCommandQueue"); - scope.Start(); - try + using var message = CreatePurgeCommandQueueRequest(id); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreatePurgeCommandQueueRequest(id); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + PurgeMessageQueueResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - PurgeMessageQueueResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = PurgeMessageQueueResult.DeserializePurgeMessageQueueResult(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = PurgeMessageQueueResult.DeserializePurgeMessageQueueResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -954,36 +784,26 @@ public Response PurgeCommandQueue(string id, Cancellati throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.PurgeCommandQueue"); - scope.Start(); - try + using var message = CreatePurgeCommandQueueRequest(id); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreatePurgeCommandQueueRequest(id); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + PurgeMessageQueueResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - PurgeMessageQueueResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = PurgeMessageQueueResult.DeserializePurgeMessageQueueResult(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = PurgeMessageQueueResult.DeserializePurgeMessageQueueResult(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -1005,110 +825,90 @@ internal HttpMessage CreateGetModulesOnDeviceRequest(string id) /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// The cancellation token to use. - public async ValueTask>> GetModulesOnDeviceAsync(string id, CancellationToken cancellationToken = default) + public async ValueTask>> GetModulesOnDeviceAsync(string id, CancellationToken cancellationToken = default) { if (id == null) { throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetModulesOnDevice"); - scope.Start(); - try + using var message = CreateGetModulesOnDeviceRequest(id); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateGetModulesOnDeviceRequest(id); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + IReadOnlyList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - IReadOnlyList value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else + value = null; + } + else + { + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) { - List array = new List(); - foreach (var item in document.RootElement.EnumerateArray()) + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(Module.DeserializeModule(item)); - } + array.Add(ModuleIdentity.DeserializeModuleIdentity(item)); } - value = array; } - return Response.FromValue(value, message.Response); + value = array; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } /// For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// The cancellation token to use. - public Response> GetModulesOnDevice(string id, CancellationToken cancellationToken = default) + public Response> GetModulesOnDevice(string id, CancellationToken cancellationToken = default) { if (id == null) { throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetModulesOnDevice"); - scope.Start(); - try + using var message = CreateGetModulesOnDeviceRequest(id); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateGetModulesOnDeviceRequest(id); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + IReadOnlyList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - IReadOnlyList value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else + value = null; + } + else + { + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) { - List array = new List(); - foreach (var item in document.RootElement.EnumerateArray()) + if (item.ValueKind == JsonValueKind.Null) { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(Module.DeserializeModule(item)); - } + array.Add(null); + } + else + { + array.Add(ModuleIdentity.DeserializeModuleIdentity(item)); } - value = array; } - return Response.FromValue(value, message.Response); + value = array; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -1132,7 +932,7 @@ internal HttpMessage CreateGetModuleRequest(string id, string mid) /// Device ID. /// Module ID. /// The cancellation token to use. - public async ValueTask> GetModuleAsync(string id, string mid, CancellationToken cancellationToken = default) + public async ValueTask> GetModuleAsync(string id, string mid, CancellationToken cancellationToken = default) { if (id == null) { @@ -1143,36 +943,26 @@ public async ValueTask> GetModuleAsync(string id, string mid, C throw new ArgumentNullException(nameof(mid)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetModule"); - scope.Start(); - try + using var message = CreateGetModuleRequest(id, mid); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateGetModuleRequest(id, mid); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + ModuleIdentity value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Module value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Module.DeserializeModule(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = ModuleIdentity.DeserializeModuleIdentity(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -1180,7 +970,7 @@ public async ValueTask> GetModuleAsync(string id, string mid, C /// Device ID. /// Module ID. /// The cancellation token to use. - public Response GetModule(string id, string mid, CancellationToken cancellationToken = default) + public Response GetModule(string id, string mid, CancellationToken cancellationToken = default) { if (id == null) { @@ -1191,40 +981,30 @@ public Response GetModule(string id, string mid, CancellationToken cance throw new ArgumentNullException(nameof(mid)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.GetModule"); - scope.Start(); - try + using var message = CreateGetModuleRequest(id, mid); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateGetModuleRequest(id, mid); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + ModuleIdentity value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Module value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Module.DeserializeModule(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = ModuleIdentity.DeserializeModuleIdentity(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateCreateOrUpdateModuleRequest(string id, string mid, Module module, string ifMatch) + internal HttpMessage CreateCreateOrUpdateModuleRequest(string id, string mid, ModuleIdentity module, string ifMatch) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -1254,7 +1034,7 @@ internal HttpMessage CreateCreateOrUpdateModuleRequest(string id, string mid, Mo /// The Module to use. /// The String to use. /// The cancellation token to use. - public async ValueTask> CreateOrUpdateModuleAsync(string id, string mid, Module module, string ifMatch = null, CancellationToken cancellationToken = default) + public async ValueTask> CreateOrUpdateModuleAsync(string id, string mid, ModuleIdentity module, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -1269,37 +1049,27 @@ public async ValueTask> CreateOrUpdateModuleAsync(string id, st throw new ArgumentNullException(nameof(module)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.CreateOrUpdateModule"); - scope.Start(); - try + using var message = CreateCreateOrUpdateModuleRequest(id, mid, module, ifMatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateCreateOrUpdateModuleRequest(id, mid, module, ifMatch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: + case 200: + case 201: + { + ModuleIdentity value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Module value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Module.DeserializeModule(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = ModuleIdentity.DeserializeModuleIdentity(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -1309,7 +1079,7 @@ public async ValueTask> CreateOrUpdateModuleAsync(string id, st /// The Module to use. /// The String to use. /// The cancellation token to use. - public Response CreateOrUpdateModule(string id, string mid, Module module, string ifMatch = null, CancellationToken cancellationToken = default) + public Response CreateOrUpdateModule(string id, string mid, ModuleIdentity module, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -1324,37 +1094,27 @@ public Response CreateOrUpdateModule(string id, string mid, Module modul throw new ArgumentNullException(nameof(module)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.CreateOrUpdateModule"); - scope.Start(); - try + using var message = CreateCreateOrUpdateModuleRequest(id, mid, module, ifMatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateCreateOrUpdateModuleRequest(id, mid, module, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: + case 200: + case 201: + { + ModuleIdentity value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Module value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Module.DeserializeModule(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = ModuleIdentity.DeserializeModuleIdentity(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -1394,24 +1154,14 @@ public async ValueTask DeleteModuleAsync(string id, string mid, string throw new ArgumentNullException(nameof(mid)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.DeleteModule"); - scope.Start(); - try - { - using var message = CreateDeleteModuleRequest(id, mid, ifMatch); - 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); - } - } - catch (Exception e) + using var message = CreateDeleteModuleRequest(id, mid, ifMatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - scope.Failed(e); - throw; + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -1431,24 +1181,14 @@ public Response DeleteModule(string id, string mid, string ifMatch = null, Cance throw new ArgumentNullException(nameof(mid)); } - using var scope = _clientDiagnostics.CreateScope("RegistryManagerClient.DeleteModule"); - scope.Start(); - try - { - using var message = CreateDeleteModuleRequest(id, mid, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) + using var message = CreateDeleteModuleRequest(id, mid, ifMatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - scope.Failed(e); - throw; + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/TwinClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/TwinClient.cs similarity index 64% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/TwinClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/TwinClient.cs index 5fdb1e6e167d3..77a980966f99d 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/TwinClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/TwinClient.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Threading; using System.Threading.Tasks; using Azure; @@ -34,17 +35,37 @@ internal TwinClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, /// Gets a device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// The cancellation token to use. - public virtual async Task> GetDeviceTwinAsync(string id, CancellationToken cancellationToken = default) + public virtual async Task> GetDeviceTwinAsync(string id, CancellationToken cancellationToken = default) { - return await RestClient.GetDeviceTwinAsync(id, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("TwinClient.GetDeviceTwin"); + scope.Start(); + try + { + return await RestClient.GetDeviceTwinAsync(id, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Gets a device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// The cancellation token to use. - public virtual Response GetDeviceTwin(string id, CancellationToken cancellationToken = default) + public virtual Response GetDeviceTwin(string id, CancellationToken cancellationToken = default) { - return RestClient.GetDeviceTwin(id, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("TwinClient.GetDeviceTwin"); + scope.Start(); + try + { + return RestClient.GetDeviceTwin(id, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Replaces a device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -52,9 +73,19 @@ public virtual Response GetDeviceTwin(string id, CancellationToken cancell /// Device twin info. /// The String to use. /// The cancellation token to use. - public virtual async Task> ReplaceDeviceTwinAsync(string id, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual async Task> ReplaceDeviceTwinAsync(string id, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { - return await RestClient.ReplaceDeviceTwinAsync(id, deviceTwinInfo, ifMatch, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("TwinClient.ReplaceDeviceTwin"); + scope.Start(); + try + { + return await RestClient.ReplaceDeviceTwinAsync(id, deviceTwinInfo, ifMatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Replaces a device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -62,9 +93,19 @@ public virtual async Task> ReplaceDeviceTwinAsync(string id, Twin /// Device twin info. /// The String to use. /// The cancellation token to use. - public virtual Response ReplaceDeviceTwin(string id, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual Response ReplaceDeviceTwin(string id, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { - return RestClient.ReplaceDeviceTwin(id, deviceTwinInfo, ifMatch, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("TwinClient.ReplaceDeviceTwin"); + scope.Start(); + try + { + return RestClient.ReplaceDeviceTwin(id, deviceTwinInfo, ifMatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Updates a device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -72,9 +113,19 @@ public virtual Response ReplaceDeviceTwin(string id, Twin deviceTwinInfo, /// Device twin info. /// The String to use. /// The cancellation token to use. - public virtual async Task> UpdateDeviceTwinAsync(string id, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual async Task> UpdateDeviceTwinAsync(string id, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { - return await RestClient.UpdateDeviceTwinAsync(id, deviceTwinInfo, ifMatch, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("TwinClient.UpdateDeviceTwin"); + scope.Start(); + try + { + return await RestClient.UpdateDeviceTwinAsync(id, deviceTwinInfo, ifMatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Updates a device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -82,27 +133,57 @@ public virtual async Task> UpdateDeviceTwinAsync(string id, Twin /// Device twin info. /// The String to use. /// The cancellation token to use. - public virtual Response UpdateDeviceTwin(string id, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual Response UpdateDeviceTwin(string id, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { - return RestClient.UpdateDeviceTwin(id, deviceTwinInfo, ifMatch, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("TwinClient.UpdateDeviceTwin"); + scope.Start(); + try + { + return RestClient.UpdateDeviceTwin(id, deviceTwinInfo, ifMatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Gets a module twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// Module ID. /// The cancellation token to use. - public virtual async Task> GetModuleTwinAsync(string id, string mid, CancellationToken cancellationToken = default) + public virtual async Task> GetModuleTwinAsync(string id, string mid, CancellationToken cancellationToken = default) { - return await RestClient.GetModuleTwinAsync(id, mid, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("TwinClient.GetModuleTwin"); + scope.Start(); + try + { + return await RestClient.GetModuleTwinAsync(id, mid, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Gets a module twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// Module ID. /// The cancellation token to use. - public virtual Response GetModuleTwin(string id, string mid, CancellationToken cancellationToken = default) + public virtual Response GetModuleTwin(string id, string mid, CancellationToken cancellationToken = default) { - return RestClient.GetModuleTwin(id, mid, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("TwinClient.GetModuleTwin"); + scope.Start(); + try + { + return RestClient.GetModuleTwin(id, mid, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Replaces a module twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -111,9 +192,19 @@ public virtual Response GetModuleTwin(string id, string mid, CancellationT /// Device twin info. /// The String to use. /// The cancellation token to use. - public virtual async Task> ReplaceModuleTwinAsync(string id, string mid, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual async Task> ReplaceModuleTwinAsync(string id, string mid, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { - return await RestClient.ReplaceModuleTwinAsync(id, mid, deviceTwinInfo, ifMatch, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("TwinClient.ReplaceModuleTwin"); + scope.Start(); + try + { + return await RestClient.ReplaceModuleTwinAsync(id, mid, deviceTwinInfo, ifMatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Replaces a module twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -122,9 +213,19 @@ public virtual async Task> ReplaceModuleTwinAsync(string id, stri /// Device twin info. /// The String to use. /// The cancellation token to use. - public virtual Response ReplaceModuleTwin(string id, string mid, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual Response ReplaceModuleTwin(string id, string mid, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { - return RestClient.ReplaceModuleTwin(id, mid, deviceTwinInfo, ifMatch, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("TwinClient.ReplaceModuleTwin"); + scope.Start(); + try + { + return RestClient.ReplaceModuleTwin(id, mid, deviceTwinInfo, ifMatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Updates a module twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -133,9 +234,19 @@ public virtual Response ReplaceModuleTwin(string id, string mid, Twin devi /// Device twin information. /// The String to use. /// The cancellation token to use. - public virtual async Task> UpdateModuleTwinAsync(string id, string mid, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual async Task> UpdateModuleTwinAsync(string id, string mid, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { - return await RestClient.UpdateModuleTwinAsync(id, mid, deviceTwinInfo, ifMatch, cancellationToken).ConfigureAwait(false); + using var scope = _clientDiagnostics.CreateScope("TwinClient.UpdateModuleTwin"); + scope.Start(); + try + { + return await RestClient.UpdateModuleTwinAsync(id, mid, deviceTwinInfo, ifMatch, cancellationToken).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// Updates a module twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. @@ -144,9 +255,19 @@ public virtual async Task> UpdateModuleTwinAsync(string id, strin /// Device twin information. /// The String to use. /// The cancellation token to use. - public virtual Response UpdateModuleTwin(string id, string mid, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual Response UpdateModuleTwin(string id, string mid, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { - return RestClient.UpdateModuleTwin(id, mid, deviceTwinInfo, ifMatch, cancellationToken); + using var scope = _clientDiagnostics.CreateScope("TwinClient.UpdateModuleTwin"); + scope.Start(); + try + { + return RestClient.UpdateModuleTwin(id, mid, deviceTwinInfo, ifMatch, cancellationToken); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/TwinRestClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/TwinRestClient.cs similarity index 54% rename from sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/TwinRestClient.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/Generated/TwinRestClient.cs index e7d65f55b8fcd..05a7928c42d9f 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Generated/Operations/TwinRestClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Generated/TwinRestClient.cs @@ -58,90 +58,70 @@ internal HttpMessage CreateGetDeviceTwinRequest(string id) /// Gets a device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// The cancellation token to use. - public async ValueTask> GetDeviceTwinAsync(string id, CancellationToken cancellationToken = default) + public async ValueTask> GetDeviceTwinAsync(string id, CancellationToken cancellationToken = default) { if (id == null) { throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("TwinClient.GetDeviceTwin"); - scope.Start(); - try + using var message = CreateGetDeviceTwinRequest(id); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateGetDeviceTwinRequest(id); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Twin value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Twin.DeserializeTwin(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinData.DeserializeTwinData(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } /// Gets a device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. For IoT Hub VNET related features(https://docs.microsoft.com/en-us/azure/iot-hub/virtual-network-support) please use API version '2020-03-13'.These features are currently in general availability in the East US, West US 2, and Southcentral US regions only. We are actively working to expand the availability of these features to all regions by end of month May. For rest of the APIs please continue using API version '2019-10-01'. /// Device ID. /// The cancellation token to use. - public Response GetDeviceTwin(string id, CancellationToken cancellationToken = default) + public Response GetDeviceTwin(string id, CancellationToken cancellationToken = default) { if (id == null) { throw new ArgumentNullException(nameof(id)); } - using var scope = _clientDiagnostics.CreateScope("TwinClient.GetDeviceTwin"); - scope.Start(); - try + using var message = CreateGetDeviceTwinRequest(id); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateGetDeviceTwinRequest(id); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Twin value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Twin.DeserializeTwin(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinData.DeserializeTwinData(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateReplaceDeviceTwinRequest(string id, Twin deviceTwinInfo, string ifMatch) + internal HttpMessage CreateReplaceDeviceTwinRequest(string id, TwinData deviceTwinInfo, string ifMatch) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -168,7 +148,7 @@ internal HttpMessage CreateReplaceDeviceTwinRequest(string id, Twin deviceTwinIn /// Device twin info. /// The String to use. /// The cancellation token to use. - public async ValueTask> ReplaceDeviceTwinAsync(string id, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public async ValueTask> ReplaceDeviceTwinAsync(string id, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -179,36 +159,26 @@ public async ValueTask> ReplaceDeviceTwinAsync(string id, Twin de throw new ArgumentNullException(nameof(deviceTwinInfo)); } - using var scope = _clientDiagnostics.CreateScope("TwinClient.ReplaceDeviceTwin"); - scope.Start(); - try + using var message = CreateReplaceDeviceTwinRequest(id, deviceTwinInfo, ifMatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateReplaceDeviceTwinRequest(id, deviceTwinInfo, ifMatch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Twin value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Twin.DeserializeTwin(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinData.DeserializeTwinData(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -217,7 +187,7 @@ public async ValueTask> ReplaceDeviceTwinAsync(string id, Twin de /// Device twin info. /// The String to use. /// The cancellation token to use. - public Response ReplaceDeviceTwin(string id, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public Response ReplaceDeviceTwin(string id, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -228,40 +198,30 @@ public Response ReplaceDeviceTwin(string id, Twin deviceTwinInfo, string i throw new ArgumentNullException(nameof(deviceTwinInfo)); } - using var scope = _clientDiagnostics.CreateScope("TwinClient.ReplaceDeviceTwin"); - scope.Start(); - try + using var message = CreateReplaceDeviceTwinRequest(id, deviceTwinInfo, ifMatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateReplaceDeviceTwinRequest(id, deviceTwinInfo, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Twin value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Twin.DeserializeTwin(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinData.DeserializeTwinData(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateUpdateDeviceTwinRequest(string id, Twin deviceTwinInfo, string ifMatch) + internal HttpMessage CreateUpdateDeviceTwinRequest(string id, TwinData deviceTwinInfo, string ifMatch) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -288,7 +248,7 @@ internal HttpMessage CreateUpdateDeviceTwinRequest(string id, Twin deviceTwinInf /// Device twin info. /// The String to use. /// The cancellation token to use. - public async ValueTask> UpdateDeviceTwinAsync(string id, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public async ValueTask> UpdateDeviceTwinAsync(string id, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -299,36 +259,26 @@ public async ValueTask> UpdateDeviceTwinAsync(string id, Twin dev throw new ArgumentNullException(nameof(deviceTwinInfo)); } - using var scope = _clientDiagnostics.CreateScope("TwinClient.UpdateDeviceTwin"); - scope.Start(); - try + using var message = CreateUpdateDeviceTwinRequest(id, deviceTwinInfo, ifMatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateUpdateDeviceTwinRequest(id, deviceTwinInfo, ifMatch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Twin value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Twin.DeserializeTwin(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinData.DeserializeTwinData(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -337,7 +287,7 @@ public async ValueTask> UpdateDeviceTwinAsync(string id, Twin dev /// Device twin info. /// The String to use. /// The cancellation token to use. - public Response UpdateDeviceTwin(string id, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public Response UpdateDeviceTwin(string id, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -348,36 +298,26 @@ public Response UpdateDeviceTwin(string id, Twin deviceTwinInfo, string if throw new ArgumentNullException(nameof(deviceTwinInfo)); } - using var scope = _clientDiagnostics.CreateScope("TwinClient.UpdateDeviceTwin"); - scope.Start(); - try + using var message = CreateUpdateDeviceTwinRequest(id, deviceTwinInfo, ifMatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateUpdateDeviceTwinRequest(id, deviceTwinInfo, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Twin value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Twin.DeserializeTwin(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinData.DeserializeTwinData(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } @@ -401,7 +341,7 @@ internal HttpMessage CreateGetModuleTwinRequest(string id, string mid) /// Device ID. /// Module ID. /// The cancellation token to use. - public async ValueTask> GetModuleTwinAsync(string id, string mid, CancellationToken cancellationToken = default) + public async ValueTask> GetModuleTwinAsync(string id, string mid, CancellationToken cancellationToken = default) { if (id == null) { @@ -412,36 +352,26 @@ public async ValueTask> GetModuleTwinAsync(string id, string mid, throw new ArgumentNullException(nameof(mid)); } - using var scope = _clientDiagnostics.CreateScope("TwinClient.GetModuleTwin"); - scope.Start(); - try + using var message = CreateGetModuleTwinRequest(id, mid); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateGetModuleTwinRequest(id, mid); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Twin value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Twin.DeserializeTwin(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinData.DeserializeTwinData(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -449,7 +379,7 @@ public async ValueTask> GetModuleTwinAsync(string id, string mid, /// Device ID. /// Module ID. /// The cancellation token to use. - public Response GetModuleTwin(string id, string mid, CancellationToken cancellationToken = default) + public Response GetModuleTwin(string id, string mid, CancellationToken cancellationToken = default) { if (id == null) { @@ -460,40 +390,30 @@ public Response GetModuleTwin(string id, string mid, CancellationToken can throw new ArgumentNullException(nameof(mid)); } - using var scope = _clientDiagnostics.CreateScope("TwinClient.GetModuleTwin"); - scope.Start(); - try + using var message = CreateGetModuleTwinRequest(id, mid); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateGetModuleTwinRequest(id, mid); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Twin value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Twin.DeserializeTwin(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinData.DeserializeTwinData(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateReplaceModuleTwinRequest(string id, string mid, Twin deviceTwinInfo, string ifMatch) + internal HttpMessage CreateReplaceModuleTwinRequest(string id, string mid, TwinData deviceTwinInfo, string ifMatch) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -523,7 +443,7 @@ internal HttpMessage CreateReplaceModuleTwinRequest(string id, string mid, Twin /// Device twin info. /// The String to use. /// The cancellation token to use. - public async ValueTask> ReplaceModuleTwinAsync(string id, string mid, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public async ValueTask> ReplaceModuleTwinAsync(string id, string mid, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -538,36 +458,26 @@ public async ValueTask> ReplaceModuleTwinAsync(string id, string throw new ArgumentNullException(nameof(deviceTwinInfo)); } - using var scope = _clientDiagnostics.CreateScope("TwinClient.ReplaceModuleTwin"); - scope.Start(); - try + using var message = CreateReplaceModuleTwinRequest(id, mid, deviceTwinInfo, ifMatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateReplaceModuleTwinRequest(id, mid, deviceTwinInfo, ifMatch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Twin value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Twin.DeserializeTwin(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinData.DeserializeTwinData(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -577,7 +487,7 @@ public async ValueTask> ReplaceModuleTwinAsync(string id, string /// Device twin info. /// The String to use. /// The cancellation token to use. - public Response ReplaceModuleTwin(string id, string mid, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public Response ReplaceModuleTwin(string id, string mid, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -592,40 +502,30 @@ public Response ReplaceModuleTwin(string id, string mid, Twin deviceTwinIn throw new ArgumentNullException(nameof(deviceTwinInfo)); } - using var scope = _clientDiagnostics.CreateScope("TwinClient.ReplaceModuleTwin"); - scope.Start(); - try + using var message = CreateReplaceModuleTwinRequest(id, mid, deviceTwinInfo, ifMatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateReplaceModuleTwinRequest(id, mid, deviceTwinInfo, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Twin value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Twin.DeserializeTwin(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinData.DeserializeTwinData(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateUpdateModuleTwinRequest(string id, string mid, Twin deviceTwinInfo, string ifMatch) + internal HttpMessage CreateUpdateModuleTwinRequest(string id, string mid, TwinData deviceTwinInfo, string ifMatch) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -655,7 +555,7 @@ internal HttpMessage CreateUpdateModuleTwinRequest(string id, string mid, Twin d /// Device twin information. /// The String to use. /// The cancellation token to use. - public async ValueTask> UpdateModuleTwinAsync(string id, string mid, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public async ValueTask> UpdateModuleTwinAsync(string id, string mid, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -670,36 +570,26 @@ public async ValueTask> UpdateModuleTwinAsync(string id, string m throw new ArgumentNullException(nameof(deviceTwinInfo)); } - using var scope = _clientDiagnostics.CreateScope("TwinClient.UpdateModuleTwin"); - scope.Start(); - try + using var message = CreateUpdateModuleTwinRequest(id, mid, deviceTwinInfo, ifMatch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) { - using var message = CreateUpdateModuleTwinRequest(id, mid, deviceTwinInfo, ifMatch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Twin value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Twin.DeserializeTwin(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinData.DeserializeTwinData(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } @@ -709,7 +599,7 @@ public async ValueTask> UpdateModuleTwinAsync(string id, string m /// Device twin information. /// The String to use. /// The cancellation token to use. - public Response UpdateModuleTwin(string id, string mid, Twin deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) + public Response UpdateModuleTwin(string id, string mid, TwinData deviceTwinInfo, string ifMatch = null, CancellationToken cancellationToken = default) { if (id == null) { @@ -724,36 +614,26 @@ public Response UpdateModuleTwin(string id, string mid, Twin deviceTwinInf throw new ArgumentNullException(nameof(deviceTwinInfo)); } - using var scope = _clientDiagnostics.CreateScope("TwinClient.UpdateModuleTwin"); - scope.Start(); - try + using var message = CreateUpdateModuleTwinRequest(id, mid, deviceTwinInfo, ifMatch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) { - using var message = CreateUpdateModuleTwinRequest(id, mid, deviceTwinInfo, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: + case 200: + { + TwinData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + if (document.RootElement.ValueKind == JsonValueKind.Null) { - Twin value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - if (document.RootElement.ValueKind == JsonValueKind.Null) - { - value = null; - } - else - { - value = Twin.DeserializeTwin(document.RootElement); - } - return Response.FromValue(value, message.Response); + value = null; } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; + else + { + value = TwinData.DeserializeTwinData(document.RootElement); + } + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } }