Source code for azure.mgmt.iothub.operations.iot_hub_resource_operations

# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

import uuid
from msrest.pipeline import ClientRawResponse
from msrestazure.azure_exceptions import CloudError
from msrest.polling import LROPoller, NoPolling
from msrestazure.polling.arm_polling import ARMPolling

from .. import models


[docs]class IotHubResourceOperations(object): """IotHubResourceOperations operations. :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. :ivar api_version: The version of the API. Constant value: "2018-04-01". """ models = models def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer self.api_version = "2018-04-01" self.config = config
[docs] def get( self, resource_group_name, resource_name, custom_headers=None, raw=False, **operation_config): """Get the non-security related metadata of an IoT hub. Get the non-security related metadata of an IoT hub. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: IotHubDescription or ClientRawResponse if raw=true :rtype: ~azure.mgmt.iothub.models.IotHubDescription or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ # Construct URL url = self.get.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} def _create_or_update_initial( self, resource_group_name, resource_name, iot_hub_description, if_match=None, custom_headers=None, raw=False, **operation_config): # Construct URL url = self.create_or_update.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200, 201]: raise models.ErrorDetailsException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', response) if response.status_code == 201: deserialized = self._deserialize('IotHubDescription', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[docs] def create_or_update( self, resource_group_name, resource_name, iot_hub_description, if_match=None, custom_headers=None, raw=False, polling=True, **operation_config): """Create or update the metadata of an IoT hub. Create or update the metadata of an Iot hub. The usual pattern to modify a property is to retrieve the IoT hub metadata and security metadata, and then combine them with the modified values in a new body to update the IoT hub. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param iot_hub_description: The IoT hub metadata and security metadata. :type iot_hub_description: ~azure.mgmt.iothub.models.IotHubDescription :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required to update an existing IoT Hub. :type if_match: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns IotHubDescription or ClientRawResponse<IotHubDescription> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.iothub.models.IotHubDescription] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.iothub.models.IotHubDescription]] :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('IotHubDescription', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} def _update_initial( self, resource_group_name, resource_name, tags=None, custom_headers=None, raw=False, **operation_config): iot_hub_tags = models.TagsResource(tags=tags) # Construct URL url = self.update.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(iot_hub_tags, 'TagsResource') # Construct and send request request = self._client.patch(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp deserialized = None if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[docs] def update( self, resource_group_name, resource_name, tags=None, custom_headers=None, raw=False, polling=True, **operation_config): """Update an existing IoT Hubs tags. Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. :param resource_group_name: Resource group identifier. :type resource_group_name: str :param resource_name: Name of iot hub to update. :type resource_name: str :param tags: Resource tags :type tags: dict[str, str] :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns IotHubDescription or ClientRawResponse<IotHubDescription> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.iothub.models.IotHubDescription] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.iothub.models.IotHubDescription]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._update_initial( resource_group_name=resource_group_name, resource_name=resource_name, tags=tags, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('IotHubDescription', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} def _delete_initial( self, resource_group_name, resource_name, custom_headers=None, raw=False, **operation_config): # Construct URL url = self.delete.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200, 202, 204, 404]: raise models.ErrorDetailsException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', response) if response.status_code == 202: deserialized = self._deserialize('IotHubDescription', response) if response.status_code == 404: deserialized = self._deserialize('ErrorDetails', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[docs] def delete( self, resource_group_name, resource_name, custom_headers=None, raw=False, polling=True, **operation_config): """Delete an IoT hub. Delete an IoT hub. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns object or ClientRawResponse<object> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[object] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[object]] :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ raw_result = self._delete_initial( resource_group_name=resource_group_name, resource_name=resource_name, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('object', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'}
[docs] def list_by_subscription( self, custom_headers=None, raw=False, **operation_config): """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of IotHubDescription :rtype: ~azure.mgmt.iothub.models.IotHubDescriptionPaged[~azure.mgmt.iothub.models.IotHubDescription] :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.list_by_subscription.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) return response # Deserialize response deserialized = models.IotHubDescriptionPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.IotHubDescriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'}
[docs] def list_by_resource_group( self, resource_group_name, custom_headers=None, raw=False, **operation_config): """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of IotHubDescription :rtype: ~azure.mgmt.iothub.models.IotHubDescriptionPaged[~azure.mgmt.iothub.models.IotHubDescription] :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.list_by_resource_group.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) return response # Deserialize response deserialized = models.IotHubDescriptionPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.IotHubDescriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'}
[docs] def get_stats( self, resource_group_name, resource_name, custom_headers=None, raw=False, **operation_config): """Get the statistics from an IoT hub. Get the statistics from an IoT hub. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: RegistryStatistics or ClientRawResponse if raw=true :rtype: ~azure.mgmt.iothub.models.RegistryStatistics or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ # Construct URL url = self.get_stats.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('RegistryStatistics', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'}
[docs] def get_valid_skus( self, resource_group_name, resource_name, custom_headers=None, raw=False, **operation_config): """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of IotHubSkuDescription :rtype: ~azure.mgmt.iothub.models.IotHubSkuDescriptionPaged[~azure.mgmt.iothub.models.IotHubSkuDescription] :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.get_valid_skus.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) return response # Deserialize response deserialized = models.IotHubSkuDescriptionPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.IotHubSkuDescriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'}
[docs] def list_event_hub_consumer_groups( self, resource_group_name, resource_name, event_hub_endpoint_name, custom_headers=None, raw=False, **operation_config): """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of EventHubConsumerGroupInfo :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfoPaged[~azure.mgmt.iothub.models.EventHubConsumerGroupInfo] :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.list_event_hub_consumer_groups.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) return response # Deserialize response deserialized = models.EventHubConsumerGroupInfoPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.EventHubConsumerGroupInfoPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'}
[docs] def get_event_hub_consumer_group( self, resource_group_name, resource_name, event_hub_endpoint_name, name, custom_headers=None, raw=False, **operation_config): """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. :type event_hub_endpoint_name: str :param name: The name of the consumer group to retrieve. :type name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: EventHubConsumerGroupInfo or ClientRawResponse if raw=true :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfo or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ # Construct URL url = self.get_event_hub_consumer_group.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), 'name': self._serialize.url("name", name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('EventHubConsumerGroupInfo', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'}
[docs] def create_event_hub_consumer_group( self, resource_group_name, resource_name, event_hub_endpoint_name, name, custom_headers=None, raw=False, **operation_config): """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. :type event_hub_endpoint_name: str :param name: The name of the consumer group to add. :type name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: EventHubConsumerGroupInfo or ClientRawResponse if raw=true :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfo or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ # Construct URL url = self.create_event_hub_consumer_group.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), 'name': self._serialize.url("name", name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('EventHubConsumerGroupInfo', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'}
[docs] def delete_event_hub_consumer_group( self, resource_group_name, resource_name, event_hub_endpoint_name, name, custom_headers=None, raw=False, **operation_config): """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. :type event_hub_endpoint_name: str :param name: The name of the consumer group to delete. :type name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ # Construct URL url = self.delete_event_hub_consumer_group.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), 'name': self._serialize.url("name", name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'}
[docs] def list_jobs( self, resource_group_name, resource_name, custom_headers=None, raw=False, **operation_config): """Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of JobResponse :rtype: ~azure.mgmt.iothub.models.JobResponsePaged[~azure.mgmt.iothub.models.JobResponse] :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.list_jobs.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) return response # Deserialize response deserialized = models.JobResponsePaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.JobResponsePaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'}
[docs] def get_job( self, resource_group_name, resource_name, job_id, custom_headers=None, raw=False, **operation_config): """Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param job_id: The job identifier. :type job_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: JobResponse or ClientRawResponse if raw=true :rtype: ~azure.mgmt.iothub.models.JobResponse or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ # Construct URL url = self.get_job.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), 'jobId': self._serialize.url("job_id", job_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('JobResponse', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'}
[docs] def get_quota_metrics( self, resource_group_name, resource_name, custom_headers=None, raw=False, **operation_config): """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of IotHubQuotaMetricInfo :rtype: ~azure.mgmt.iothub.models.IotHubQuotaMetricInfoPaged[~azure.mgmt.iothub.models.IotHubQuotaMetricInfo] :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.get_quota_metrics.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) return response # Deserialize response deserialized = models.IotHubQuotaMetricInfoPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.IotHubQuotaMetricInfoPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'}
[docs] def check_name_availability( self, name, custom_headers=None, raw=False, **operation_config): """Check if an IoT hub name is available. Check if an IoT hub name is available. :param name: The name of the IoT hub to check. :type name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: IotHubNameAvailabilityInfo or ClientRawResponse if raw=true :rtype: ~azure.mgmt.iothub.models.IotHubNameAvailabilityInfo or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ operation_inputs = models.OperationInputs(name=name) # Construct URL url = self.check_name_availability.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(operation_inputs, 'OperationInputs') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('IotHubNameAvailabilityInfo', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'}
[docs] def list_keys( self, resource_group_name, resource_name, custom_headers=None, raw=False, **operation_config): """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of SharedAccessSignatureAuthorizationRule :rtype: ~azure.mgmt.iothub.models.SharedAccessSignatureAuthorizationRulePaged[~azure.mgmt.iothub.models.SharedAccessSignatureAuthorizationRule] :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.list_keys.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) return response # Deserialize response deserialized = models.SharedAccessSignatureAuthorizationRulePaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.SharedAccessSignatureAuthorizationRulePaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'}
[docs] def get_keys_for_key_name( self, resource_group_name, resource_name, key_name, custom_headers=None, raw=False, **operation_config): """Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param key_name: The name of the shared access policy. :type key_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: SharedAccessSignatureAuthorizationRule or ClientRawResponse if raw=true :rtype: ~azure.mgmt.iothub.models.SharedAccessSignatureAuthorizationRule or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ # Construct URL url = self.get_keys_for_key_name.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), 'keyName': self._serialize.url("key_name", key_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'}
[docs] def export_devices( self, resource_group_name, resource_name, export_blob_container_uri, exclude_keys, custom_headers=None, raw=False, **operation_config): """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param export_blob_container_uri: The export blob container URI. :type export_blob_container_uri: str :param exclude_keys: The value indicating whether keys should be excluded during export. :type exclude_keys: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: JobResponse or ClientRawResponse if raw=true :rtype: ~azure.mgmt.iothub.models.JobResponse or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ export_devices_parameters = models.ExportDevicesRequest(export_blob_container_uri=export_blob_container_uri, exclude_keys=exclude_keys) # Construct URL url = self.export_devices.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('JobResponse', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'}
[docs] def import_devices( self, resource_group_name, resource_name, input_blob_container_uri, output_blob_container_uri, custom_headers=None, raw=False, **operation_config): """Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :param resource_name: The name of the IoT hub. :type resource_name: str :param input_blob_container_uri: The input blob container URI. :type input_blob_container_uri: str :param output_blob_container_uri: The output blob container URI. :type output_blob_container_uri: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: JobResponse or ClientRawResponse if raw=true :rtype: ~azure.mgmt.iothub.models.JobResponse or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorDetailsException<azure.mgmt.iothub.models.ErrorDetailsException>` """ import_devices_parameters = models.ImportDevicesRequest(input_blob_container_uri=input_blob_container_uri, output_blob_container_uri=output_blob_container_uri) # Construct URL url = self.import_devices.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'resourceName': self._serialize.url("resource_name", resource_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorDetailsException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('JobResponse', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'}