Skip to content

Commit

Permalink
Update Autorest C# - IOT (#13558)
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym authored Jul 21, 2020
1 parent 2a886f9 commit e241ebe
Show file tree
Hide file tree
Showing 78 changed files with 592 additions and 1,900 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ internal CloudToDeviceMethodResponse() { }
public partial class Components10Jnwi5SchemasDigitaltwininterfacespatchPropertiesInterfacesAdditionalproperties
{
public Components10Jnwi5SchemasDigitaltwininterfacespatchPropertiesInterfacesAdditionalproperties() { }
public System.Collections.Generic.IDictionary<string, Azure.Iot.Hub.Service.Models.Components17Cpi2FSchemasDigitaltwininterfacespatchPropertiesInterfacesAdditionalpropertiesPropertiesAdditionalproperties> Properties { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, Azure.Iot.Hub.Service.Models.Components17Cpi2FSchemasDigitaltwininterfacespatchPropertiesInterfacesAdditionalpropertiesPropertiesAdditionalproperties> Properties { get { throw null; } }
}
public partial class Components17Cpi2FSchemasDigitaltwininterfacespatchPropertiesInterfacesAdditionalpropertiesPropertiesAdditionalproperties
{
Expand All @@ -171,20 +171,20 @@ public Components17Cpi2FSchemasDigitaltwininterfacespatchPropertiesInterfacesAdd
public partial class ConfigurationContent
{
public ConfigurationContent() { }
public System.Collections.Generic.IDictionary<string, object> DeviceContent { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> ModuleContent { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> ModulesContent { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> DeviceContent { get { throw null; } }
public System.Collections.Generic.IDictionary<string, object> ModuleContent { get { throw null; } }
public System.Collections.Generic.IDictionary<string, object> ModulesContent { get { throw null; } }
}
public partial class ConfigurationMetrics
{
public ConfigurationMetrics() { }
public System.Collections.Generic.IDictionary<string, string> Queries { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, long> Results { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, string> Queries { get { throw null; } }
public System.Collections.Generic.IDictionary<string, long> Results { get { throw null; } }
}
public partial class ConfigurationQueriesTestInput
{
public ConfigurationQueriesTestInput() { }
public System.Collections.Generic.IDictionary<string, string> CustomMetricQueries { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, string> CustomMetricQueries { get { throw null; } }
public string TargetCondition { get { throw null; } set { } }
}
public partial class ConfigurationQueriesTestResponse
Expand Down Expand Up @@ -236,7 +236,7 @@ public DeviceIdentity() { }
public string Etag { get { throw null; } set { } }
public string GenerationId { get { throw null; } set { } }
public System.DateTimeOffset? LastActivityTime { get { throw null; } set { } }
public System.Collections.Generic.IList<string> ParentScopes { get { throw null; } set { } }
public System.Collections.Generic.IList<string> ParentScopes { get { throw null; } }
public Azure.Iot.Hub.Service.Models.DeviceStatus? Status { get { throw null; } set { } }
public string StatusReason { get { throw null; } set { } }
public System.DateTimeOffset? StatusUpdatedTime { get { throw null; } set { } }
Expand Down Expand Up @@ -518,7 +518,7 @@ internal DeviceRegistryOperationWarning() { }
public partial class DigitalTwinInterfacesPatch
{
public DigitalTwinInterfacesPatch() { }
public System.Collections.Generic.IDictionary<string, Azure.Iot.Hub.Service.Models.Components10Jnwi5SchemasDigitaltwininterfacespatchPropertiesInterfacesAdditionalproperties> Interfaces { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, Azure.Iot.Hub.Service.Models.Components10Jnwi5SchemasDigitaltwininterfacespatchPropertiesInterfacesAdditionalproperties> Interfaces { get { throw null; } }
}
public partial class DigitalTwinInterfacesPatchInterfacesPropertiesAdditionalPropertiesDesired
{
Expand All @@ -535,11 +535,11 @@ public ExportImportDevice() { }
public string Id { get { throw null; } set { } }
public Azure.Iot.Hub.Service.Models.ExportImportDeviceImportMode? ImportMode { get { throw null; } set { } }
public string ModuleId { get { throw null; } set { } }
public System.Collections.Generic.IList<string> ParentScopes { get { throw null; } set { } }
public System.Collections.Generic.IList<string> ParentScopes { get { throw null; } }
public Azure.Iot.Hub.Service.Models.PropertyContainer Properties { get { throw null; } set { } }
public Azure.Iot.Hub.Service.Models.ExportImportDeviceStatus? Status { get { throw null; } set { } }
public string StatusReason { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> Tags { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> Tags { get { throw null; } }
public string TwinETag { get { throw null; } set { } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
Expand Down Expand Up @@ -851,8 +851,8 @@ public ModuleIdentity() { }
public partial class PropertyContainer
{
public PropertyContainer() { }
public System.Collections.Generic.IDictionary<string, object> Desired { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> Reported { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> Desired { get { throw null; } }
public System.Collections.Generic.IDictionary<string, object> Reported { get { throw null; } }
}
public partial class PurgeMessageQueueResult
{
Expand Down Expand Up @@ -942,7 +942,7 @@ public TwinConfiguration() { }
public System.DateTimeOffset? CreatedTimeUtc { get { throw null; } set { } }
public string Etag { get { throw null; } set { } }
public string Id { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, string> Labels { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, string> Labels { get { throw null; } }
public System.DateTimeOffset? LastUpdatedTimeUtc { get { throw null; } set { } }
public Azure.Iot.Hub.Service.Models.ConfigurationMetrics Metrics { get { throw null; } set { } }
public int? Priority { get { throw null; } set { } }
Expand Down Expand Up @@ -981,20 +981,20 @@ public TwinData() { }
public string Etag { get { throw null; } set { } }
public System.DateTimeOffset? LastActivityTime { get { throw null; } set { } }
public string ModuleId { get { throw null; } set { } }
public System.Collections.Generic.IList<string> ParentScopes { get { throw null; } set { } }
public System.Collections.Generic.IList<string> ParentScopes { get { throw null; } }
public Azure.Iot.Hub.Service.Models.TwinProperties Properties { get { throw null; } set { } }
public Azure.Iot.Hub.Service.Models.TwinStatus? Status { get { throw null; } set { } }
public string StatusReason { get { throw null; } set { } }
public System.DateTimeOffset? StatusUpdateTime { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> Tags { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> Tags { get { throw null; } }
public long? Version { get { throw null; } set { } }
public Azure.Iot.Hub.Service.Models.X509Thumbprint X509Thumbprint { get { throw null; } set { } }
}
public partial class TwinProperties
{
public TwinProperties() { }
public System.Collections.Generic.IDictionary<string, object> Desired { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> Reported { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> Desired { get { throw null; } }
public System.Collections.Generic.IDictionary<string, object> Reported { get { throw null; } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct TwinStatus : System.IEquatable<Azure.Iot.Hub.Service.Models.TwinStatus>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<EnableApiCompat>false</EnableApiCompat>
<!-- These supressions should be removed in a production library -->
<NoWarn>$(NoWarn);CA1812;1591</NoWarn>
<TemporaryUsePreviousGeneratorVersion>true</TemporaryUsePreviousGeneratorVersion><!-- https://github.com/Azure/azure-sdk-for-net/issues/13506 -->
</PropertyGroup>

<!-- Nuget properties -->
Expand Down
30 changes: 8 additions & 22 deletions sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,12 @@ public virtual Task<Response<BulkRegistryOperationResponse>> CreateIdentitiesWit
Authentication = x.Key.Authentication,
Capabilities = x.Key.Capabilities,
DeviceScope = x.Key.DeviceScope,
ParentScopes = x.Key.ParentScopes,
Status = string.Equals(ExportImportDeviceStatus.Disabled.ToString(), x.Key.Status?.ToString(), StringComparison.OrdinalIgnoreCase)
? ExportImportDeviceStatus.Disabled
: ExportImportDeviceStatus.Enabled,
StatusReason = x.Key.StatusReason,
Tags = x.Value.Tags,
Properties = new PropertyContainer(x.Value.Properties?.Desired, x.Value.Properties?.Reported),
ImportMode = ExportImportDeviceImportMode.Create
});
}.WithTags(x.Value.Tags).WithPropertiesFrom(x.Value.Properties).WithParentScopes(x.Key.ParentScopes));

return _registryManagerClient.BulkDeviceCrudAsync(registryOperations, cancellationToken);
}
Expand All @@ -181,15 +178,12 @@ public virtual Response<BulkRegistryOperationResponse> CreateIdentitiesWithTwin(
Authentication = x.Key.Authentication,
Capabilities = x.Key.Capabilities,
DeviceScope = x.Key.DeviceScope,
ParentScopes = x.Key.ParentScopes,
Status = string.Equals(ExportImportDeviceStatus.Disabled.ToString(), x.Key.Status?.ToString(), StringComparison.OrdinalIgnoreCase)
? ExportImportDeviceStatus.Disabled
: ExportImportDeviceStatus.Enabled,
StatusReason = x.Key.StatusReason,
Tags = x.Value.Tags,
Properties = new PropertyContainer(x.Value.Properties?.Desired, x.Value.Properties?.Reported),
ImportMode = ExportImportDeviceImportMode.Create
});
}.WithTags(x.Value.Tags).WithPropertiesFrom(x.Value.Properties).WithParentScopes(x.Key.ParentScopes));

return _registryManagerClient.BulkDeviceCrud(registryOperations, cancellationToken);
}
Expand All @@ -209,13 +203,12 @@ public virtual Task<Response<BulkRegistryOperationResponse>> CreateIdentitiesAsy
Authentication = x.Authentication,
Capabilities = x.Capabilities,
DeviceScope = x.DeviceScope,
ParentScopes = x.ParentScopes,
Status = string.Equals(ExportImportDeviceStatus.Disabled.ToString(), x.Status?.ToString(), StringComparison.OrdinalIgnoreCase)
? ExportImportDeviceStatus.Disabled
: ExportImportDeviceStatus.Enabled,
StatusReason = x.StatusReason,
ImportMode = ExportImportDeviceImportMode.Create
});
}.WithParentScopes(x.ParentScopes));

return _registryManagerClient.BulkDeviceCrudAsync(registryOperations, cancellationToken);
}
Expand All @@ -235,13 +228,12 @@ public virtual Response<BulkRegistryOperationResponse> CreateIdentities(IEnumera
Authentication = x.Authentication,
Capabilities = x.Capabilities,
DeviceScope = x.DeviceScope,
ParentScopes = x.ParentScopes,
Status = string.Equals(ExportImportDeviceStatus.Disabled.ToString(), x.Status?.ToString(), StringComparison.OrdinalIgnoreCase)
? ExportImportDeviceStatus.Disabled
: ExportImportDeviceStatus.Enabled,
StatusReason = x.StatusReason,
ImportMode = ExportImportDeviceImportMode.Create
});
}.WithParentScopes(x.ParentScopes));

return _registryManagerClient.BulkDeviceCrud(registryOperations, cancellationToken);
}
Expand All @@ -265,14 +257,13 @@ public virtual Task<Response<BulkRegistryOperationResponse>> UpdateIdentitiesAsy
Authentication = x.Authentication,
Capabilities = x.Capabilities,
DeviceScope = x.DeviceScope,
ParentScopes = x.ParentScopes,
ETag = x.Etag,
Status = string.Equals(ExportImportDeviceStatus.Disabled.ToString(), x.Status?.ToString(), StringComparison.OrdinalIgnoreCase)
? ExportImportDeviceStatus.Disabled
: ExportImportDeviceStatus.Enabled,
StatusReason = x.StatusReason,
ImportMode = precondition == BulkIfMatchPrecondition.Unconditional ? ExportImportDeviceImportMode.Update : ExportImportDeviceImportMode.UpdateIfMatchETag
});
}.WithParentScopes(x.ParentScopes));

return _registryManagerClient.BulkDeviceCrudAsync(registryOperations, cancellationToken);
}
Expand All @@ -296,14 +287,13 @@ public virtual Response<BulkRegistryOperationResponse> UpdateIdentities(
Authentication = x.Authentication,
Capabilities = x.Capabilities,
DeviceScope = x.DeviceScope,
ParentScopes = x.ParentScopes,
ETag = x.Etag,
Status = string.Equals(ExportImportDeviceStatus.Disabled.ToString(), x.Status?.ToString(), StringComparison.OrdinalIgnoreCase)
? ExportImportDeviceStatus.Disabled
: ExportImportDeviceStatus.Enabled,
StatusReason = x.StatusReason,
ImportMode = precondition == BulkIfMatchPrecondition.Unconditional ? ExportImportDeviceImportMode.Update : ExportImportDeviceImportMode.UpdateIfMatchETag
});
}.WithParentScopes(x.ParentScopes));

return _registryManagerClient.BulkDeviceCrud(registryOperations, cancellationToken);
}
Expand Down Expand Up @@ -513,11 +503,9 @@ public virtual Task<Response<BulkRegistryOperationResponse>> UpdateTwinsAsync(
.Select(x => new ExportImportDevice()
{
Id = x.DeviceId,
Tags = x.Tags,
Properties = new PropertyContainer(x.Properties?.Desired, x.Properties?.Reported),
TwinETag = x.Etag,
ImportMode = precondition == BulkIfMatchPrecondition.Unconditional ? ExportImportDeviceImportMode.UpdateTwin : ExportImportDeviceImportMode.UpdateTwinIfMatchETag
});
}.WithTags(x.Tags).WithPropertiesFrom(x.Properties));

return _registryManagerClient.BulkDeviceCrudAsync(registryOperations, cancellationToken);
}
Expand All @@ -538,13 +526,11 @@ public virtual Response<BulkRegistryOperationResponse> UpdateTwins(
.Select(x => new ExportImportDevice()
{
Id = x.DeviceId,
Tags = x.Tags,
Properties = new PropertyContainer(x.Properties?.Desired, x.Properties?.Reported),
TwinETag = x.Etag,
ImportMode = precondition == BulkIfMatchPrecondition.Unconditional
? ExportImportDeviceImportMode.UpdateTwin
: ExportImportDeviceImportMode.UpdateTwinIfMatchETag
});
}.WithTags(x.Tags).WithPropertiesFrom(x.Properties));

return _registryManagerClient.BulkDeviceCrud(registryOperations, cancellationToken);
}
Expand Down
62 changes: 62 additions & 0 deletions sdk/iot/Azure.Iot.Hub.Service/src/ExportImportDeviceExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;
using Azure.Iot.Hub.Service.Models;

namespace Azure.Iot.Hub.Service
{
/// <summary>
/// Helper functions for mutating the <see cref="ExportImportDevice"/> instance.
/// </summary>
internal static class ExportImportDeviceExtensions
{
/// <summary>
/// Initializes the <see cref="ExportImportDevice.Tags"/> property using provided values.
/// </summary>
public static ExportImportDevice WithTags(this ExportImportDevice device, IDictionary<string, object> tags)
{
foreach (var tag in tags)
{
device.Tags.Add(tag);
}
return device;
}

/// <summary>
/// Initializes the <see cref="ExportImportDevice.Properties"/> property using provided values.
/// </summary>
public static ExportImportDevice WithPropertiesFrom(this ExportImportDevice device, TwinProperties properties)
{

var container = new PropertyContainer();
if (properties != null)
{
foreach (var property in properties.Desired)
{
container.Desired.Add(property);
}
foreach (var property in properties.Reported)
{
container.Reported.Add(property);
}
}

device.Properties = container;

return device;
}

/// <summary>
/// Initializes the <see cref="ExportImportDevice.ParentScopes"/> property using provided values.
/// </summary>
public static ExportImportDevice WithParentScopes(this ExportImportDevice device, IList<string> parentScopes)
{
foreach (var parentScope in parentScopes)
{
device.ParentScopes.Add(parentScope);
}
return device;
}
}
}
Loading

0 comments on commit e241ebe

Please sign in to comment.