def __init__(
         self,
         credential: "AsyncTokenCredential",
         endpoint: str,
         api_version: Optional[str] = None,
         profile: KnownProfiles = KnownProfiles.default,
         **kwargs  # type: Any
 ) -> None:
     if api_version == 'v3.0':
         base_url = '{Endpoint}/text/analytics/v3.0'
     elif api_version == 'v3.1':
         base_url = '{Endpoint}/text/analytics/v3.1'
     elif api_version == 'v3.2-preview.2':
         base_url = '{Endpoint}/text/analytics/v3.2-preview.2'
     else:
         raise ValueError(
             "API version {} is not available".format(api_version))
     self._config = TextAnalyticsClientConfiguration(
         credential, endpoint, **kwargs)
     self._client = AsyncPipelineClient(base_url=base_url,
                                        config=self._config,
                                        **kwargs)
     super(TextAnalyticsClient, self).__init__(api_version=api_version,
                                               profile=profile)
Exemplo n.º 2
0
    def __init__(self, url, file_system, path1, **kwargs):

        base_url = '{url}'
        self._config = DataLakeStorageClientConfiguration(
            url, file_system, path1, **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self.api_version = '2019-12-12'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.service = ServiceOperations(self._client, self._config,
                                         self._serialize, self._deserialize)
        self.file_system = FileSystemOperations(self._client, self._config,
                                                self._serialize,
                                                self._deserialize)
        self.path = PathOperations(self._client, self._config, self._serialize,
                                   self._deserialize)
class ConfidentialLedgerIdentityServiceClient(object):
    """The ConfidentialLedgerIdentityServiceClient is used to retrieve the TLS certificate required for connecting to a Confidential Ledger.

    :ivar confidential_ledger_identity_service: ConfidentialLedgerIdentityServiceOperations operations
    :vartype confidential_ledger_identity_service: azure.confidentialledger._generated/_generated_identity.v0_1_preview.aio.operations.ConfidentialLedgerIdentityServiceOperations
    :param identity_service_uri: The Identity Service URL, for example https://identity.accledger.azure.com.
    :type identity_service_uri: str
    """
    def __init__(self, identity_service_uri: str, **kwargs: Any) -> None:
        base_url = '{identityServiceUri}'
        self._config = ConfidentialLedgerIdentityServiceClientConfiguration(
            identity_service_uri, **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._serialize.client_side_validation = False
        self._deserialize = Deserializer(client_models)

        self.confidential_ledger_identity_service = ConfidentialLedgerIdentityServiceOperations(
            self._client, self._config, self._serialize, self._deserialize)

    async def _send_request(self, http_request: HttpRequest,
                            **kwargs: Any) -> AsyncHttpResponse:
        """Runs the network request through the client's chained policies.

        :param http_request: The network request you want to make. Required.
        :type http_request: ~azure.core.pipeline.transport.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to True.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
        """
        path_format_arguments = {
            'identityServiceUri':
            self._serialize.url("self._config.identity_service_uri",
                                self._config.identity_service_uri,
                                'str',
                                skip_quote=True),
        }
        http_request.url = self._client.format_url(http_request.url,
                                                   **path_format_arguments)
        stream = kwargs.pop("stream", True)
        pipeline_response = await self._client._pipeline.run(http_request,
                                                             stream=stream,
                                                             **kwargs)
        return pipeline_response.http_response

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "ConfidentialLedgerIdentityServiceClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
Exemplo n.º 4
0
class PurviewCatalogClient(object):
    """Purview Catalog Service is a fully managed cloud service whose users can discover the data sources they need and understand the data sources they find. At the same time, Data Catalog helps organizations get more value from their existing investments. This spec defines REST API of Purview Catalog Service.

    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials_async.AsyncTokenCredential
    :param endpoint: The catalog endpoint of your Purview account. Example: https://{accountName}.catalog.purview.azure.com.
    :type endpoint: str
    """
    def __init__(self, credential: "AsyncTokenCredential", endpoint: str,
                 **kwargs: Any) -> None:
        base_url = '{Endpoint}/api'
        self._config = PurviewCatalogClientConfiguration(
            credential, endpoint, **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        self._serialize = Serializer()
        self._deserialize = Deserializer()
        self._serialize.client_side_validation = False

    async def send_request(self, http_request: HttpRequest,
                           **kwargs: Any) -> AsyncHttpResponse:
        """Runs the network request through the client's chained policies.

        We have helper methods to create requests specific to this service in `azure.purview.catalog.rest`.
        Use these helper methods to create the request you pass to this method. See our example below:

        >>> from azure.purview.catalog.rest import build_create_or_update_request
        >>> request = build_create_or_update_request(json, content)
        <HttpRequest [POST], url: '/atlas/v2/entity'>
        >>> response = await client.send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        For advanced cases, you can also create your own :class:`~azure.purview.catalog.core.rest.HttpRequest`
        and pass it in.

        :param http_request: The network request you want to make. Required.
        :type http_request: ~azure.purview.catalog.core.rest.HttpRequest
        :keyword bool stream_response: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.purview.catalog.core.rest.AsyncHttpResponse
        """
        request_copy = deepcopy(http_request)
        path_format_arguments = {
            'Endpoint':
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }
        request_copy.url = self._client.format_url(request_copy.url,
                                                   **path_format_arguments)
        if kwargs.pop("stream_response", False):
            return _AsyncStreamContextManager(
                client=self._client._pipeline,
                request=request_copy,
            )
        pipeline_response = await self._client._pipeline.run(
            request_copy._internal_request, **kwargs)
        response = AsyncHttpResponse(
            status_code=pipeline_response.http_response.status_code,
            request=request_copy,
            _internal_response=pipeline_response.http_response)
        await response.read()
        return response

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "PurviewCatalogClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class ConversationAnalysisClient(ConversationAnalysisClientOperationsMixin):
    """This API accepts a request and mediates among multiple language projects, such as LUIS
    Generally Available, Question Answering, Conversational Language Understanding, and then calls
    the best candidate service to handle the request. At last, it returns a response with the
    candidate service's response as a payload.

     In some cases, this API needs to forward requests and responses between the caller and an
    upstream service.

    :param endpoint: Supported Cognitive Services endpoint (e.g.,
     https://:code:`<resource-name>`.api.cognitiveservices.azure.com).
    :type endpoint: str
    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials.AzureKeyCredential
    :keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
     this default value may result in unsupported behavior.
    :paramtype api_version: str
    """
    def __init__(self, endpoint: str, credential: AzureKeyCredential,
                 **kwargs: Any) -> None:
        _endpoint = '{Endpoint}/language'
        self._config = ConversationAnalysisClientConfiguration(
            endpoint=endpoint, credential=credential, **kwargs)
        self._client = AsyncPipelineClient(base_url=_endpoint,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)
        self._serialize.client_side_validation = False

    def send_request(self, request: HttpRequest,
                     **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        >>> from azure.core.rest import HttpRequest
        >>> request = HttpRequest("GET", "https://www.example.org/")
        <HttpRequest [GET], url: 'https://www.example.org/'>
        >>> response = await client.send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        path_format_arguments = {
            "Endpoint":
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }

        request_copy.url = self._client.format_url(request_copy.url,
                                                   **path_format_arguments)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "ConversationAnalysisClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class AzureFileStorage(object):
    """AzureFileStorage.

    :ivar service: ServiceOperations operations
    :vartype service: azure.storage.fileshare.aio.operations.ServiceOperations
    :ivar share: ShareOperations operations
    :vartype share: azure.storage.fileshare.aio.operations.ShareOperations
    :ivar directory: DirectoryOperations operations
    :vartype directory: azure.storage.fileshare.aio.operations.DirectoryOperations
    :ivar file: FileOperations operations
    :vartype file: azure.storage.fileshare.aio.operations.FileOperations
    :param url: The URL of the service account, share, directory or file that is the target of the desired operation.
    :type url: str
    """
    def __init__(self, url: str, **kwargs: Any) -> None:
        base_url = '{url}'
        self._config = AzureFileStorageConfiguration(url, **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._serialize.client_side_validation = False
        self._deserialize = Deserializer(client_models)

        self.service = ServiceOperations(self._client, self._config,
                                         self._serialize, self._deserialize)
        self.share = ShareOperations(self._client, self._config,
                                     self._serialize, self._deserialize)
        self.directory = DirectoryOperations(self._client, self._config,
                                             self._serialize,
                                             self._deserialize)
        self.file = FileOperations(self._client, self._config, self._serialize,
                                   self._deserialize)

    async def _send_request(self, http_request: HttpRequest,
                            **kwargs: Any) -> AsyncHttpResponse:
        """Runs the network request through the client's chained policies.

        :param http_request: The network request you want to make. Required.
        :type http_request: ~azure.core.pipeline.transport.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to True.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
        """
        path_format_arguments = {
            'url':
            self._serialize.url("self._config.url",
                                self._config.url,
                                'str',
                                skip_quote=True),
        }
        http_request.url = self._client.format_url(http_request.url,
                                                   **path_format_arguments)
        stream = kwargs.pop("stream", True)
        pipeline_response = await self._client._pipeline.run(http_request,
                                                             stream=stream,
                                                             **kwargs)
        return pipeline_response.http_response

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "AzureFileStorage":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
Exemplo n.º 7
0
class AzureSchemaRegistry:
    """Azure Schema Registry is as a central schema repository, complete with support for versioning, management, compatibility checking, and RBAC.

    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials_async.AsyncTokenCredential
    :param endpoint: The Schema Registry service endpoint, for example
         my-namespace.servicebus.windows.net.
    :type endpoint: str
    """

    def __init__(
        self,
        credential: "AsyncTokenCredential",
        endpoint: str,
        **kwargs: Any
    ) -> None:
        base_url = 'https://{endpoint}'
        self._config = AzureSchemaRegistryConfiguration(credential, endpoint, **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)

        client_models = {}  # type: Dict[str, Any]
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)
        self._serialize.client_side_validation = False


    def send_request(
        self,
        request: HttpRequest,
        **kwargs: Any
    ) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        We have helper methods to create requests specific to this service in `azure.schemaregistry._generated.rest`.
        Use these helper methods to create the request you pass to this method.

        >>> from azure.schemaregistry._generated.rest import schema
        >>> request = schema.build_get_by_id_request(schema_id, **kwargs)
        <HttpRequest [GET], url: '/$schemagroups/getSchemaById/{schema-id}'>
        >>> response = await client.send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest`
        and pass it in.

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        path_format_arguments = {
            'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
        }
        request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "AzureSchemaRegistry":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class QuantumClient:
    """Azure Quantum REST API client.

    :ivar jobs: JobsOperations operations
    :vartype jobs: azure.quantum._client.aio.operations.JobsOperations
    :ivar providers: ProvidersOperations operations
    :vartype providers: azure.quantum._client.aio.operations.ProvidersOperations
    :ivar storage: StorageOperations operations
    :vartype storage: azure.quantum._client.aio.operations.StorageOperations
    :ivar quotas: QuotasOperations operations
    :vartype quotas: azure.quantum._client.aio.operations.QuotasOperations
    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials_async.AsyncTokenCredential
    :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g.
     00000000-0000-0000-0000-000000000000).
    :type subscription_id: str
    :param resource_group_name: Name of an Azure resource group.
    :type resource_group_name: str
    :param workspace_name: Name of the workspace.
    :type workspace_name: str
    :param base_url: Service URL. Default value is "https://quantum.azure.com".
    :type base_url: str
    """
    def __init__(self,
                 credential: "AsyncTokenCredential",
                 subscription_id: str,
                 resource_group_name: str,
                 workspace_name: str,
                 base_url: str = "https://quantum.azure.com",
                 **kwargs: Any) -> None:
        self._config = QuantumClientConfiguration(
            credential=credential,
            subscription_id=subscription_id,
            resource_group_name=resource_group_name,
            workspace_name=workspace_name,
            **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)
        self._serialize.client_side_validation = False
        self.jobs = JobsOperations(self._client, self._config, self._serialize,
                                   self._deserialize)
        self.providers = ProvidersOperations(self._client, self._config,
                                             self._serialize,
                                             self._deserialize)
        self.storage = StorageOperations(self._client, self._config,
                                         self._serialize, self._deserialize)
        self.quotas = QuotasOperations(self._client, self._config,
                                       self._serialize, self._deserialize)

    def _send_request(self, request: HttpRequest,
                      **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        >>> from azure.core.rest import HttpRequest
        >>> request = HttpRequest("GET", "https://www.example.org/")
        <HttpRequest [GET], url: 'https://www.example.org/'>
        >>> response = await client._send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        request_copy.url = self._client.format_url(request_copy.url)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "QuantumClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class FarmBeatsClient(object):
    """APIs documentation for Azure AgPlatform DataPlane Service.

    :ivar application_data: ApplicationDataOperations operations
    :vartype application_data: azure.agrifood.farming.aio.operations.ApplicationDataOperations
    :ivar attachments: AttachmentsOperations operations
    :vartype attachments: azure.agrifood.farming.aio.operations.AttachmentsOperations
    :ivar boundaries: BoundariesOperations operations
    :vartype boundaries: azure.agrifood.farming.aio.operations.BoundariesOperations
    :ivar crops: CropsOperations operations
    :vartype crops: azure.agrifood.farming.aio.operations.CropsOperations
    :ivar crop_varieties: CropVarietiesOperations operations
    :vartype crop_varieties: azure.agrifood.farming.aio.operations.CropVarietiesOperations
    :ivar farmers: FarmersOperations operations
    :vartype farmers: azure.agrifood.farming.aio.operations.FarmersOperations
    :ivar farm_operations: FarmOperationsOperations operations
    :vartype farm_operations: azure.agrifood.farming.aio.operations.FarmOperationsOperations
    :ivar farms: FarmsOperations operations
    :vartype farms: azure.agrifood.farming.aio.operations.FarmsOperations
    :ivar fields: FieldsOperations operations
    :vartype fields: azure.agrifood.farming.aio.operations.FieldsOperations
    :ivar harvest_data: HarvestDataOperations operations
    :vartype harvest_data: azure.agrifood.farming.aio.operations.HarvestDataOperations
    :ivar image_processing: ImageProcessingOperations operations
    :vartype image_processing: azure.agrifood.farming.aio.operations.ImageProcessingOperations
    :ivar oauth_providers: OAuthProvidersOperations operations
    :vartype oauth_providers: azure.agrifood.farming.aio.operations.OAuthProvidersOperations
    :ivar oauth_tokens: OAuthTokensOperations operations
    :vartype oauth_tokens: azure.agrifood.farming.aio.operations.OAuthTokensOperations
    :ivar planting_data: PlantingDataOperations operations
    :vartype planting_data: azure.agrifood.farming.aio.operations.PlantingDataOperations
    :ivar scenes: ScenesOperations operations
    :vartype scenes: azure.agrifood.farming.aio.operations.ScenesOperations
    :ivar seasonal_fields: SeasonalFieldsOperations operations
    :vartype seasonal_fields: azure.agrifood.farming.aio.operations.SeasonalFieldsOperations
    :ivar seasons: SeasonsOperations operations
    :vartype seasons: azure.agrifood.farming.aio.operations.SeasonsOperations
    :ivar tillage_data: TillageDataOperations operations
    :vartype tillage_data: azure.agrifood.farming.aio.operations.TillageDataOperations
    :ivar weather: WeatherOperations operations
    :vartype weather: azure.agrifood.farming.aio.operations.WeatherOperations
    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials_async.AsyncTokenCredential
    :param endpoint: The endpoint of your FarmBeats resource (protocol and hostname, for example: https://{resourceName}.farmbeats.azure.net).
    :type endpoint: str
    :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
    """
    def __init__(self, credential: "AsyncTokenCredential", endpoint: str,
                 **kwargs: Any) -> None:
        base_url = '{Endpoint}'
        self._config = FarmBeatsClientConfiguration(credential, endpoint,
                                                    **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._serialize.client_side_validation = False
        self._deserialize = Deserializer(client_models)

        self.application_data = ApplicationDataOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.attachments = AttachmentsOperations(self._client, self._config,
                                                 self._serialize,
                                                 self._deserialize)
        self.boundaries = BoundariesOperations(self._client, self._config,
                                               self._serialize,
                                               self._deserialize)
        self.crops = CropsOperations(self._client, self._config,
                                     self._serialize, self._deserialize)
        self.crop_varieties = CropVarietiesOperations(self._client,
                                                      self._config,
                                                      self._serialize,
                                                      self._deserialize)
        self.farmers = FarmersOperations(self._client, self._config,
                                         self._serialize, self._deserialize)
        self.farm_operations = FarmOperationsOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.farms = FarmsOperations(self._client, self._config,
                                     self._serialize, self._deserialize)
        self.fields = FieldsOperations(self._client, self._config,
                                       self._serialize, self._deserialize)
        self.harvest_data = HarvestDataOperations(self._client, self._config,
                                                  self._serialize,
                                                  self._deserialize)
        self.image_processing = ImageProcessingOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.oauth_providers = OAuthProvidersOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.oauth_tokens = OAuthTokensOperations(self._client, self._config,
                                                  self._serialize,
                                                  self._deserialize)
        self.planting_data = PlantingDataOperations(self._client, self._config,
                                                    self._serialize,
                                                    self._deserialize)
        self.scenes = ScenesOperations(self._client, self._config,
                                       self._serialize, self._deserialize)
        self.seasonal_fields = SeasonalFieldsOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.seasons = SeasonsOperations(self._client, self._config,
                                         self._serialize, self._deserialize)
        self.tillage_data = TillageDataOperations(self._client, self._config,
                                                  self._serialize,
                                                  self._deserialize)
        self.weather = WeatherOperations(self._client, self._config,
                                         self._serialize, self._deserialize)

    async def _send_request(self, http_request: HttpRequest,
                            **kwargs: Any) -> AsyncHttpResponse:
        """Runs the network request through the client's chained policies.

        :param http_request: The network request you want to make. Required.
        :type http_request: ~azure.core.pipeline.transport.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to True.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
        """
        path_format_arguments = {
            'Endpoint':
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }
        http_request.url = self._client.format_url(http_request.url,
                                                   **path_format_arguments)
        stream = kwargs.pop("stream", True)
        pipeline_response = await self._client._pipeline.run(http_request,
                                                             stream=stream,
                                                             **kwargs)
        return pipeline_response.http_response

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "FarmBeatsClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class PhoneNumbersClient:
    """The phone numbers client uses Azure Communication Services to purchase and manage phone numbers.

    :ivar phone_numbers: PhoneNumbersOperations operations
    :vartype phone_numbers: azure.communication.phonenumbers.aio.operations.PhoneNumbersOperations
    :param endpoint: The communication resource, for example
     https://resourcename.communication.azure.com.
    :type endpoint: str
    :keyword api_version: Api Version. The default value is "2022-01-11-preview2". Note that
     overriding this default value may result in unsupported behavior.
    :paramtype api_version: str
    :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
     Retry-After header is present.
    """
    def __init__(self, endpoint: str, **kwargs: Any) -> None:
        _base_url = '{endpoint}'
        self._config = PhoneNumbersClientConfiguration(endpoint=endpoint,
                                                       **kwargs)
        self._client = AsyncPipelineClient(base_url=_base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)
        self._serialize.client_side_validation = False
        self.phone_numbers = PhoneNumbersOperations(self._client, self._config,
                                                    self._serialize,
                                                    self._deserialize)

    def _send_request(self, request: HttpRequest,
                      **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        >>> from azure.core.rest import HttpRequest
        >>> request = HttpRequest("GET", "https://www.example.org/")
        <HttpRequest [GET], url: 'https://www.example.org/'>
        >>> response = await client._send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        path_format_arguments = {
            "endpoint":
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }

        request_copy.url = self._client.format_url(request_copy.url,
                                                   **path_format_arguments)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "PhoneNumbersClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class PurviewScanningClient(object):
    """Creates a Microsoft.Scanning management client.

    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials_async.AsyncTokenCredential
    :param endpoint: The scanning endpoint of your purview account. Example: https://{accountName}.scan.purview.azure.com.
    :type endpoint: str
    """
    def __init__(self, credential: "AsyncTokenCredential", endpoint: str,
                 **kwargs: Any) -> None:
        base_url = '{Endpoint}'
        self._config = PurviewScanningClientConfiguration(
            credential, endpoint, **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        self._serialize = Serializer()
        self._deserialize = Deserializer()
        self._serialize.client_side_validation = False

    async def send_request(self, http_request: HttpRequest,
                           **kwargs: Any) -> AsyncHttpResponse:
        """Runs the network request through the client's chained policies.

        We have helper methods to create requests specific to this service in `azure.purview.scanning.rest`.
        Use these helper methods to create the request you pass to this method. See our example below:

        >>> from azure.purview.scanning.rest import build_get_request
        >>> request = build_get_request(key_vault_name)
        <HttpRequest [GET], url: '/azureKeyVaults/{keyVaultName}'>
        >>> response = await client.send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        For advanced cases, you can also create your own :class:`~azure.purview.scanning.core.rest.HttpRequest`
        and pass it in.

        :param http_request: The network request you want to make. Required.
        :type http_request: ~azure.purview.scanning.core.rest.HttpRequest
        :keyword bool stream_response: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.purview.scanning.core.rest.AsyncHttpResponse
        """
        request_copy = deepcopy(http_request)
        path_format_arguments = {
            'Endpoint':
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }
        request_copy.url = self._client.format_url(request_copy.url,
                                                   **path_format_arguments)
        if kwargs.pop("stream_response", False):
            return _AsyncStreamContextManager(
                client=self._client._pipeline,
                request=request_copy,
            )
        pipeline_response = await self._client._pipeline.run(
            request_copy._internal_request, **kwargs)
        response = AsyncHttpResponse(
            status_code=pipeline_response.http_response.status_code,
            request=request_copy,
            _internal_response=pipeline_response.http_response)
        await response.read()
        return response

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "PurviewScanningClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class KeyVaultClient(KeyVaultClientOperationsMixin):
    """The key vault client performs cryptographic key operations and vault operations against the Key
    Vault service.

    :ivar role_definitions: RoleDefinitionsOperations operations
    :vartype role_definitions: azure.keyvault.v7_2.aio.operations.RoleDefinitionsOperations
    :ivar role_assignments: RoleAssignmentsOperations operations
    :vartype role_assignments: azure.keyvault.v7_2.aio.operations.RoleAssignmentsOperations
    :keyword api_version: Api Version. Default value is "7.2". Note that overriding this default
     value may result in unsupported behavior.
    :paramtype api_version: str
    :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
     Retry-After header is present.
    """
    def __init__(self, **kwargs: Any) -> None:
        _base_url = '{vaultBaseUrl}'
        self._config = KeyVaultClientConfiguration(**kwargs)
        self._client = AsyncPipelineClient(base_url=_base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)
        self._serialize.client_side_validation = False
        self.role_definitions = RoleDefinitionsOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.role_assignments = RoleAssignmentsOperations(
            self._client, self._config, self._serialize, self._deserialize)

    def _send_request(self, request: HttpRequest,
                      **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        >>> from azure.core.rest import HttpRequest
        >>> request = HttpRequest("GET", "https://www.example.org/")
        <HttpRequest [GET], url: 'https://www.example.org/'>
        >>> response = await client._send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        request_copy.url = self._client.format_url(request_copy.url)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "KeyVaultClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class BatchDocumentTranslationClient(object):
    """BatchDocumentTranslationClient.

    :ivar document_translation: DocumentTranslationOperations operations
    :vartype document_translation: azure.ai.translation.document.aio.operations.DocumentTranslationOperations
    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials_async.AsyncTokenCredential
    :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).
    :type endpoint: str
    :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
    """
    def __init__(self, credential: "AsyncTokenCredential", endpoint: str,
                 **kwargs: Any) -> None:
        base_url = '{endpoint}/translator/text/batch/v1.0'
        self._config = BatchDocumentTranslationClientConfiguration(
            credential, endpoint, **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._serialize.client_side_validation = False
        self._deserialize = Deserializer(client_models)

        self.document_translation = DocumentTranslationOperations(
            self._client, self._config, self._serialize, self._deserialize)

    async def _send_request(self, http_request: HttpRequest,
                            **kwargs: Any) -> AsyncHttpResponse:
        """Runs the network request through the client's chained policies.

        :param http_request: The network request you want to make. Required.
        :type http_request: ~azure.core.pipeline.transport.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to True.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
        """
        path_format_arguments = {
            'endpoint':
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }
        http_request.url = self._client.format_url(http_request.url,
                                                   **path_format_arguments)
        stream = kwargs.pop("stream", True)
        pipeline_response = await self._client._pipeline.run(http_request,
                                                             stream=stream,
                                                             **kwargs)
        return pipeline_response.http_response

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "BatchDocumentTranslationClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
Exemplo n.º 14
0
class TextAnalyticsClient(TextAnalyticsClientOperationsMixin):
    """The Text Analytics API is a suite of natural language processing (NLP) services built with best-in-class Microsoft machine learning algorithms.  The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction and language detection. Functionality for analysis of text specific to the healthcare domain and personal information are also available in the API. Further documentation can be found in :code:`<a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview">https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview</a>`.

    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials_async.AsyncTokenCredential
    :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
     https://westus.api.cognitive.microsoft.com).
    :type endpoint: str
    :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
     Retry-After header is present.
    """
    def __init__(self, credential: "AsyncTokenCredential", endpoint: str,
                 **kwargs: Any) -> None:
        _base_url = '{Endpoint}/text/analytics/v3.2-preview.2'
        self._config = TextAnalyticsClientConfiguration(
            credential, endpoint, **kwargs)
        self._client = AsyncPipelineClient(base_url=_base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)
        self._serialize.client_side_validation = False

    def _send_request(self, request: HttpRequest,
                      **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        >>> from azure.core.rest import HttpRequest
        >>> request = HttpRequest("GET", "https://www.example.org/")
        <HttpRequest [GET], url: 'https://www.example.org/'>
        >>> response = await client._send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        path_format_arguments = {
            "Endpoint":
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }

        request_copy.url = self._client.format_url(request_copy.url,
                                                   **path_format_arguments)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "TextAnalyticsClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
Exemplo n.º 15
0
class QuestionAnsweringProjectsClient(QuestionAnsweringProjectsClientOperationsMixin):
    """The language service API is a suite of natural language processing (NLP) skills built with
    best-in-class Microsoft machine learning algorithms.  The API can be used to analyze
    unstructured text for tasks such as sentiment analysis, key phrase extraction, language
    detection and question answering. Further documentation can be found in :code:`<a
    href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview">https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview</a>`.

    :param endpoint: Supported Cognitive Services endpoint (e.g.,
     https://:code:`<resource-name>`.api.cognitiveservices.azure.com).
    :type endpoint: str
    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials.AzureKeyCredential
    :keyword api_version: Api Version. The default value is "2021-10-01". Note that overriding this
     default value may result in unsupported behavior.
    :paramtype api_version: str
    :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
     Retry-After header is present.
    """

    def __init__(
        self,
        endpoint: str,
        credential: AzureKeyCredential,
        **kwargs: Any
    ) -> None:
        _endpoint = '{Endpoint}/language'
        self._config = QuestionAnsweringProjectsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
        self._client = AsyncPipelineClient(base_url=_endpoint, config=self._config, **kwargs)

        self._serialize = Serializer()
        self._deserialize = Deserializer()
        self._serialize.client_side_validation = False


    def send_request(
        self,
        request: HttpRequest,
        **kwargs: Any
    ) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        >>> from azure.core.rest import HttpRequest
        >>> request = HttpRequest("GET", "https://www.example.org/")
        <HttpRequest [GET], url: 'https://www.example.org/'>
        >>> response = await client.send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        path_format_arguments = {
            "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
        }

        request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "QuestionAnsweringProjectsClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class SearchClient(SearchClientOperationsMixin):
    """Client that can be used to manage and query indexes and documents, as well as manage other resources, on a search service.

    :ivar data_sources: DataSourcesOperations operations
    :vartype data_sources: azure.search.documents.indexes.aio.operations.DataSourcesOperations
    :ivar indexers: IndexersOperations operations
    :vartype indexers: azure.search.documents.indexes.aio.operations.IndexersOperations
    :ivar skillsets: SkillsetsOperations operations
    :vartype skillsets: azure.search.documents.indexes.aio.operations.SkillsetsOperations
    :ivar synonym_maps: SynonymMapsOperations operations
    :vartype synonym_maps: azure.search.documents.indexes.aio.operations.SynonymMapsOperations
    :ivar indexes: IndexesOperations operations
    :vartype indexes: azure.search.documents.indexes.aio.operations.IndexesOperations
    :param endpoint: The endpoint URL of the search service.
    :type endpoint: str
    :keyword api_version: Api Version. The default value is "2021-04-30-Preview". Note that
     overriding this default value may result in unsupported behavior.
    :paramtype api_version: str
    """
    def __init__(self, endpoint: str, **kwargs: Any) -> None:
        _base_url = '{endpoint}'
        self._config = SearchClientConfiguration(endpoint=endpoint, **kwargs)
        self._client = AsyncPipelineClient(base_url=_base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)
        self._serialize.client_side_validation = False
        self.data_sources = DataSourcesOperations(self._client, self._config,
                                                  self._serialize,
                                                  self._deserialize)
        self.indexers = IndexersOperations(self._client, self._config,
                                           self._serialize, self._deserialize)
        self.skillsets = SkillsetsOperations(self._client, self._config,
                                             self._serialize,
                                             self._deserialize)
        self.synonym_maps = SynonymMapsOperations(self._client, self._config,
                                                  self._serialize,
                                                  self._deserialize)
        self.indexes = IndexesOperations(self._client, self._config,
                                         self._serialize, self._deserialize)

    def _send_request(self, request: HttpRequest,
                      **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        >>> from azure.core.rest import HttpRequest
        >>> request = HttpRequest("GET", "https://www.example.org/")
        <HttpRequest [GET], url: 'https://www.example.org/'>
        >>> response = await client._send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        path_format_arguments = {
            "endpoint":
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }

        request_copy.url = self._client.format_url(request_copy.url,
                                                   **path_format_arguments)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "SearchClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class BadEndpointError(Exception):
    pass

TEST_NAME = 'foo'
RESPONSE_BODY = {'properties':{'provisioningState': 'InProgress'}}
ASYNC_BODY = json.dumps({ 'status': 'Succeeded' })
ASYNC_URL = 'http://dummyurlFromAzureAsyncOPHeader_Return200'
LOCATION_BODY = json.dumps({ 'name': TEST_NAME })
LOCATION_URL = 'http://dummyurlurlFromLocationHeader_Return200'
RESOURCE_BODY = json.dumps({ 'name': TEST_NAME })
RESOURCE_URL = 'http://subscriptions/sub1/resourcegroups/g1/resourcetype1/resource1'
ERROR = 'http://dummyurl_ReturnError'
POLLING_STATUS = 200

CLIENT = AsyncPipelineClient("http://example.org")
async def mock_run(client_self, request, **kwargs):
    return TestArmPolling.mock_update(request.url)
CLIENT._pipeline.run = types.MethodType(mock_run, CLIENT)


@pytest.fixture
def async_pipeline_client_builder():
    """Build a client that use the "send" callback as final transport layer

    send will receive "request" and kwargs as any transport layer
    """
    def create_client(send_cb):
        class TestHttpTransport(AsyncHttpTransport):
            async def open(self): pass
            async def close(self): pass
class AzureCommunicationChatService(object):
    """Azure Communication Chat Service.

    :ivar chat_thread: ChatThreadOperations operations
    :vartype chat_thread: azure.communication.chat.aio.operations.ChatThreadOperations
    :ivar chat: ChatOperations operations
    :vartype chat: azure.communication.chat.aio.operations.ChatOperations
    :param endpoint: The endpoint of the Azure Communication resource.
    :type endpoint: str
    """
    def __init__(self, endpoint: str, **kwargs: Any) -> None:
        base_url = '{endpoint}'
        self._config = AzureCommunicationChatServiceConfiguration(
            endpoint, **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._serialize.client_side_validation = False
        self._deserialize = Deserializer(client_models)

        self.chat_thread = ChatThreadOperations(self._client, self._config,
                                                self._serialize,
                                                self._deserialize)
        self.chat = ChatOperations(self._client, self._config, self._serialize,
                                   self._deserialize)

    async def _send_request(self, http_request: HttpRequest,
                            **kwargs: Any) -> AsyncHttpResponse:
        """Runs the network request through the client's chained policies.

        :param http_request: The network request you want to make. Required.
        :type http_request: ~azure.core.pipeline.transport.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to True.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
        """
        path_format_arguments = {
            'endpoint':
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }
        http_request.url = self._client.format_url(http_request.url,
                                                   **path_format_arguments)
        stream = kwargs.pop("stream", True)
        pipeline_response = await self._client._pipeline.run(http_request,
                                                             stream=stream,
                                                             **kwargs)
        return pipeline_response.http_response

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "AzureCommunicationChatService":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
    def __init__(self, credential: "AsyncTokenCredential", endpoint: str,
                 **kwargs: Any) -> None:
        base_url = '{Endpoint}'
        self._config = FarmBeatsClientConfiguration(credential, endpoint,
                                                    **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._serialize.client_side_validation = False
        self._deserialize = Deserializer(client_models)

        self.application_data = ApplicationDataOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.attachments = AttachmentsOperations(self._client, self._config,
                                                 self._serialize,
                                                 self._deserialize)
        self.boundaries = BoundariesOperations(self._client, self._config,
                                               self._serialize,
                                               self._deserialize)
        self.crops = CropsOperations(self._client, self._config,
                                     self._serialize, self._deserialize)
        self.crop_varieties = CropVarietiesOperations(self._client,
                                                      self._config,
                                                      self._serialize,
                                                      self._deserialize)
        self.farmers = FarmersOperations(self._client, self._config,
                                         self._serialize, self._deserialize)
        self.farm_operations = FarmOperationsOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.farms = FarmsOperations(self._client, self._config,
                                     self._serialize, self._deserialize)
        self.fields = FieldsOperations(self._client, self._config,
                                       self._serialize, self._deserialize)
        self.harvest_data = HarvestDataOperations(self._client, self._config,
                                                  self._serialize,
                                                  self._deserialize)
        self.image_processing = ImageProcessingOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.oauth_providers = OAuthProvidersOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.oauth_tokens = OAuthTokensOperations(self._client, self._config,
                                                  self._serialize,
                                                  self._deserialize)
        self.planting_data = PlantingDataOperations(self._client, self._config,
                                                    self._serialize,
                                                    self._deserialize)
        self.scenes = ScenesOperations(self._client, self._config,
                                       self._serialize, self._deserialize)
        self.seasonal_fields = SeasonalFieldsOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.seasons = SeasonsOperations(self._client, self._config,
                                         self._serialize, self._deserialize)
        self.tillage_data = TillageDataOperations(self._client, self._config,
                                                  self._serialize,
                                                  self._deserialize)
        self.weather = WeatherOperations(self._client, self._config,
                                         self._serialize, self._deserialize)
Exemplo n.º 20
0
class PurviewAccountClient:
    """Creates a Microsoft.Purview data plane account client.

    :ivar accounts: AccountsOperations operations
    :vartype accounts: azure.purview.administration.account.aio.operations.AccountsOperations
    :ivar collections: CollectionsOperations operations
    :vartype collections: azure.purview.administration.account.aio.operations.CollectionsOperations
    :ivar resource_set_rules: ResourceSetRulesOperations operations
    :vartype resource_set_rules:
     azure.purview.administration.account.aio.operations.ResourceSetRulesOperations
    :param endpoint: The account endpoint of your Purview account. Example:
     https://{accountName}.purview.azure.com/account/.
    :type endpoint: str
    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials_async.AsyncTokenCredential
    """
    def __init__(self, endpoint: str, credential: "AsyncTokenCredential",
                 **kwargs: Any) -> None:
        _endpoint = '{endpoint}'
        self._config = PurviewAccountClientConfiguration(
            endpoint, credential, **kwargs)
        self._client = AsyncPipelineClient(base_url=_endpoint,
                                           config=self._config,
                                           **kwargs)

        self._serialize = Serializer()
        self._deserialize = Deserializer()
        self._serialize.client_side_validation = False
        self.accounts = AccountsOperations(self._client, self._config,
                                           self._serialize, self._deserialize)
        self.collections = CollectionsOperations(self._client, self._config,
                                                 self._serialize,
                                                 self._deserialize)
        self.resource_set_rules = ResourceSetRulesOperations(
            self._client, self._config, self._serialize, self._deserialize)

    def send_request(self, request: HttpRequest,
                     **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        >>> from azure.core.rest import HttpRequest
        >>> request = HttpRequest("GET", "https://www.example.org/")
        <HttpRequest [GET], url: 'https://www.example.org/'>
        >>> response = await client.send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        path_format_arguments = {
            "endpoint":
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }

        request_copy.url = self._client.format_url(request_copy.url,
                                                   **path_format_arguments)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "PurviewAccountClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
Exemplo n.º 21
0
class ContainerRegistry:
    """Metadata API definition for the Azure Container Registry runtime.

    :ivar container_registry: ContainerRegistryOperations operations
    :vartype container_registry: container_registry.aio.operations.ContainerRegistryOperations
    :ivar container_registry_blob: ContainerRegistryBlobOperations operations
    :vartype container_registry_blob:
     container_registry.aio.operations.ContainerRegistryBlobOperations
    :ivar authentication: AuthenticationOperations operations
    :vartype authentication: container_registry.aio.operations.AuthenticationOperations
    :param url: Registry login URL.
    :type url: str
    :keyword api_version: Api Version. The default value is "2021-07-01". Note that overriding this
     default value may result in unsupported behavior.
    :paramtype api_version: str
    """
    def __init__(self, url: str, **kwargs: Any) -> None:
        _base_url = '{url}'
        self._config = ContainerRegistryConfiguration(url=url, **kwargs)
        self._client = AsyncPipelineClient(base_url=_base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)
        self._serialize.client_side_validation = False
        self.container_registry = ContainerRegistryOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.container_registry_blob = ContainerRegistryBlobOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.authentication = AuthenticationOperations(self._client,
                                                       self._config,
                                                       self._serialize,
                                                       self._deserialize)

    def _send_request(self, request: HttpRequest,
                      **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        >>> from azure.core.rest import HttpRequest
        >>> request = HttpRequest("GET", "https://www.example.org/")
        <HttpRequest [GET], url: 'https://www.example.org/'>
        >>> response = await client._send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        path_format_arguments = {
            "url":
            self._serialize.url("self._config.url",
                                self._config.url,
                                'str',
                                skip_quote=True),
        }

        request_copy.url = self._client.format_url(request_copy.url,
                                                   **path_format_arguments)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "ContainerRegistry":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
Exemplo n.º 22
0
class SearchClient(SearchClientOperationsMixin):
    """Client that can be used to manage and query indexes and documents, as well as manage other resources, on a search service.

    :ivar data_sources: DataSourcesOperations operations
    :vartype data_sources: azure.search.documents.indexes.v2020_06_preview.aio.operations.DataSourcesOperations
    :ivar indexers: IndexersOperations operations
    :vartype indexers: azure.search.documents.indexes.v2020_06_preview.aio.operations.IndexersOperations
    :ivar skillsets: SkillsetsOperations operations
    :vartype skillsets: azure.search.documents.indexes.v2020_06_preview.aio.operations.SkillsetsOperations
    :ivar synonym_maps: SynonymMapsOperations operations
    :vartype synonym_maps: azure.search.documents.indexes.v2020_06_preview.aio.operations.SynonymMapsOperations
    :ivar indexes: IndexesOperations operations
    :vartype indexes: azure.search.documents.indexes.v2020_06_preview.aio.operations.IndexesOperations
    :param endpoint: The endpoint URL of the search service.
    :type endpoint: str
    """
    def __init__(self, endpoint: str, **kwargs: Any) -> None:
        base_url = '{endpoint}'
        self._config = SearchClientConfiguration(endpoint, **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._serialize.client_side_validation = False
        self._deserialize = Deserializer(client_models)

        self.data_sources = DataSourcesOperations(self._client, self._config,
                                                  self._serialize,
                                                  self._deserialize)
        self.indexers = IndexersOperations(self._client, self._config,
                                           self._serialize, self._deserialize)
        self.skillsets = SkillsetsOperations(self._client, self._config,
                                             self._serialize,
                                             self._deserialize)
        self.synonym_maps = SynonymMapsOperations(self._client, self._config,
                                                  self._serialize,
                                                  self._deserialize)
        self.indexes = IndexesOperations(self._client, self._config,
                                         self._serialize, self._deserialize)

    async def _send_request(self, http_request: HttpRequest,
                            **kwargs: Any) -> AsyncHttpResponse:
        """Runs the network request through the client's chained policies.

        :param http_request: The network request you want to make. Required.
        :type http_request: ~azure.core.pipeline.transport.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to True.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
        """
        path_format_arguments = {
            'endpoint':
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }
        http_request.url = self._client.format_url(http_request.url,
                                                   **path_format_arguments)
        stream = kwargs.pop("stream", True)
        pipeline_response = await self._client._pipeline.run(http_request,
                                                             stream=stream,
                                                             **kwargs)
        return pipeline_response.http_response

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "SearchClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class AzureFileStorage:
    """AzureFileStorage.

    :ivar service: ServiceOperations operations
    :vartype service: azure.storage.fileshare.aio.operations.ServiceOperations
    :ivar share: ShareOperations operations
    :vartype share: azure.storage.fileshare.aio.operations.ShareOperations
    :ivar directory: DirectoryOperations operations
    :vartype directory: azure.storage.fileshare.aio.operations.DirectoryOperations
    :ivar file: FileOperations operations
    :vartype file: azure.storage.fileshare.aio.operations.FileOperations
    :param url: The URL of the service account, share, directory or file that is the target of the
     desired operation.
    :type url: str
    :param base_url: Service URL. Default value is "".
    :type base_url: str
    :keyword version: Specifies the version of the operation to use for this request. Default value
     is "2021-04-10". Note that overriding this default value may result in unsupported behavior.
    :paramtype version: str
    :keyword file_range_write_from_url: Only update is supported: - Update: Writes the bytes
     downloaded from the source url into the specified range. Default value is "update". Note that
     overriding this default value may result in unsupported behavior.
    :paramtype file_range_write_from_url: str
    """
    def __init__(self, url: str, base_url: str = "", **kwargs: Any) -> None:
        self._config = AzureFileStorageConfiguration(url=url, **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)
        self._serialize.client_side_validation = False
        self.service = ServiceOperations(self._client, self._config,
                                         self._serialize, self._deserialize)
        self.share = ShareOperations(self._client, self._config,
                                     self._serialize, self._deserialize)
        self.directory = DirectoryOperations(self._client, self._config,
                                             self._serialize,
                                             self._deserialize)
        self.file = FileOperations(self._client, self._config, self._serialize,
                                   self._deserialize)

    def _send_request(self, request: HttpRequest,
                      **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        >>> from azure.core.rest import HttpRequest
        >>> request = HttpRequest("GET", "https://www.example.org/")
        <HttpRequest [GET], url: 'https://www.example.org/'>
        >>> response = await client._send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        request_copy.url = self._client.format_url(request_copy.url)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "AzureFileStorage":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class AzureSchemaRegistry:
    """Azure Schema Registry is as a central schema repository, with support for versioning, management, compatibility checking, and RBAC.

    :param endpoint: The Schema Registry service endpoint, for example
     my-namespace.servicebus.windows.net.
    :type endpoint: str
    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials_async.AsyncTokenCredential
    :keyword api_version: Api Version. The default value is "2021-10". Note that overriding this
     default value may result in unsupported behavior.
    :paramtype api_version: str
    """
    def __init__(self, endpoint: str, credential: "AsyncTokenCredential",
                 **kwargs: Any) -> None:
        _endpoint = 'https://{endpoint}'
        self._config = AzureSchemaRegistryConfiguration(endpoint=endpoint,
                                                        credential=credential,
                                                        **kwargs)
        self._client = AsyncPipelineClient(base_url=_endpoint,
                                           config=self._config,
                                           **kwargs)

        self._serialize = Serializer()
        self._deserialize = Deserializer()
        self._serialize.client_side_validation = False

    def send_request(self, request: HttpRequest,
                     **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        We have helper methods to create requests specific to this service in `azure.schemaregistry._generated.rest`.
        Use these helper methods to create the request you pass to this method.

        >>> from azure.schemaregistry._generated.rest import schema_groups
        >>> request = schema_groups.build_list_request(**kwargs)
        <HttpRequest [GET], url: '/$schemaGroups'>
        >>> response = await client.send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        path_format_arguments = {
            "endpoint":
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }

        request_copy.url = self._client.format_url(request_copy.url,
                                                   **path_format_arguments)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "AzureSchemaRegistry":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
class ContainerRegistry(object):
    """Metadata API definition for the Azure Container Registry runtime.

    :ivar container_registry: ContainerRegistryOperations operations
    :vartype container_registry: container_registry.aio.operations.ContainerRegistryOperations
    :ivar container_registry_blob: ContainerRegistryBlobOperations operations
    :vartype container_registry_blob: container_registry.aio.operations.ContainerRegistryBlobOperations
    :ivar authentication: AuthenticationOperations operations
    :vartype authentication: container_registry.aio.operations.AuthenticationOperations
    :param url: Registry login URL.
    :type url: str
    """
    def __init__(self, url: str, **kwargs: Any) -> None:
        base_url = '{url}'
        self._config = ContainerRegistryConfiguration(url, **kwargs)
        self._client = AsyncPipelineClient(base_url=base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._serialize.client_side_validation = False
        self._deserialize = Deserializer(client_models)

        self.container_registry = ContainerRegistryOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.container_registry_blob = ContainerRegistryBlobOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.authentication = AuthenticationOperations(self._client,
                                                       self._config,
                                                       self._serialize,
                                                       self._deserialize)

    async def _send_request(self, http_request: HttpRequest,
                            **kwargs: Any) -> AsyncHttpResponse:
        """Runs the network request through the client's chained policies.

        :param http_request: The network request you want to make. Required.
        :type http_request: ~azure.core.pipeline.transport.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to True.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
        """
        path_format_arguments = {
            'url':
            self._serialize.url("self._config.url",
                                self._config.url,
                                'str',
                                skip_quote=True),
        }
        http_request.url = self._client.format_url(http_request.url,
                                                   **path_format_arguments)
        stream = kwargs.pop("stream", True)
        pipeline_response = await self._client._pipeline.run(http_request,
                                                             stream=stream,
                                                             **kwargs)
        return pipeline_response.http_response

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "ContainerRegistry":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
Exemplo n.º 26
0
class PurviewScanningClient:
    """Creates a Microsoft.Scanning management client.

    :ivar key_vault_connections: KeyVaultConnectionsOperations operations
    :vartype key_vault_connections:
     azure.purview.scanning.aio.operations.KeyVaultConnectionsOperations
    :ivar classification_rules: ClassificationRulesOperations operations
    :vartype classification_rules:
     azure.purview.scanning.aio.operations.ClassificationRulesOperations
    :ivar data_sources: DataSourcesOperations operations
    :vartype data_sources: azure.purview.scanning.aio.operations.DataSourcesOperations
    :ivar filters: FiltersOperations operations
    :vartype filters: azure.purview.scanning.aio.operations.FiltersOperations
    :ivar scans: ScansOperations operations
    :vartype scans: azure.purview.scanning.aio.operations.ScansOperations
    :ivar scan_result: ScanResultOperations operations
    :vartype scan_result: azure.purview.scanning.aio.operations.ScanResultOperations
    :ivar scan_rulesets: ScanRulesetsOperations operations
    :vartype scan_rulesets: azure.purview.scanning.aio.operations.ScanRulesetsOperations
    :ivar system_scan_rulesets: SystemScanRulesetsOperations operations
    :vartype system_scan_rulesets:
     azure.purview.scanning.aio.operations.SystemScanRulesetsOperations
    :ivar triggers: TriggersOperations operations
    :vartype triggers: azure.purview.scanning.aio.operations.TriggersOperations
    :param endpoint: The scanning endpoint of your purview account. Example:
     https://{accountName}.scan.purview.azure.com.
    :type endpoint: str
    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials_async.AsyncTokenCredential
    """
    def __init__(self, endpoint: str, credential: "AsyncTokenCredential",
                 **kwargs: Any) -> None:
        _endpoint = '{Endpoint}'
        self._config = PurviewScanningClientConfiguration(
            endpoint, credential, **kwargs)
        self._client = AsyncPipelineClient(base_url=_endpoint,
                                           config=self._config,
                                           **kwargs)

        self._serialize = Serializer()
        self._deserialize = Deserializer()
        self._serialize.client_side_validation = False
        self.key_vault_connections = KeyVaultConnectionsOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.classification_rules = ClassificationRulesOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.data_sources = DataSourcesOperations(self._client, self._config,
                                                  self._serialize,
                                                  self._deserialize)
        self.filters = FiltersOperations(self._client, self._config,
                                         self._serialize, self._deserialize)
        self.scans = ScansOperations(self._client, self._config,
                                     self._serialize, self._deserialize)
        self.scan_result = ScanResultOperations(self._client, self._config,
                                                self._serialize,
                                                self._deserialize)
        self.scan_rulesets = ScanRulesetsOperations(self._client, self._config,
                                                    self._serialize,
                                                    self._deserialize)
        self.system_scan_rulesets = SystemScanRulesetsOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.triggers = TriggersOperations(self._client, self._config,
                                           self._serialize, self._deserialize)

    def send_request(self, request: HttpRequest,
                     **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        >>> from azure.core.rest import HttpRequest
        >>> request = HttpRequest("GET", "https://www.example.org/")
        <HttpRequest [GET], url: 'https://www.example.org/'>
        >>> response = await client.send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        path_format_arguments = {
            "Endpoint":
            self._serialize.url("self._config.endpoint",
                                self._config.endpoint,
                                'str',
                                skip_quote=True),
        }

        request_copy.url = self._client.format_url(request_copy.url,
                                                   **path_format_arguments)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "PurviewScanningClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
Exemplo n.º 27
0
async def test_add_custom_policy():
    class BooPolicy(AsyncHTTPPolicy):
        def send(*args):
            raise AzureError('boo')

    class FooPolicy(AsyncHTTPPolicy):
        def send(*args):
            raise AzureError('boo')

    config = Configuration()
    retry_policy = AsyncRetryPolicy()
    config.retry_policy = retry_policy
    boo_policy = BooPolicy()
    foo_policy = FooPolicy()
    client = AsyncPipelineClient(base_url="test",
                                 config=config,
                                 per_call_policies=boo_policy)
    policies = client._pipeline._impl_policies
    assert boo_policy in policies
    pos_boo = policies.index(boo_policy)
    pos_retry = policies.index(retry_policy)
    assert pos_boo < pos_retry

    client = AsyncPipelineClient(base_url="test",
                                 config=config,
                                 per_call_policies=[boo_policy])
    policies = client._pipeline._impl_policies
    assert boo_policy in policies
    pos_boo = policies.index(boo_policy)
    pos_retry = policies.index(retry_policy)
    assert pos_boo < pos_retry

    client = AsyncPipelineClient(base_url="test",
                                 config=config,
                                 per_retry_policies=boo_policy)
    policies = client._pipeline._impl_policies
    assert boo_policy in policies
    pos_boo = policies.index(boo_policy)
    pos_retry = policies.index(retry_policy)
    assert pos_boo > pos_retry

    client = AsyncPipelineClient(base_url="test",
                                 config=config,
                                 per_retry_policies=[boo_policy])
    policies = client._pipeline._impl_policies
    assert boo_policy in policies
    pos_boo = policies.index(boo_policy)
    pos_retry = policies.index(retry_policy)
    assert pos_boo > pos_retry

    client = AsyncPipelineClient(base_url="test",
                                 config=config,
                                 per_call_policies=boo_policy,
                                 per_retry_policies=foo_policy)
    policies = client._pipeline._impl_policies
    assert boo_policy in policies
    assert foo_policy in policies
    pos_boo = policies.index(boo_policy)
    pos_foo = policies.index(foo_policy)
    pos_retry = policies.index(retry_policy)
    assert pos_boo < pos_retry
    assert pos_foo > pos_retry

    client = AsyncPipelineClient(base_url="test",
                                 config=config,
                                 per_call_policies=[boo_policy],
                                 per_retry_policies=[foo_policy])
    policies = client._pipeline._impl_policies
    assert boo_policy in policies
    assert foo_policy in policies
    pos_boo = policies.index(boo_policy)
    pos_foo = policies.index(foo_policy)
    pos_retry = policies.index(retry_policy)
    assert pos_boo < pos_retry
    assert pos_foo > pos_retry

    policies = [
        UserAgentPolicy(),
        AsyncRetryPolicy(),
        DistributedTracingPolicy()
    ]
    client = AsyncPipelineClient(base_url="test",
                                 policies=policies,
                                 per_call_policies=boo_policy)
    actual_policies = client._pipeline._impl_policies
    assert boo_policy == actual_policies[0]
    client = AsyncPipelineClient(base_url="test",
                                 policies=policies,
                                 per_call_policies=[boo_policy])
    actual_policies = client._pipeline._impl_policies
    assert boo_policy == actual_policies[0]

    client = AsyncPipelineClient(base_url="test",
                                 policies=policies,
                                 per_retry_policies=foo_policy)
    actual_policies = client._pipeline._impl_policies
    assert foo_policy == actual_policies[2]
    client = AsyncPipelineClient(base_url="test",
                                 policies=policies,
                                 per_retry_policies=[foo_policy])
    actual_policies = client._pipeline._impl_policies
    assert foo_policy == actual_policies[2]

    client = AsyncPipelineClient(base_url="test",
                                 policies=policies,
                                 per_call_policies=boo_policy,
                                 per_retry_policies=[foo_policy])
    actual_policies = client._pipeline._impl_policies
    assert boo_policy == actual_policies[0]
    assert foo_policy == actual_policies[3]
    client = AsyncPipelineClient(base_url="test",
                                 policies=policies,
                                 per_call_policies=[boo_policy],
                                 per_retry_policies=[foo_policy])
    actual_policies = client._pipeline._impl_policies
    assert boo_policy == actual_policies[0]
    assert foo_policy == actual_policies[3]

    policies = [UserAgentPolicy(), DistributedTracingPolicy()]
    with pytest.raises(ValueError):
        client = AsyncPipelineClient(base_url="test",
                                     policies=policies,
                                     per_retry_policies=foo_policy)
    with pytest.raises(ValueError):
        client = AsyncPipelineClient(base_url="test",
                                     policies=policies,
                                     per_retry_policies=[foo_policy])
Exemplo n.º 28
0
def client():
    # The poller itself don't use it, so we don't need something functionnal
    return AsyncPipelineClient("https://baseurl")
Exemplo n.º 29
0
def test_default_http_logging_policy():
    config = Configuration()
    pipeline_client = AsyncPipelineClient(base_url="test")
    pipeline = pipeline_client._build_pipeline(config)
    http_logging_policy = pipeline._impl_policies[-1]._policy
    assert http_logging_policy.allowed_header_names == HttpLoggingPolicy.DEFAULT_HEADERS_WHITELIST
Exemplo n.º 30
0
class AzureMonitorClient(AzureMonitorClientOperationsMixin):
    """OpenTelemetry Exporter for Azure Monitor.

    :param host: Breeze endpoint: https://dc.services.visualstudio.com. Default value is
     "https://dc.services.visualstudio.com".
    :type host: str
    """
    def __init__(self,
                 host: str = "https://dc.services.visualstudio.com",
                 **kwargs: Any) -> None:
        _base_url = '{Host}/v2.1'
        self._config = AzureMonitorClientConfiguration(host=host, **kwargs)
        self._client = AsyncPipelineClient(base_url=_base_url,
                                           config=self._config,
                                           **kwargs)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)
        self._serialize.client_side_validation = False

    def _send_request(self, request: HttpRequest,
                      **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
        """Runs the network request through the client's chained policies.

        >>> from azure.core.rest import HttpRequest
        >>> request = HttpRequest("GET", "https://www.example.org/")
        <HttpRequest [GET], url: 'https://www.example.org/'>
        >>> response = await client._send_request(request)
        <AsyncHttpResponse: 200 OK>

        For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

        :param request: The network request you want to make. Required.
        :type request: ~azure.core.rest.HttpRequest
        :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
        :return: The response of your network call. Does not do error handling on your response.
        :rtype: ~azure.core.rest.AsyncHttpResponse
        """

        request_copy = deepcopy(request)
        path_format_arguments = {
            "Host":
            self._serialize.url("self._config.host",
                                self._config.host,
                                'str',
                                skip_quote=True),
        }

        request_copy.url = self._client.format_url(request_copy.url,
                                                   **path_format_arguments)
        return self._client.send_request(request_copy, **kwargs)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "AzureMonitorClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)