text: # pylint: disable=too-many-lines
  # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar
  
  from azure.core.async_paging import AsyncItemPaged, AsyncList
  from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
  from azure.core.pipeline import PipelineResponse
  from azure.core.pipeline.transport import AsyncHttpResponse
  from azure.core.rest import HttpRequest
  from azure.core.tracing.decorator import distributed_trace
  
  from ... import models as _models
  from ..._vendor import _convert_request
  from ...operations._environment_type_operations import build_list_by_project_request
  T = TypeVar('T')
  ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
  
  class EnvironmentTypeOperations:
      """
      .. warning::
          **DO NOT** instantiate this class directly.
  
          Instead, you should access the following operations through
          :class:`~azure.fidalgo.aio.FidalgoDataplaneClient`'s
          :attr:`environment_type` attribute.
      """
  
      models = _models
  
      def __init__(self, *args, **kwargs) -> None:
          args = list(args)
          self._client = args.pop(0) if args else kwargs.pop("client")
          self._config = args.pop(0) if args else kwargs.pop("config")
          self._serialize = args.pop(0) if args else kwargs.pop("serializer")
          self._deserialize = args.pop(0) if args else kwargs.pop("deserializer")
  
  
      @distributed_trace
      def list_by_project(
          self,
          dev_center: str,
          project_name: str,
          fidalgo_dns_suffix: str = "devcenters.fidalgo.azure.com",
          top: Optional[int] = None,
          **kwargs: Any
      ) -> AsyncIterable["_models.EnvironmentTypeListResult"]:
          """Lists all environment types configured for a project.
  
          :param dev_center: The DevCenter to operate on.
          :type dev_center: str
          :param project_name: The Fidalgo Project upon which to execute operations.
          :type project_name: str
          :param fidalgo_dns_suffix: The DNS suffix used as the base for all fidalgo requests. Default
           value is "devcenters.fidalgo.azure.com".
          :type fidalgo_dns_suffix: str
          :param top: The maximum number of resources to return from the operation. Example: '$top=10'.
           Default value is None.
          :type top: int
          :keyword callable cls: A custom type or function that will be passed the direct response
          :return: An iterator like instance of either EnvironmentTypeListResult or the result of
           cls(response)
          :rtype:
           ~azure.core.async_paging.AsyncItemPaged[~azure.fidalgo.models.EnvironmentTypeListResult]
          :raises: ~azure.core.exceptions.HttpResponseError
          """
          api_version = kwargs.pop('api_version', "2021-09-01-privatepreview")  # type: str
  
          cls = kwargs.pop('cls', None)  # type: ClsType["_models.EnvironmentTypeListResult"]
          error_map = {
              401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
          }
          error_map.update(kwargs.pop('error_map', {}))
          def prepare_request(next_link=None):
              if not next_link:
                  
                  request = build_list_by_project_request(
                      project_name=project_name,
                      api_version=api_version,
                      top=top,
                      template_url=self.list_by_project.metadata['url'],
                  )
                  request = _convert_request(request)
                  path_format_arguments = {
                      "devCenter": self._serialize.url("dev_center", dev_center, 'str', skip_quote=True),
                      "fidalgoDnsSuffix": self._serialize.url("fidalgo_dns_suffix", fidalgo_dns_suffix, 'str', skip_quote=True),
                  }
                  request.url = self._client.format_url(request.url, **path_format_arguments)
  
              else:
                  
                  request = build_list_by_project_request(
                      project_name=project_name,
                      api_version=api_version,
                      top=top,
                      template_url=next_link,
                  )
                  request = _convert_request(request)
                  path_format_arguments = {
                      "devCenter": self._serialize.url("dev_center", dev_center, 'str', skip_quote=True),
                      "fidalgoDnsSuffix": self._serialize.url("fidalgo_dns_suffix", fidalgo_dns_suffix, 'str', skip_quote=True),
                  }
                  request.url = self._client.format_url(request.url, **path_format_arguments)
  
                  path_format_arguments = {
                      "devCenter": self._serialize.url("dev_center", dev_center, 'str', skip_quote=True),
                      "fidalgoDnsSuffix": self._serialize.url("fidalgo_dns_suffix", fidalgo_dns_suffix, 'str', skip_quote=True),
                  }
                  request.method = "GET"
              return request
  
          async def extract_data(pipeline_response):
              deserialized = self._deserialize("EnvironmentTypeListResult", pipeline_response)
              list_of_elem = deserialized.value
              if cls:
                  list_of_elem = cls(list_of_elem)
              return deserialized.next_link or None, AsyncList(list_of_elem)
  
          async def get_next(next_link=None):
              request = prepare_request(next_link)
  
              pipeline_response = await self._client._pipeline.run(  # pylint: disable=protected-access
                  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.CloudError, pipeline_response)
                  raise HttpResponseError(response=response, model=error)
  
              return pipeline_response
  
  
          return AsyncItemPaged(
              get_next, extract_data
          )
      list_by_project.metadata = {'url': "/projects/{projectName}/environmentTypes"}  # type: ignore
  