text: # 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.
  # --------------------------------------------------------------------------
  from typing import TYPE_CHECKING
  import warnings
  
  from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
  from azure.core.paging import ItemPaged
  from azure.core.pipeline import PipelineResponse
  from azure.core.pipeline.transport import HttpRequest, HttpResponse
  from azure.core.polling import LROPoller, NoPolling, PollingMethod
  from azure.mgmt.core.exceptions import ARMErrorFormat
  from azure.mgmt.core.polling.arm_polling import ARMPolling
  
  from .. import models as _models
  
  if TYPE_CHECKING:
      # pylint: disable=unused-import,ungrouped-imports
      from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union
  
      T = TypeVar('T')
      ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
  
  class IotHubResourceOperations(object):
      """IotHubResourceOperations operations.
  
      You should not instantiate this class directly. Instead, you should create a Client instance that
      instantiates it for you and attaches it as an attribute.
  
      :ivar models: Alias to model classes used in this operation group.
      :type models: ~azure.mgmt.iothub.models
      :param client: Client for service requests.
      :param config: Configuration of service client.
      :param serializer: An object model serializer.
      :param deserializer: An object model deserializer.
      """
  
      models = _models
  
      def __init__(self, client, config, serializer, deserializer):
          self._client = client
          self._serialize = serializer
          self._deserialize = deserializer
          self._config = config
  
      def get(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> "_models.IotHubDescription"
          """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
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: IotHubDescription, or the result of cls(response)
          :rtype: ~azure.mgmt.iothub.models.IotHubDescription
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.IotHubDescription"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          # Construct URL
          url = self.get.metadata['url']  # type: ignore
          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 = {}  # type: Dict[str, Any]
          query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
          request = self._client.get(url, query_parameters, header_parameters)
          pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(_models.ErrorDetails, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('IotHubDescription', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'}  # type: ignore
  
      def _create_or_update_initial(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          iot_hub_description,  # type: "_models.IotHubDescription"
          **kwargs  # type: Any
      ):
          # type: (...) -> "_models.IotHubDescription"
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.IotHubDescription"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          content_type = kwargs.pop("content_type", "application/json")
          accept = "application/json, text/json"
  
          # Construct URL
          url = self._create_or_update_initial.metadata['url']  # type: ignore
          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 = {}  # type: Dict[str, Any]
          query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
          header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
          body_content_kwargs = {}  # type: Dict[str, Any]
          body_content = self._serialize.body(iot_hub_description, 'IotHubDescription')
          body_content_kwargs['content'] = body_content
          request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
          pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200, 201]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(_models.ErrorDetails, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          if response.status_code == 200:
              deserialized = self._deserialize('IotHubDescription', pipeline_response)
  
          if response.status_code == 201:
              deserialized = self._deserialize('IotHubDescription', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'}  # type: ignore
  
      def begin_create_or_update(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          iot_hub_description,  # type: "_models.IotHubDescription"
          **kwargs  # type: Any
      ):
          # type: (...) -> LROPoller["_models.IotHubDescription"]
          """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 to create or update.
          :type resource_name: str
          :param iot_hub_description: The IoT hub metadata and security metadata.
          :type iot_hub_description: ~azure.mgmt.iothub.models.IotHubDescription
          :keyword callable cls: A custom type or function that will be passed the direct response
          :keyword str continuation_token: A continuation token to restart a poller from a saved state.
          :keyword polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :paramtype polling: bool or ~azure.core.polling.PollingMethod
          :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
          :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response)
          :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.models.IotHubDescription]
          :raises ~azure.core.exceptions.HttpResponseError:
          """
          polling = kwargs.pop('polling', True)  # type: Union[bool, PollingMethod]
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.IotHubDescription"]
          lro_delay = kwargs.pop(
              'polling_interval',
              self._config.polling_interval
          )
          cont_token = kwargs.pop('continuation_token', None)  # type: Optional[str]
          if cont_token is None:
              raw_result = self._create_or_update_initial(
                  resource_group_name=resource_group_name,
                  resource_name=resource_name,
                  iot_hub_description=iot_hub_description,
                  cls=lambda x,y,z: x,
                  **kwargs
              )
  
          kwargs.pop('error_map', None)
          kwargs.pop('content_type', None)
  
          def get_long_running_output(pipeline_response):
              deserialized = self._deserialize('IotHubDescription', pipeline_response)
  
              if cls:
                  return cls(pipeline_response, deserialized, {})
              return deserialized
  
          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'),
          }
  
          if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments,  **kwargs)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          if cont_token:
              return LROPoller.from_continuation_token(
                  polling_method=polling_method,
                  continuation_token=cont_token,
                  client=self._client,
                  deserialization_callback=get_long_running_output
              )
          else:
              return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'}  # type: ignore
  
      def _delete_initial(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> Optional["_models.IotHubDescription"]
          cls = kwargs.pop('cls', None)  # type: ClsType[Optional["_models.IotHubDescription"]]
          error_map = {
              401: ClientAuthenticationError,
              409: ResourceExistsError,
              404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.ErrorDetails, response), error_format=ARMErrorFormat),
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          # Construct URL
          url = self._delete_initial.metadata['url']  # type: ignore
          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 = {}  # type: Dict[str, Any]
          query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
          request = self._client.delete(url, query_parameters, header_parameters)
          pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200, 202, 204]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(_models.ErrorDetails, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          deserialized = None
          if response.status_code == 200:
              deserialized = self._deserialize('IotHubDescription', pipeline_response)
  
          if response.status_code == 202:
              deserialized = self._deserialize('IotHubDescription', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'}  # type: ignore
  
      def begin_delete(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> LROPoller["_models.IotHubDescription"]
          """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 to delete.
          :type resource_name: str
          :keyword callable cls: A custom type or function that will be passed the direct response
          :keyword str continuation_token: A continuation token to restart a poller from a saved state.
          :keyword polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :paramtype polling: bool or ~azure.core.polling.PollingMethod
          :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
          :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response)
          :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.models.IotHubDescription]
          :raises ~azure.core.exceptions.HttpResponseError:
          """
          polling = kwargs.pop('polling', True)  # type: Union[bool, PollingMethod]
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.IotHubDescription"]
          lro_delay = kwargs.pop(
              'polling_interval',
              self._config.polling_interval
          )
          cont_token = kwargs.pop('continuation_token', None)  # type: Optional[str]
          if cont_token is None:
              raw_result = self._delete_initial(
                  resource_group_name=resource_group_name,
                  resource_name=resource_name,
                  cls=lambda x,y,z: x,
                  **kwargs
              )
  
          kwargs.pop('error_map', None)
          kwargs.pop('content_type', None)
  
          def get_long_running_output(pipeline_response):
              deserialized = self._deserialize('IotHubDescription', pipeline_response)
  
              if cls:
                  return cls(pipeline_response, deserialized, {})
              return deserialized
  
          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'),
          }
  
          if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments,  **kwargs)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          if cont_token:
              return LROPoller.from_continuation_token(
                  polling_method=polling_method,
                  continuation_token=cont_token,
                  client=self._client,
                  deserialization_callback=get_long_running_output
              )
          else:
              return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'}  # type: ignore
  
      def list_by_subscription(
          self,
          **kwargs  # type: Any
      ):
          # type: (...) -> Iterable["_models.IotHubDescriptionListResult"]
          """Get all the IoT hubs in a subscription.
  
          Get all the IoT hubs in a subscription.
  
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response)
          :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.models.IotHubDescriptionListResult]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.IotHubDescriptionListResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          def prepare_request(next_link=None):
              # Construct headers
              header_parameters = {}  # type: Dict[str, Any]
              header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
              if not next_link:
                  # Construct URL
                  url = self.list_by_subscription.metadata['url']  # type: ignore
                  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 = {}  # type: Dict[str, Any]
                  query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
                  request = self._client.get(url, query_parameters, header_parameters)
              else:
                  url = next_link
                  query_parameters = {}  # type: Dict[str, Any]
                  request = self._client.get(url, query_parameters, header_parameters)
              return request
  
          def extract_data(pipeline_response):
              deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response)
              list_of_elem = deserialized.value
              if cls:
                  list_of_elem = cls(list_of_elem)
              return deserialized.next_link or None, iter(list_of_elem)
  
          def get_next(next_link=None):
              request = prepare_request(next_link)
  
              pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
              response = pipeline_response.http_response
  
              if response.status_code not in [200]:
                  error = self._deserialize(_models.ErrorDetails, response)
                  map_error(status_code=response.status_code, response=response, error_map=error_map)
                  raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
              return pipeline_response
  
          return ItemPaged(
              get_next, extract_data
          )
      list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'}  # type: ignore
  
      def list_by_resource_group(
          self,
          resource_group_name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> Iterable["_models.IotHubDescriptionListResult"]
          """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 hubs.
          :type resource_group_name: str
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response)
          :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.models.IotHubDescriptionListResult]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.IotHubDescriptionListResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          def prepare_request(next_link=None):
              # Construct headers
              header_parameters = {}  # type: Dict[str, Any]
              header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
              if not next_link:
                  # Construct URL
                  url = self.list_by_resource_group.metadata['url']  # type: ignore
                  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 = {}  # type: Dict[str, Any]
                  query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
                  request = self._client.get(url, query_parameters, header_parameters)
              else:
                  url = next_link
                  query_parameters = {}  # type: Dict[str, Any]
                  request = self._client.get(url, query_parameters, header_parameters)
              return request
  
          def extract_data(pipeline_response):
              deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response)
              list_of_elem = deserialized.value
              if cls:
                  list_of_elem = cls(list_of_elem)
              return deserialized.next_link or None, iter(list_of_elem)
  
          def get_next(next_link=None):
              request = prepare_request(next_link)
  
              pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
              response = pipeline_response.http_response
  
              if response.status_code not in [200]:
                  error = self._deserialize(_models.ErrorDetails, response)
                  map_error(status_code=response.status_code, response=response, error_map=error_map)
                  raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
              return pipeline_response
  
          return ItemPaged(
              get_next, extract_data
          )
      list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'}  # type: ignore
  
      def get_stats(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> "_models.RegistryStatistics"
          """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
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: RegistryStatistics, or the result of cls(response)
          :rtype: ~azure.mgmt.iothub.models.RegistryStatistics
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.RegistryStatistics"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          # Construct URL
          url = self.get_stats.metadata['url']  # type: ignore
          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 = {}  # type: Dict[str, Any]
          query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
          request = self._client.get(url, query_parameters, header_parameters)
          pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(_models.ErrorDetails, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('RegistryStatistics', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'}  # type: ignore
  
      def get_valid_skus(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"]
          """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
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response)
          :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.models.IotHubSkuDescriptionListResult]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.IotHubSkuDescriptionListResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          def prepare_request(next_link=None):
              # Construct headers
              header_parameters = {}  # type: Dict[str, Any]
              header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
              if not next_link:
                  # Construct URL
                  url = self.get_valid_skus.metadata['url']  # type: ignore
                  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 = {}  # type: Dict[str, Any]
                  query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
                  request = self._client.get(url, query_parameters, header_parameters)
              else:
                  url = next_link
                  query_parameters = {}  # type: Dict[str, Any]
                  request = self._client.get(url, query_parameters, header_parameters)
              return request
  
          def extract_data(pipeline_response):
              deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response)
              list_of_elem = deserialized.value
              if cls:
                  list_of_elem = cls(list_of_elem)
              return deserialized.next_link or None, iter(list_of_elem)
  
          def get_next(next_link=None):
              request = prepare_request(next_link)
  
              pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
              response = pipeline_response.http_response
  
              if response.status_code not in [200]:
                  error = self._deserialize(_models.ErrorDetails, response)
                  map_error(status_code=response.status_code, response=response, error_map=error_map)
                  raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
              return pipeline_response
  
          return ItemPaged(
              get_next, extract_data
          )
      get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'}  # type: ignore
  
      def list_event_hub_consumer_groups(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          event_hub_endpoint_name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"]
          """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
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response)
          :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.models.EventHubConsumerGroupsListResult]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.EventHubConsumerGroupsListResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          def prepare_request(next_link=None):
              # Construct headers
              header_parameters = {}  # type: Dict[str, Any]
              header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
              if not next_link:
                  # Construct URL
                  url = self.list_event_hub_consumer_groups.metadata['url']  # type: ignore
                  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 = {}  # type: Dict[str, Any]
                  query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
                  request = self._client.get(url, query_parameters, header_parameters)
              else:
                  url = next_link
                  query_parameters = {}  # type: Dict[str, Any]
                  request = self._client.get(url, query_parameters, header_parameters)
              return request
  
          def extract_data(pipeline_response):
              deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response)
              list_of_elem = deserialized.value
              if cls:
                  list_of_elem = cls(list_of_elem)
              return deserialized.next_link or None, iter(list_of_elem)
  
          def get_next(next_link=None):
              request = prepare_request(next_link)
  
              pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
              response = pipeline_response.http_response
  
              if response.status_code not in [200]:
                  error = self._deserialize(_models.ErrorDetails, response)
                  map_error(status_code=response.status_code, response=response, error_map=error_map)
                  raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
              return pipeline_response
  
          return ItemPaged(
              get_next, extract_data
          )
      list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'}  # type: ignore
  
      def get_event_hub_consumer_group(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          event_hub_endpoint_name,  # type: str
          name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> "_models.EventHubConsumerGroupInfo"
          """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
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: EventHubConsumerGroupInfo, or the result of cls(response)
          :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfo
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.EventHubConsumerGroupInfo"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          # Construct URL
          url = self.get_event_hub_consumer_group.metadata['url']  # type: ignore
          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 = {}  # type: Dict[str, Any]
          query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
          request = self._client.get(url, query_parameters, header_parameters)
          pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(_models.ErrorDetails, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'}  # type: ignore
  
      def create_event_hub_consumer_group(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          event_hub_endpoint_name,  # type: str
          name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> "_models.EventHubConsumerGroupInfo"
          """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
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: EventHubConsumerGroupInfo, or the result of cls(response)
          :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfo
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.EventHubConsumerGroupInfo"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          # Construct URL
          url = self.create_event_hub_consumer_group.metadata['url']  # type: ignore
          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 = {}  # type: Dict[str, Any]
          query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
          request = self._client.put(url, query_parameters, header_parameters)
          pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(_models.ErrorDetails, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'}  # type: ignore
  
      def delete_event_hub_consumer_group(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          event_hub_endpoint_name,  # type: str
          name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> None
          """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
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: None, or the result of cls(response)
          :rtype: None
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType[None]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          # Construct URL
          url = self.delete_event_hub_consumer_group.metadata['url']  # type: ignore
          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 = {}  # type: Dict[str, Any]
          query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
          request = self._client.delete(url, query_parameters, header_parameters)
          pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(_models.ErrorDetails, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          if cls:
              return cls(pipeline_response, None, {})
  
      delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'}  # type: ignore
  
      def list_jobs(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> Iterable["_models.JobResponseListResult"]
          """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
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: An iterator like instance of either JobResponseListResult or the result of cls(response)
          :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.models.JobResponseListResult]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.JobResponseListResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          def prepare_request(next_link=None):
              # Construct headers
              header_parameters = {}  # type: Dict[str, Any]
              header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
              if not next_link:
                  # Construct URL
                  url = self.list_jobs.metadata['url']  # type: ignore
                  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 = {}  # type: Dict[str, Any]
                  query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
                  request = self._client.get(url, query_parameters, header_parameters)
              else:
                  url = next_link
                  query_parameters = {}  # type: Dict[str, Any]
                  request = self._client.get(url, query_parameters, header_parameters)
              return request
  
          def extract_data(pipeline_response):
              deserialized = self._deserialize('JobResponseListResult', pipeline_response)
              list_of_elem = deserialized.value
              if cls:
                  list_of_elem = cls(list_of_elem)
              return deserialized.next_link or None, iter(list_of_elem)
  
          def get_next(next_link=None):
              request = prepare_request(next_link)
  
              pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
              response = pipeline_response.http_response
  
              if response.status_code not in [200]:
                  error = self._deserialize(_models.ErrorDetails, response)
                  map_error(status_code=response.status_code, response=response, error_map=error_map)
                  raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
              return pipeline_response
  
          return ItemPaged(
              get_next, extract_data
          )
      list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'}  # type: ignore
  
      def get_job(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          job_id,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> "_models.JobResponse"
          """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
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: JobResponse, or the result of cls(response)
          :rtype: ~azure.mgmt.iothub.models.JobResponse
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.JobResponse"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          # Construct URL
          url = self.get_job.metadata['url']  # type: ignore
          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 = {}  # type: Dict[str, Any]
          query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
          request = self._client.get(url, query_parameters, header_parameters)
          pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(_models.ErrorDetails, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('JobResponse', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'}  # type: ignore
  
      def get_quota_metrics(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]
          """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
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response)
          :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.models.IotHubQuotaMetricInfoListResult]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.IotHubQuotaMetricInfoListResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          def prepare_request(next_link=None):
              # Construct headers
              header_parameters = {}  # type: Dict[str, Any]
              header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
              if not next_link:
                  # Construct URL
                  url = self.get_quota_metrics.metadata['url']  # type: ignore
                  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 = {}  # type: Dict[str, Any]
                  query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
                  request = self._client.get(url, query_parameters, header_parameters)
              else:
                  url = next_link
                  query_parameters = {}  # type: Dict[str, Any]
                  request = self._client.get(url, query_parameters, header_parameters)
              return request
  
          def extract_data(pipeline_response):
              deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response)
              list_of_elem = deserialized.value
              if cls:
                  list_of_elem = cls(list_of_elem)
              return deserialized.next_link or None, iter(list_of_elem)
  
          def get_next(next_link=None):
              request = prepare_request(next_link)
  
              pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
              response = pipeline_response.http_response
  
              if response.status_code not in [200]:
                  error = self._deserialize(_models.ErrorDetails, response)
                  map_error(status_code=response.status_code, response=response, error_map=error_map)
                  raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
              return pipeline_response
  
          return ItemPaged(
              get_next, extract_data
          )
      get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'}  # type: ignore
  
      def check_name_availability(
          self,
          operation_inputs,  # type: "_models.OperationInputs"
          **kwargs  # type: Any
      ):
          # type: (...) -> "_models.IotHubNameAvailabilityInfo"
          """Check if an IoT hub name is available.
  
          Check if an IoT hub name is available.
  
          :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of
           the IoT hub to check.
          :type operation_inputs: ~azure.mgmt.iothub.models.OperationInputs
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: IotHubNameAvailabilityInfo, or the result of cls(response)
          :rtype: ~azure.mgmt.iothub.models.IotHubNameAvailabilityInfo
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.IotHubNameAvailabilityInfo"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          content_type = kwargs.pop("content_type", "application/json")
          accept = "application/json, text/json"
  
          # Construct URL
          url = self.check_name_availability.metadata['url']  # type: ignore
          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 = {}  # type: Dict[str, Any]
          query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
          header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
          body_content_kwargs = {}  # type: Dict[str, Any]
          body_content = self._serialize.body(operation_inputs, 'OperationInputs')
          body_content_kwargs['content'] = body_content
          request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs)
          pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(_models.ErrorDetails, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'}  # type: ignore
  
      def list_keys(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]
          """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
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response)
          :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.models.SharedAccessSignatureAuthorizationRuleListResult]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          def prepare_request(next_link=None):
              # Construct headers
              header_parameters = {}  # type: Dict[str, Any]
              header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
              if not next_link:
                  # Construct URL
                  url = self.list_keys.metadata['url']  # type: ignore
                  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 = {}  # type: Dict[str, Any]
                  query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
                  request = self._client.post(url, query_parameters, header_parameters)
              else:
                  url = next_link
                  query_parameters = {}  # type: Dict[str, Any]
                  request = self._client.get(url, query_parameters, header_parameters)
              return request
  
          def extract_data(pipeline_response):
              deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response)
              list_of_elem = deserialized.value
              if cls:
                  list_of_elem = cls(list_of_elem)
              return deserialized.next_link or None, iter(list_of_elem)
  
          def get_next(next_link=None):
              request = prepare_request(next_link)
  
              pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
              response = pipeline_response.http_response
  
              if response.status_code not in [200]:
                  error = self._deserialize(_models.ErrorDetails, response)
                  map_error(status_code=response.status_code, response=response, error_map=error_map)
                  raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
              return pipeline_response
  
          return ItemPaged(
              get_next, extract_data
          )
      list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'}  # type: ignore
  
      def get_keys_for_key_name(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          key_name,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> "_models.SharedAccessSignatureAuthorizationRule"
          """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
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: SharedAccessSignatureAuthorizationRule, or the result of cls(response)
          :rtype: ~azure.mgmt.iothub.models.SharedAccessSignatureAuthorizationRule
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.SharedAccessSignatureAuthorizationRule"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          accept = "application/json, text/json"
  
          # Construct URL
          url = self.get_keys_for_key_name.metadata['url']  # type: ignore
          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 = {}  # type: Dict[str, Any]
          query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
          request = self._client.post(url, query_parameters, header_parameters)
          pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(_models.ErrorDetails, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'}  # type: ignore
  
      def export_devices(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          export_devices_parameters,  # type: "_models.ExportDevicesRequest"
          **kwargs  # type: Any
      ):
          # type: (...) -> "_models.JobResponse"
          """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_devices_parameters: The parameters that specify the export devices operation.
          :type export_devices_parameters: ~azure.mgmt.iothub.models.ExportDevicesRequest
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: JobResponse, or the result of cls(response)
          :rtype: ~azure.mgmt.iothub.models.JobResponse
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.JobResponse"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          content_type = kwargs.pop("content_type", "application/json")
          accept = "application/json, text/json"
  
          # Construct URL
          url = self.export_devices.metadata['url']  # type: ignore
          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 = {}  # type: Dict[str, Any]
          query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
          header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
          body_content_kwargs = {}  # type: Dict[str, Any]
          body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest')
          body_content_kwargs['content'] = body_content
          request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs)
          pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(_models.ErrorDetails, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('JobResponse', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'}  # type: ignore
  
      def import_devices(
          self,
          resource_group_name,  # type: str
          resource_name,  # type: str
          import_devices_parameters,  # type: "_models.ImportDevicesRequest"
          **kwargs  # type: Any
      ):
          # type: (...) -> "_models.JobResponse"
          """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 import_devices_parameters: The parameters that specify the import devices operation.
          :type import_devices_parameters: ~azure.mgmt.iothub.models.ImportDevicesRequest
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: JobResponse, or the result of cls(response)
          :rtype: ~azure.mgmt.iothub.models.JobResponse
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.JobResponse"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2016-02-03"
          content_type = kwargs.pop("content_type", "application/json")
          accept = "application/json, text/json"
  
          # Construct URL
          url = self.import_devices.metadata['url']  # type: ignore
          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 = {}  # type: Dict[str, Any]
          query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
          header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
  
          body_content_kwargs = {}  # type: Dict[str, Any]
          body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest')
          body_content_kwargs['content'] = body_content
          request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs)
          pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
          response = pipeline_response.http_response
  
          if response.status_code not in [200]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(_models.ErrorDetails, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('JobResponse', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'}  # type: ignore
  