Exemplo n.º 1
0
        private IotHubServiceClient(IotHubSasCredential credential, IotHubServiceClientOptions options)
        {
            options ??= new IotHubServiceClientOptions();
            _clientDiagnostics = new ClientDiagnostics(options);

            options.AddPolicy(new BearerTokenAuthenticationPolicy(credential, s_authorizationScopes), HttpPipelinePosition.PerCall);
            _httpPipeline = HttpPipelineBuilder.Build(options);

            _devicesRestClient       = new DevicesRestClient(_clientDiagnostics, _httpPipeline, credential.Endpoint, options.GetVersionString());
            _modulesRestClient       = new ModulesRestClient(_clientDiagnostics, _httpPipeline, credential.Endpoint, options.GetVersionString());
            _queryRestClient         = new QueryRestClient(_clientDiagnostics, _httpPipeline, credential.Endpoint, options.GetVersionString());
            _statisticsRestClient    = new StatisticsRestClient(_clientDiagnostics, _httpPipeline, credential.Endpoint, options.GetVersionString());
            _configurationRestClient = new ConfigurationRestClient(_clientDiagnostics, _httpPipeline, credential.Endpoint, options.GetVersionString());

            // Note that the devices and modules subclient take a reference to the Query convenience layer client. This
            // is because they each expose a helper function that uses the query client for listing twins. By passing in
            // the convenience layer query client rather than the protocol layer query client, we minimize rewriting the
            // same pagination logic that now exists only in the query convenience layer client.
            Query          = new QueryClient(_queryRestClient);
            Devices        = new DevicesClient(_devicesRestClient, Query);
            Modules        = new ModulesClient(_devicesRestClient, _modulesRestClient, Query);
            Statistics     = new StatisticsClient(_statisticsRestClient);
            Configurations = new ConfigurationsClient(_configurationRestClient);

            Messages = new CloudToDeviceMessagesClient();
            Files    = new FilesClient();
            Jobs     = new JobsClient();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 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>
        /// </summary>
        internal DevicesClient(DevicesRestClient devicesRestClient, QueryClient queryClient)
        {
            Argument.AssertNotNull(devicesRestClient, nameof(devicesRestClient));
            Argument.AssertNotNull(queryClient, nameof(queryClient));

            _devicesRestClient = devicesRestClient;
            _queryClient       = queryClient;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of DevicesClient.
        /// <param name="devicesRestClient"> The REST client to perform bulk operations on the module. </param>
        /// <param name="modulesRestClient"> The REST client to perform module and module twin 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 modules. </param>
        /// </summary>
        internal ModulesClient(DevicesRestClient devicesRestClient, ModulesRestClient modulesRestClient, QueryClient queryClient, BulkRegistryRestClient bulkRegistryClient)
        {
            Argument.AssertNotNull(devicesRestClient, nameof(devicesRestClient));
            Argument.AssertNotNull(modulesRestClient, nameof(modulesRestClient));
            Argument.AssertNotNull(queryClient, nameof(queryClient));
            Argument.AssertNotNull(bulkRegistryClient, nameof(bulkRegistryClient));

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