|
1 |
| -# coding=utf-8 |
2 |
| -# -------------------------------------------------------------------------- |
3 |
| -# Copyright (c) Microsoft Corporation. All rights reserved. |
4 |
| -# Licensed under the MIT License. See License.txt in the project root for license information. |
5 |
| -# Code generated by Microsoft (R) Python Code Generator. |
6 |
| -# Changes may cause incorrect behavior and will be lost if the code is regenerated. |
7 |
| -# -------------------------------------------------------------------------- |
8 |
| - |
9 |
| -from copy import deepcopy |
10 |
| -from typing import Any, TYPE_CHECKING, Union |
11 |
| -from typing_extensions import Self |
12 |
| - |
13 |
| -from azure.core import PipelineClient |
14 |
| -from azure.core.credentials import AzureKeyCredential |
15 |
| -from azure.core.pipeline import policies |
16 |
| -from azure.core.rest import HttpRequest, HttpResponse |
17 |
| - |
18 |
| -from ._configuration import AIProjectClientConfiguration |
19 |
| -from ._serialization import Deserializer, Serializer |
20 |
| -from .operations import ( |
21 |
| - ConnectionsOperations, |
22 |
| - DatasetsOperations, |
23 |
| - DeploymentsOperations, |
24 |
| - EvaluationResultsOperations, |
25 |
| - EvaluationsOperations, |
26 |
| - IndexesOperations, |
27 |
| - RedTeamsOperations, |
28 |
| - ServicePatternsOperations, |
29 |
| -) |
30 |
| - |
31 |
| -if TYPE_CHECKING: |
32 |
| - from azure.core.credentials import TokenCredential |
33 |
| - |
34 |
| - |
35 |
| -class AIProjectClient: # pylint: disable=too-many-instance-attributes |
36 |
| - """AIProjectClient. |
37 |
| -
|
38 |
| - :ivar service_patterns: ServicePatternsOperations operations |
39 |
| - :vartype service_patterns: azure.ai.projects.onedp.operations.ServicePatternsOperations |
40 |
| - :ivar connections: ConnectionsOperations operations |
41 |
| - :vartype connections: azure.ai.projects.onedp.operations.ConnectionsOperations |
42 |
| - :ivar evaluations: EvaluationsOperations operations |
43 |
| - :vartype evaluations: azure.ai.projects.onedp.operations.EvaluationsOperations |
44 |
| - :ivar datasets: DatasetsOperations operations |
45 |
| - :vartype datasets: azure.ai.projects.onedp.operations.DatasetsOperations |
46 |
| - :ivar indexes: IndexesOperations operations |
47 |
| - :vartype indexes: azure.ai.projects.onedp.operations.IndexesOperations |
48 |
| - :ivar deployments: DeploymentsOperations operations |
49 |
| - :vartype deployments: azure.ai.projects.onedp.operations.DeploymentsOperations |
50 |
| - :ivar red_teams: RedTeamsOperations operations |
51 |
| - :vartype red_teams: azure.ai.projects.onedp.operations.RedTeamsOperations |
52 |
| - :ivar evaluation_results: EvaluationResultsOperations operations |
53 |
| - :vartype evaluation_results: azure.ai.projects.onedp.operations.EvaluationResultsOperations |
54 |
| - :param endpoint: Project endpoint in the form of: |
55 |
| - https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. Required. |
56 |
| - :type endpoint: str |
57 |
| - :param credential: Credential used to authenticate requests to the service. Is either a key |
58 |
| - credential type or a token credential type. Required. |
59 |
| - :type credential: ~azure.core.credentials.AzureKeyCredential or |
60 |
| - ~azure.core.credentials.TokenCredential |
61 |
| - :keyword api_version: The API version to use for this operation. Default value is |
62 |
| - "2025-05-15-preview". Note that overriding this default value may result in unsupported |
63 |
| - behavior. |
64 |
| - :paramtype api_version: str |
65 |
| - """ |
66 |
| - |
67 |
| - def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None: |
68 |
| - _endpoint = "{endpoint}" |
69 |
| - self._config = AIProjectClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) |
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 |
| - self.service_patterns = ServicePatternsOperations( |
93 |
| - self._client, self._config, self._serialize, self._deserialize |
94 |
| - ) |
95 |
| - self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) |
96 |
| - self.evaluations = EvaluationsOperations(self._client, self._config, self._serialize, self._deserialize) |
97 |
| - self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize) |
98 |
| - self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize) |
99 |
| - self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) |
100 |
| - self.red_teams = RedTeamsOperations(self._client, self._config, self._serialize, self._deserialize) |
101 |
| - self.evaluation_results = EvaluationResultsOperations( |
102 |
| - self._client, self._config, self._serialize, self._deserialize |
103 |
| - ) |
104 |
| - |
105 |
| - def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: |
106 |
| - """Runs the network request through the client's chained policies. |
107 |
| -
|
108 |
| - >>> from azure.core.rest import HttpRequest |
109 |
| - >>> request = HttpRequest("GET", "https://www.example.org/") |
110 |
| - <HttpRequest [GET], url: 'https://www.example.org/'> |
111 |
| - >>> response = client.send_request(request) |
112 |
| - <HttpResponse: 200 OK> |
113 |
| -
|
114 |
| - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
115 |
| -
|
116 |
| - :param request: The network request you want to make. Required. |
117 |
| - :type request: ~azure.core.rest.HttpRequest |
118 |
| - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
119 |
| - :return: The response of your network call. Does not do error handling on your response. |
120 |
| - :rtype: ~azure.core.rest.HttpResponse |
121 |
| - """ |
122 |
| - |
123 |
| - request_copy = deepcopy(request) |
124 |
| - path_format_arguments = { |
125 |
| - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), |
126 |
| - } |
127 |
| - |
128 |
| - request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) |
129 |
| - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore |
130 |
| - |
131 |
| - def close(self) -> None: |
132 |
| - self._client.close() |
133 |
| - |
134 |
| - def __enter__(self) -> Self: |
135 |
| - self._client.__enter__() |
136 |
| - return self |
137 |
| - |
138 |
| - def __exit__(self, *exc_details: Any) -> None: |
139 |
| - self._client.__exit__(*exc_details) |
| 1 | +# coding=utf-8 |
| 2 | +# -------------------------------------------------------------------------- |
| 3 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
| 5 | +# Code generated by Microsoft (R) Python Code Generator. |
| 6 | +# Changes may cause incorrect behavior and will be lost if the code is regenerated. |
| 7 | +# -------------------------------------------------------------------------- |
| 8 | + |
| 9 | +from copy import deepcopy |
| 10 | +from typing import Any, TYPE_CHECKING |
| 11 | +from typing_extensions import Self |
| 12 | + |
| 13 | +from azure.core import PipelineClient |
| 14 | +from azure.core.pipeline import policies |
| 15 | +from azure.core.rest import HttpRequest, HttpResponse |
| 16 | + |
| 17 | +from ._configuration import AIProjectClientConfiguration |
| 18 | +from ._utils.serialization import Deserializer, Serializer |
| 19 | +from .operations import ( |
| 20 | + ConnectionsOperations, |
| 21 | + DatasetsOperations, |
| 22 | + DeploymentsOperations, |
| 23 | + EvaluationResultsOperations, |
| 24 | + EvaluationsOperations, |
| 25 | + IndexesOperations, |
| 26 | + RedTeamsOperations, |
| 27 | +) |
| 28 | + |
| 29 | +if TYPE_CHECKING: |
| 30 | + from azure.core.credentials import TokenCredential |
| 31 | + |
| 32 | + |
| 33 | +class AIProjectClient: # pylint: disable=too-many-instance-attributes |
| 34 | + """AIProjectClient. |
| 35 | +
|
| 36 | + :ivar connections: ConnectionsOperations operations |
| 37 | + :vartype connections: azure.ai.projects.onedp.operations.ConnectionsOperations |
| 38 | + :ivar evaluations: EvaluationsOperations operations |
| 39 | + :vartype evaluations: azure.ai.projects.onedp.operations.EvaluationsOperations |
| 40 | + :ivar datasets: DatasetsOperations operations |
| 41 | + :vartype datasets: azure.ai.projects.onedp.operations.DatasetsOperations |
| 42 | + :ivar indexes: IndexesOperations operations |
| 43 | + :vartype indexes: azure.ai.projects.onedp.operations.IndexesOperations |
| 44 | + :ivar deployments: DeploymentsOperations operations |
| 45 | + :vartype deployments: azure.ai.projects.onedp.operations.DeploymentsOperations |
| 46 | + :ivar red_teams: RedTeamsOperations operations |
| 47 | + :vartype red_teams: azure.ai.projects.onedp.operations.RedTeamsOperations |
| 48 | + :ivar evaluation_results: EvaluationResultsOperations operations |
| 49 | + :vartype evaluation_results: azure.ai.projects.onedp.operations.EvaluationResultsOperations |
| 50 | + :param endpoint: Project endpoint. In the form |
| 51 | + "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project" |
| 52 | + if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the |
| 53 | + form |
| 54 | + "https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>" |
| 55 | + if you want to explicitly |
| 56 | + specify the Foundry Project name. Required. |
| 57 | + :type endpoint: str |
| 58 | + :param credential: Credential used to authenticate requests to the service. Required. |
| 59 | + :type credential: ~azure.core.credentials.TokenCredential |
| 60 | + :keyword api_version: The API version to use for this operation. Default value is |
| 61 | + "2025-05-15-preview". Note that overriding this default value may result in unsupported |
| 62 | + behavior. |
| 63 | + :paramtype api_version: str |
| 64 | + """ |
| 65 | + |
| 66 | + def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: |
| 67 | + _endpoint = "{endpoint}" |
| 68 | + self._config = AIProjectClientConfiguration(endpoint=endpoint, credential=credential, **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 | + self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 93 | + self.evaluations = EvaluationsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 94 | + self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 95 | + self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 96 | + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 97 | + self.red_teams = RedTeamsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 98 | + self.evaluation_results = EvaluationResultsOperations( |
| 99 | + self._client, self._config, self._serialize, self._deserialize |
| 100 | + ) |
| 101 | + |
| 102 | + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: |
| 103 | + """Runs the network request through the client's chained policies. |
| 104 | +
|
| 105 | + >>> from azure.core.rest import HttpRequest |
| 106 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 107 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 108 | + >>> response = client.send_request(request) |
| 109 | + <HttpResponse: 200 OK> |
| 110 | +
|
| 111 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 112 | +
|
| 113 | + :param request: The network request you want to make. Required. |
| 114 | + :type request: ~azure.core.rest.HttpRequest |
| 115 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
| 116 | + :return: The response of your network call. Does not do error handling on your response. |
| 117 | + :rtype: ~azure.core.rest.HttpResponse |
| 118 | + """ |
| 119 | + |
| 120 | + request_copy = deepcopy(request) |
| 121 | + path_format_arguments = { |
| 122 | + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), |
| 123 | + } |
| 124 | + |
| 125 | + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) |
| 126 | + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore |
| 127 | + |
| 128 | + def close(self) -> None: |
| 129 | + self._client.close() |
| 130 | + |
| 131 | + def __enter__(self) -> Self: |
| 132 | + self._client.__enter__() |
| 133 | + return self |
| 134 | + |
| 135 | + def __exit__(self, *exc_details: Any) -> None: |
| 136 | + self._client.__exit__(*exc_details) |
0 commit comments