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 HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
  from azure.core.pipeline import PipelineResponse
  from azure.core.pipeline.transport import HttpRequest, HttpResponse
  from azure.mgmt.core.exceptions import ARMErrorFormat
  
  from .. import models
  
  if TYPE_CHECKING:
      # pylint: disable=unused-import,ungrouped-imports
      from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union
  
      T = TypeVar('T')
      ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
  
  class Operations(object):
      """Operations 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: ~synapse_management_client.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 check_name_availability(
          self,
          request,  # type: "models.CheckNameAvailabilityRequest"
          **kwargs  # type: Any
      ):
          # type: (...) -> "models.CheckNameAvailabilityResponse"
          """Check name availability.
  
          Check whether a workspace name is available.
  
          :param request: The check request.
          :type request: ~synapse_management_client.models.CheckNameAvailabilityRequest
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: CheckNameAvailabilityResponse, or the result of cls(response)
          :rtype: ~synapse_management_client.models.CheckNameAvailabilityResponse
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType["models.CheckNameAvailabilityResponse"]
          error_map = {404: ResourceNotFoundError, 409: ResourceExistsError}
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2019-06-01-preview"
          content_type = kwargs.pop("content_type", "application/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', min_length=1),
          }
          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'] = 'application/json'
  
          body_content_kwargs = {}  # type: Dict[str, Any]
          body_content = self._serialize.body(request, 'CheckNameAvailabilityRequest')
          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.ErrorContract, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('CheckNameAvailabilityResponse', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/checkNameAvailability'}  # type: ignore
  
      def list(
          self,
          **kwargs  # type: Any
      ):
          # type: (...) -> List["models.AvailableRpOperation"]
          """All operations.
  
          Get all available operations.
  
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: list of AvailableRpOperation, or the result of cls(response)
          :rtype: list[~synapse_management_client.models.AvailableRpOperation]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType[List["models.AvailableRpOperation"]]
          error_map = {404: ResourceNotFoundError, 409: ResourceExistsError}
          error_map.update(kwargs.pop('error_map', {}))
  
          # Construct URL
          url = self.list.metadata['url']  # type: ignore
  
          # Construct parameters
          query_parameters = {}  # type: Dict[str, Any]
  
          # Construct headers
          header_parameters = {}  # type: Dict[str, Any]
          header_parameters['Accept'] = 'application/json'
  
          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)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          deserialized = self._deserialize('[AvailableRpOperation]', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      list.metadata = {'url': '/providers/Microsoft.Synapse/operations'}  # type: ignore
  
      def get_location_header_result(
          self,
          resource_group_name,  # type: str
          workspace_name,  # type: str
          operation_id,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> None
          """Get operation result.
  
          Get the result of an operation.
  
          :param resource_group_name: The name of the resource group. The name is case insensitive.
          :type resource_group_name: str
          :param workspace_name: The name of the workspace.
          :type workspace_name: str
          :param operation_id: Operation ID.
          :type operation_id: 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 = {404: ResourceNotFoundError, 409: ResourceExistsError}
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2019-06-01-preview"
  
          # Construct URL
          url = self.get_location_header_result.metadata['url']  # type: ignore
          path_format_arguments = {
              'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1),
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'),
              'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str'),
              'operationId': self._serialize.url("operation_id", operation_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]
  
          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, 204]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              error = self._deserialize(models.ErrorContract, response)
              raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
  
          if cls:
              return cls(pipeline_response, None, {})
  
      get_location_header_result.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationResults/{operationId}'}  # type: ignore
  
      def get_azure_async_header_result(
          self,
          resource_group_name,  # type: str
          workspace_name,  # type: str
          operation_id,  # type: str
          **kwargs  # type: Any
      ):
          # type: (...) -> Optional[Union["models.OperationResource", "models.ErrorContract"]]
          """Get operation status.
  
          Get the status of an operation.
  
          :param resource_group_name: The name of the resource group. The name is case insensitive.
          :type resource_group_name: str
          :param workspace_name: The name of the workspace.
          :type workspace_name: str
          :param operation_id: Operation ID.
          :type operation_id: str
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: OperationResource or ErrorContract, or the result of cls(response)
          :rtype: ~synapse_management_client.models.OperationResource or ~synapse_management_client.models.ErrorContract or None
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          cls = kwargs.pop('cls', None)  # type: ClsType[Optional[Union["models.OperationResource", "models.ErrorContract"]]]
          error_map = {404: ResourceNotFoundError, 409: ResourceExistsError}
          error_map.update(kwargs.pop('error_map', {}))
          api_version = "2019-06-01-preview"
  
          # Construct URL
          url = self.get_azure_async_header_result.metadata['url']  # type: ignore
          path_format_arguments = {
              'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1),
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'),
              'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str'),
              'operationId': self._serialize.url("operation_id", operation_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'] = 'application/json'
  
          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, 404, 500]:
              map_error(status_code=response.status_code, response=response, error_map=error_map)
              raise HttpResponseError(response=response, error_format=ARMErrorFormat)
  
          deserialized = None
          if response.status_code == 200:
              deserialized = self._deserialize('OperationResource', pipeline_response)
  
          if response.status_code == 500:
              deserialized = self._deserialize('ErrorContract', pipeline_response)
  
          if cls:
              return cls(pipeline_response, deserialized, {})
  
          return deserialized
      get_azure_async_header_result.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationStatuses/{operationId}'}  # type: ignore
  