From 6e0c3a6a1b6785fb2453beb0182ab576b3cc4d7f Mon Sep 17 00:00:00 2001 From: bikamani <41314966+bikamani@users.noreply.github.com> Date: Thu, 21 May 2020 14:29:54 -0700 Subject: [PATCH 1/5] initial changes --- sdk/iot/Azure.Iot.Hub.Service/src/Devices.cs | 35 +++++++++++++ .../src/IoTHubServiceClient.cs | 51 +++++++++++++++++++ sdk/iot/Azure.Iot.Hub.Service/src/Modules.cs | 13 +++++ 3 files changed, 99 insertions(+) create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/Devices.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/Modules.cs diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Devices.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Devices.cs new file mode 100644 index 000000000000..91f41c9f6081 --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Devices.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Azure.Iot.Hub.Service.Models; + +namespace Azure.Iot.Hub.Service +{ + /// + /// + /// + public class Devices + { + internal RegistryManagerClient _registryManagerClient; + /// + /// + /// + public Devices() + { + _registryManagerClient = new RegistryManagerRestClient(); + } + + /// + /// Get a single device. + /// + /// The unique identifier of the device to get. + /// The cancellation token. + /// The retrieved device. + public virtual async Task> GetIdentityAsync(string deviceId, CancellationToken cancellationToken = default) + { + return _registryManagerClient.GetDeviceAsync(deviceId); + } + + + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs new file mode 100644 index 000000000000..ca82e629b8d0 --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Azure.Iot.Hub.Service +{ + /// + /// The IoT Hub Service Client + /// + public class IoTHubServiceClient + { + /// + /// + /// + public Devices Devices; + /// + /// + /// + public Modules Modules; + /// + /// + /// + public Statistics Statistics; + /// + /// + /// + public Messages Messages; + /// + /// + /// + public Files Files; + + + /// + /// Initializes a new instance of the class. + /// + public IoTHubServiceClient(Uri endpoint, IoTHubServiceClientOptions options) + { + FaultInjectionClient = new FaultInjectionClient(); + } + + + /// + /// Initializes a new instance of the class. + /// + protected IoTHubServiceClient() + { + + } + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Modules.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Modules.cs new file mode 100644 index 000000000000..7c5bd3f58996 --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/Modules.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Azure.Iot.Hub.Service +{ + /// + /// + /// + public class Modules + { + } +} From 08e3734ce4453c41428d3dbfdb248f0e4a2a3d6a Mon Sep 17 00:00:00 2001 From: bikamani <41314966+bikamani@users.noreply.github.com> Date: Thu, 21 May 2020 15:21:29 -0700 Subject: [PATCH 2/5] commit #2 --- sdk/iot/Azure.Iot.Hub.Service/src/Devices.cs | 35 ------------------- .../src/DevicesClient.cs | 20 +++++++++++ .../Azure.Iot.Hub.Service/src/FilesClient.cs | 20 +++++++++++ .../src/IoTHubServiceClient.cs | 19 ++++------ .../Azure.Iot.Hub.Service/src/JobsClient.cs | 20 +++++++++++ .../src/MessagesClient.cs | 20 +++++++++++ .../src/ModulesClient.cs | 20 +++++++++++ .../src/{Modules.cs => StatisticsClient.cs} | 5 +-- 8 files changed, 108 insertions(+), 51 deletions(-) delete mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/Devices.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/FilesClient.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/JobsClient.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/MessagesClient.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/ModulesClient.cs rename sdk/iot/Azure.Iot.Hub.Service/src/{Modules.cs => StatisticsClient.cs} (62%) diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Devices.cs b/sdk/iot/Azure.Iot.Hub.Service/src/Devices.cs deleted file mode 100644 index 91f41c9f6081..000000000000 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Devices.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Azure.Iot.Hub.Service.Models; - -namespace Azure.Iot.Hub.Service -{ - /// - /// - /// - public class Devices - { - internal RegistryManagerClient _registryManagerClient; - /// - /// - /// - public Devices() - { - _registryManagerClient = new RegistryManagerRestClient(); - } - - /// - /// Get a single device. - /// - /// The unique identifier of the device to get. - /// The cancellation token. - /// The retrieved device. - public virtual async Task> GetIdentityAsync(string deviceId, CancellationToken cancellationToken = default) - { - return _registryManagerClient.GetDeviceAsync(deviceId); - } - - - } -} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs new file mode 100644 index 000000000000..89c74c2ecb2e --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Azure.Iot.Hub.Service.Models; + +namespace Azure.Iot.Hub.Service +{ + /// + /// + /// + public class DevicesClient + { + /// + /// + /// + protected DevicesClient() + { + } + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/FilesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/FilesClient.cs new file mode 100644 index 000000000000..666e06c6af92 --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/FilesClient.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Azure.Iot.Hub.Service +{ + /// + /// + /// + public class FilesClient + { + /// + /// + /// + protected FilesClient() + { + + } + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs index ca82e629b8d0..4e8f99699515 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs @@ -12,32 +12,27 @@ public class IoTHubServiceClient /// /// /// - public Devices Devices; + public DevicesClient Devices; /// /// /// - public Modules Modules; + public ModulesClient Modules; /// /// /// - public Statistics Statistics; + public StatisticsClient Statistics; /// /// /// - public Messages Messages; + public MessagesClient Messages; /// /// /// - public Files Files; - - + public FilesClient Files; /// - /// Initializes a new instance of the class. + /// /// - public IoTHubServiceClient(Uri endpoint, IoTHubServiceClientOptions options) - { - FaultInjectionClient = new FaultInjectionClient(); - } + public JobsClient Jobs; /// diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/JobsClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/JobsClient.cs new file mode 100644 index 000000000000..ebb580caa887 --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/JobsClient.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Azure.Iot.Hub.Service +{ + /// + /// + /// + public class JobsClient + { + /// + /// + /// + public JobsClient() + { + + } + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/MessagesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/MessagesClient.cs new file mode 100644 index 000000000000..3ec0387f09ad --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/MessagesClient.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Azure.Iot.Hub.Service +{ + /// + /// + /// + public class MessagesClient + { + /// + /// + /// + protected MessagesClient() + { + + } + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/ModulesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/ModulesClient.cs new file mode 100644 index 000000000000..ac35b9afdf6f --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/ModulesClient.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Azure.Iot.Hub.Service +{ + /// + /// + /// + public class ModulesClient + { + /// + /// + /// + protected ModulesClient() + { + + } + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/Modules.cs b/sdk/iot/Azure.Iot.Hub.Service/src/StatisticsClient.cs similarity index 62% rename from sdk/iot/Azure.Iot.Hub.Service/src/Modules.cs rename to sdk/iot/Azure.Iot.Hub.Service/src/StatisticsClient.cs index 7c5bd3f58996..01cabcaa03c9 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/Modules.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/StatisticsClient.cs @@ -4,10 +4,7 @@ namespace Azure.Iot.Hub.Service { - /// - /// - /// - public class Modules + class StatisticsClient { } } From 8a2473bf8758d613d5804383b0bc0b697dbd686b Mon Sep 17 00:00:00 2001 From: bikamani <41314966+bikamani@users.noreply.github.com> Date: Tue, 26 May 2020 17:53:25 -0700 Subject: [PATCH 3/5] cl skeleton --- .../src/CloudToDeviceMessagesClient.cs | 19 ++++++++++++++++++ .../src/DevicesClient.cs | 9 ++++++--- .../Azure.Iot.Hub.Service/src/FilesClient.cs | 9 ++++++--- .../src/GlobalSuppressions.cs | 11 ++++++++++ .../src/IoTHubServiceClient.cs | 20 ++++++++++--------- .../Azure.Iot.Hub.Service/src/JobsClient.cs | 11 ++++++---- .../src/MessagesClient.cs | 20 ------------------- .../src/ModulesClient.cs | 9 ++++++--- .../src/StatisticsClient.cs | 17 ++++++++++++++-- 9 files changed, 81 insertions(+), 44 deletions(-) create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/CloudToDeviceMessagesClient.cs create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/GlobalSuppressions.cs delete mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/MessagesClient.cs diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/CloudToDeviceMessagesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/CloudToDeviceMessagesClient.cs new file mode 100644 index 000000000000..f5439c35ec38 --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/CloudToDeviceMessagesClient.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.Iot.Hub.Service +{ + /// + /// C2D Messages Client place holder + /// + public class CloudToDeviceMessagesClient + { + /// + /// place holder + /// + protected CloudToDeviceMessagesClient() + { + + } + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs index 89c74c2ecb2e..707a2132f127 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; using System.Collections.Generic; using System.Text; using Azure.Iot.Hub.Service.Models; @@ -6,12 +9,12 @@ namespace Azure.Iot.Hub.Service { /// - /// + /// Device Client place holder /// public class DevicesClient { /// - /// + /// place holder /// protected DevicesClient() { diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/FilesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/FilesClient.cs index 666e06c6af92..2aa44486e885 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/FilesClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/FilesClient.cs @@ -1,16 +1,19 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; using System.Collections.Generic; using System.Text; namespace Azure.Iot.Hub.Service { /// - /// + /// Files Client place holder /// public class FilesClient { /// - /// + /// place holder /// protected FilesClient() { diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/GlobalSuppressions.cs b/sdk/iot/Azure.Iot.Hub.Service/src/GlobalSuppressions.cs new file mode 100644 index 000000000000..914f88294582 --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/GlobalSuppressions.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "", Scope = "member", Target = "~F:Azure.Iot.Hub.Service.IoTHubServiceClient.Devices")] +[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "", Scope = "member", Target = "~F:Azure.Iot.Hub.Service.IoTHubServiceClient.Modules")] +[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "", Scope = "member", Target = "~F:Azure.Iot.Hub.Service.IoTHubServiceClient.Statistics")] +[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "", Scope = "member", Target = "~F:Azure.Iot.Hub.Service.IoTHubServiceClient.Messages")] +[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "", Scope = "member", Target = "~F:Azure.Iot.Hub.Service.IoTHubServiceClient.Files")] +[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "", Scope = "member", Target = "~F:Azure.Iot.Hub.Service.IoTHubServiceClient.Jobs")] diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs index 4e8f99699515..72cc91bda5c5 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; using System.Collections.Generic; using System.Text; @@ -10,31 +13,30 @@ namespace Azure.Iot.Hub.Service public class IoTHubServiceClient { /// - /// + /// place holder for Devices /// public DevicesClient Devices; /// - /// + /// place holder for Modules /// public ModulesClient Modules; /// - /// + /// place holder for Statistics /// public StatisticsClient Statistics; /// - /// + /// place holder for Messages /// - public MessagesClient Messages; + public CloudToDeviceMessagesClient Messages; /// - /// + /// place holder for Files /// public FilesClient Files; /// - /// + /// place holder for Jobs /// public JobsClient Jobs; - /// /// Initializes a new instance of the class. /// diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/JobsClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/JobsClient.cs index ebb580caa887..764b00884ec4 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/JobsClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/JobsClient.cs @@ -1,18 +1,21 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; using System.Collections.Generic; using System.Text; namespace Azure.Iot.Hub.Service { /// - /// + /// Jobs Client place holder /// public class JobsClient { /// - /// + /// place holder /// - public JobsClient() + protected JobsClient() { } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/MessagesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/MessagesClient.cs deleted file mode 100644 index 3ec0387f09ad..000000000000 --- a/sdk/iot/Azure.Iot.Hub.Service/src/MessagesClient.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Azure.Iot.Hub.Service -{ - /// - /// - /// - public class MessagesClient - { - /// - /// - /// - protected MessagesClient() - { - - } - } -} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/ModulesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/ModulesClient.cs index ac35b9afdf6f..15ea1313cf44 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/ModulesClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/ModulesClient.cs @@ -1,16 +1,19 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; using System.Collections.Generic; using System.Text; namespace Azure.Iot.Hub.Service { /// - /// + /// Modules Client place holder /// public class ModulesClient { /// - /// + /// place holder /// protected ModulesClient() { diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/StatisticsClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/StatisticsClient.cs index 01cabcaa03c9..bd6267e019c5 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/StatisticsClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/StatisticsClient.cs @@ -1,10 +1,23 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; using System.Collections.Generic; using System.Text; namespace Azure.Iot.Hub.Service { - class StatisticsClient + /// + /// Statistics Client place holder + /// + public class StatisticsClient { + /// + /// place holder + /// + protected StatisticsClient() + { + + } } } From 48275ba9b34c798797a2e93f06ebdc40787ed12c Mon Sep 17 00:00:00 2001 From: bikamani <41314966+bikamani@users.noreply.github.com> Date: Wed, 27 May 2020 11:04:32 -0700 Subject: [PATCH 4/5] add client options --- .../src/CloudToDeviceMessagesClient.cs | 4 +- .../src/DevicesClient.cs | 4 +- .../Azure.Iot.Hub.Service/src/FilesClient.cs | 4 +- .../src/IoTHubServiceClient.cs | 21 +++++-- .../src/IoTHubServiceClientOptions.cs | 55 +++++++++++++++++++ .../Azure.Iot.Hub.Service/src/JobsClient.cs | 4 +- .../src/ModulesClient.cs | 4 +- .../src/StatisticsClient.cs | 4 +- 8 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClientOptions.cs diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/CloudToDeviceMessagesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/CloudToDeviceMessagesClient.cs index f5439c35ec38..f3a32a1a2a63 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/CloudToDeviceMessagesClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/CloudToDeviceMessagesClient.cs @@ -11,7 +11,9 @@ public class CloudToDeviceMessagesClient /// /// place holder /// - protected CloudToDeviceMessagesClient() +#pragma warning disable AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. + public CloudToDeviceMessagesClient() +#pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. { } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs index 707a2132f127..faf5aa910881 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/DevicesClient.cs @@ -16,7 +16,9 @@ public class DevicesClient /// /// place holder /// - protected DevicesClient() +#pragma warning disable AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. + public DevicesClient() +#pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. { } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/FilesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/FilesClient.cs index 2aa44486e885..d3fc62131163 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/FilesClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/FilesClient.cs @@ -15,7 +15,9 @@ public class FilesClient /// /// place holder /// - protected FilesClient() +#pragma warning disable AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. + public FilesClient() +#pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. { } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs index 72cc91bda5c5..8cb90e15fdec 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; -using System.Collections.Generic; -using System.Text; +using Azure.Core; namespace Azure.Iot.Hub.Service { @@ -40,9 +38,24 @@ public class IoTHubServiceClient /// /// Initializes a new instance of the class. /// - protected IoTHubServiceClient() + public IoTHubServiceClient() + : this(new IoTHubServiceClientOptions()) { + } + + /// + /// Initializes a new instance of the class. + /// + public IoTHubServiceClient(IoTHubServiceClientOptions options) + { + Argument.AssertNotNull(options, nameof(options)); + Devices = new DevicesClient(); + Modules = new ModulesClient(); + Statistics = new StatisticsClient(); + Messages = new CloudToDeviceMessagesClient(); + Files = new FilesClient(); + Jobs = new JobsClient(); } } } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClientOptions.cs b/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClientOptions.cs new file mode 100644 index 000000000000..902429a8e3ea --- /dev/null +++ b/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClientOptions.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Azure.Core; + +namespace Azure.Iot.Hub.Service +{ + /// + /// Options that allow configuration of requests sent to the IoTHub service. + /// + public class IoTHubServiceClientOptions : ClientOptions + { + internal const ServiceVersion LatestVersion = ServiceVersion.V2020_03_13; + + /// + /// The versions of IoTHub Service supported by this client + /// library. + /// + public enum ServiceVersion + { + /// + /// 2020-03-13 + /// +#pragma warning disable CA1707 // Identifiers should not contain underscores + V2020_03_13 = 1 +#pragma warning restore CA1707 // Identifiers should not contain underscores + } + + /// + /// Gets the of the service API used when + /// making requests. + /// + public ServiceVersion Version { get; } + + /// + /// Initializes a new instance of the + /// class. + /// + public IoTHubServiceClientOptions(ServiceVersion version = LatestVersion) + { + Version = version; + } + + + internal string GetVersionString() + { + return Version switch + { + ServiceVersion.V2020_03_13 => "2020-03-13", + _ => throw new ArgumentException(Version.ToString()), + }; + } + } +} diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/JobsClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/JobsClient.cs index 764b00884ec4..67544ebb8312 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/JobsClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/JobsClient.cs @@ -15,7 +15,9 @@ public class JobsClient /// /// place holder /// - protected JobsClient() +#pragma warning disable AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. + public JobsClient() +#pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. { } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/ModulesClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/ModulesClient.cs index 15ea1313cf44..e811e4583814 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/ModulesClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/ModulesClient.cs @@ -15,7 +15,9 @@ public class ModulesClient /// /// place holder /// - protected ModulesClient() +#pragma warning disable AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. + public ModulesClient() +#pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. { } diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/StatisticsClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/StatisticsClient.cs index bd6267e019c5..944beaa4cbd3 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/StatisticsClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/StatisticsClient.cs @@ -15,7 +15,9 @@ public class StatisticsClient /// /// place holder /// - protected StatisticsClient() +#pragma warning disable AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. + public StatisticsClient() +#pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. { } From 2166dbc033467a0177dc245bc5ab82aca74b6712 Mon Sep 17 00:00:00 2001 From: bikamani <41314966+bikamani@users.noreply.github.com> Date: Wed, 27 May 2020 16:20:15 -0700 Subject: [PATCH 5/5] remove global suppression file --- .../Azure.Iot.Hub.Service/src/GlobalSuppressions.cs | 11 ----------- .../Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs | 12 ++++++------ 2 files changed, 6 insertions(+), 17 deletions(-) delete mode 100644 sdk/iot/Azure.Iot.Hub.Service/src/GlobalSuppressions.cs diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/GlobalSuppressions.cs b/sdk/iot/Azure.Iot.Hub.Service/src/GlobalSuppressions.cs deleted file mode 100644 index 914f88294582..000000000000 --- a/sdk/iot/Azure.Iot.Hub.Service/src/GlobalSuppressions.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Diagnostics.CodeAnalysis; - -[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "", Scope = "member", Target = "~F:Azure.Iot.Hub.Service.IoTHubServiceClient.Devices")] -[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "", Scope = "member", Target = "~F:Azure.Iot.Hub.Service.IoTHubServiceClient.Modules")] -[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "", Scope = "member", Target = "~F:Azure.Iot.Hub.Service.IoTHubServiceClient.Statistics")] -[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "", Scope = "member", Target = "~F:Azure.Iot.Hub.Service.IoTHubServiceClient.Messages")] -[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "", Scope = "member", Target = "~F:Azure.Iot.Hub.Service.IoTHubServiceClient.Files")] -[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "", Scope = "member", Target = "~F:Azure.Iot.Hub.Service.IoTHubServiceClient.Jobs")] diff --git a/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs b/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs index 8cb90e15fdec..ba442dd4ff27 100644 --- a/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs +++ b/sdk/iot/Azure.Iot.Hub.Service/src/IoTHubServiceClient.cs @@ -13,27 +13,27 @@ public class IoTHubServiceClient /// /// place holder for Devices /// - public DevicesClient Devices; + public DevicesClient Devices { get; private set; } /// /// place holder for Modules /// - public ModulesClient Modules; + public ModulesClient Modules { get; private set; } /// /// place holder for Statistics /// - public StatisticsClient Statistics; + public StatisticsClient Statistics { get; private set; } /// /// place holder for Messages /// - public CloudToDeviceMessagesClient Messages; + public CloudToDeviceMessagesClient Messages { get; private set; } /// /// place holder for Files /// - public FilesClient Files; + public FilesClient Files { get; private set; } /// /// place holder for Jobs /// - public JobsClient Jobs; + public JobsClient Jobs { get; private set; } /// /// Initializes a new instance of the class.