Skip to content

Commit

Permalink
Updating to latest swagger and regenerating code. (Azure#14762)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinagesh authored Sep 1, 2020
1 parent ab32661 commit 05bff31
Show file tree
Hide file tree
Showing 72 changed files with 1,888 additions and 2,476 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ 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; } }
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 @@ -564,7 +563,6 @@ 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; } }
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 { } }
Expand Down Expand Up @@ -989,7 +987,6 @@ 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; } }
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 { } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.Pipeline;

namespace Azure.Iot.Hub.Service.Authentication
{
Expand Down Expand Up @@ -144,11 +143,23 @@ private AccessToken GetSasTokenAsync(CancellationToken cancellationToken)
}
}

/// <summary>
/// Gets an Azure.Core.AccessToken for the specified set of scopes.
/// </summary>
/// <param name="requestContext">The Azure.Core.TokenRequestContext with authentication information.</param>
/// <param name="cancellationToken">The System.Threading.CancellationToken to use.</param>
/// <returns> A valid Azure token <see cref="AccessToken"/>.</returns>
public override ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
{
return new ValueTask<AccessToken>(GetSasTokenAsync(cancellationToken));
}

/// <summary>
/// Gets an Azure.Core.AccessToken for the specified set of scopes.
/// </summary>
/// <param name="requestContext">The Azure.Core.TokenRequestContext with authentication information.</param>
/// <param name="cancellationToken">The System.Threading.CancellationToken to use.</param>
/// <returns> A valid Azure token <see cref="AccessToken"/>.</returns>
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
{
return GetSasTokenAsync(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<AssemblyTitle>Azure IoT Hub Service Client SDK</AssemblyTitle>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<EnableApiCompat>false</EnableApiCompat>
<!-- These supressions should be removed in a production library -->
<NoWarn>$(NoWarn);CA1812;1591</NoWarn>
</PropertyGroup>

<!-- Nuget properties -->
Expand Down Expand Up @@ -53,5 +51,4 @@
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\..\core\Azure.Core\src\Azure.Core.props" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace Azure.Iot.Hub.Service.Models
{
public partial class DeviceCapabilities
{
/// <summary>
/// The property that determines if the device is an edge device or not.
/// </summary>
[CodeGenMember("IotEdge")]
public bool? IsIotEdgeDevice { get; set; }
}
Expand Down
42 changes: 23 additions & 19 deletions sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class DevicesClient

private readonly DevicesRestClient _devicesRestClient;
private readonly QueryClient _queryClient;
private readonly BulkRegistryRestClient _bulkRegistryClient;

/// <summary>
/// Initializes a new instance of DevicesClient.
Expand All @@ -33,14 +34,17 @@ protected DevicesClient()
/// Initializes a new instance of DevicesClient.
/// <param name="devicesRestClient"> The REST client to perform device, device twin, and bulk operations. </param>
/// <param name="queryClient"> The convenience layer query client to perform query operations for the device. </param>
/// <param name="bulkRegistryClient"> The convenience layer client to perform bulk operations on devices. </param>
/// </summary>
internal DevicesClient(DevicesRestClient devicesRestClient, QueryClient queryClient)
internal DevicesClient(DevicesRestClient devicesRestClient, QueryClient queryClient, BulkRegistryRestClient bulkRegistryClient)
{
Argument.AssertNotNull(devicesRestClient, nameof(devicesRestClient));
Argument.AssertNotNull(queryClient, nameof(queryClient));
Argument.AssertNotNull(bulkRegistryClient, nameof(bulkRegistryClient));

_devicesRestClient = devicesRestClient;
_queryClient = queryClient;
_bulkRegistryClient = bulkRegistryClient;
}

/// <summary>
Expand Down Expand Up @@ -118,7 +122,7 @@ public virtual Response<DeviceIdentity> CreateOrUpdateIdentity(
/// </code>
public virtual Task<Response<DeviceIdentity>> GetIdentityAsync(string deviceId, CancellationToken cancellationToken = default)
{
return _devicesRestClient.GetDeviceAsync(deviceId, cancellationToken);
return _devicesRestClient.GetIdentityAsync(deviceId, cancellationToken);
}

/// <summary>
Expand All @@ -129,7 +133,7 @@ public virtual Task<Response<DeviceIdentity>> GetIdentityAsync(string deviceId,
/// <returns>The retrieved device identity and the http response <see cref="Response{T}"/>.</returns>
public virtual Response<DeviceIdentity> GetIdentity(string deviceId, CancellationToken cancellationToken = default)
{
return _devicesRestClient.GetDevice(deviceId, cancellationToken);
return _devicesRestClient.GetIdentity(deviceId, cancellationToken);
}

/// <summary>
Expand Down Expand Up @@ -192,9 +196,9 @@ public virtual Task<Response<BulkRegistryOperationResponse>> CreateIdentitiesWit
: ExportImportDeviceStatus.Enabled,
StatusReason = x.Key.StatusReason,
ImportMode = ExportImportDeviceImportMode.Create
}.WithTags(x.Value.Tags).WithPropertiesFrom(x.Value.Properties).WithParentScopes(x.Key.ParentScopes));
}.WithTags(x.Value.Tags).WithPropertiesFrom(x.Value.Properties));

return _devicesRestClient.BulkRegistryOperationsAsync(registryOperations, cancellationToken);
return _bulkRegistryClient.UpdateRegistryAsync(registryOperations, cancellationToken);
}

/// <summary>
Expand All @@ -218,9 +222,9 @@ public virtual Response<BulkRegistryOperationResponse> CreateIdentitiesWithTwin(
: ExportImportDeviceStatus.Enabled,
StatusReason = x.Key.StatusReason,
ImportMode = ExportImportDeviceImportMode.Create
}.WithTags(x.Value.Tags).WithPropertiesFrom(x.Value.Properties).WithParentScopes(x.Key.ParentScopes));
}.WithTags(x.Value.Tags).WithPropertiesFrom(x.Value.Properties));

return _devicesRestClient.BulkRegistryOperations(registryOperations, cancellationToken);
return _bulkRegistryClient.UpdateRegistry(registryOperations, cancellationToken);
}

/// <summary>
Expand All @@ -243,9 +247,9 @@ public virtual Task<Response<BulkRegistryOperationResponse>> CreateIdentitiesAsy
: ExportImportDeviceStatus.Enabled,
StatusReason = x.StatusReason,
ImportMode = ExportImportDeviceImportMode.Create
}.WithParentScopes(x.ParentScopes));
});

return _devicesRestClient.BulkRegistryOperationsAsync(registryOperations, cancellationToken);
return _bulkRegistryClient.UpdateRegistryAsync(registryOperations, cancellationToken);
}

/// <summary>
Expand All @@ -268,9 +272,9 @@ public virtual Response<BulkRegistryOperationResponse> CreateIdentities(IEnumera
: ExportImportDeviceStatus.Enabled,
StatusReason = x.StatusReason,
ImportMode = ExportImportDeviceImportMode.Create
}.WithParentScopes(x.ParentScopes));
});

return _devicesRestClient.BulkRegistryOperations(registryOperations, cancellationToken);
return _bulkRegistryClient.UpdateRegistry(registryOperations, cancellationToken);
}

/// <summary>
Expand Down Expand Up @@ -298,9 +302,9 @@ public virtual Task<Response<BulkRegistryOperationResponse>> UpdateIdentitiesAsy
: ExportImportDeviceStatus.Enabled,
StatusReason = x.StatusReason,
ImportMode = precondition == BulkIfMatchPrecondition.Unconditional ? ExportImportDeviceImportMode.Update : ExportImportDeviceImportMode.UpdateIfMatchETag
}.WithParentScopes(x.ParentScopes));
});

return _devicesRestClient.BulkRegistryOperationsAsync(registryOperations, cancellationToken);
return _bulkRegistryClient.UpdateRegistryAsync(registryOperations, cancellationToken);
}

/// <summary>
Expand Down Expand Up @@ -328,9 +332,9 @@ public virtual Response<BulkRegistryOperationResponse> UpdateIdentities(
: ExportImportDeviceStatus.Enabled,
StatusReason = x.StatusReason,
ImportMode = precondition == BulkIfMatchPrecondition.Unconditional ? ExportImportDeviceImportMode.Update : ExportImportDeviceImportMode.UpdateIfMatchETag
}.WithParentScopes(x.ParentScopes));
});

return _devicesRestClient.BulkRegistryOperations(registryOperations, cancellationToken);
return _bulkRegistryClient.UpdateRegistry(registryOperations, cancellationToken);
}

/// <summary>
Expand All @@ -355,7 +359,7 @@ public virtual Task<Response<BulkRegistryOperationResponse>> DeleteIdentitiesAsy
: ExportImportDeviceImportMode.DeleteIfMatchETag
});

return _devicesRestClient.BulkRegistryOperationsAsync(registryOperations, cancellationToken);
return _bulkRegistryClient.UpdateRegistryAsync(registryOperations, cancellationToken);
}

/// <summary>
Expand All @@ -380,7 +384,7 @@ public virtual Response<BulkRegistryOperationResponse> DeleteIdentities(
: ExportImportDeviceImportMode.DeleteIfMatchETag
});

return _devicesRestClient.BulkRegistryOperations(registryOperations, cancellationToken);
return _bulkRegistryClient.UpdateRegistry(registryOperations, cancellationToken);
}

/// <summary>
Expand Down Expand Up @@ -506,7 +510,7 @@ public virtual Task<Response<BulkRegistryOperationResponse>> UpdateTwinsAsync(
ImportMode = precondition == BulkIfMatchPrecondition.Unconditional ? ExportImportDeviceImportMode.UpdateTwin : ExportImportDeviceImportMode.UpdateTwinIfMatchETag
}.WithTags(x.Tags).WithPropertiesFrom(x.Properties));

return _devicesRestClient.BulkRegistryOperationsAsync(registryOperations, cancellationToken);
return _bulkRegistryClient.UpdateRegistryAsync(registryOperations, cancellationToken);
}

/// <summary>
Expand All @@ -531,7 +535,7 @@ public virtual Response<BulkRegistryOperationResponse> UpdateTwins(
: ExportImportDeviceImportMode.UpdateTwinIfMatchETag
}.WithTags(x.Tags).WithPropertiesFrom(x.Properties));

return _devicesRestClient.BulkRegistryOperations(registryOperations, cancellationToken);
return _bulkRegistryClient.UpdateRegistry(registryOperations, cancellationToken);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public static ExportImportDevice WithTags(this ExportImportDevice device, IDicti
/// </summary>
public static ExportImportDevice WithPropertiesFrom(this ExportImportDevice device, TwinProperties properties)
{

var container = new PropertyContainer();
if (properties != null)
{
Expand All @@ -46,17 +45,5 @@ public static ExportImportDevice WithPropertiesFrom(this ExportImportDevice devi

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 05bff31

Please sign in to comment.