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.pipeline import PipelineResponse
  from azure.core.pipeline.transport import HttpRequest, HttpResponse
  
  from .. import models as _models
  
  if TYPE_CHECKING:
      # pylint: disable=unused-import,ungrouped-imports
      from typing import Any, Callable, Dict, Generic, Optional, TypeVar
  
      T = TypeVar('T')
      ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
  
  class SearchClientOperationsMixin(object):
  
      def get_service_statistics(
          self,
          request_options=None,  # type: Optional["_models.RequestOptions"]
          **kwargs  # type: Any
      ):
          # type: (...) -> "_models.ServiceStatistics"
          """Gets service level statistics for a search service.
  
          :param request_options: Parameter group.
          :type request_options: ~azure.search.documents.indexes.v2020_06.models.RequestOptions
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: ServiceStatistics, or the result of cls(response)
          :rtype: ~azure.search.documents.indexes.v2020_06.models.ServiceStatistics
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.ServiceStatistics"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          
          _x_ms_client_request_id = None
          if request_options is not None:
              _x_ms_client_request_id = request_options.x_ms_client_request_id
          api_version = "2020-06-30"
          accept = "application/json"
  
          # Construct URL
          url = self.get_service_statistics.metadata['url']  # type: ignore
          path_format_arguments = {
              'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
          }
          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]
          if _x_ms_client_request_id is not None:
              header_parameters['x-ms-client-request-id'] = self._serialize.header("x_ms_client_request_id", _x_ms_client_request_id, 'str')
          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.failsafe_deserialize(_models.SearchError, response)
              raise HttpResponseError(response=response, model=error)
  
          deserialized = self._deserialize('ServiceStatistics', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      get_service_statistics.metadata = {'url': '/servicestats'}  # type: ignore
  