|
| 1 | +# pylint: disable=line-too-long,useless-suppression |
| 2 | +# coding=utf-8 |
| 3 | +# -------------------------------------------------------------------------- |
| 4 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 5 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
| 6 | +# Code generated by Microsoft (R) Python Code Generator. |
| 7 | +# Changes may cause incorrect behavior and will be lost if the code is regenerated. |
| 8 | +# -------------------------------------------------------------------------- |
| 9 | + |
| 10 | +from copy import deepcopy |
| 11 | +from typing import Any, TYPE_CHECKING, Union |
| 12 | +from typing_extensions import Self |
| 13 | + |
| 14 | +from azure.core import PipelineClient |
| 15 | +from azure.core.credentials import AzureKeyCredential |
| 16 | +from azure.core.pipeline import policies |
| 17 | +from azure.core.rest import HttpRequest, HttpResponse |
| 18 | + |
| 19 | +from ._configuration import AssistantsClientConfiguration |
| 20 | +from ._operations import AssistantsClientOperationsMixin |
| 21 | +from ._serialization import Deserializer, Serializer |
| 22 | + |
| 23 | +if TYPE_CHECKING: |
| 24 | + from azure.core.credentials import TokenCredential |
| 25 | + |
| 26 | + |
| 27 | +class AssistantsClient(AssistantsClientOperationsMixin): |
| 28 | + """AssistantsClient. |
| 29 | +
|
| 30 | + :param endpoint: The Azure AI Foundry project endpoint, in the form |
| 31 | + ``https://<azure-region>.api.azureml.ms`` or |
| 32 | + ``https://<private-link-guid>.<azure-region>.api.azureml.ms``, where <azure-region> is the |
| 33 | + Azure region where the project is deployed (e.g. westus) and <private-link-guid> is the GUID of |
| 34 | + the Enterprise private link. Required. |
| 35 | + :type endpoint: str |
| 36 | + :param subscription_id: The Azure subscription ID. Required. |
| 37 | + :type subscription_id: str |
| 38 | + :param resource_group_name: The name of the Azure Resource Group. Required. |
| 39 | + :type resource_group_name: str |
| 40 | + :param project_name: The Azure AI Foundry project name. Required. |
| 41 | + :type project_name: str |
| 42 | + :param credential: Credential used to authenticate requests to the service. Is either a key |
| 43 | + credential type or a token credential type. Required. |
| 44 | + :type credential: ~azure.core.credentials.AzureKeyCredential or |
| 45 | + ~azure.core.credentials.TokenCredential |
| 46 | + :keyword api_version: The API version to use for this operation. Default value is |
| 47 | + "2025-05-15-preview". Note that overriding this default value may result in unsupported |
| 48 | + behavior. |
| 49 | + :paramtype api_version: str |
| 50 | + """ |
| 51 | + |
| 52 | + def __init__( |
| 53 | + self, |
| 54 | + endpoint: str, |
| 55 | + subscription_id: str, |
| 56 | + resource_group_name: str, |
| 57 | + project_name: str, |
| 58 | + credential: Union[AzureKeyCredential, "TokenCredential"], |
| 59 | + **kwargs: Any |
| 60 | + ) -> None: |
| 61 | + _endpoint = "{endpoint}/agents/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{projectName}" |
| 62 | + self._config = AssistantsClientConfiguration( |
| 63 | + endpoint=endpoint, |
| 64 | + subscription_id=subscription_id, |
| 65 | + resource_group_name=resource_group_name, |
| 66 | + project_name=project_name, |
| 67 | + credential=credential, |
| 68 | + **kwargs |
| 69 | + ) |
| 70 | + _policies = kwargs.pop("policies", None) |
| 71 | + if _policies is None: |
| 72 | + _policies = [ |
| 73 | + policies.RequestIdPolicy(**kwargs), |
| 74 | + self._config.headers_policy, |
| 75 | + self._config.user_agent_policy, |
| 76 | + self._config.proxy_policy, |
| 77 | + policies.ContentDecodePolicy(**kwargs), |
| 78 | + self._config.redirect_policy, |
| 79 | + self._config.retry_policy, |
| 80 | + self._config.authentication_policy, |
| 81 | + self._config.custom_hook_policy, |
| 82 | + self._config.logging_policy, |
| 83 | + policies.DistributedTracingPolicy(**kwargs), |
| 84 | + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, |
| 85 | + self._config.http_logging_policy, |
| 86 | + ] |
| 87 | + self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) |
| 88 | + |
| 89 | + self._serialize = Serializer() |
| 90 | + self._deserialize = Deserializer() |
| 91 | + self._serialize.client_side_validation = False |
| 92 | + |
| 93 | + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: |
| 94 | + """Runs the network request through the client's chained policies. |
| 95 | +
|
| 96 | + >>> from azure.core.rest import HttpRequest |
| 97 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 98 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 99 | + >>> response = client.send_request(request) |
| 100 | + <HttpResponse: 200 OK> |
| 101 | +
|
| 102 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 103 | +
|
| 104 | + :param request: The network request you want to make. Required. |
| 105 | + :type request: ~azure.core.rest.HttpRequest |
| 106 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
| 107 | + :return: The response of your network call. Does not do error handling on your response. |
| 108 | + :rtype: ~azure.core.rest.HttpResponse |
| 109 | + """ |
| 110 | + |
| 111 | + request_copy = deepcopy(request) |
| 112 | + path_format_arguments = { |
| 113 | + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str"), |
| 114 | + "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"), |
| 115 | + "resourceGroupName": self._serialize.url( |
| 116 | + "self._config.resource_group_name", self._config.resource_group_name, "str" |
| 117 | + ), |
| 118 | + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), |
| 119 | + } |
| 120 | + |
| 121 | + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) |
| 122 | + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore |
| 123 | + |
| 124 | + def close(self) -> None: |
| 125 | + self._client.close() |
| 126 | + |
| 127 | + def __enter__(self) -> Self: |
| 128 | + self._client.__enter__() |
| 129 | + return self |
| 130 | + |
| 131 | + def __exit__(self, *exc_details: Any) -> None: |
| 132 | + self._client.__exit__(*exc_details) |
0 commit comments