text: # coding=utf-8
  # --------------------------------------------------------------------------
  # Code generated by Microsoft (R) AutoRest Code Generator.
  # Changes may cause incorrect behavior and will be lost if the code is
  # regenerated.
  # --------------------------------------------------------------------------
  
  from msrest.service_client import SDKClient
  from msrest import Configuration, Serializer, Deserializer
  from .version import VERSION
  from msrest.pipeline import ClientRawResponse
  from . import models
  
  
  class ProvisioningServiceClientConfiguration(Configuration):
      """Configuration for ProvisioningServiceClient
      Note that all parameters used to create this instance are saved as instance
      attributes.
  
      :param credentials: Subscription credentials which uniquely identify
       client subscription.
      :type credentials: None
      :param str base_url: Service URL
      """
  
      def __init__(self, credentials, base_url=None):
  
          if credentials is None:
              raise ValueError("Parameter 'credentials' must not be None.")
          if not base_url:
              base_url = "https://localhost"
  
          super(ProvisioningServiceClientConfiguration, self).__init__(base_url)
  
          self.add_user_agent("provisioningserviceclient/{}".format(VERSION))
  
          self.credentials = credentials
  
  
  class ProvisioningServiceClient(SDKClient):
      """API for service operations with the Azure IoT Hub Device Provisioning Service
  
      :ivar config: Configuration for client.
      :vartype config: ProvisioningServiceClientConfiguration
  
      :param credentials: Subscription credentials which uniquely identify
       client subscription.
      :type credentials: None
      :param str base_url: Service URL
      """
  
      def __init__(self, credentials, base_url=None):
  
          self.config = ProvisioningServiceClientConfiguration(credentials, base_url)
          super(ProvisioningServiceClient, self).__init__(self.config.credentials, self.config)
  
          client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
          self.api_version = "2018-09-01-preview"
          self._serialize = Serializer(client_models)
          self._deserialize = Deserializer(client_models)
  
      def get_individual_enrollment(self, id, custom_headers=None, raw=False, **operation_config):
          """Get a device enrollment record.
  
          :param id: Registration ID.
          :type 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: IndividualEnrollment or ClientRawResponse if raw=true
          :rtype: ~protocol.models.IndividualEnrollment or
           ~msrest.pipeline.ClientRawResponse
          :raises:
           :class:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.get_individual_enrollment.metadata["url"]
          path_format_arguments = {"id": self._serialize.url("id", 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["Accept"] = "application/json"
          if custom_headers:
              header_parameters.update(custom_headers)
  
          # Construct and send request
          request = self._client.get(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          deserialized = None
  
          if response.status_code == 200:
              deserialized = self._deserialize("IndividualEnrollment", response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
  
      get_individual_enrollment.metadata = {"url": "/enrollments/{id}"}
  
      def create_or_update_individual_enrollment(
          self, id, enrollment, if_match=None, custom_headers=None, raw=False, **operation_config
      ):
          """Create or update a device enrollment record.
  
          :param id: The registration ID is alphanumeric, lowercase, and may
           contain hyphens.
          :type id: str
          :param enrollment: The device enrollment record.
          :type enrollment: ~protocol.models.IndividualEnrollment
          :param if_match: The ETag of the enrollment record.
          :type if_match: 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: IndividualEnrollment or ClientRawResponse if raw=true
          :rtype: ~protocol.models.IndividualEnrollment or
           ~msrest.pipeline.ClientRawResponse
          :raises:
           :class:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.create_or_update_individual_enrollment.metadata["url"]
          path_format_arguments = {"id": self._serialize.url("id", 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["Accept"] = "application/json"
          header_parameters["Content-Type"] = "application/json; charset=utf-8"
          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")
  
          # Construct body
          body_content = self._serialize.body(enrollment, "IndividualEnrollment")
  
          # Construct and send request
          request = self._client.put(url, query_parameters, header_parameters, body_content)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          deserialized = None
  
          if response.status_code == 200:
              deserialized = self._deserialize("IndividualEnrollment", response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
  
      create_or_update_individual_enrollment.metadata = {"url": "/enrollments/{id}"}
  
      def delete_individual_enrollment(
          self, id, if_match=None, custom_headers=None, raw=False, **operation_config
      ):
          """Delete a device enrollment record.
  
          :param id: Registration ID.
          :type id: str
          :param if_match: The ETag of the enrollment record.
          :type if_match: 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:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.delete_individual_enrollment.metadata["url"]
          path_format_arguments = {"id": self._serialize.url("id", 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 = {}
          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")
  
          # Construct and send request
          request = self._client.delete(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [204]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          if raw:
              client_raw_response = ClientRawResponse(None, response)
              return client_raw_response
  
      delete_individual_enrollment.metadata = {"url": "/enrollments/{id}"}
  
      def get_enrollment_group(self, id, custom_headers=None, raw=False, **operation_config):
          """Get a device enrollment group.
  
          :param id: Enrollment group ID.
          :type 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: EnrollmentGroup or ClientRawResponse if raw=true
          :rtype: ~protocol.models.EnrollmentGroup or
           ~msrest.pipeline.ClientRawResponse
          :raises:
           :class:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.get_enrollment_group.metadata["url"]
          path_format_arguments = {"id": self._serialize.url("id", 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["Accept"] = "application/json"
          if custom_headers:
              header_parameters.update(custom_headers)
  
          # Construct and send request
          request = self._client.get(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          deserialized = None
  
          if response.status_code == 200:
              deserialized = self._deserialize("EnrollmentGroup", response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
  
      get_enrollment_group.metadata = {"url": "/enrollmentGroups/{id}"}
  
      def create_or_update_enrollment_group(
          self,
          id,
          enrollment_group,
          if_match=None,
          custom_headers=None,
          raw=False,
          **operation_config
      ):
          """Create or update a device enrollment group.
  
          :param id: Enrollment group ID.
          :type id: str
          :param enrollment_group: The device enrollment group.
          :type enrollment_group: ~protocol.models.EnrollmentGroup
          :param if_match: The ETag of the enrollment record.
          :type if_match: 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: EnrollmentGroup or ClientRawResponse if raw=true
          :rtype: ~protocol.models.EnrollmentGroup or
           ~msrest.pipeline.ClientRawResponse
          :raises:
           :class:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.create_or_update_enrollment_group.metadata["url"]
          path_format_arguments = {"id": self._serialize.url("id", 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["Accept"] = "application/json"
          header_parameters["Content-Type"] = "application/json; charset=utf-8"
          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")
  
          # Construct body
          body_content = self._serialize.body(enrollment_group, "EnrollmentGroup")
  
          # Construct and send request
          request = self._client.put(url, query_parameters, header_parameters, body_content)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          deserialized = None
  
          if response.status_code == 200:
              deserialized = self._deserialize("EnrollmentGroup", response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
  
      create_or_update_enrollment_group.metadata = {"url": "/enrollmentGroups/{id}"}
  
      def delete_enrollment_group(
          self, id, if_match=None, custom_headers=None, raw=False, **operation_config
      ):
          """Delete a device enrollment group.
  
          :param id: Enrollment group ID.
          :type id: str
          :param if_match: The ETag of the enrollment group record.
          :type if_match: 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:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.delete_enrollment_group.metadata["url"]
          path_format_arguments = {"id": self._serialize.url("id", 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 = {}
          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")
  
          # Construct and send request
          request = self._client.delete(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [204]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          if raw:
              client_raw_response = ClientRawResponse(None, response)
              return client_raw_response
  
      delete_enrollment_group.metadata = {"url": "/enrollmentGroups/{id}"}
  
      def get_device_registration_state(self, id, custom_headers=None, raw=False, **operation_config):
          """Gets the device registration state.
  
          :param id: Registration ID.
          :type 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: DeviceRegistrationState or ClientRawResponse if raw=true
          :rtype: ~protocol.models.DeviceRegistrationState or
           ~msrest.pipeline.ClientRawResponse
          :raises:
           :class:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.get_device_registration_state.metadata["url"]
          path_format_arguments = {"id": self._serialize.url("id", 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["Accept"] = "application/json"
          if custom_headers:
              header_parameters.update(custom_headers)
  
          # Construct and send request
          request = self._client.get(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          deserialized = None
  
          if response.status_code == 200:
              deserialized = self._deserialize("DeviceRegistrationState", response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
  
      get_device_registration_state.metadata = {"url": "/registrations/{id}"}
  
      def delete_device_registration_state(
          self, id, if_match=None, custom_headers=None, raw=False, **operation_config
      ):
          """Deletes the device registration.
  
          :param id: Registration ID.
          :type id: str
          :param if_match: The ETag of the registration status record.
          :type if_match: 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:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.delete_device_registration_state.metadata["url"]
          path_format_arguments = {"id": self._serialize.url("id", 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 = {}
          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")
  
          # Construct and send request
          request = self._client.delete(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [204]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          if raw:
              client_raw_response = ClientRawResponse(None, response)
              return client_raw_response
  
      delete_device_registration_state.metadata = {"url": "/registrations/{id}"}
  
      def run_bulk_enrollment_operation(
          self, bulk_operation, custom_headers=None, raw=False, **operation_config
      ):
          """Bulk device enrollment operation.
  
          :param bulk_operation: Bulk operation.
          :type bulk_operation: ~protocol.models.BulkEnrollmentOperation
          :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: BulkEnrollmentOperationResult or ClientRawResponse if
           raw=true
          :rtype: ~protocol.models.BulkEnrollmentOperationResult or
           ~msrest.pipeline.ClientRawResponse
          :raises:
           :class:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.run_bulk_enrollment_operation.metadata["url"]
  
          # Construct parameters
          query_parameters = {}
          query_parameters["api-version"] = self._serialize.query(
              "self.api_version", self.api_version, "str"
          )
  
          # Construct headers
          header_parameters = {}
          header_parameters["Accept"] = "application/json"
          header_parameters["Content-Type"] = "application/json; charset=utf-8"
          if custom_headers:
              header_parameters.update(custom_headers)
  
          # Construct body
          body_content = self._serialize.body(bulk_operation, "BulkEnrollmentOperation")
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters, body_content)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          deserialized = None
  
          if response.status_code == 200:
              deserialized = self._deserialize("BulkEnrollmentOperationResult", response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
  
      run_bulk_enrollment_operation.metadata = {"url": "/enrollments"}
  
      def query_individual_enrollments(
          self,
          query_specification,
          x_ms_max_item_count=None,
          x_ms_continuation=None,
          custom_headers=None,
          raw=False,
          **operation_config
      ):
          """Query the device enrollment records.
  
          :param query_specification: The query specification.
          :type query_specification: ~protocol.models.QuerySpecification
          :param x_ms_max_item_count: pageSize
          :type x_ms_max_item_count: int
          :param x_ms_continuation: continuation token
          :type x_ms_continuation: 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: list or ClientRawResponse if raw=true
          :rtype: list[~protocol.models.IndividualEnrollment] or
           ~msrest.pipeline.ClientRawResponse
          :raises:
           :class:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.query_individual_enrollments.metadata["url"]
  
          # Construct parameters
          query_parameters = {}
          query_parameters["api-version"] = self._serialize.query(
              "self.api_version", self.api_version, "str"
          )
  
          # Construct headers
          header_parameters = {}
          header_parameters["Accept"] = "application/json"
          header_parameters["Content-Type"] = "application/json; charset=utf-8"
          if custom_headers:
              header_parameters.update(custom_headers)
          if x_ms_max_item_count is not None:
              header_parameters["x-ms-max-item-count"] = self._serialize.header(
                  "x_ms_max_item_count", x_ms_max_item_count, "int"
              )
          if x_ms_continuation is not None:
              header_parameters["x-ms-continuation"] = self._serialize.header(
                  "x_ms_continuation", x_ms_continuation, "str"
              )
  
          # Construct body
          body_content = self._serialize.body(query_specification, "QuerySpecification")
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters, body_content)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          deserialized = None
          header_dict = {}
  
          if response.status_code == 200:
              deserialized = self._deserialize("[IndividualEnrollment]", response)
              header_dict = {
                  "x-ms-continuation": "str",
                  "x-ms-max-item-count": "int",
                  "x-ms-item-type": "str",
              }
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              client_raw_response.add_headers(header_dict)
              return client_raw_response
  
          return deserialized
  
      query_individual_enrollments.metadata = {"url": "/enrollments/query"}
  
      def get_individual_enrollment_attestation_mechanism(
          self, id, custom_headers=None, raw=False, **operation_config
      ):
          """Get the attestation mechanism in the device enrollment record.
  
          :param id: Registration ID.
          :type 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: AttestationMechanism or ClientRawResponse if raw=true
          :rtype: ~protocol.models.AttestationMechanism or
           ~msrest.pipeline.ClientRawResponse
          :raises:
           :class:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.get_individual_enrollment_attestation_mechanism.metadata["url"]
          path_format_arguments = {"id": self._serialize.url("id", 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["Accept"] = "application/json"
          if custom_headers:
              header_parameters.update(custom_headers)
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          deserialized = None
  
          if response.status_code == 200:
              deserialized = self._deserialize("AttestationMechanism", response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
  
      get_individual_enrollment_attestation_mechanism.metadata = {
          "url": "/enrollments/{id}/attestationmechanism"
      }
  
      def query_enrollment_groups(
          self,
          query_specification,
          x_ms_max_item_count=None,
          x_ms_continuation=None,
          custom_headers=None,
          raw=False,
          **operation_config
      ):
          """Query the device enrollment groups.
  
          :param query_specification: The query specification.
          :type query_specification: ~protocol.models.QuerySpecification
          :param x_ms_max_item_count: pageSize
          :type x_ms_max_item_count: int
          :param x_ms_continuation: continuation token
          :type x_ms_continuation: 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: list or ClientRawResponse if raw=true
          :rtype: list[~protocol.models.EnrollmentGroup] or
           ~msrest.pipeline.ClientRawResponse
          :raises:
           :class:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.query_enrollment_groups.metadata["url"]
  
          # Construct parameters
          query_parameters = {}
          query_parameters["api-version"] = self._serialize.query(
              "self.api_version", self.api_version, "str"
          )
  
          # Construct headers
          header_parameters = {}
          header_parameters["Accept"] = "application/json"
          header_parameters["Content-Type"] = "application/json; charset=utf-8"
          if custom_headers:
              header_parameters.update(custom_headers)
          if x_ms_max_item_count is not None:
              header_parameters["x-ms-max-item-count"] = self._serialize.header(
                  "x_ms_max_item_count", x_ms_max_item_count, "int"
              )
          if x_ms_continuation is not None:
              header_parameters["x-ms-continuation"] = self._serialize.header(
                  "x_ms_continuation", x_ms_continuation, "str"
              )
  
          # Construct body
          body_content = self._serialize.body(query_specification, "QuerySpecification")
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters, body_content)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          deserialized = None
          header_dict = {}
  
          if response.status_code == 200:
              deserialized = self._deserialize("[EnrollmentGroup]", response)
              header_dict = {
                  "x-ms-continuation": "str",
                  "x-ms-max-item-count": "int",
                  "x-ms-item-type": "str",
              }
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              client_raw_response.add_headers(header_dict)
              return client_raw_response
  
          return deserialized
  
      query_enrollment_groups.metadata = {"url": "/enrollmentGroups/query"}
  
      def get_enrollment_group_attestation_mechanism(
          self, id, custom_headers=None, raw=False, **operation_config
      ):
          """Get the attestation mechanism in the device enrollment group record.
  
          :param id: Enrollment group ID
          :type 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: AttestationMechanism or ClientRawResponse if raw=true
          :rtype: ~protocol.models.AttestationMechanism or
           ~msrest.pipeline.ClientRawResponse
          :raises:
           :class:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.get_enrollment_group_attestation_mechanism.metadata["url"]
          path_format_arguments = {"id": self._serialize.url("id", 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["Accept"] = "application/json"
          if custom_headers:
              header_parameters.update(custom_headers)
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          deserialized = None
  
          if response.status_code == 200:
              deserialized = self._deserialize("AttestationMechanism", response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
  
      get_enrollment_group_attestation_mechanism.metadata = {
          "url": "/enrollmentGroups/{id}/attestationmechanism"
      }
  
      def query_device_registration_states(
          self, id, custom_headers=None, raw=False, **operation_config
      ):
          """Gets the registration state of devices in this enrollmentGroup.
  
          :param id: Enrollment group ID.
          :type 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: list or ClientRawResponse if raw=true
          :rtype: list[~protocol.models.DeviceRegistrationState] or
           ~msrest.pipeline.ClientRawResponse
          :raises:
           :class:`ProvisioningServiceErrorDetailsException<protocol.models.ProvisioningServiceErrorDetailsException>`
          """
          # Construct URL
          url = self.query_device_registration_states.metadata["url"]
          path_format_arguments = {"id": self._serialize.url("id", 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["Accept"] = "application/json"
          if custom_headers:
              header_parameters.update(custom_headers)
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              raise models.ProvisioningServiceErrorDetailsException(self._deserialize, response)
  
          deserialized = None
  
          if response.status_code == 200:
              deserialized = self._deserialize("[DeviceRegistrationState]", response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
  
      query_device_registration_states.metadata = {"url": "/registrations/{id}/query"}
  