azure-ai-evaluation 1.5.0__py3-none-any.whl → 1.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of azure-ai-evaluation might be problematic. Click here for more details.
- azure/ai/evaluation/__init__.py +10 -0
- azure/ai/evaluation/_aoai/__init__.py +10 -0
- azure/ai/evaluation/_aoai/aoai_grader.py +89 -0
- azure/ai/evaluation/_aoai/label_grader.py +66 -0
- azure/ai/evaluation/_aoai/string_check_grader.py +65 -0
- azure/ai/evaluation/_aoai/text_similarity_grader.py +88 -0
- azure/ai/evaluation/_azure/_clients.py +4 -4
- azure/ai/evaluation/_azure/_envs.py +208 -0
- azure/ai/evaluation/_azure/_token_manager.py +12 -7
- azure/ai/evaluation/_common/__init__.py +7 -0
- azure/ai/evaluation/_common/evaluation_onedp_client.py +163 -0
- azure/ai/evaluation/_common/onedp/__init__.py +32 -0
- azure/ai/evaluation/_common/onedp/_client.py +139 -0
- azure/ai/evaluation/_common/onedp/_configuration.py +73 -0
- azure/ai/evaluation/_common/onedp/_model_base.py +1232 -0
- azure/ai/evaluation/_common/onedp/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/_serialization.py +2032 -0
- azure/ai/evaluation/_common/onedp/_types.py +21 -0
- azure/ai/evaluation/_common/onedp/_validation.py +50 -0
- azure/ai/evaluation/_common/onedp/_vendor.py +50 -0
- azure/ai/evaluation/_common/onedp/_version.py +9 -0
- azure/ai/evaluation/_common/onedp/aio/__init__.py +29 -0
- azure/ai/evaluation/_common/onedp/aio/_client.py +143 -0
- azure/ai/evaluation/_common/onedp/aio/_configuration.py +75 -0
- azure/ai/evaluation/_common/onedp/aio/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/aio/_vendor.py +40 -0
- azure/ai/evaluation/_common/onedp/aio/operations/__init__.py +39 -0
- azure/ai/evaluation/_common/onedp/aio/operations/_operations.py +4494 -0
- azure/ai/evaluation/_common/onedp/aio/operations/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/models/__init__.py +142 -0
- azure/ai/evaluation/_common/onedp/models/_enums.py +162 -0
- azure/ai/evaluation/_common/onedp/models/_models.py +2228 -0
- azure/ai/evaluation/_common/onedp/models/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/operations/__init__.py +39 -0
- azure/ai/evaluation/_common/onedp/operations/_operations.py +5655 -0
- azure/ai/evaluation/_common/onedp/operations/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/py.typed +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/__init__.py +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/aio/__init__.py +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/__init__.py +25 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/_operations.py +34 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/__init__.py +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/__init__.py +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/__init__.py +22 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/_operations.py +29 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/__init__.py +22 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/_operations.py +29 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/operations/__init__.py +25 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/operations/_operations.py +34 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/rai_service.py +165 -34
- azure/ai/evaluation/_common/raiclient/_version.py +1 -1
- azure/ai/evaluation/_common/utils.py +79 -1
- azure/ai/evaluation/_constants.py +16 -0
- azure/ai/evaluation/_converters/_ai_services.py +162 -118
- azure/ai/evaluation/_converters/_models.py +76 -6
- azure/ai/evaluation/_eval_mapping.py +73 -0
- azure/ai/evaluation/_evaluate/_batch_run/_run_submitter_client.py +30 -16
- azure/ai/evaluation/_evaluate/_batch_run/eval_run_context.py +8 -0
- azure/ai/evaluation/_evaluate/_batch_run/proxy_client.py +5 -0
- azure/ai/evaluation/_evaluate/_batch_run/target_run_context.py +17 -1
- azure/ai/evaluation/_evaluate/_eval_run.py +1 -1
- azure/ai/evaluation/_evaluate/_evaluate.py +325 -76
- azure/ai/evaluation/_evaluate/_evaluate_aoai.py +553 -0
- azure/ai/evaluation/_evaluate/_utils.py +117 -4
- azure/ai/evaluation/_evaluators/_bleu/_bleu.py +11 -1
- azure/ai/evaluation/_evaluators/_code_vulnerability/_code_vulnerability.py +9 -1
- azure/ai/evaluation/_evaluators/_coherence/_coherence.py +12 -2
- azure/ai/evaluation/_evaluators/_common/_base_eval.py +12 -3
- azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py +12 -3
- azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py +2 -2
- azure/ai/evaluation/_evaluators/_content_safety/_content_safety.py +12 -2
- azure/ai/evaluation/_evaluators/_content_safety/_hate_unfairness.py +14 -4
- azure/ai/evaluation/_evaluators/_content_safety/_self_harm.py +9 -8
- azure/ai/evaluation/_evaluators/_content_safety/_sexual.py +10 -0
- azure/ai/evaluation/_evaluators/_content_safety/_violence.py +10 -0
- azure/ai/evaluation/_evaluators/_document_retrieval/__init__.py +11 -0
- azure/ai/evaluation/_evaluators/_document_retrieval/_document_retrieval.py +469 -0
- azure/ai/evaluation/_evaluators/_f1_score/_f1_score.py +10 -0
- azure/ai/evaluation/_evaluators/_fluency/_fluency.py +11 -1
- azure/ai/evaluation/_evaluators/_gleu/_gleu.py +10 -0
- azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py +11 -1
- azure/ai/evaluation/_evaluators/_intent_resolution/_intent_resolution.py +16 -2
- azure/ai/evaluation/_evaluators/_meteor/_meteor.py +10 -0
- azure/ai/evaluation/_evaluators/_protected_material/_protected_material.py +11 -0
- azure/ai/evaluation/_evaluators/_qa/_qa.py +10 -0
- azure/ai/evaluation/_evaluators/_relevance/_relevance.py +11 -1
- azure/ai/evaluation/_evaluators/_response_completeness/_response_completeness.py +20 -2
- azure/ai/evaluation/_evaluators/_response_completeness/response_completeness.prompty +31 -46
- azure/ai/evaluation/_evaluators/_retrieval/_retrieval.py +10 -0
- azure/ai/evaluation/_evaluators/_rouge/_rouge.py +10 -0
- azure/ai/evaluation/_evaluators/_service_groundedness/_service_groundedness.py +10 -0
- azure/ai/evaluation/_evaluators/_similarity/_similarity.py +11 -1
- azure/ai/evaluation/_evaluators/_task_adherence/_task_adherence.py +16 -2
- azure/ai/evaluation/_evaluators/_tool_call_accuracy/_tool_call_accuracy.py +86 -12
- azure/ai/evaluation/_evaluators/_ungrounded_attributes/_ungrounded_attributes.py +10 -0
- azure/ai/evaluation/_evaluators/_xpia/xpia.py +11 -0
- azure/ai/evaluation/_exceptions.py +2 -0
- azure/ai/evaluation/_legacy/_adapters/__init__.py +0 -14
- azure/ai/evaluation/_legacy/_adapters/_check.py +17 -0
- azure/ai/evaluation/_legacy/_adapters/_flows.py +1 -1
- azure/ai/evaluation/_legacy/_batch_engine/_engine.py +51 -32
- azure/ai/evaluation/_legacy/_batch_engine/_openai_injector.py +114 -8
- azure/ai/evaluation/_legacy/_batch_engine/_result.py +6 -0
- azure/ai/evaluation/_legacy/_batch_engine/_run.py +6 -0
- azure/ai/evaluation/_legacy/_batch_engine/_run_submitter.py +69 -29
- azure/ai/evaluation/_legacy/_batch_engine/_trace.py +54 -62
- azure/ai/evaluation/_legacy/_batch_engine/_utils.py +19 -1
- azure/ai/evaluation/_legacy/_common/__init__.py +3 -0
- azure/ai/evaluation/_legacy/_common/_async_token_provider.py +124 -0
- azure/ai/evaluation/_legacy/_common/_thread_pool_executor_with_context.py +15 -0
- azure/ai/evaluation/_legacy/prompty/_connection.py +11 -74
- azure/ai/evaluation/_legacy/prompty/_exceptions.py +80 -0
- azure/ai/evaluation/_legacy/prompty/_prompty.py +119 -9
- azure/ai/evaluation/_legacy/prompty/_utils.py +72 -2
- azure/ai/evaluation/_safety_evaluation/_safety_evaluation.py +114 -22
- azure/ai/evaluation/_version.py +1 -1
- azure/ai/evaluation/red_team/_attack_strategy.py +1 -1
- azure/ai/evaluation/red_team/_red_team.py +976 -546
- azure/ai/evaluation/red_team/_utils/metric_mapping.py +23 -0
- azure/ai/evaluation/red_team/_utils/strategy_utils.py +1 -1
- azure/ai/evaluation/simulator/_adversarial_simulator.py +63 -39
- azure/ai/evaluation/simulator/_constants.py +1 -0
- azure/ai/evaluation/simulator/_conversation/__init__.py +13 -6
- azure/ai/evaluation/simulator/_conversation/_conversation.py +2 -1
- azure/ai/evaluation/simulator/_conversation/constants.py +1 -1
- azure/ai/evaluation/simulator/_direct_attack_simulator.py +38 -25
- azure/ai/evaluation/simulator/_helpers/_language_suffix_mapping.py +1 -0
- azure/ai/evaluation/simulator/_indirect_attack_simulator.py +43 -28
- azure/ai/evaluation/simulator/_model_tools/__init__.py +2 -1
- azure/ai/evaluation/simulator/_model_tools/_generated_rai_client.py +26 -18
- azure/ai/evaluation/simulator/_model_tools/_identity_manager.py +5 -10
- azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py +65 -41
- azure/ai/evaluation/simulator/_model_tools/_template_handler.py +15 -10
- azure/ai/evaluation/simulator/_model_tools/models.py +20 -17
- {azure_ai_evaluation-1.5.0.dist-info → azure_ai_evaluation-1.7.0.dist-info}/METADATA +49 -3
- {azure_ai_evaluation-1.5.0.dist-info → azure_ai_evaluation-1.7.0.dist-info}/RECORD +144 -86
- /azure/ai/evaluation/_legacy/{_batch_engine → _common}/_logging.py +0 -0
- {azure_ai_evaluation-1.5.0.dist-info → azure_ai_evaluation-1.7.0.dist-info}/NOTICE.txt +0 -0
- {azure_ai_evaluation-1.5.0.dist-info → azure_ai_evaluation-1.7.0.dist-info}/WHEEL +0 -0
- {azure_ai_evaluation-1.5.0.dist-info → azure_ai_evaluation-1.7.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,4494 @@
|
|
|
1
|
+
# pylint: disable=too-many-lines
|
|
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
|
+
from collections.abc import MutableMapping
|
|
10
|
+
from io import IOBase
|
|
11
|
+
import json
|
|
12
|
+
from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, overload
|
|
13
|
+
import urllib.parse
|
|
14
|
+
|
|
15
|
+
from azure.core import AsyncPipelineClient
|
|
16
|
+
from azure.core.async_paging import AsyncItemPaged, AsyncList
|
|
17
|
+
from azure.core.exceptions import (
|
|
18
|
+
ClientAuthenticationError,
|
|
19
|
+
HttpResponseError,
|
|
20
|
+
ResourceExistsError,
|
|
21
|
+
ResourceNotFoundError,
|
|
22
|
+
ResourceNotModifiedError,
|
|
23
|
+
StreamClosedError,
|
|
24
|
+
StreamConsumedError,
|
|
25
|
+
map_error,
|
|
26
|
+
)
|
|
27
|
+
from azure.core.pipeline import PipelineResponse
|
|
28
|
+
from azure.core.rest import AsyncHttpResponse, HttpRequest
|
|
29
|
+
from azure.core.tracing.decorator import distributed_trace
|
|
30
|
+
from azure.core.tracing.decorator_async import distributed_trace_async
|
|
31
|
+
from azure.core.utils import case_insensitive_dict
|
|
32
|
+
|
|
33
|
+
from ... import models as _models
|
|
34
|
+
from ..._model_base import SdkJSONEncoder, _deserialize
|
|
35
|
+
from ..._serialization import Deserializer, Serializer
|
|
36
|
+
from ..._validation import api_version_validation
|
|
37
|
+
from ...operations._operations import (
|
|
38
|
+
build_connections_get_request,
|
|
39
|
+
build_connections_get_with_credentials_request,
|
|
40
|
+
build_connections_list_request,
|
|
41
|
+
build_datasets_create_or_update_version_request,
|
|
42
|
+
build_datasets_delete_version_request,
|
|
43
|
+
build_datasets_get_credentials_request,
|
|
44
|
+
build_datasets_get_version_request,
|
|
45
|
+
build_datasets_list_latest_request,
|
|
46
|
+
build_datasets_list_versions_request,
|
|
47
|
+
build_datasets_start_pending_upload_version_request,
|
|
48
|
+
build_deployments_get_request,
|
|
49
|
+
build_deployments_list_request,
|
|
50
|
+
build_evaluation_results_create_or_update_version_request,
|
|
51
|
+
build_evaluation_results_delete_version_request,
|
|
52
|
+
build_evaluation_results_get_credentials_request,
|
|
53
|
+
build_evaluation_results_get_version_request,
|
|
54
|
+
build_evaluation_results_list_latest_request,
|
|
55
|
+
build_evaluation_results_list_versions_request,
|
|
56
|
+
build_evaluation_results_start_pending_upload_request,
|
|
57
|
+
build_evaluations_check_annotation_request,
|
|
58
|
+
build_evaluations_create_run_request,
|
|
59
|
+
build_evaluations_get_request,
|
|
60
|
+
build_evaluations_list_request,
|
|
61
|
+
build_evaluations_operation_results_request,
|
|
62
|
+
build_evaluations_submit_annotation_request,
|
|
63
|
+
build_evaluations_upload_run_request,
|
|
64
|
+
build_evaluations_upload_update_run_request,
|
|
65
|
+
build_indexes_create_or_update_version_request,
|
|
66
|
+
build_indexes_delete_version_request,
|
|
67
|
+
build_indexes_get_version_request,
|
|
68
|
+
build_indexes_list_latest_request,
|
|
69
|
+
build_indexes_list_versions_request,
|
|
70
|
+
build_red_teams_create_run_request,
|
|
71
|
+
build_red_teams_get_attack_objectives_request,
|
|
72
|
+
build_red_teams_get_jail_break_dataset_request,
|
|
73
|
+
build_red_teams_get_jail_break_dataset_with_type_request,
|
|
74
|
+
build_red_teams_get_request,
|
|
75
|
+
build_red_teams_get_template_parameters_image_request,
|
|
76
|
+
build_red_teams_get_template_parameters_request,
|
|
77
|
+
build_red_teams_get_template_parameters_with_type_request,
|
|
78
|
+
build_red_teams_list_request,
|
|
79
|
+
build_red_teams_submit_simulation_request,
|
|
80
|
+
build_red_teams_upload_run_request,
|
|
81
|
+
build_red_teams_upload_update_run_request,
|
|
82
|
+
)
|
|
83
|
+
from .._configuration import AIProjectClientConfiguration
|
|
84
|
+
|
|
85
|
+
T = TypeVar("T")
|
|
86
|
+
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
|
|
87
|
+
JSON = MutableMapping[str, Any]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class ServicePatternsOperations:
|
|
91
|
+
"""
|
|
92
|
+
.. warning::
|
|
93
|
+
**DO NOT** instantiate this class directly.
|
|
94
|
+
|
|
95
|
+
Instead, you should access the following operations through
|
|
96
|
+
:class:`~azure.ai.projects.onedp.aio.AIProjectClient`'s
|
|
97
|
+
:attr:`service_patterns` attribute.
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
101
|
+
input_args = list(args)
|
|
102
|
+
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
103
|
+
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
104
|
+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
105
|
+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
106
|
+
|
|
107
|
+
self.building_blocks = ServicePatternsBuildingBlocksOperations(
|
|
108
|
+
self._client, self._config, self._serialize, self._deserialize
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class ConnectionsOperations:
|
|
113
|
+
"""
|
|
114
|
+
.. warning::
|
|
115
|
+
**DO NOT** instantiate this class directly.
|
|
116
|
+
|
|
117
|
+
Instead, you should access the following operations through
|
|
118
|
+
:class:`~azure.ai.projects.onedp.aio.AIProjectClient`'s
|
|
119
|
+
:attr:`connections` attribute.
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
123
|
+
input_args = list(args)
|
|
124
|
+
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
125
|
+
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
126
|
+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
127
|
+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
128
|
+
|
|
129
|
+
@distributed_trace_async
|
|
130
|
+
async def get(self, name: str, **kwargs: Any) -> _models.Connection:
|
|
131
|
+
"""Get a connection by name, without populating connection credentials.
|
|
132
|
+
|
|
133
|
+
:param name: The name of the resource. Required.
|
|
134
|
+
:type name: str
|
|
135
|
+
:return: Connection. The Connection is compatible with MutableMapping
|
|
136
|
+
:rtype: ~azure.ai.projects.onedp.models.Connection
|
|
137
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
138
|
+
"""
|
|
139
|
+
error_map: MutableMapping = {
|
|
140
|
+
401: ClientAuthenticationError,
|
|
141
|
+
404: ResourceNotFoundError,
|
|
142
|
+
409: ResourceExistsError,
|
|
143
|
+
304: ResourceNotModifiedError,
|
|
144
|
+
}
|
|
145
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
146
|
+
|
|
147
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
148
|
+
_params = kwargs.pop("params", {}) or {}
|
|
149
|
+
|
|
150
|
+
cls: ClsType[_models.Connection] = kwargs.pop("cls", None)
|
|
151
|
+
|
|
152
|
+
_request = build_connections_get_request(
|
|
153
|
+
name=name,
|
|
154
|
+
api_version=self._config.api_version,
|
|
155
|
+
headers=_headers,
|
|
156
|
+
params=_params,
|
|
157
|
+
)
|
|
158
|
+
path_format_arguments = {
|
|
159
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
160
|
+
}
|
|
161
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
162
|
+
|
|
163
|
+
_stream = kwargs.pop("stream", False)
|
|
164
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
165
|
+
_request, stream=_stream, **kwargs
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
response = pipeline_response.http_response
|
|
169
|
+
|
|
170
|
+
if response.status_code not in [200]:
|
|
171
|
+
if _stream:
|
|
172
|
+
try:
|
|
173
|
+
await response.read() # Load the body in memory and close the socket
|
|
174
|
+
except (StreamConsumedError, StreamClosedError):
|
|
175
|
+
pass
|
|
176
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
177
|
+
raise HttpResponseError(response=response)
|
|
178
|
+
|
|
179
|
+
response_headers = {}
|
|
180
|
+
response_headers["x-ms-client-request-id"] = self._deserialize(
|
|
181
|
+
"str", response.headers.get("x-ms-client-request-id")
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
if _stream:
|
|
185
|
+
deserialized = response.iter_bytes()
|
|
186
|
+
else:
|
|
187
|
+
deserialized = _deserialize(_models.Connection, response.json())
|
|
188
|
+
|
|
189
|
+
if cls:
|
|
190
|
+
return cls(pipeline_response, deserialized, response_headers) # type: ignore
|
|
191
|
+
|
|
192
|
+
return deserialized # type: ignore
|
|
193
|
+
|
|
194
|
+
@distributed_trace_async
|
|
195
|
+
async def get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection:
|
|
196
|
+
"""Get a connection by name, with its connection credentials.
|
|
197
|
+
|
|
198
|
+
:param name: The name of the resource. Required.
|
|
199
|
+
:type name: str
|
|
200
|
+
:return: Connection. The Connection is compatible with MutableMapping
|
|
201
|
+
:rtype: ~azure.ai.projects.onedp.models.Connection
|
|
202
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
203
|
+
"""
|
|
204
|
+
error_map: MutableMapping = {
|
|
205
|
+
401: ClientAuthenticationError,
|
|
206
|
+
404: ResourceNotFoundError,
|
|
207
|
+
409: ResourceExistsError,
|
|
208
|
+
304: ResourceNotModifiedError,
|
|
209
|
+
}
|
|
210
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
211
|
+
|
|
212
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
213
|
+
_params = kwargs.pop("params", {}) or {}
|
|
214
|
+
|
|
215
|
+
cls: ClsType[_models.Connection] = kwargs.pop("cls", None)
|
|
216
|
+
|
|
217
|
+
_request = build_connections_get_with_credentials_request(
|
|
218
|
+
name=name,
|
|
219
|
+
api_version=self._config.api_version,
|
|
220
|
+
headers=_headers,
|
|
221
|
+
params=_params,
|
|
222
|
+
)
|
|
223
|
+
path_format_arguments = {
|
|
224
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
225
|
+
}
|
|
226
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
227
|
+
|
|
228
|
+
_stream = kwargs.pop("stream", False)
|
|
229
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
230
|
+
_request, stream=_stream, **kwargs
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
response = pipeline_response.http_response
|
|
234
|
+
|
|
235
|
+
if response.status_code not in [200]:
|
|
236
|
+
if _stream:
|
|
237
|
+
try:
|
|
238
|
+
await response.read() # Load the body in memory and close the socket
|
|
239
|
+
except (StreamConsumedError, StreamClosedError):
|
|
240
|
+
pass
|
|
241
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
242
|
+
raise HttpResponseError(response=response)
|
|
243
|
+
|
|
244
|
+
response_headers = {}
|
|
245
|
+
response_headers["x-ms-client-request-id"] = self._deserialize(
|
|
246
|
+
"str", response.headers.get("x-ms-client-request-id")
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
if _stream:
|
|
250
|
+
deserialized = response.iter_bytes()
|
|
251
|
+
else:
|
|
252
|
+
deserialized = _deserialize(_models.Connection, response.json())
|
|
253
|
+
|
|
254
|
+
if cls:
|
|
255
|
+
return cls(pipeline_response, deserialized, response_headers) # type: ignore
|
|
256
|
+
|
|
257
|
+
return deserialized # type: ignore
|
|
258
|
+
|
|
259
|
+
@distributed_trace
|
|
260
|
+
def list(
|
|
261
|
+
self,
|
|
262
|
+
*,
|
|
263
|
+
connection_type: Optional[Union[str, _models.ConnectionType]] = None,
|
|
264
|
+
default_connection: Optional[bool] = None,
|
|
265
|
+
top: Optional[int] = None,
|
|
266
|
+
skip: Optional[int] = None,
|
|
267
|
+
**kwargs: Any
|
|
268
|
+
) -> AsyncIterable["_models.Connection"]:
|
|
269
|
+
"""List all connections in the project, without populating connection credentials.
|
|
270
|
+
|
|
271
|
+
:keyword connection_type: List connections of this specific type. Known values are:
|
|
272
|
+
"AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey",
|
|
273
|
+
"AppConfig", "AppInsights", and "CustomKeys". Default value is None.
|
|
274
|
+
:paramtype connection_type: str or ~azure.ai.projects.onedp.models.ConnectionType
|
|
275
|
+
:keyword default_connection: List connections that are default connections. Default value is
|
|
276
|
+
None.
|
|
277
|
+
:paramtype default_connection: bool
|
|
278
|
+
:keyword top: The number of result items to return. Default value is None.
|
|
279
|
+
:paramtype top: int
|
|
280
|
+
:keyword skip: The number of result items to skip. Default value is None.
|
|
281
|
+
:paramtype skip: int
|
|
282
|
+
:return: An iterator like instance of Connection
|
|
283
|
+
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.onedp.models.Connection]
|
|
284
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
285
|
+
"""
|
|
286
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
287
|
+
_params = kwargs.pop("params", {}) or {}
|
|
288
|
+
|
|
289
|
+
maxpagesize = kwargs.pop("maxpagesize", None)
|
|
290
|
+
cls: ClsType[List[_models.Connection]] = kwargs.pop("cls", None)
|
|
291
|
+
|
|
292
|
+
error_map: MutableMapping = {
|
|
293
|
+
401: ClientAuthenticationError,
|
|
294
|
+
404: ResourceNotFoundError,
|
|
295
|
+
409: ResourceExistsError,
|
|
296
|
+
304: ResourceNotModifiedError,
|
|
297
|
+
}
|
|
298
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
299
|
+
|
|
300
|
+
def prepare_request(next_link=None):
|
|
301
|
+
if not next_link:
|
|
302
|
+
|
|
303
|
+
_request = build_connections_list_request(
|
|
304
|
+
connection_type=connection_type,
|
|
305
|
+
default_connection=default_connection,
|
|
306
|
+
top=top,
|
|
307
|
+
skip=skip,
|
|
308
|
+
maxpagesize=maxpagesize,
|
|
309
|
+
api_version=self._config.api_version,
|
|
310
|
+
headers=_headers,
|
|
311
|
+
params=_params,
|
|
312
|
+
)
|
|
313
|
+
path_format_arguments = {
|
|
314
|
+
"endpoint": self._serialize.url(
|
|
315
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
316
|
+
),
|
|
317
|
+
}
|
|
318
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
319
|
+
|
|
320
|
+
else:
|
|
321
|
+
# make call to next link with the client's api-version
|
|
322
|
+
_parsed_next_link = urllib.parse.urlparse(next_link)
|
|
323
|
+
_next_request_params = case_insensitive_dict(
|
|
324
|
+
{
|
|
325
|
+
key: [urllib.parse.quote(v) for v in value]
|
|
326
|
+
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
|
|
327
|
+
}
|
|
328
|
+
)
|
|
329
|
+
_next_request_params["api-version"] = self._config.api_version
|
|
330
|
+
_request = HttpRequest(
|
|
331
|
+
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
|
|
332
|
+
)
|
|
333
|
+
path_format_arguments = {
|
|
334
|
+
"endpoint": self._serialize.url(
|
|
335
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
336
|
+
),
|
|
337
|
+
}
|
|
338
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
339
|
+
|
|
340
|
+
return _request
|
|
341
|
+
|
|
342
|
+
async def extract_data(pipeline_response):
|
|
343
|
+
deserialized = pipeline_response.http_response.json()
|
|
344
|
+
list_of_elem = _deserialize(List[_models.Connection], deserialized.get("value", []))
|
|
345
|
+
if cls:
|
|
346
|
+
list_of_elem = cls(list_of_elem) # type: ignore
|
|
347
|
+
return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
|
|
348
|
+
|
|
349
|
+
async def get_next(next_link=None):
|
|
350
|
+
_request = prepare_request(next_link)
|
|
351
|
+
|
|
352
|
+
_stream = False
|
|
353
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
354
|
+
_request, stream=_stream, **kwargs
|
|
355
|
+
)
|
|
356
|
+
response = pipeline_response.http_response
|
|
357
|
+
|
|
358
|
+
if response.status_code not in [200]:
|
|
359
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
360
|
+
raise HttpResponseError(response=response)
|
|
361
|
+
|
|
362
|
+
return pipeline_response
|
|
363
|
+
|
|
364
|
+
return AsyncItemPaged(get_next, extract_data)
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
class EvaluationsOperations:
|
|
368
|
+
"""
|
|
369
|
+
.. warning::
|
|
370
|
+
**DO NOT** instantiate this class directly.
|
|
371
|
+
|
|
372
|
+
Instead, you should access the following operations through
|
|
373
|
+
:class:`~azure.ai.projects.onedp.aio.AIProjectClient`'s
|
|
374
|
+
:attr:`evaluations` attribute.
|
|
375
|
+
"""
|
|
376
|
+
|
|
377
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
378
|
+
input_args = list(args)
|
|
379
|
+
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
380
|
+
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
381
|
+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
382
|
+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
383
|
+
|
|
384
|
+
@distributed_trace_async
|
|
385
|
+
@api_version_validation(
|
|
386
|
+
method_added_on="2025-05-15-preview",
|
|
387
|
+
params_added_on={"2025-05-15-preview": ["api_version", "name", "client_request_id", "accept"]},
|
|
388
|
+
)
|
|
389
|
+
async def get(self, name: str, **kwargs: Any) -> _models.Evaluation:
|
|
390
|
+
"""Get an evaluation run by name.
|
|
391
|
+
|
|
392
|
+
:param name: Identifier of the evaluation. Required.
|
|
393
|
+
:type name: str
|
|
394
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
395
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
396
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
397
|
+
"""
|
|
398
|
+
error_map: MutableMapping = {
|
|
399
|
+
401: ClientAuthenticationError,
|
|
400
|
+
404: ResourceNotFoundError,
|
|
401
|
+
409: ResourceExistsError,
|
|
402
|
+
304: ResourceNotModifiedError,
|
|
403
|
+
}
|
|
404
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
405
|
+
|
|
406
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
407
|
+
_params = kwargs.pop("params", {}) or {}
|
|
408
|
+
|
|
409
|
+
cls: ClsType[_models.Evaluation] = kwargs.pop("cls", None)
|
|
410
|
+
|
|
411
|
+
_request = build_evaluations_get_request(
|
|
412
|
+
name=name,
|
|
413
|
+
api_version=self._config.api_version,
|
|
414
|
+
headers=_headers,
|
|
415
|
+
params=_params,
|
|
416
|
+
)
|
|
417
|
+
path_format_arguments = {
|
|
418
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
419
|
+
}
|
|
420
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
421
|
+
|
|
422
|
+
_stream = kwargs.pop("stream", False)
|
|
423
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
424
|
+
_request, stream=_stream, **kwargs
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
response = pipeline_response.http_response
|
|
428
|
+
|
|
429
|
+
if response.status_code not in [200]:
|
|
430
|
+
if _stream:
|
|
431
|
+
try:
|
|
432
|
+
await response.read() # Load the body in memory and close the socket
|
|
433
|
+
except (StreamConsumedError, StreamClosedError):
|
|
434
|
+
pass
|
|
435
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
436
|
+
raise HttpResponseError(response=response)
|
|
437
|
+
|
|
438
|
+
response_headers = {}
|
|
439
|
+
response_headers["x-ms-client-request-id"] = self._deserialize(
|
|
440
|
+
"str", response.headers.get("x-ms-client-request-id")
|
|
441
|
+
)
|
|
442
|
+
|
|
443
|
+
if _stream:
|
|
444
|
+
deserialized = response.iter_bytes()
|
|
445
|
+
else:
|
|
446
|
+
deserialized = _deserialize(_models.Evaluation, response.json())
|
|
447
|
+
|
|
448
|
+
if cls:
|
|
449
|
+
return cls(pipeline_response, deserialized, response_headers) # type: ignore
|
|
450
|
+
|
|
451
|
+
return deserialized # type: ignore
|
|
452
|
+
|
|
453
|
+
@distributed_trace
|
|
454
|
+
@api_version_validation(
|
|
455
|
+
method_added_on="2025-05-15-preview",
|
|
456
|
+
params_added_on={
|
|
457
|
+
"2025-05-15-preview": [
|
|
458
|
+
"api_version",
|
|
459
|
+
"tags",
|
|
460
|
+
"properties",
|
|
461
|
+
"top",
|
|
462
|
+
"skip",
|
|
463
|
+
"maxpagesize",
|
|
464
|
+
"client_request_id",
|
|
465
|
+
"accept",
|
|
466
|
+
]
|
|
467
|
+
},
|
|
468
|
+
)
|
|
469
|
+
def list(
|
|
470
|
+
self,
|
|
471
|
+
*,
|
|
472
|
+
tags: Optional[str] = None,
|
|
473
|
+
properties: Optional[str] = None,
|
|
474
|
+
top: Optional[int] = None,
|
|
475
|
+
skip: Optional[int] = None,
|
|
476
|
+
**kwargs: Any
|
|
477
|
+
) -> AsyncIterable["_models.Evaluation"]:
|
|
478
|
+
"""List evaluation runs.
|
|
479
|
+
|
|
480
|
+
:keyword tags: Comma-separated list of tag names (and optionally values). Example:
|
|
481
|
+
tag1,tag2=value2. Default value is None.
|
|
482
|
+
:paramtype tags: str
|
|
483
|
+
:keyword properties: Comma-separated list of property names (and optionally values). Example:
|
|
484
|
+
prop1,prop2=value2. Default value is None.
|
|
485
|
+
:paramtype properties: str
|
|
486
|
+
:keyword top: The number of result items to return. Default value is None.
|
|
487
|
+
:paramtype top: int
|
|
488
|
+
:keyword skip: The number of result items to skip. Default value is None.
|
|
489
|
+
:paramtype skip: int
|
|
490
|
+
:return: An iterator like instance of Evaluation
|
|
491
|
+
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.onedp.models.Evaluation]
|
|
492
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
493
|
+
"""
|
|
494
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
495
|
+
_params = kwargs.pop("params", {}) or {}
|
|
496
|
+
|
|
497
|
+
maxpagesize = kwargs.pop("maxpagesize", None)
|
|
498
|
+
cls: ClsType[List[_models.Evaluation]] = kwargs.pop("cls", None)
|
|
499
|
+
|
|
500
|
+
error_map: MutableMapping = {
|
|
501
|
+
401: ClientAuthenticationError,
|
|
502
|
+
404: ResourceNotFoundError,
|
|
503
|
+
409: ResourceExistsError,
|
|
504
|
+
304: ResourceNotModifiedError,
|
|
505
|
+
}
|
|
506
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
507
|
+
|
|
508
|
+
def prepare_request(next_link=None):
|
|
509
|
+
if not next_link:
|
|
510
|
+
|
|
511
|
+
_request = build_evaluations_list_request(
|
|
512
|
+
tags=tags,
|
|
513
|
+
properties=properties,
|
|
514
|
+
top=top,
|
|
515
|
+
skip=skip,
|
|
516
|
+
maxpagesize=maxpagesize,
|
|
517
|
+
api_version=self._config.api_version,
|
|
518
|
+
headers=_headers,
|
|
519
|
+
params=_params,
|
|
520
|
+
)
|
|
521
|
+
path_format_arguments = {
|
|
522
|
+
"endpoint": self._serialize.url(
|
|
523
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
524
|
+
),
|
|
525
|
+
}
|
|
526
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
527
|
+
|
|
528
|
+
else:
|
|
529
|
+
# make call to next link with the client's api-version
|
|
530
|
+
_parsed_next_link = urllib.parse.urlparse(next_link)
|
|
531
|
+
_next_request_params = case_insensitive_dict(
|
|
532
|
+
{
|
|
533
|
+
key: [urllib.parse.quote(v) for v in value]
|
|
534
|
+
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
|
|
535
|
+
}
|
|
536
|
+
)
|
|
537
|
+
_next_request_params["api-version"] = self._config.api_version
|
|
538
|
+
_request = HttpRequest(
|
|
539
|
+
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
|
|
540
|
+
)
|
|
541
|
+
path_format_arguments = {
|
|
542
|
+
"endpoint": self._serialize.url(
|
|
543
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
544
|
+
),
|
|
545
|
+
}
|
|
546
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
547
|
+
|
|
548
|
+
return _request
|
|
549
|
+
|
|
550
|
+
async def extract_data(pipeline_response):
|
|
551
|
+
deserialized = pipeline_response.http_response.json()
|
|
552
|
+
list_of_elem = _deserialize(List[_models.Evaluation], deserialized.get("value", []))
|
|
553
|
+
if cls:
|
|
554
|
+
list_of_elem = cls(list_of_elem) # type: ignore
|
|
555
|
+
return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
|
|
556
|
+
|
|
557
|
+
async def get_next(next_link=None):
|
|
558
|
+
_request = prepare_request(next_link)
|
|
559
|
+
|
|
560
|
+
_stream = False
|
|
561
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
562
|
+
_request, stream=_stream, **kwargs
|
|
563
|
+
)
|
|
564
|
+
response = pipeline_response.http_response
|
|
565
|
+
|
|
566
|
+
if response.status_code not in [200]:
|
|
567
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
568
|
+
raise HttpResponseError(response=response)
|
|
569
|
+
|
|
570
|
+
return pipeline_response
|
|
571
|
+
|
|
572
|
+
return AsyncItemPaged(get_next, extract_data)
|
|
573
|
+
|
|
574
|
+
@overload
|
|
575
|
+
async def create_run(
|
|
576
|
+
self, evaluation: _models.Evaluation, *, content_type: str = "application/json", **kwargs: Any
|
|
577
|
+
) -> _models.Evaluation:
|
|
578
|
+
"""Creates an evaluation run.
|
|
579
|
+
|
|
580
|
+
:param evaluation: Evaluation to be run. Required.
|
|
581
|
+
:type evaluation: ~azure.ai.projects.onedp.models.Evaluation
|
|
582
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
583
|
+
Default value is "application/json".
|
|
584
|
+
:paramtype content_type: str
|
|
585
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
586
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
587
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
588
|
+
"""
|
|
589
|
+
|
|
590
|
+
@overload
|
|
591
|
+
async def create_run(
|
|
592
|
+
self, evaluation: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
593
|
+
) -> _models.Evaluation:
|
|
594
|
+
"""Creates an evaluation run.
|
|
595
|
+
|
|
596
|
+
:param evaluation: Evaluation to be run. Required.
|
|
597
|
+
:type evaluation: JSON
|
|
598
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
599
|
+
Default value is "application/json".
|
|
600
|
+
:paramtype content_type: str
|
|
601
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
602
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
603
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
604
|
+
"""
|
|
605
|
+
|
|
606
|
+
@overload
|
|
607
|
+
async def create_run(
|
|
608
|
+
self, evaluation: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
609
|
+
) -> _models.Evaluation:
|
|
610
|
+
"""Creates an evaluation run.
|
|
611
|
+
|
|
612
|
+
:param evaluation: Evaluation to be run. Required.
|
|
613
|
+
:type evaluation: IO[bytes]
|
|
614
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
615
|
+
Default value is "application/json".
|
|
616
|
+
:paramtype content_type: str
|
|
617
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
618
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
619
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
620
|
+
"""
|
|
621
|
+
|
|
622
|
+
@distributed_trace_async
|
|
623
|
+
@api_version_validation(
|
|
624
|
+
method_added_on="2025-05-15-preview",
|
|
625
|
+
params_added_on={"2025-05-15-preview": ["api_version", "content_type", "accept"]},
|
|
626
|
+
)
|
|
627
|
+
async def create_run(
|
|
628
|
+
self, evaluation: Union[_models.Evaluation, JSON, IO[bytes]], **kwargs: Any
|
|
629
|
+
) -> _models.Evaluation:
|
|
630
|
+
"""Creates an evaluation run.
|
|
631
|
+
|
|
632
|
+
:param evaluation: Evaluation to be run. Is one of the following types: Evaluation, JSON,
|
|
633
|
+
IO[bytes] Required.
|
|
634
|
+
:type evaluation: ~azure.ai.projects.onedp.models.Evaluation or JSON or IO[bytes]
|
|
635
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
636
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
637
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
638
|
+
"""
|
|
639
|
+
error_map: MutableMapping = {
|
|
640
|
+
401: ClientAuthenticationError,
|
|
641
|
+
404: ResourceNotFoundError,
|
|
642
|
+
409: ResourceExistsError,
|
|
643
|
+
304: ResourceNotModifiedError,
|
|
644
|
+
}
|
|
645
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
646
|
+
|
|
647
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
648
|
+
_params = kwargs.pop("params", {}) or {}
|
|
649
|
+
|
|
650
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
651
|
+
cls: ClsType[_models.Evaluation] = kwargs.pop("cls", None)
|
|
652
|
+
|
|
653
|
+
content_type = content_type or "application/json"
|
|
654
|
+
_content = None
|
|
655
|
+
if isinstance(evaluation, (IOBase, bytes)):
|
|
656
|
+
_content = evaluation
|
|
657
|
+
else:
|
|
658
|
+
_content = json.dumps(evaluation, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
659
|
+
|
|
660
|
+
_request = build_evaluations_create_run_request(
|
|
661
|
+
content_type=content_type,
|
|
662
|
+
api_version=self._config.api_version,
|
|
663
|
+
content=_content,
|
|
664
|
+
headers=_headers,
|
|
665
|
+
params=_params,
|
|
666
|
+
)
|
|
667
|
+
path_format_arguments = {
|
|
668
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
669
|
+
}
|
|
670
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
671
|
+
|
|
672
|
+
_stream = kwargs.pop("stream", False)
|
|
673
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
674
|
+
_request, stream=_stream, **kwargs
|
|
675
|
+
)
|
|
676
|
+
|
|
677
|
+
response = pipeline_response.http_response
|
|
678
|
+
|
|
679
|
+
if response.status_code not in [200]:
|
|
680
|
+
if _stream:
|
|
681
|
+
try:
|
|
682
|
+
await response.read() # Load the body in memory and close the socket
|
|
683
|
+
except (StreamConsumedError, StreamClosedError):
|
|
684
|
+
pass
|
|
685
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
686
|
+
raise HttpResponseError(response=response)
|
|
687
|
+
|
|
688
|
+
if _stream:
|
|
689
|
+
deserialized = response.iter_bytes()
|
|
690
|
+
else:
|
|
691
|
+
deserialized = _deserialize(_models.Evaluation, response.json())
|
|
692
|
+
|
|
693
|
+
if cls:
|
|
694
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
695
|
+
|
|
696
|
+
return deserialized # type: ignore
|
|
697
|
+
|
|
698
|
+
@distributed_trace_async
|
|
699
|
+
@api_version_validation(
|
|
700
|
+
method_added_on="2025-05-15-preview",
|
|
701
|
+
params_added_on={"2025-05-15-preview": ["api_version", "accept"]},
|
|
702
|
+
)
|
|
703
|
+
async def check_annotation(self, **kwargs: Any) -> List[str]:
|
|
704
|
+
"""Check annotation supported by the service.
|
|
705
|
+
|
|
706
|
+
:return: list of str
|
|
707
|
+
:rtype: list[str]
|
|
708
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
709
|
+
"""
|
|
710
|
+
error_map: MutableMapping = {
|
|
711
|
+
401: ClientAuthenticationError,
|
|
712
|
+
404: ResourceNotFoundError,
|
|
713
|
+
409: ResourceExistsError,
|
|
714
|
+
304: ResourceNotModifiedError,
|
|
715
|
+
}
|
|
716
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
717
|
+
|
|
718
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
719
|
+
_params = kwargs.pop("params", {}) or {}
|
|
720
|
+
|
|
721
|
+
cls: ClsType[List[str]] = kwargs.pop("cls", None)
|
|
722
|
+
|
|
723
|
+
_request = build_evaluations_check_annotation_request(
|
|
724
|
+
api_version=self._config.api_version,
|
|
725
|
+
headers=_headers,
|
|
726
|
+
params=_params,
|
|
727
|
+
)
|
|
728
|
+
path_format_arguments = {
|
|
729
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
730
|
+
}
|
|
731
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
732
|
+
|
|
733
|
+
_stream = kwargs.pop("stream", False)
|
|
734
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
735
|
+
_request, stream=_stream, **kwargs
|
|
736
|
+
)
|
|
737
|
+
|
|
738
|
+
response = pipeline_response.http_response
|
|
739
|
+
|
|
740
|
+
if response.status_code not in [200]:
|
|
741
|
+
if _stream:
|
|
742
|
+
try:
|
|
743
|
+
await response.read() # Load the body in memory and close the socket
|
|
744
|
+
except (StreamConsumedError, StreamClosedError):
|
|
745
|
+
pass
|
|
746
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
747
|
+
raise HttpResponseError(response=response)
|
|
748
|
+
|
|
749
|
+
if _stream:
|
|
750
|
+
deserialized = response.iter_bytes()
|
|
751
|
+
else:
|
|
752
|
+
deserialized = _deserialize(List[str], response.json())
|
|
753
|
+
|
|
754
|
+
if cls:
|
|
755
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
756
|
+
|
|
757
|
+
return deserialized # type: ignore
|
|
758
|
+
|
|
759
|
+
@overload
|
|
760
|
+
async def submit_annotation(
|
|
761
|
+
self, annotation_dto: _models.AnnotationDTO, *, content_type: str = "application/json", **kwargs: Any
|
|
762
|
+
) -> str:
|
|
763
|
+
"""Submit the annotation.
|
|
764
|
+
|
|
765
|
+
:param annotation_dto: Annotation data inputList of supported annotation. Required.
|
|
766
|
+
:type annotation_dto: ~azure.ai.projects.onedp.models.AnnotationDTO
|
|
767
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
768
|
+
Default value is "application/json".
|
|
769
|
+
:paramtype content_type: str
|
|
770
|
+
:return: str
|
|
771
|
+
:rtype: str
|
|
772
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
773
|
+
"""
|
|
774
|
+
|
|
775
|
+
@overload
|
|
776
|
+
async def submit_annotation(
|
|
777
|
+
self, annotation_dto: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
778
|
+
) -> str:
|
|
779
|
+
"""Submit the annotation.
|
|
780
|
+
|
|
781
|
+
:param annotation_dto: Annotation data inputList of supported annotation. Required.
|
|
782
|
+
:type annotation_dto: JSON
|
|
783
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
784
|
+
Default value is "application/json".
|
|
785
|
+
:paramtype content_type: str
|
|
786
|
+
:return: str
|
|
787
|
+
:rtype: str
|
|
788
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
789
|
+
"""
|
|
790
|
+
|
|
791
|
+
@overload
|
|
792
|
+
async def submit_annotation(
|
|
793
|
+
self, annotation_dto: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
794
|
+
) -> str:
|
|
795
|
+
"""Submit the annotation.
|
|
796
|
+
|
|
797
|
+
:param annotation_dto: Annotation data inputList of supported annotation. Required.
|
|
798
|
+
:type annotation_dto: IO[bytes]
|
|
799
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
800
|
+
Default value is "application/json".
|
|
801
|
+
:paramtype content_type: str
|
|
802
|
+
:return: str
|
|
803
|
+
:rtype: str
|
|
804
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
805
|
+
"""
|
|
806
|
+
|
|
807
|
+
@distributed_trace_async
|
|
808
|
+
@api_version_validation(
|
|
809
|
+
method_added_on="2025-05-15-preview",
|
|
810
|
+
params_added_on={"2025-05-15-preview": ["api_version", "content_type", "accept"]},
|
|
811
|
+
)
|
|
812
|
+
async def submit_annotation(
|
|
813
|
+
self, annotation_dto: Union[_models.AnnotationDTO, JSON, IO[bytes]], **kwargs: Any
|
|
814
|
+
) -> str:
|
|
815
|
+
"""Submit the annotation.
|
|
816
|
+
|
|
817
|
+
:param annotation_dto: Annotation data inputList of supported annotation. Is one of the
|
|
818
|
+
following types: AnnotationDTO, JSON, IO[bytes] Required.
|
|
819
|
+
:type annotation_dto: ~azure.ai.projects.onedp.models.AnnotationDTO or JSON or IO[bytes]
|
|
820
|
+
:return: str
|
|
821
|
+
:rtype: str
|
|
822
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
823
|
+
"""
|
|
824
|
+
error_map: MutableMapping = {
|
|
825
|
+
401: ClientAuthenticationError,
|
|
826
|
+
404: ResourceNotFoundError,
|
|
827
|
+
409: ResourceExistsError,
|
|
828
|
+
304: ResourceNotModifiedError,
|
|
829
|
+
}
|
|
830
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
831
|
+
|
|
832
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
833
|
+
_params = kwargs.pop("params", {}) or {}
|
|
834
|
+
|
|
835
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
836
|
+
cls: ClsType[str] = kwargs.pop("cls", None)
|
|
837
|
+
|
|
838
|
+
content_type = content_type or "application/json"
|
|
839
|
+
_content = None
|
|
840
|
+
if isinstance(annotation_dto, (IOBase, bytes)):
|
|
841
|
+
_content = annotation_dto
|
|
842
|
+
else:
|
|
843
|
+
_content = json.dumps(annotation_dto, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
844
|
+
|
|
845
|
+
_request = build_evaluations_submit_annotation_request(
|
|
846
|
+
content_type=content_type,
|
|
847
|
+
api_version=self._config.api_version,
|
|
848
|
+
content=_content,
|
|
849
|
+
headers=_headers,
|
|
850
|
+
params=_params,
|
|
851
|
+
)
|
|
852
|
+
path_format_arguments = {
|
|
853
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
854
|
+
}
|
|
855
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
856
|
+
|
|
857
|
+
_stream = kwargs.pop("stream", False)
|
|
858
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
859
|
+
_request, stream=_stream, **kwargs
|
|
860
|
+
)
|
|
861
|
+
|
|
862
|
+
response = pipeline_response.http_response
|
|
863
|
+
|
|
864
|
+
if response.status_code not in [202]:
|
|
865
|
+
if _stream:
|
|
866
|
+
try:
|
|
867
|
+
await response.read() # Load the body in memory and close the socket
|
|
868
|
+
except (StreamConsumedError, StreamClosedError):
|
|
869
|
+
pass
|
|
870
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
871
|
+
raise HttpResponseError(response=response)
|
|
872
|
+
|
|
873
|
+
if _stream:
|
|
874
|
+
deserialized = response.iter_bytes()
|
|
875
|
+
else:
|
|
876
|
+
deserialized = _deserialize(str, response.text())
|
|
877
|
+
|
|
878
|
+
if cls:
|
|
879
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
880
|
+
|
|
881
|
+
return deserialized # type: ignore
|
|
882
|
+
|
|
883
|
+
@distributed_trace_async
|
|
884
|
+
@api_version_validation(
|
|
885
|
+
method_added_on="2025-05-15-preview",
|
|
886
|
+
params_added_on={"2025-05-15-preview": ["api_version", "operation_id", "accept"]},
|
|
887
|
+
)
|
|
888
|
+
async def operation_results(self, operation_id: str, **kwargs: Any) -> List[Dict[str, Any]]:
|
|
889
|
+
"""Poll for the operation results.
|
|
890
|
+
|
|
891
|
+
:param operation_id: Operation ID for the polling operation. Required.
|
|
892
|
+
:type operation_id: str
|
|
893
|
+
:return: list of dict mapping str to any
|
|
894
|
+
:rtype: list[dict[str, any]]
|
|
895
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
896
|
+
"""
|
|
897
|
+
error_map: MutableMapping = {
|
|
898
|
+
401: ClientAuthenticationError,
|
|
899
|
+
404: ResourceNotFoundError,
|
|
900
|
+
409: ResourceExistsError,
|
|
901
|
+
304: ResourceNotModifiedError,
|
|
902
|
+
}
|
|
903
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
904
|
+
|
|
905
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
906
|
+
_params = kwargs.pop("params", {}) or {}
|
|
907
|
+
|
|
908
|
+
cls: ClsType[List[Dict[str, Any]]] = kwargs.pop("cls", None)
|
|
909
|
+
|
|
910
|
+
_request = build_evaluations_operation_results_request(
|
|
911
|
+
operation_id=operation_id,
|
|
912
|
+
api_version=self._config.api_version,
|
|
913
|
+
headers=_headers,
|
|
914
|
+
params=_params,
|
|
915
|
+
)
|
|
916
|
+
path_format_arguments = {
|
|
917
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
918
|
+
}
|
|
919
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
920
|
+
|
|
921
|
+
_stream = kwargs.pop("stream", False)
|
|
922
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
923
|
+
_request, stream=_stream, **kwargs
|
|
924
|
+
)
|
|
925
|
+
|
|
926
|
+
response = pipeline_response.http_response
|
|
927
|
+
|
|
928
|
+
if response.status_code not in [200]:
|
|
929
|
+
if _stream:
|
|
930
|
+
try:
|
|
931
|
+
await response.read() # Load the body in memory and close the socket
|
|
932
|
+
except (StreamConsumedError, StreamClosedError):
|
|
933
|
+
pass
|
|
934
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
935
|
+
raise HttpResponseError(response=response)
|
|
936
|
+
|
|
937
|
+
if _stream:
|
|
938
|
+
deserialized = response.iter_bytes()
|
|
939
|
+
else:
|
|
940
|
+
deserialized = _deserialize(List[Dict[str, Any]], response.json())
|
|
941
|
+
|
|
942
|
+
if cls:
|
|
943
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
944
|
+
|
|
945
|
+
return deserialized # type: ignore
|
|
946
|
+
|
|
947
|
+
@overload
|
|
948
|
+
async def upload_run(
|
|
949
|
+
self, evaluation: _models.EvaluationUpload, *, content_type: str = "application/json", **kwargs: Any
|
|
950
|
+
) -> _models.Evaluation:
|
|
951
|
+
"""Upload the result to an evaluation run.
|
|
952
|
+
|
|
953
|
+
:param evaluation: Evaluation to upload. Required.
|
|
954
|
+
:type evaluation: ~azure.ai.projects.onedp.models.EvaluationUpload
|
|
955
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
956
|
+
Default value is "application/json".
|
|
957
|
+
:paramtype content_type: str
|
|
958
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
959
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
960
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
961
|
+
"""
|
|
962
|
+
|
|
963
|
+
@overload
|
|
964
|
+
async def upload_run(
|
|
965
|
+
self, evaluation: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
966
|
+
) -> _models.Evaluation:
|
|
967
|
+
"""Upload the result to an evaluation run.
|
|
968
|
+
|
|
969
|
+
:param evaluation: Evaluation to upload. Required.
|
|
970
|
+
:type evaluation: JSON
|
|
971
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
972
|
+
Default value is "application/json".
|
|
973
|
+
:paramtype content_type: str
|
|
974
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
975
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
976
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
977
|
+
"""
|
|
978
|
+
|
|
979
|
+
@overload
|
|
980
|
+
async def upload_run(
|
|
981
|
+
self, evaluation: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
982
|
+
) -> _models.Evaluation:
|
|
983
|
+
"""Upload the result to an evaluation run.
|
|
984
|
+
|
|
985
|
+
:param evaluation: Evaluation to upload. Required.
|
|
986
|
+
:type evaluation: IO[bytes]
|
|
987
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
988
|
+
Default value is "application/json".
|
|
989
|
+
:paramtype content_type: str
|
|
990
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
991
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
992
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
993
|
+
"""
|
|
994
|
+
|
|
995
|
+
@distributed_trace_async
|
|
996
|
+
@api_version_validation(
|
|
997
|
+
method_added_on="2025-05-15-preview",
|
|
998
|
+
params_added_on={"2025-05-15-preview": ["api_version", "content_type", "accept"]},
|
|
999
|
+
)
|
|
1000
|
+
async def upload_run(
|
|
1001
|
+
self, evaluation: Union[_models.EvaluationUpload, JSON, IO[bytes]], **kwargs: Any
|
|
1002
|
+
) -> _models.Evaluation:
|
|
1003
|
+
"""Upload the result to an evaluation run.
|
|
1004
|
+
|
|
1005
|
+
:param evaluation: Evaluation to upload. Is one of the following types: EvaluationUpload, JSON,
|
|
1006
|
+
IO[bytes] Required.
|
|
1007
|
+
:type evaluation: ~azure.ai.projects.onedp.models.EvaluationUpload or JSON or IO[bytes]
|
|
1008
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
1009
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
1010
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1011
|
+
"""
|
|
1012
|
+
error_map: MutableMapping = {
|
|
1013
|
+
401: ClientAuthenticationError,
|
|
1014
|
+
404: ResourceNotFoundError,
|
|
1015
|
+
409: ResourceExistsError,
|
|
1016
|
+
304: ResourceNotModifiedError,
|
|
1017
|
+
}
|
|
1018
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
1019
|
+
|
|
1020
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
1021
|
+
_params = kwargs.pop("params", {}) or {}
|
|
1022
|
+
|
|
1023
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
1024
|
+
cls: ClsType[_models.Evaluation] = kwargs.pop("cls", None)
|
|
1025
|
+
|
|
1026
|
+
content_type = content_type or "application/json"
|
|
1027
|
+
_content = None
|
|
1028
|
+
if isinstance(evaluation, (IOBase, bytes)):
|
|
1029
|
+
_content = evaluation
|
|
1030
|
+
else:
|
|
1031
|
+
_content = json.dumps(evaluation, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
1032
|
+
|
|
1033
|
+
_request = build_evaluations_upload_run_request(
|
|
1034
|
+
content_type=content_type,
|
|
1035
|
+
api_version=self._config.api_version,
|
|
1036
|
+
content=_content,
|
|
1037
|
+
headers=_headers,
|
|
1038
|
+
params=_params,
|
|
1039
|
+
)
|
|
1040
|
+
path_format_arguments = {
|
|
1041
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
1042
|
+
}
|
|
1043
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
1044
|
+
|
|
1045
|
+
_stream = kwargs.pop("stream", False)
|
|
1046
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
1047
|
+
_request, stream=_stream, **kwargs
|
|
1048
|
+
)
|
|
1049
|
+
|
|
1050
|
+
response = pipeline_response.http_response
|
|
1051
|
+
|
|
1052
|
+
if response.status_code not in [200]:
|
|
1053
|
+
if _stream:
|
|
1054
|
+
try:
|
|
1055
|
+
await response.read() # Load the body in memory and close the socket
|
|
1056
|
+
except (StreamConsumedError, StreamClosedError):
|
|
1057
|
+
pass
|
|
1058
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
1059
|
+
raise HttpResponseError(response=response)
|
|
1060
|
+
|
|
1061
|
+
if _stream:
|
|
1062
|
+
deserialized = response.iter_bytes()
|
|
1063
|
+
else:
|
|
1064
|
+
deserialized = _deserialize(_models.Evaluation, response.json())
|
|
1065
|
+
|
|
1066
|
+
if cls:
|
|
1067
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
1068
|
+
|
|
1069
|
+
return deserialized # type: ignore
|
|
1070
|
+
|
|
1071
|
+
@overload
|
|
1072
|
+
async def upload_update_run(
|
|
1073
|
+
self, name: str, evaluation: _models.EvaluationUpload, *, content_type: str = "application/json", **kwargs: Any
|
|
1074
|
+
) -> _models.Evaluation:
|
|
1075
|
+
"""Update the uploaded the result to an evaluation run.
|
|
1076
|
+
|
|
1077
|
+
:param name: Name of the evaluation run to update. Required.
|
|
1078
|
+
:type name: str
|
|
1079
|
+
:param evaluation: Evaluation upload to update. Required.
|
|
1080
|
+
:type evaluation: ~azure.ai.projects.onedp.models.EvaluationUpload
|
|
1081
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
1082
|
+
Default value is "application/json".
|
|
1083
|
+
:paramtype content_type: str
|
|
1084
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
1085
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
1086
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1087
|
+
"""
|
|
1088
|
+
|
|
1089
|
+
@overload
|
|
1090
|
+
async def upload_update_run(
|
|
1091
|
+
self, name: str, evaluation: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
1092
|
+
) -> _models.Evaluation:
|
|
1093
|
+
"""Update the uploaded the result to an evaluation run.
|
|
1094
|
+
|
|
1095
|
+
:param name: Name of the evaluation run to update. Required.
|
|
1096
|
+
:type name: str
|
|
1097
|
+
:param evaluation: Evaluation upload to update. Required.
|
|
1098
|
+
:type evaluation: JSON
|
|
1099
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
1100
|
+
Default value is "application/json".
|
|
1101
|
+
:paramtype content_type: str
|
|
1102
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
1103
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
1104
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1105
|
+
"""
|
|
1106
|
+
|
|
1107
|
+
@overload
|
|
1108
|
+
async def upload_update_run(
|
|
1109
|
+
self, name: str, evaluation: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
1110
|
+
) -> _models.Evaluation:
|
|
1111
|
+
"""Update the uploaded the result to an evaluation run.
|
|
1112
|
+
|
|
1113
|
+
:param name: Name of the evaluation run to update. Required.
|
|
1114
|
+
:type name: str
|
|
1115
|
+
:param evaluation: Evaluation upload to update. Required.
|
|
1116
|
+
:type evaluation: IO[bytes]
|
|
1117
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
1118
|
+
Default value is "application/json".
|
|
1119
|
+
:paramtype content_type: str
|
|
1120
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
1121
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
1122
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1123
|
+
"""
|
|
1124
|
+
|
|
1125
|
+
@distributed_trace_async
|
|
1126
|
+
@api_version_validation(
|
|
1127
|
+
method_added_on="2025-05-15-preview",
|
|
1128
|
+
params_added_on={"2025-05-15-preview": ["api_version", "name", "content_type", "accept"]},
|
|
1129
|
+
)
|
|
1130
|
+
async def upload_update_run(
|
|
1131
|
+
self, name: str, evaluation: Union[_models.EvaluationUpload, JSON, IO[bytes]], **kwargs: Any
|
|
1132
|
+
) -> _models.Evaluation:
|
|
1133
|
+
"""Update the uploaded the result to an evaluation run.
|
|
1134
|
+
|
|
1135
|
+
:param name: Name of the evaluation run to update. Required.
|
|
1136
|
+
:type name: str
|
|
1137
|
+
:param evaluation: Evaluation upload to update. Is one of the following types:
|
|
1138
|
+
EvaluationUpload, JSON, IO[bytes] Required.
|
|
1139
|
+
:type evaluation: ~azure.ai.projects.onedp.models.EvaluationUpload or JSON or IO[bytes]
|
|
1140
|
+
:return: Evaluation. The Evaluation is compatible with MutableMapping
|
|
1141
|
+
:rtype: ~azure.ai.projects.onedp.models.Evaluation
|
|
1142
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1143
|
+
"""
|
|
1144
|
+
error_map: MutableMapping = {
|
|
1145
|
+
401: ClientAuthenticationError,
|
|
1146
|
+
404: ResourceNotFoundError,
|
|
1147
|
+
409: ResourceExistsError,
|
|
1148
|
+
304: ResourceNotModifiedError,
|
|
1149
|
+
}
|
|
1150
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
1151
|
+
|
|
1152
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
1153
|
+
_params = kwargs.pop("params", {}) or {}
|
|
1154
|
+
|
|
1155
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
1156
|
+
cls: ClsType[_models.Evaluation] = kwargs.pop("cls", None)
|
|
1157
|
+
|
|
1158
|
+
content_type = content_type or "application/json"
|
|
1159
|
+
_content = None
|
|
1160
|
+
if isinstance(evaluation, (IOBase, bytes)):
|
|
1161
|
+
_content = evaluation
|
|
1162
|
+
else:
|
|
1163
|
+
_content = json.dumps(evaluation, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
1164
|
+
|
|
1165
|
+
_request = build_evaluations_upload_update_run_request(
|
|
1166
|
+
name=name,
|
|
1167
|
+
content_type=content_type,
|
|
1168
|
+
api_version=self._config.api_version,
|
|
1169
|
+
content=_content,
|
|
1170
|
+
headers=_headers,
|
|
1171
|
+
params=_params,
|
|
1172
|
+
)
|
|
1173
|
+
path_format_arguments = {
|
|
1174
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
1175
|
+
}
|
|
1176
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
1177
|
+
|
|
1178
|
+
_stream = kwargs.pop("stream", False)
|
|
1179
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
1180
|
+
_request, stream=_stream, **kwargs
|
|
1181
|
+
)
|
|
1182
|
+
|
|
1183
|
+
response = pipeline_response.http_response
|
|
1184
|
+
|
|
1185
|
+
if response.status_code not in [200]:
|
|
1186
|
+
if _stream:
|
|
1187
|
+
try:
|
|
1188
|
+
await response.read() # Load the body in memory and close the socket
|
|
1189
|
+
except (StreamConsumedError, StreamClosedError):
|
|
1190
|
+
pass
|
|
1191
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
1192
|
+
raise HttpResponseError(response=response)
|
|
1193
|
+
|
|
1194
|
+
if _stream:
|
|
1195
|
+
deserialized = response.iter_bytes()
|
|
1196
|
+
else:
|
|
1197
|
+
deserialized = _deserialize(_models.Evaluation, response.json())
|
|
1198
|
+
|
|
1199
|
+
if cls:
|
|
1200
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
1201
|
+
|
|
1202
|
+
return deserialized # type: ignore
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
class DatasetsOperations:
|
|
1206
|
+
"""
|
|
1207
|
+
.. warning::
|
|
1208
|
+
**DO NOT** instantiate this class directly.
|
|
1209
|
+
|
|
1210
|
+
Instead, you should access the following operations through
|
|
1211
|
+
:class:`~azure.ai.projects.onedp.aio.AIProjectClient`'s
|
|
1212
|
+
:attr:`datasets` attribute.
|
|
1213
|
+
"""
|
|
1214
|
+
|
|
1215
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
1216
|
+
input_args = list(args)
|
|
1217
|
+
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
1218
|
+
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
1219
|
+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
1220
|
+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
1221
|
+
|
|
1222
|
+
@distributed_trace
|
|
1223
|
+
def list_versions(
|
|
1224
|
+
self,
|
|
1225
|
+
name: str,
|
|
1226
|
+
*,
|
|
1227
|
+
top: Optional[int] = None,
|
|
1228
|
+
skip: Optional[str] = None,
|
|
1229
|
+
tags: Optional[str] = None,
|
|
1230
|
+
list_view_type: Optional[Union[str, _models.ListViewType]] = None,
|
|
1231
|
+
**kwargs: Any
|
|
1232
|
+
) -> AsyncIterable["_models.DatasetVersion"]:
|
|
1233
|
+
"""List all versions of the given DatasetVersion.
|
|
1234
|
+
|
|
1235
|
+
:param name: The name of the resource. Required.
|
|
1236
|
+
:type name: str
|
|
1237
|
+
:keyword top: Top count of results, top count cannot be greater than the page size. If topCount
|
|
1238
|
+
> page size, results with be default page size count will be returned. Default value is None.
|
|
1239
|
+
:paramtype top: int
|
|
1240
|
+
:keyword skip: Continuation token for pagination. Default value is None.
|
|
1241
|
+
:paramtype skip: str
|
|
1242
|
+
:keyword tags: Comma-separated list of tag names (and optionally values). Example:
|
|
1243
|
+
tag1,tag2=value2. Default value is None.
|
|
1244
|
+
:paramtype tags: str
|
|
1245
|
+
:keyword list_view_type: [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All]
|
|
1246
|
+
View type for including/excluding (for example) archived entities. Known values are:
|
|
1247
|
+
"ActiveOnly", "ArchivedOnly", and "All". Default value is None.
|
|
1248
|
+
:paramtype list_view_type: str or ~azure.ai.projects.onedp.models.ListViewType
|
|
1249
|
+
:return: An iterator like instance of DatasetVersion
|
|
1250
|
+
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.onedp.models.DatasetVersion]
|
|
1251
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1252
|
+
"""
|
|
1253
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
1254
|
+
_params = kwargs.pop("params", {}) or {}
|
|
1255
|
+
|
|
1256
|
+
cls: ClsType[List[_models.DatasetVersion]] = kwargs.pop("cls", None)
|
|
1257
|
+
|
|
1258
|
+
error_map: MutableMapping = {
|
|
1259
|
+
401: ClientAuthenticationError,
|
|
1260
|
+
404: ResourceNotFoundError,
|
|
1261
|
+
409: ResourceExistsError,
|
|
1262
|
+
304: ResourceNotModifiedError,
|
|
1263
|
+
}
|
|
1264
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
1265
|
+
|
|
1266
|
+
def prepare_request(next_link=None):
|
|
1267
|
+
if not next_link:
|
|
1268
|
+
|
|
1269
|
+
_request = build_datasets_list_versions_request(
|
|
1270
|
+
name=name,
|
|
1271
|
+
top=top,
|
|
1272
|
+
skip=skip,
|
|
1273
|
+
tags=tags,
|
|
1274
|
+
list_view_type=list_view_type,
|
|
1275
|
+
api_version=self._config.api_version,
|
|
1276
|
+
headers=_headers,
|
|
1277
|
+
params=_params,
|
|
1278
|
+
)
|
|
1279
|
+
path_format_arguments = {
|
|
1280
|
+
"endpoint": self._serialize.url(
|
|
1281
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
1282
|
+
),
|
|
1283
|
+
}
|
|
1284
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
1285
|
+
|
|
1286
|
+
else:
|
|
1287
|
+
# make call to next link with the client's api-version
|
|
1288
|
+
_parsed_next_link = urllib.parse.urlparse(next_link)
|
|
1289
|
+
_next_request_params = case_insensitive_dict(
|
|
1290
|
+
{
|
|
1291
|
+
key: [urllib.parse.quote(v) for v in value]
|
|
1292
|
+
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
|
|
1293
|
+
}
|
|
1294
|
+
)
|
|
1295
|
+
_next_request_params["api-version"] = self._config.api_version
|
|
1296
|
+
_request = HttpRequest(
|
|
1297
|
+
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
|
|
1298
|
+
)
|
|
1299
|
+
path_format_arguments = {
|
|
1300
|
+
"endpoint": self._serialize.url(
|
|
1301
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
1302
|
+
),
|
|
1303
|
+
}
|
|
1304
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
1305
|
+
|
|
1306
|
+
return _request
|
|
1307
|
+
|
|
1308
|
+
async def extract_data(pipeline_response):
|
|
1309
|
+
deserialized = pipeline_response.http_response.json()
|
|
1310
|
+
list_of_elem = _deserialize(List[_models.DatasetVersion], deserialized.get("value", []))
|
|
1311
|
+
if cls:
|
|
1312
|
+
list_of_elem = cls(list_of_elem) # type: ignore
|
|
1313
|
+
return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
|
|
1314
|
+
|
|
1315
|
+
async def get_next(next_link=None):
|
|
1316
|
+
_request = prepare_request(next_link)
|
|
1317
|
+
|
|
1318
|
+
_stream = False
|
|
1319
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
1320
|
+
_request, stream=_stream, **kwargs
|
|
1321
|
+
)
|
|
1322
|
+
response = pipeline_response.http_response
|
|
1323
|
+
|
|
1324
|
+
if response.status_code not in [200]:
|
|
1325
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
1326
|
+
raise HttpResponseError(response=response)
|
|
1327
|
+
|
|
1328
|
+
return pipeline_response
|
|
1329
|
+
|
|
1330
|
+
return AsyncItemPaged(get_next, extract_data)
|
|
1331
|
+
|
|
1332
|
+
@distributed_trace
|
|
1333
|
+
def list_latest(
|
|
1334
|
+
self,
|
|
1335
|
+
*,
|
|
1336
|
+
top: Optional[int] = None,
|
|
1337
|
+
skip: Optional[str] = None,
|
|
1338
|
+
tags: Optional[str] = None,
|
|
1339
|
+
list_view_type: Optional[Union[str, _models.ListViewType]] = None,
|
|
1340
|
+
**kwargs: Any
|
|
1341
|
+
) -> AsyncIterable["_models.DatasetVersion"]:
|
|
1342
|
+
"""List the latest version of each DatasetVersion.
|
|
1343
|
+
|
|
1344
|
+
:keyword top: Top count of results, top count cannot be greater than the page size. If topCount
|
|
1345
|
+
> page size, results with be default page size count will be returned. Default value is None.
|
|
1346
|
+
:paramtype top: int
|
|
1347
|
+
:keyword skip: Continuation token for pagination. Default value is None.
|
|
1348
|
+
:paramtype skip: str
|
|
1349
|
+
:keyword tags: Comma-separated list of tag names (and optionally values). Example:
|
|
1350
|
+
tag1,tag2=value2. Default value is None.
|
|
1351
|
+
:paramtype tags: str
|
|
1352
|
+
:keyword list_view_type: [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All]
|
|
1353
|
+
View type for including/excluding (for example) archived entities. Known values are:
|
|
1354
|
+
"ActiveOnly", "ArchivedOnly", and "All". Default value is None.
|
|
1355
|
+
:paramtype list_view_type: str or ~azure.ai.projects.onedp.models.ListViewType
|
|
1356
|
+
:return: An iterator like instance of DatasetVersion
|
|
1357
|
+
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.onedp.models.DatasetVersion]
|
|
1358
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1359
|
+
"""
|
|
1360
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
1361
|
+
_params = kwargs.pop("params", {}) or {}
|
|
1362
|
+
|
|
1363
|
+
cls: ClsType[List[_models.DatasetVersion]] = kwargs.pop("cls", None)
|
|
1364
|
+
|
|
1365
|
+
error_map: MutableMapping = {
|
|
1366
|
+
401: ClientAuthenticationError,
|
|
1367
|
+
404: ResourceNotFoundError,
|
|
1368
|
+
409: ResourceExistsError,
|
|
1369
|
+
304: ResourceNotModifiedError,
|
|
1370
|
+
}
|
|
1371
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
1372
|
+
|
|
1373
|
+
def prepare_request(next_link=None):
|
|
1374
|
+
if not next_link:
|
|
1375
|
+
|
|
1376
|
+
_request = build_datasets_list_latest_request(
|
|
1377
|
+
top=top,
|
|
1378
|
+
skip=skip,
|
|
1379
|
+
tags=tags,
|
|
1380
|
+
list_view_type=list_view_type,
|
|
1381
|
+
api_version=self._config.api_version,
|
|
1382
|
+
headers=_headers,
|
|
1383
|
+
params=_params,
|
|
1384
|
+
)
|
|
1385
|
+
path_format_arguments = {
|
|
1386
|
+
"endpoint": self._serialize.url(
|
|
1387
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
1388
|
+
),
|
|
1389
|
+
}
|
|
1390
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
1391
|
+
|
|
1392
|
+
else:
|
|
1393
|
+
# make call to next link with the client's api-version
|
|
1394
|
+
_parsed_next_link = urllib.parse.urlparse(next_link)
|
|
1395
|
+
_next_request_params = case_insensitive_dict(
|
|
1396
|
+
{
|
|
1397
|
+
key: [urllib.parse.quote(v) for v in value]
|
|
1398
|
+
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
|
|
1399
|
+
}
|
|
1400
|
+
)
|
|
1401
|
+
_next_request_params["api-version"] = self._config.api_version
|
|
1402
|
+
_request = HttpRequest(
|
|
1403
|
+
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
|
|
1404
|
+
)
|
|
1405
|
+
path_format_arguments = {
|
|
1406
|
+
"endpoint": self._serialize.url(
|
|
1407
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
1408
|
+
),
|
|
1409
|
+
}
|
|
1410
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
1411
|
+
|
|
1412
|
+
return _request
|
|
1413
|
+
|
|
1414
|
+
async def extract_data(pipeline_response):
|
|
1415
|
+
deserialized = pipeline_response.http_response.json()
|
|
1416
|
+
list_of_elem = _deserialize(List[_models.DatasetVersion], deserialized.get("value", []))
|
|
1417
|
+
if cls:
|
|
1418
|
+
list_of_elem = cls(list_of_elem) # type: ignore
|
|
1419
|
+
return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
|
|
1420
|
+
|
|
1421
|
+
async def get_next(next_link=None):
|
|
1422
|
+
_request = prepare_request(next_link)
|
|
1423
|
+
|
|
1424
|
+
_stream = False
|
|
1425
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
1426
|
+
_request, stream=_stream, **kwargs
|
|
1427
|
+
)
|
|
1428
|
+
response = pipeline_response.http_response
|
|
1429
|
+
|
|
1430
|
+
if response.status_code not in [200]:
|
|
1431
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
1432
|
+
raise HttpResponseError(response=response)
|
|
1433
|
+
|
|
1434
|
+
return pipeline_response
|
|
1435
|
+
|
|
1436
|
+
return AsyncItemPaged(get_next, extract_data)
|
|
1437
|
+
|
|
1438
|
+
@distributed_trace_async
|
|
1439
|
+
async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion:
|
|
1440
|
+
"""Get the specific version of the DatasetVersion.
|
|
1441
|
+
|
|
1442
|
+
:param name: The name of the resource. Required.
|
|
1443
|
+
:type name: str
|
|
1444
|
+
:param version: The specific version id of the DatasetVersion to retrieve. Required.
|
|
1445
|
+
:type version: str
|
|
1446
|
+
:return: DatasetVersion. The DatasetVersion is compatible with MutableMapping
|
|
1447
|
+
:rtype: ~azure.ai.projects.onedp.models.DatasetVersion
|
|
1448
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1449
|
+
"""
|
|
1450
|
+
error_map: MutableMapping = {
|
|
1451
|
+
401: ClientAuthenticationError,
|
|
1452
|
+
404: ResourceNotFoundError,
|
|
1453
|
+
409: ResourceExistsError,
|
|
1454
|
+
304: ResourceNotModifiedError,
|
|
1455
|
+
}
|
|
1456
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
1457
|
+
|
|
1458
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
1459
|
+
_params = kwargs.pop("params", {}) or {}
|
|
1460
|
+
|
|
1461
|
+
cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None)
|
|
1462
|
+
|
|
1463
|
+
_request = build_datasets_get_version_request(
|
|
1464
|
+
name=name,
|
|
1465
|
+
version=version,
|
|
1466
|
+
api_version=self._config.api_version,
|
|
1467
|
+
headers=_headers,
|
|
1468
|
+
params=_params,
|
|
1469
|
+
)
|
|
1470
|
+
path_format_arguments = {
|
|
1471
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
1472
|
+
}
|
|
1473
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
1474
|
+
|
|
1475
|
+
_stream = kwargs.pop("stream", False)
|
|
1476
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
1477
|
+
_request, stream=_stream, **kwargs
|
|
1478
|
+
)
|
|
1479
|
+
|
|
1480
|
+
response = pipeline_response.http_response
|
|
1481
|
+
|
|
1482
|
+
if response.status_code not in [200]:
|
|
1483
|
+
if _stream:
|
|
1484
|
+
try:
|
|
1485
|
+
await response.read() # Load the body in memory and close the socket
|
|
1486
|
+
except (StreamConsumedError, StreamClosedError):
|
|
1487
|
+
pass
|
|
1488
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
1489
|
+
raise HttpResponseError(response=response)
|
|
1490
|
+
|
|
1491
|
+
if _stream:
|
|
1492
|
+
deserialized = response.iter_bytes()
|
|
1493
|
+
else:
|
|
1494
|
+
deserialized = _deserialize(_models.DatasetVersion, response.json())
|
|
1495
|
+
|
|
1496
|
+
if cls:
|
|
1497
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
1498
|
+
|
|
1499
|
+
return deserialized # type: ignore
|
|
1500
|
+
|
|
1501
|
+
@distributed_trace_async
|
|
1502
|
+
async def delete_version(self, name: str, version: str, **kwargs: Any) -> None:
|
|
1503
|
+
"""Delete the specific version of the DatasetVersion.
|
|
1504
|
+
|
|
1505
|
+
:param name: The name of the resource. Required.
|
|
1506
|
+
:type name: str
|
|
1507
|
+
:param version: The version of the DatasetVersion to delete. Required.
|
|
1508
|
+
:type version: str
|
|
1509
|
+
:return: None
|
|
1510
|
+
:rtype: None
|
|
1511
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1512
|
+
"""
|
|
1513
|
+
error_map: MutableMapping = {
|
|
1514
|
+
401: ClientAuthenticationError,
|
|
1515
|
+
404: ResourceNotFoundError,
|
|
1516
|
+
409: ResourceExistsError,
|
|
1517
|
+
304: ResourceNotModifiedError,
|
|
1518
|
+
}
|
|
1519
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
1520
|
+
|
|
1521
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
1522
|
+
_params = kwargs.pop("params", {}) or {}
|
|
1523
|
+
|
|
1524
|
+
cls: ClsType[None] = kwargs.pop("cls", None)
|
|
1525
|
+
|
|
1526
|
+
_request = build_datasets_delete_version_request(
|
|
1527
|
+
name=name,
|
|
1528
|
+
version=version,
|
|
1529
|
+
api_version=self._config.api_version,
|
|
1530
|
+
headers=_headers,
|
|
1531
|
+
params=_params,
|
|
1532
|
+
)
|
|
1533
|
+
path_format_arguments = {
|
|
1534
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
1535
|
+
}
|
|
1536
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
1537
|
+
|
|
1538
|
+
_stream = False
|
|
1539
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
1540
|
+
_request, stream=_stream, **kwargs
|
|
1541
|
+
)
|
|
1542
|
+
|
|
1543
|
+
response = pipeline_response.http_response
|
|
1544
|
+
|
|
1545
|
+
if response.status_code not in [204]:
|
|
1546
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
1547
|
+
raise HttpResponseError(response=response)
|
|
1548
|
+
|
|
1549
|
+
if cls:
|
|
1550
|
+
return cls(pipeline_response, None, {}) # type: ignore
|
|
1551
|
+
|
|
1552
|
+
@overload
|
|
1553
|
+
async def create_or_update_version(
|
|
1554
|
+
self,
|
|
1555
|
+
name: str,
|
|
1556
|
+
version: str,
|
|
1557
|
+
body: _models.DatasetVersion,
|
|
1558
|
+
*,
|
|
1559
|
+
content_type: str = "application/json",
|
|
1560
|
+
**kwargs: Any
|
|
1561
|
+
) -> _models.DatasetVersion:
|
|
1562
|
+
"""Create a new or update an existing DatasetVersion with the given version id.
|
|
1563
|
+
|
|
1564
|
+
:param name: The name of the resource. Required.
|
|
1565
|
+
:type name: str
|
|
1566
|
+
:param version: The specific version id of the DatasetVersion to create or replace. Required.
|
|
1567
|
+
:type version: str
|
|
1568
|
+
:param body: The definition of the DatasetVersion to create or update. Required.
|
|
1569
|
+
:type body: ~azure.ai.projects.onedp.models.DatasetVersion
|
|
1570
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
1571
|
+
Default value is "application/json".
|
|
1572
|
+
:paramtype content_type: str
|
|
1573
|
+
:return: DatasetVersion. The DatasetVersion is compatible with MutableMapping
|
|
1574
|
+
:rtype: ~azure.ai.projects.onedp.models.DatasetVersion
|
|
1575
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1576
|
+
"""
|
|
1577
|
+
|
|
1578
|
+
@overload
|
|
1579
|
+
async def create_or_update_version(
|
|
1580
|
+
self, name: str, version: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
1581
|
+
) -> _models.DatasetVersion:
|
|
1582
|
+
"""Create a new or update an existing DatasetVersion with the given version id.
|
|
1583
|
+
|
|
1584
|
+
:param name: The name of the resource. Required.
|
|
1585
|
+
:type name: str
|
|
1586
|
+
:param version: The specific version id of the DatasetVersion to create or replace. Required.
|
|
1587
|
+
:type version: str
|
|
1588
|
+
:param body: The definition of the DatasetVersion to create or update. Required.
|
|
1589
|
+
:type body: JSON
|
|
1590
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
1591
|
+
Default value is "application/json".
|
|
1592
|
+
:paramtype content_type: str
|
|
1593
|
+
:return: DatasetVersion. The DatasetVersion is compatible with MutableMapping
|
|
1594
|
+
:rtype: ~azure.ai.projects.onedp.models.DatasetVersion
|
|
1595
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1596
|
+
"""
|
|
1597
|
+
|
|
1598
|
+
@overload
|
|
1599
|
+
async def create_or_update_version(
|
|
1600
|
+
self, name: str, version: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
1601
|
+
) -> _models.DatasetVersion:
|
|
1602
|
+
"""Create a new or update an existing DatasetVersion with the given version id.
|
|
1603
|
+
|
|
1604
|
+
:param name: The name of the resource. Required.
|
|
1605
|
+
:type name: str
|
|
1606
|
+
:param version: The specific version id of the DatasetVersion to create or replace. Required.
|
|
1607
|
+
:type version: str
|
|
1608
|
+
:param body: The definition of the DatasetVersion to create or update. Required.
|
|
1609
|
+
:type body: IO[bytes]
|
|
1610
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
1611
|
+
Default value is "application/json".
|
|
1612
|
+
:paramtype content_type: str
|
|
1613
|
+
:return: DatasetVersion. The DatasetVersion is compatible with MutableMapping
|
|
1614
|
+
:rtype: ~azure.ai.projects.onedp.models.DatasetVersion
|
|
1615
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1616
|
+
"""
|
|
1617
|
+
|
|
1618
|
+
@distributed_trace_async
|
|
1619
|
+
async def create_or_update_version(
|
|
1620
|
+
self, name: str, version: str, body: Union[_models.DatasetVersion, JSON, IO[bytes]], **kwargs: Any
|
|
1621
|
+
) -> _models.DatasetVersion:
|
|
1622
|
+
"""Create a new or update an existing DatasetVersion with the given version id.
|
|
1623
|
+
|
|
1624
|
+
:param name: The name of the resource. Required.
|
|
1625
|
+
:type name: str
|
|
1626
|
+
:param version: The specific version id of the DatasetVersion to create or replace. Required.
|
|
1627
|
+
:type version: str
|
|
1628
|
+
:param body: The definition of the DatasetVersion to create or update. Is one of the following
|
|
1629
|
+
types: DatasetVersion, JSON, IO[bytes] Required.
|
|
1630
|
+
:type body: ~azure.ai.projects.onedp.models.DatasetVersion or JSON or IO[bytes]
|
|
1631
|
+
:return: DatasetVersion. The DatasetVersion is compatible with MutableMapping
|
|
1632
|
+
:rtype: ~azure.ai.projects.onedp.models.DatasetVersion
|
|
1633
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1634
|
+
"""
|
|
1635
|
+
error_map: MutableMapping = {
|
|
1636
|
+
401: ClientAuthenticationError,
|
|
1637
|
+
404: ResourceNotFoundError,
|
|
1638
|
+
409: ResourceExistsError,
|
|
1639
|
+
304: ResourceNotModifiedError,
|
|
1640
|
+
}
|
|
1641
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
1642
|
+
|
|
1643
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
1644
|
+
_params = kwargs.pop("params", {}) or {}
|
|
1645
|
+
|
|
1646
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
1647
|
+
cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None)
|
|
1648
|
+
|
|
1649
|
+
content_type = content_type or "application/json"
|
|
1650
|
+
_content = None
|
|
1651
|
+
if isinstance(body, (IOBase, bytes)):
|
|
1652
|
+
_content = body
|
|
1653
|
+
else:
|
|
1654
|
+
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
1655
|
+
|
|
1656
|
+
_request = build_datasets_create_or_update_version_request(
|
|
1657
|
+
name=name,
|
|
1658
|
+
version=version,
|
|
1659
|
+
content_type=content_type,
|
|
1660
|
+
api_version=self._config.api_version,
|
|
1661
|
+
content=_content,
|
|
1662
|
+
headers=_headers,
|
|
1663
|
+
params=_params,
|
|
1664
|
+
)
|
|
1665
|
+
path_format_arguments = {
|
|
1666
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
1667
|
+
}
|
|
1668
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
1669
|
+
|
|
1670
|
+
_stream = kwargs.pop("stream", False)
|
|
1671
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
1672
|
+
_request, stream=_stream, **kwargs
|
|
1673
|
+
)
|
|
1674
|
+
|
|
1675
|
+
response = pipeline_response.http_response
|
|
1676
|
+
|
|
1677
|
+
if response.status_code not in [200, 201]:
|
|
1678
|
+
if _stream:
|
|
1679
|
+
try:
|
|
1680
|
+
await response.read() # Load the body in memory and close the socket
|
|
1681
|
+
except (StreamConsumedError, StreamClosedError):
|
|
1682
|
+
pass
|
|
1683
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
1684
|
+
raise HttpResponseError(response=response)
|
|
1685
|
+
|
|
1686
|
+
if _stream:
|
|
1687
|
+
deserialized = response.iter_bytes()
|
|
1688
|
+
else:
|
|
1689
|
+
deserialized = _deserialize(_models.DatasetVersion, response.json())
|
|
1690
|
+
|
|
1691
|
+
if cls:
|
|
1692
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
1693
|
+
|
|
1694
|
+
return deserialized # type: ignore
|
|
1695
|
+
|
|
1696
|
+
@overload
|
|
1697
|
+
async def start_pending_upload_version(
|
|
1698
|
+
self,
|
|
1699
|
+
name: str,
|
|
1700
|
+
version: str,
|
|
1701
|
+
body: _models.PendingUploadRequest,
|
|
1702
|
+
*,
|
|
1703
|
+
content_type: str = "application/json",
|
|
1704
|
+
**kwargs: Any
|
|
1705
|
+
) -> _models.PendingUploadResponse:
|
|
1706
|
+
"""Start a new or get an existing pending upload of a dataset for a specific version.
|
|
1707
|
+
|
|
1708
|
+
:param name: The name of the resource. Required.
|
|
1709
|
+
:type name: str
|
|
1710
|
+
:param version: The specific version id of the DatasetVersion to operate on. Required.
|
|
1711
|
+
:type version: str
|
|
1712
|
+
:param body: Parameters for the action. Required.
|
|
1713
|
+
:type body: ~azure.ai.projects.onedp.models.PendingUploadRequest
|
|
1714
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
1715
|
+
Default value is "application/json".
|
|
1716
|
+
:paramtype content_type: str
|
|
1717
|
+
:return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping
|
|
1718
|
+
:rtype: ~azure.ai.projects.onedp.models.PendingUploadResponse
|
|
1719
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1720
|
+
"""
|
|
1721
|
+
|
|
1722
|
+
@overload
|
|
1723
|
+
async def start_pending_upload_version(
|
|
1724
|
+
self, name: str, version: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
1725
|
+
) -> _models.PendingUploadResponse:
|
|
1726
|
+
"""Start a new or get an existing pending upload of a dataset for a specific version.
|
|
1727
|
+
|
|
1728
|
+
:param name: The name of the resource. Required.
|
|
1729
|
+
:type name: str
|
|
1730
|
+
:param version: The specific version id of the DatasetVersion to operate on. Required.
|
|
1731
|
+
:type version: str
|
|
1732
|
+
:param body: Parameters for the action. Required.
|
|
1733
|
+
:type body: JSON
|
|
1734
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
1735
|
+
Default value is "application/json".
|
|
1736
|
+
:paramtype content_type: str
|
|
1737
|
+
:return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping
|
|
1738
|
+
:rtype: ~azure.ai.projects.onedp.models.PendingUploadResponse
|
|
1739
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1740
|
+
"""
|
|
1741
|
+
|
|
1742
|
+
@overload
|
|
1743
|
+
async def start_pending_upload_version(
|
|
1744
|
+
self, name: str, version: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
1745
|
+
) -> _models.PendingUploadResponse:
|
|
1746
|
+
"""Start a new or get an existing pending upload of a dataset for a specific version.
|
|
1747
|
+
|
|
1748
|
+
:param name: The name of the resource. Required.
|
|
1749
|
+
:type name: str
|
|
1750
|
+
:param version: The specific version id of the DatasetVersion to operate on. Required.
|
|
1751
|
+
:type version: str
|
|
1752
|
+
:param body: Parameters for the action. Required.
|
|
1753
|
+
:type body: IO[bytes]
|
|
1754
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
1755
|
+
Default value is "application/json".
|
|
1756
|
+
:paramtype content_type: str
|
|
1757
|
+
:return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping
|
|
1758
|
+
:rtype: ~azure.ai.projects.onedp.models.PendingUploadResponse
|
|
1759
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1760
|
+
"""
|
|
1761
|
+
|
|
1762
|
+
@distributed_trace_async
|
|
1763
|
+
async def start_pending_upload_version(
|
|
1764
|
+
self, name: str, version: str, body: Union[_models.PendingUploadRequest, JSON, IO[bytes]], **kwargs: Any
|
|
1765
|
+
) -> _models.PendingUploadResponse:
|
|
1766
|
+
"""Start a new or get an existing pending upload of a dataset for a specific version.
|
|
1767
|
+
|
|
1768
|
+
:param name: The name of the resource. Required.
|
|
1769
|
+
:type name: str
|
|
1770
|
+
:param version: The specific version id of the DatasetVersion to operate on. Required.
|
|
1771
|
+
:type version: str
|
|
1772
|
+
:param body: Parameters for the action. Is one of the following types: PendingUploadRequest,
|
|
1773
|
+
JSON, IO[bytes] Required.
|
|
1774
|
+
:type body: ~azure.ai.projects.onedp.models.PendingUploadRequest or JSON or IO[bytes]
|
|
1775
|
+
:return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping
|
|
1776
|
+
:rtype: ~azure.ai.projects.onedp.models.PendingUploadResponse
|
|
1777
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1778
|
+
"""
|
|
1779
|
+
error_map: MutableMapping = {
|
|
1780
|
+
401: ClientAuthenticationError,
|
|
1781
|
+
404: ResourceNotFoundError,
|
|
1782
|
+
409: ResourceExistsError,
|
|
1783
|
+
304: ResourceNotModifiedError,
|
|
1784
|
+
}
|
|
1785
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
1786
|
+
|
|
1787
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
1788
|
+
_params = kwargs.pop("params", {}) or {}
|
|
1789
|
+
|
|
1790
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
1791
|
+
cls: ClsType[_models.PendingUploadResponse] = kwargs.pop("cls", None)
|
|
1792
|
+
|
|
1793
|
+
content_type = content_type or "application/json"
|
|
1794
|
+
_content = None
|
|
1795
|
+
if isinstance(body, (IOBase, bytes)):
|
|
1796
|
+
_content = body
|
|
1797
|
+
else:
|
|
1798
|
+
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
1799
|
+
|
|
1800
|
+
_request = build_datasets_start_pending_upload_version_request(
|
|
1801
|
+
name=name,
|
|
1802
|
+
version=version,
|
|
1803
|
+
content_type=content_type,
|
|
1804
|
+
api_version=self._config.api_version,
|
|
1805
|
+
content=_content,
|
|
1806
|
+
headers=_headers,
|
|
1807
|
+
params=_params,
|
|
1808
|
+
)
|
|
1809
|
+
path_format_arguments = {
|
|
1810
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
1811
|
+
}
|
|
1812
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
1813
|
+
|
|
1814
|
+
_stream = kwargs.pop("stream", False)
|
|
1815
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
1816
|
+
_request, stream=_stream, **kwargs
|
|
1817
|
+
)
|
|
1818
|
+
|
|
1819
|
+
response = pipeline_response.http_response
|
|
1820
|
+
|
|
1821
|
+
if response.status_code not in [200]:
|
|
1822
|
+
if _stream:
|
|
1823
|
+
try:
|
|
1824
|
+
await response.read() # Load the body in memory and close the socket
|
|
1825
|
+
except (StreamConsumedError, StreamClosedError):
|
|
1826
|
+
pass
|
|
1827
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
1828
|
+
raise HttpResponseError(response=response)
|
|
1829
|
+
|
|
1830
|
+
if _stream:
|
|
1831
|
+
deserialized = response.iter_bytes()
|
|
1832
|
+
else:
|
|
1833
|
+
deserialized = _deserialize(_models.PendingUploadResponse, response.json())
|
|
1834
|
+
|
|
1835
|
+
if cls:
|
|
1836
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
1837
|
+
|
|
1838
|
+
return deserialized # type: ignore
|
|
1839
|
+
|
|
1840
|
+
@distributed_trace_async
|
|
1841
|
+
async def get_credentials(
|
|
1842
|
+
self, name: str, version: str, body: Any, **kwargs: Any
|
|
1843
|
+
) -> _models.AssetCredentialResponse:
|
|
1844
|
+
"""Get download sas for dataset version.
|
|
1845
|
+
|
|
1846
|
+
:param name: The name of the resource. Required.
|
|
1847
|
+
:type name: str
|
|
1848
|
+
:param version: The specific version id of the DatasetVersion to operate on. Required.
|
|
1849
|
+
:type version: str
|
|
1850
|
+
:param body: Parameters for the action. Required.
|
|
1851
|
+
:type body: any
|
|
1852
|
+
:return: AssetCredentialResponse. The AssetCredentialResponse is compatible with MutableMapping
|
|
1853
|
+
:rtype: ~azure.ai.projects.onedp.models.AssetCredentialResponse
|
|
1854
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1855
|
+
"""
|
|
1856
|
+
error_map: MutableMapping = {
|
|
1857
|
+
401: ClientAuthenticationError,
|
|
1858
|
+
404: ResourceNotFoundError,
|
|
1859
|
+
409: ResourceExistsError,
|
|
1860
|
+
304: ResourceNotModifiedError,
|
|
1861
|
+
}
|
|
1862
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
1863
|
+
|
|
1864
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
1865
|
+
_params = kwargs.pop("params", {}) or {}
|
|
1866
|
+
|
|
1867
|
+
content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json"))
|
|
1868
|
+
cls: ClsType[_models.AssetCredentialResponse] = kwargs.pop("cls", None)
|
|
1869
|
+
|
|
1870
|
+
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
1871
|
+
|
|
1872
|
+
_request = build_datasets_get_credentials_request(
|
|
1873
|
+
name=name,
|
|
1874
|
+
version=version,
|
|
1875
|
+
content_type=content_type,
|
|
1876
|
+
api_version=self._config.api_version,
|
|
1877
|
+
content=_content,
|
|
1878
|
+
headers=_headers,
|
|
1879
|
+
params=_params,
|
|
1880
|
+
)
|
|
1881
|
+
path_format_arguments = {
|
|
1882
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
1883
|
+
}
|
|
1884
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
1885
|
+
|
|
1886
|
+
_stream = kwargs.pop("stream", False)
|
|
1887
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
1888
|
+
_request, stream=_stream, **kwargs
|
|
1889
|
+
)
|
|
1890
|
+
|
|
1891
|
+
response = pipeline_response.http_response
|
|
1892
|
+
|
|
1893
|
+
if response.status_code not in [200]:
|
|
1894
|
+
if _stream:
|
|
1895
|
+
try:
|
|
1896
|
+
await response.read() # Load the body in memory and close the socket
|
|
1897
|
+
except (StreamConsumedError, StreamClosedError):
|
|
1898
|
+
pass
|
|
1899
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
1900
|
+
raise HttpResponseError(response=response)
|
|
1901
|
+
|
|
1902
|
+
if _stream:
|
|
1903
|
+
deserialized = response.iter_bytes()
|
|
1904
|
+
else:
|
|
1905
|
+
deserialized = _deserialize(_models.AssetCredentialResponse, response.json())
|
|
1906
|
+
|
|
1907
|
+
if cls:
|
|
1908
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
1909
|
+
|
|
1910
|
+
return deserialized # type: ignore
|
|
1911
|
+
|
|
1912
|
+
|
|
1913
|
+
class IndexesOperations:
|
|
1914
|
+
"""
|
|
1915
|
+
.. warning::
|
|
1916
|
+
**DO NOT** instantiate this class directly.
|
|
1917
|
+
|
|
1918
|
+
Instead, you should access the following operations through
|
|
1919
|
+
:class:`~azure.ai.projects.onedp.aio.AIProjectClient`'s
|
|
1920
|
+
:attr:`indexes` attribute.
|
|
1921
|
+
"""
|
|
1922
|
+
|
|
1923
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
1924
|
+
input_args = list(args)
|
|
1925
|
+
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
1926
|
+
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
1927
|
+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
1928
|
+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
1929
|
+
|
|
1930
|
+
@distributed_trace
|
|
1931
|
+
def list_versions(
|
|
1932
|
+
self,
|
|
1933
|
+
name: str,
|
|
1934
|
+
*,
|
|
1935
|
+
top: Optional[int] = None,
|
|
1936
|
+
skip: Optional[str] = None,
|
|
1937
|
+
tags: Optional[str] = None,
|
|
1938
|
+
list_view_type: Optional[Union[str, _models.ListViewType]] = None,
|
|
1939
|
+
**kwargs: Any
|
|
1940
|
+
) -> AsyncIterable["_models.Index"]:
|
|
1941
|
+
"""List all versions of the given Index.
|
|
1942
|
+
|
|
1943
|
+
:param name: The name of the resource. Required.
|
|
1944
|
+
:type name: str
|
|
1945
|
+
:keyword top: Top count of results, top count cannot be greater than the page size. If topCount
|
|
1946
|
+
> page size, results with be default page size count will be returned. Default value is None.
|
|
1947
|
+
:paramtype top: int
|
|
1948
|
+
:keyword skip: Continuation token for pagination. Default value is None.
|
|
1949
|
+
:paramtype skip: str
|
|
1950
|
+
:keyword tags: Comma-separated list of tag names (and optionally values). Example:
|
|
1951
|
+
tag1,tag2=value2. Default value is None.
|
|
1952
|
+
:paramtype tags: str
|
|
1953
|
+
:keyword list_view_type: [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All]
|
|
1954
|
+
View type for including/excluding (for example) archived entities. Known values are:
|
|
1955
|
+
"ActiveOnly", "ArchivedOnly", and "All". Default value is None.
|
|
1956
|
+
:paramtype list_view_type: str or ~azure.ai.projects.onedp.models.ListViewType
|
|
1957
|
+
:return: An iterator like instance of Index
|
|
1958
|
+
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.onedp.models.Index]
|
|
1959
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1960
|
+
"""
|
|
1961
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
1962
|
+
_params = kwargs.pop("params", {}) or {}
|
|
1963
|
+
|
|
1964
|
+
cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None)
|
|
1965
|
+
|
|
1966
|
+
error_map: MutableMapping = {
|
|
1967
|
+
401: ClientAuthenticationError,
|
|
1968
|
+
404: ResourceNotFoundError,
|
|
1969
|
+
409: ResourceExistsError,
|
|
1970
|
+
304: ResourceNotModifiedError,
|
|
1971
|
+
}
|
|
1972
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
1973
|
+
|
|
1974
|
+
def prepare_request(next_link=None):
|
|
1975
|
+
if not next_link:
|
|
1976
|
+
|
|
1977
|
+
_request = build_indexes_list_versions_request(
|
|
1978
|
+
name=name,
|
|
1979
|
+
top=top,
|
|
1980
|
+
skip=skip,
|
|
1981
|
+
tags=tags,
|
|
1982
|
+
list_view_type=list_view_type,
|
|
1983
|
+
api_version=self._config.api_version,
|
|
1984
|
+
headers=_headers,
|
|
1985
|
+
params=_params,
|
|
1986
|
+
)
|
|
1987
|
+
path_format_arguments = {
|
|
1988
|
+
"endpoint": self._serialize.url(
|
|
1989
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
1990
|
+
),
|
|
1991
|
+
}
|
|
1992
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
1993
|
+
|
|
1994
|
+
else:
|
|
1995
|
+
# make call to next link with the client's api-version
|
|
1996
|
+
_parsed_next_link = urllib.parse.urlparse(next_link)
|
|
1997
|
+
_next_request_params = case_insensitive_dict(
|
|
1998
|
+
{
|
|
1999
|
+
key: [urllib.parse.quote(v) for v in value]
|
|
2000
|
+
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
|
|
2001
|
+
}
|
|
2002
|
+
)
|
|
2003
|
+
_next_request_params["api-version"] = self._config.api_version
|
|
2004
|
+
_request = HttpRequest(
|
|
2005
|
+
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
|
|
2006
|
+
)
|
|
2007
|
+
path_format_arguments = {
|
|
2008
|
+
"endpoint": self._serialize.url(
|
|
2009
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
2010
|
+
),
|
|
2011
|
+
}
|
|
2012
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2013
|
+
|
|
2014
|
+
return _request
|
|
2015
|
+
|
|
2016
|
+
async def extract_data(pipeline_response):
|
|
2017
|
+
deserialized = pipeline_response.http_response.json()
|
|
2018
|
+
list_of_elem = _deserialize(List[_models.Index], deserialized.get("value", []))
|
|
2019
|
+
if cls:
|
|
2020
|
+
list_of_elem = cls(list_of_elem) # type: ignore
|
|
2021
|
+
return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
|
|
2022
|
+
|
|
2023
|
+
async def get_next(next_link=None):
|
|
2024
|
+
_request = prepare_request(next_link)
|
|
2025
|
+
|
|
2026
|
+
_stream = False
|
|
2027
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
2028
|
+
_request, stream=_stream, **kwargs
|
|
2029
|
+
)
|
|
2030
|
+
response = pipeline_response.http_response
|
|
2031
|
+
|
|
2032
|
+
if response.status_code not in [200]:
|
|
2033
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
2034
|
+
raise HttpResponseError(response=response)
|
|
2035
|
+
|
|
2036
|
+
return pipeline_response
|
|
2037
|
+
|
|
2038
|
+
return AsyncItemPaged(get_next, extract_data)
|
|
2039
|
+
|
|
2040
|
+
@distributed_trace
|
|
2041
|
+
def list_latest(
|
|
2042
|
+
self,
|
|
2043
|
+
*,
|
|
2044
|
+
top: Optional[int] = None,
|
|
2045
|
+
skip: Optional[str] = None,
|
|
2046
|
+
tags: Optional[str] = None,
|
|
2047
|
+
list_view_type: Optional[Union[str, _models.ListViewType]] = None,
|
|
2048
|
+
**kwargs: Any
|
|
2049
|
+
) -> AsyncIterable["_models.Index"]:
|
|
2050
|
+
"""List the latest version of each Index.
|
|
2051
|
+
|
|
2052
|
+
:keyword top: Top count of results, top count cannot be greater than the page size. If topCount
|
|
2053
|
+
> page size, results with be default page size count will be returned. Default value is None.
|
|
2054
|
+
:paramtype top: int
|
|
2055
|
+
:keyword skip: Continuation token for pagination. Default value is None.
|
|
2056
|
+
:paramtype skip: str
|
|
2057
|
+
:keyword tags: Comma-separated list of tag names (and optionally values). Example:
|
|
2058
|
+
tag1,tag2=value2. Default value is None.
|
|
2059
|
+
:paramtype tags: str
|
|
2060
|
+
:keyword list_view_type: [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All]
|
|
2061
|
+
View type for including/excluding (for example) archived entities. Known values are:
|
|
2062
|
+
"ActiveOnly", "ArchivedOnly", and "All". Default value is None.
|
|
2063
|
+
:paramtype list_view_type: str or ~azure.ai.projects.onedp.models.ListViewType
|
|
2064
|
+
:return: An iterator like instance of Index
|
|
2065
|
+
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.onedp.models.Index]
|
|
2066
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2067
|
+
"""
|
|
2068
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
2069
|
+
_params = kwargs.pop("params", {}) or {}
|
|
2070
|
+
|
|
2071
|
+
cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None)
|
|
2072
|
+
|
|
2073
|
+
error_map: MutableMapping = {
|
|
2074
|
+
401: ClientAuthenticationError,
|
|
2075
|
+
404: ResourceNotFoundError,
|
|
2076
|
+
409: ResourceExistsError,
|
|
2077
|
+
304: ResourceNotModifiedError,
|
|
2078
|
+
}
|
|
2079
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
2080
|
+
|
|
2081
|
+
def prepare_request(next_link=None):
|
|
2082
|
+
if not next_link:
|
|
2083
|
+
|
|
2084
|
+
_request = build_indexes_list_latest_request(
|
|
2085
|
+
top=top,
|
|
2086
|
+
skip=skip,
|
|
2087
|
+
tags=tags,
|
|
2088
|
+
list_view_type=list_view_type,
|
|
2089
|
+
api_version=self._config.api_version,
|
|
2090
|
+
headers=_headers,
|
|
2091
|
+
params=_params,
|
|
2092
|
+
)
|
|
2093
|
+
path_format_arguments = {
|
|
2094
|
+
"endpoint": self._serialize.url(
|
|
2095
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
2096
|
+
),
|
|
2097
|
+
}
|
|
2098
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2099
|
+
|
|
2100
|
+
else:
|
|
2101
|
+
# make call to next link with the client's api-version
|
|
2102
|
+
_parsed_next_link = urllib.parse.urlparse(next_link)
|
|
2103
|
+
_next_request_params = case_insensitive_dict(
|
|
2104
|
+
{
|
|
2105
|
+
key: [urllib.parse.quote(v) for v in value]
|
|
2106
|
+
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
|
|
2107
|
+
}
|
|
2108
|
+
)
|
|
2109
|
+
_next_request_params["api-version"] = self._config.api_version
|
|
2110
|
+
_request = HttpRequest(
|
|
2111
|
+
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
|
|
2112
|
+
)
|
|
2113
|
+
path_format_arguments = {
|
|
2114
|
+
"endpoint": self._serialize.url(
|
|
2115
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
2116
|
+
),
|
|
2117
|
+
}
|
|
2118
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2119
|
+
|
|
2120
|
+
return _request
|
|
2121
|
+
|
|
2122
|
+
async def extract_data(pipeline_response):
|
|
2123
|
+
deserialized = pipeline_response.http_response.json()
|
|
2124
|
+
list_of_elem = _deserialize(List[_models.Index], deserialized.get("value", []))
|
|
2125
|
+
if cls:
|
|
2126
|
+
list_of_elem = cls(list_of_elem) # type: ignore
|
|
2127
|
+
return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
|
|
2128
|
+
|
|
2129
|
+
async def get_next(next_link=None):
|
|
2130
|
+
_request = prepare_request(next_link)
|
|
2131
|
+
|
|
2132
|
+
_stream = False
|
|
2133
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
2134
|
+
_request, stream=_stream, **kwargs
|
|
2135
|
+
)
|
|
2136
|
+
response = pipeline_response.http_response
|
|
2137
|
+
|
|
2138
|
+
if response.status_code not in [200]:
|
|
2139
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
2140
|
+
raise HttpResponseError(response=response)
|
|
2141
|
+
|
|
2142
|
+
return pipeline_response
|
|
2143
|
+
|
|
2144
|
+
return AsyncItemPaged(get_next, extract_data)
|
|
2145
|
+
|
|
2146
|
+
@distributed_trace_async
|
|
2147
|
+
async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.Index:
|
|
2148
|
+
"""Get the specific version of the Index.
|
|
2149
|
+
|
|
2150
|
+
:param name: The name of the resource. Required.
|
|
2151
|
+
:type name: str
|
|
2152
|
+
:param version: The specific version id of the Index to retrieve. Required.
|
|
2153
|
+
:type version: str
|
|
2154
|
+
:return: Index. The Index is compatible with MutableMapping
|
|
2155
|
+
:rtype: ~azure.ai.projects.onedp.models.Index
|
|
2156
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2157
|
+
"""
|
|
2158
|
+
error_map: MutableMapping = {
|
|
2159
|
+
401: ClientAuthenticationError,
|
|
2160
|
+
404: ResourceNotFoundError,
|
|
2161
|
+
409: ResourceExistsError,
|
|
2162
|
+
304: ResourceNotModifiedError,
|
|
2163
|
+
}
|
|
2164
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
2165
|
+
|
|
2166
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
2167
|
+
_params = kwargs.pop("params", {}) or {}
|
|
2168
|
+
|
|
2169
|
+
cls: ClsType[_models.Index] = kwargs.pop("cls", None)
|
|
2170
|
+
|
|
2171
|
+
_request = build_indexes_get_version_request(
|
|
2172
|
+
name=name,
|
|
2173
|
+
version=version,
|
|
2174
|
+
api_version=self._config.api_version,
|
|
2175
|
+
headers=_headers,
|
|
2176
|
+
params=_params,
|
|
2177
|
+
)
|
|
2178
|
+
path_format_arguments = {
|
|
2179
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
2180
|
+
}
|
|
2181
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2182
|
+
|
|
2183
|
+
_stream = kwargs.pop("stream", False)
|
|
2184
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
2185
|
+
_request, stream=_stream, **kwargs
|
|
2186
|
+
)
|
|
2187
|
+
|
|
2188
|
+
response = pipeline_response.http_response
|
|
2189
|
+
|
|
2190
|
+
if response.status_code not in [200]:
|
|
2191
|
+
if _stream:
|
|
2192
|
+
try:
|
|
2193
|
+
await response.read() # Load the body in memory and close the socket
|
|
2194
|
+
except (StreamConsumedError, StreamClosedError):
|
|
2195
|
+
pass
|
|
2196
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
2197
|
+
raise HttpResponseError(response=response)
|
|
2198
|
+
|
|
2199
|
+
if _stream:
|
|
2200
|
+
deserialized = response.iter_bytes()
|
|
2201
|
+
else:
|
|
2202
|
+
deserialized = _deserialize(_models.Index, response.json())
|
|
2203
|
+
|
|
2204
|
+
if cls:
|
|
2205
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
2206
|
+
|
|
2207
|
+
return deserialized # type: ignore
|
|
2208
|
+
|
|
2209
|
+
@distributed_trace_async
|
|
2210
|
+
async def delete_version(self, name: str, version: str, **kwargs: Any) -> None:
|
|
2211
|
+
"""Delete the specific version of the Index.
|
|
2212
|
+
|
|
2213
|
+
:param name: The name of the resource. Required.
|
|
2214
|
+
:type name: str
|
|
2215
|
+
:param version: The version of the Index to delete. Required.
|
|
2216
|
+
:type version: str
|
|
2217
|
+
:return: None
|
|
2218
|
+
:rtype: None
|
|
2219
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2220
|
+
"""
|
|
2221
|
+
error_map: MutableMapping = {
|
|
2222
|
+
401: ClientAuthenticationError,
|
|
2223
|
+
404: ResourceNotFoundError,
|
|
2224
|
+
409: ResourceExistsError,
|
|
2225
|
+
304: ResourceNotModifiedError,
|
|
2226
|
+
}
|
|
2227
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
2228
|
+
|
|
2229
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
2230
|
+
_params = kwargs.pop("params", {}) or {}
|
|
2231
|
+
|
|
2232
|
+
cls: ClsType[None] = kwargs.pop("cls", None)
|
|
2233
|
+
|
|
2234
|
+
_request = build_indexes_delete_version_request(
|
|
2235
|
+
name=name,
|
|
2236
|
+
version=version,
|
|
2237
|
+
api_version=self._config.api_version,
|
|
2238
|
+
headers=_headers,
|
|
2239
|
+
params=_params,
|
|
2240
|
+
)
|
|
2241
|
+
path_format_arguments = {
|
|
2242
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
2243
|
+
}
|
|
2244
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2245
|
+
|
|
2246
|
+
_stream = False
|
|
2247
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
2248
|
+
_request, stream=_stream, **kwargs
|
|
2249
|
+
)
|
|
2250
|
+
|
|
2251
|
+
response = pipeline_response.http_response
|
|
2252
|
+
|
|
2253
|
+
if response.status_code not in [204]:
|
|
2254
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
2255
|
+
raise HttpResponseError(response=response)
|
|
2256
|
+
|
|
2257
|
+
if cls:
|
|
2258
|
+
return cls(pipeline_response, None, {}) # type: ignore
|
|
2259
|
+
|
|
2260
|
+
@overload
|
|
2261
|
+
async def create_or_update_version(
|
|
2262
|
+
self, name: str, version: str, body: _models.Index, *, content_type: str = "application/json", **kwargs: Any
|
|
2263
|
+
) -> _models.Index:
|
|
2264
|
+
"""Create a new or update an existing Index with the given version id.
|
|
2265
|
+
|
|
2266
|
+
:param name: The name of the resource. Required.
|
|
2267
|
+
:type name: str
|
|
2268
|
+
:param version: The specific version id of the Index to create or replace. Required.
|
|
2269
|
+
:type version: str
|
|
2270
|
+
:param body: The definition of the Index to create or update. Required.
|
|
2271
|
+
:type body: ~azure.ai.projects.onedp.models.Index
|
|
2272
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
2273
|
+
Default value is "application/json".
|
|
2274
|
+
:paramtype content_type: str
|
|
2275
|
+
:return: Index. The Index is compatible with MutableMapping
|
|
2276
|
+
:rtype: ~azure.ai.projects.onedp.models.Index
|
|
2277
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2278
|
+
"""
|
|
2279
|
+
|
|
2280
|
+
@overload
|
|
2281
|
+
async def create_or_update_version(
|
|
2282
|
+
self, name: str, version: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
2283
|
+
) -> _models.Index:
|
|
2284
|
+
"""Create a new or update an existing Index with the given version id.
|
|
2285
|
+
|
|
2286
|
+
:param name: The name of the resource. Required.
|
|
2287
|
+
:type name: str
|
|
2288
|
+
:param version: The specific version id of the Index to create or replace. Required.
|
|
2289
|
+
:type version: str
|
|
2290
|
+
:param body: The definition of the Index to create or update. Required.
|
|
2291
|
+
:type body: JSON
|
|
2292
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
2293
|
+
Default value is "application/json".
|
|
2294
|
+
:paramtype content_type: str
|
|
2295
|
+
:return: Index. The Index is compatible with MutableMapping
|
|
2296
|
+
:rtype: ~azure.ai.projects.onedp.models.Index
|
|
2297
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2298
|
+
"""
|
|
2299
|
+
|
|
2300
|
+
@overload
|
|
2301
|
+
async def create_or_update_version(
|
|
2302
|
+
self, name: str, version: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
2303
|
+
) -> _models.Index:
|
|
2304
|
+
"""Create a new or update an existing Index with the given version id.
|
|
2305
|
+
|
|
2306
|
+
:param name: The name of the resource. Required.
|
|
2307
|
+
:type name: str
|
|
2308
|
+
:param version: The specific version id of the Index to create or replace. Required.
|
|
2309
|
+
:type version: str
|
|
2310
|
+
:param body: The definition of the Index to create or update. Required.
|
|
2311
|
+
:type body: IO[bytes]
|
|
2312
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
2313
|
+
Default value is "application/json".
|
|
2314
|
+
:paramtype content_type: str
|
|
2315
|
+
:return: Index. The Index is compatible with MutableMapping
|
|
2316
|
+
:rtype: ~azure.ai.projects.onedp.models.Index
|
|
2317
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2318
|
+
"""
|
|
2319
|
+
|
|
2320
|
+
@distributed_trace_async
|
|
2321
|
+
async def create_or_update_version(
|
|
2322
|
+
self, name: str, version: str, body: Union[_models.Index, JSON, IO[bytes]], **kwargs: Any
|
|
2323
|
+
) -> _models.Index:
|
|
2324
|
+
"""Create a new or update an existing Index with the given version id.
|
|
2325
|
+
|
|
2326
|
+
:param name: The name of the resource. Required.
|
|
2327
|
+
:type name: str
|
|
2328
|
+
:param version: The specific version id of the Index to create or replace. Required.
|
|
2329
|
+
:type version: str
|
|
2330
|
+
:param body: The definition of the Index to create or update. Is one of the following types:
|
|
2331
|
+
Index, JSON, IO[bytes] Required.
|
|
2332
|
+
:type body: ~azure.ai.projects.onedp.models.Index or JSON or IO[bytes]
|
|
2333
|
+
:return: Index. The Index is compatible with MutableMapping
|
|
2334
|
+
:rtype: ~azure.ai.projects.onedp.models.Index
|
|
2335
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2336
|
+
"""
|
|
2337
|
+
error_map: MutableMapping = {
|
|
2338
|
+
401: ClientAuthenticationError,
|
|
2339
|
+
404: ResourceNotFoundError,
|
|
2340
|
+
409: ResourceExistsError,
|
|
2341
|
+
304: ResourceNotModifiedError,
|
|
2342
|
+
}
|
|
2343
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
2344
|
+
|
|
2345
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
2346
|
+
_params = kwargs.pop("params", {}) or {}
|
|
2347
|
+
|
|
2348
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
2349
|
+
cls: ClsType[_models.Index] = kwargs.pop("cls", None)
|
|
2350
|
+
|
|
2351
|
+
content_type = content_type or "application/json"
|
|
2352
|
+
_content = None
|
|
2353
|
+
if isinstance(body, (IOBase, bytes)):
|
|
2354
|
+
_content = body
|
|
2355
|
+
else:
|
|
2356
|
+
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
2357
|
+
|
|
2358
|
+
_request = build_indexes_create_or_update_version_request(
|
|
2359
|
+
name=name,
|
|
2360
|
+
version=version,
|
|
2361
|
+
content_type=content_type,
|
|
2362
|
+
api_version=self._config.api_version,
|
|
2363
|
+
content=_content,
|
|
2364
|
+
headers=_headers,
|
|
2365
|
+
params=_params,
|
|
2366
|
+
)
|
|
2367
|
+
path_format_arguments = {
|
|
2368
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
2369
|
+
}
|
|
2370
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2371
|
+
|
|
2372
|
+
_stream = kwargs.pop("stream", False)
|
|
2373
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
2374
|
+
_request, stream=_stream, **kwargs
|
|
2375
|
+
)
|
|
2376
|
+
|
|
2377
|
+
response = pipeline_response.http_response
|
|
2378
|
+
|
|
2379
|
+
if response.status_code not in [200, 201]:
|
|
2380
|
+
if _stream:
|
|
2381
|
+
try:
|
|
2382
|
+
await response.read() # Load the body in memory and close the socket
|
|
2383
|
+
except (StreamConsumedError, StreamClosedError):
|
|
2384
|
+
pass
|
|
2385
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
2386
|
+
raise HttpResponseError(response=response)
|
|
2387
|
+
|
|
2388
|
+
if _stream:
|
|
2389
|
+
deserialized = response.iter_bytes()
|
|
2390
|
+
else:
|
|
2391
|
+
deserialized = _deserialize(_models.Index, response.json())
|
|
2392
|
+
|
|
2393
|
+
if cls:
|
|
2394
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
2395
|
+
|
|
2396
|
+
return deserialized # type: ignore
|
|
2397
|
+
|
|
2398
|
+
|
|
2399
|
+
class DeploymentsOperations:
|
|
2400
|
+
"""
|
|
2401
|
+
.. warning::
|
|
2402
|
+
**DO NOT** instantiate this class directly.
|
|
2403
|
+
|
|
2404
|
+
Instead, you should access the following operations through
|
|
2405
|
+
:class:`~azure.ai.projects.onedp.aio.AIProjectClient`'s
|
|
2406
|
+
:attr:`deployments` attribute.
|
|
2407
|
+
"""
|
|
2408
|
+
|
|
2409
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
2410
|
+
input_args = list(args)
|
|
2411
|
+
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
2412
|
+
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
2413
|
+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
2414
|
+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
2415
|
+
|
|
2416
|
+
@distributed_trace_async
|
|
2417
|
+
async def get(self, name: str, **kwargs: Any) -> _models.Deployment:
|
|
2418
|
+
"""Get a deployed model.
|
|
2419
|
+
|
|
2420
|
+
:param name: Name of the deployment. Required.
|
|
2421
|
+
:type name: str
|
|
2422
|
+
:return: Deployment. The Deployment is compatible with MutableMapping
|
|
2423
|
+
:rtype: ~azure.ai.projects.onedp.models.Deployment
|
|
2424
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2425
|
+
"""
|
|
2426
|
+
error_map: MutableMapping = {
|
|
2427
|
+
401: ClientAuthenticationError,
|
|
2428
|
+
404: ResourceNotFoundError,
|
|
2429
|
+
409: ResourceExistsError,
|
|
2430
|
+
304: ResourceNotModifiedError,
|
|
2431
|
+
}
|
|
2432
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
2433
|
+
|
|
2434
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
2435
|
+
_params = kwargs.pop("params", {}) or {}
|
|
2436
|
+
|
|
2437
|
+
cls: ClsType[_models.Deployment] = kwargs.pop("cls", None)
|
|
2438
|
+
|
|
2439
|
+
_request = build_deployments_get_request(
|
|
2440
|
+
name=name,
|
|
2441
|
+
api_version=self._config.api_version,
|
|
2442
|
+
headers=_headers,
|
|
2443
|
+
params=_params,
|
|
2444
|
+
)
|
|
2445
|
+
path_format_arguments = {
|
|
2446
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
2447
|
+
}
|
|
2448
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2449
|
+
|
|
2450
|
+
_stream = kwargs.pop("stream", False)
|
|
2451
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
2452
|
+
_request, stream=_stream, **kwargs
|
|
2453
|
+
)
|
|
2454
|
+
|
|
2455
|
+
response = pipeline_response.http_response
|
|
2456
|
+
|
|
2457
|
+
if response.status_code not in [200]:
|
|
2458
|
+
if _stream:
|
|
2459
|
+
try:
|
|
2460
|
+
await response.read() # Load the body in memory and close the socket
|
|
2461
|
+
except (StreamConsumedError, StreamClosedError):
|
|
2462
|
+
pass
|
|
2463
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
2464
|
+
raise HttpResponseError(response=response)
|
|
2465
|
+
|
|
2466
|
+
response_headers = {}
|
|
2467
|
+
response_headers["x-ms-client-request-id"] = self._deserialize(
|
|
2468
|
+
"str", response.headers.get("x-ms-client-request-id")
|
|
2469
|
+
)
|
|
2470
|
+
|
|
2471
|
+
if _stream:
|
|
2472
|
+
deserialized = response.iter_bytes()
|
|
2473
|
+
else:
|
|
2474
|
+
deserialized = _deserialize(_models.Deployment, response.json())
|
|
2475
|
+
|
|
2476
|
+
if cls:
|
|
2477
|
+
return cls(pipeline_response, deserialized, response_headers) # type: ignore
|
|
2478
|
+
|
|
2479
|
+
return deserialized # type: ignore
|
|
2480
|
+
|
|
2481
|
+
@distributed_trace
|
|
2482
|
+
def list(
|
|
2483
|
+
self,
|
|
2484
|
+
*,
|
|
2485
|
+
model_publisher: Optional[str] = None,
|
|
2486
|
+
model_name: Optional[str] = None,
|
|
2487
|
+
top: Optional[int] = None,
|
|
2488
|
+
skip: Optional[int] = None,
|
|
2489
|
+
**kwargs: Any
|
|
2490
|
+
) -> AsyncIterable["_models.Deployment"]:
|
|
2491
|
+
"""List all deployed models in the project.
|
|
2492
|
+
|
|
2493
|
+
:keyword model_publisher: Model publisher to filter models by. Default value is None.
|
|
2494
|
+
:paramtype model_publisher: str
|
|
2495
|
+
:keyword model_name: Model name (the publisher specific name) to filter models by. Default
|
|
2496
|
+
value is None.
|
|
2497
|
+
:paramtype model_name: str
|
|
2498
|
+
:keyword top: The number of result items to return. Default value is None.
|
|
2499
|
+
:paramtype top: int
|
|
2500
|
+
:keyword skip: The number of result items to skip. Default value is None.
|
|
2501
|
+
:paramtype skip: int
|
|
2502
|
+
:return: An iterator like instance of Deployment
|
|
2503
|
+
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.onedp.models.Deployment]
|
|
2504
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2505
|
+
"""
|
|
2506
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
2507
|
+
_params = kwargs.pop("params", {}) or {}
|
|
2508
|
+
|
|
2509
|
+
maxpagesize = kwargs.pop("maxpagesize", None)
|
|
2510
|
+
cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None)
|
|
2511
|
+
|
|
2512
|
+
error_map: MutableMapping = {
|
|
2513
|
+
401: ClientAuthenticationError,
|
|
2514
|
+
404: ResourceNotFoundError,
|
|
2515
|
+
409: ResourceExistsError,
|
|
2516
|
+
304: ResourceNotModifiedError,
|
|
2517
|
+
}
|
|
2518
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
2519
|
+
|
|
2520
|
+
def prepare_request(next_link=None):
|
|
2521
|
+
if not next_link:
|
|
2522
|
+
|
|
2523
|
+
_request = build_deployments_list_request(
|
|
2524
|
+
model_publisher=model_publisher,
|
|
2525
|
+
model_name=model_name,
|
|
2526
|
+
top=top,
|
|
2527
|
+
skip=skip,
|
|
2528
|
+
maxpagesize=maxpagesize,
|
|
2529
|
+
api_version=self._config.api_version,
|
|
2530
|
+
headers=_headers,
|
|
2531
|
+
params=_params,
|
|
2532
|
+
)
|
|
2533
|
+
path_format_arguments = {
|
|
2534
|
+
"endpoint": self._serialize.url(
|
|
2535
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
2536
|
+
),
|
|
2537
|
+
}
|
|
2538
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2539
|
+
|
|
2540
|
+
else:
|
|
2541
|
+
# make call to next link with the client's api-version
|
|
2542
|
+
_parsed_next_link = urllib.parse.urlparse(next_link)
|
|
2543
|
+
_next_request_params = case_insensitive_dict(
|
|
2544
|
+
{
|
|
2545
|
+
key: [urllib.parse.quote(v) for v in value]
|
|
2546
|
+
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
|
|
2547
|
+
}
|
|
2548
|
+
)
|
|
2549
|
+
_next_request_params["api-version"] = self._config.api_version
|
|
2550
|
+
_request = HttpRequest(
|
|
2551
|
+
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
|
|
2552
|
+
)
|
|
2553
|
+
path_format_arguments = {
|
|
2554
|
+
"endpoint": self._serialize.url(
|
|
2555
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
2556
|
+
),
|
|
2557
|
+
}
|
|
2558
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2559
|
+
|
|
2560
|
+
return _request
|
|
2561
|
+
|
|
2562
|
+
async def extract_data(pipeline_response):
|
|
2563
|
+
deserialized = pipeline_response.http_response.json()
|
|
2564
|
+
list_of_elem = _deserialize(List[_models.Deployment], deserialized.get("value", []))
|
|
2565
|
+
if cls:
|
|
2566
|
+
list_of_elem = cls(list_of_elem) # type: ignore
|
|
2567
|
+
return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
|
|
2568
|
+
|
|
2569
|
+
async def get_next(next_link=None):
|
|
2570
|
+
_request = prepare_request(next_link)
|
|
2571
|
+
|
|
2572
|
+
_stream = False
|
|
2573
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
2574
|
+
_request, stream=_stream, **kwargs
|
|
2575
|
+
)
|
|
2576
|
+
response = pipeline_response.http_response
|
|
2577
|
+
|
|
2578
|
+
if response.status_code not in [200]:
|
|
2579
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
2580
|
+
raise HttpResponseError(response=response)
|
|
2581
|
+
|
|
2582
|
+
return pipeline_response
|
|
2583
|
+
|
|
2584
|
+
return AsyncItemPaged(get_next, extract_data)
|
|
2585
|
+
|
|
2586
|
+
|
|
2587
|
+
class RedTeamsOperations:
|
|
2588
|
+
"""
|
|
2589
|
+
.. warning::
|
|
2590
|
+
**DO NOT** instantiate this class directly.
|
|
2591
|
+
|
|
2592
|
+
Instead, you should access the following operations through
|
|
2593
|
+
:class:`~azure.ai.projects.onedp.aio.AIProjectClient`'s
|
|
2594
|
+
:attr:`red_teams` attribute.
|
|
2595
|
+
"""
|
|
2596
|
+
|
|
2597
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
2598
|
+
input_args = list(args)
|
|
2599
|
+
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
2600
|
+
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
2601
|
+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
2602
|
+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
2603
|
+
|
|
2604
|
+
@distributed_trace_async
|
|
2605
|
+
@api_version_validation(
|
|
2606
|
+
method_added_on="2025-05-15-preview",
|
|
2607
|
+
params_added_on={"2025-05-15-preview": ["api_version", "name", "client_request_id", "accept"]},
|
|
2608
|
+
)
|
|
2609
|
+
async def get(self, name: str, **kwargs: Any) -> _models.RedTeam:
|
|
2610
|
+
"""Get a redteam by name.
|
|
2611
|
+
|
|
2612
|
+
:param name: Identifier of the red team. Required.
|
|
2613
|
+
:type name: str
|
|
2614
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
2615
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
2616
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2617
|
+
"""
|
|
2618
|
+
error_map: MutableMapping = {
|
|
2619
|
+
401: ClientAuthenticationError,
|
|
2620
|
+
404: ResourceNotFoundError,
|
|
2621
|
+
409: ResourceExistsError,
|
|
2622
|
+
304: ResourceNotModifiedError,
|
|
2623
|
+
}
|
|
2624
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
2625
|
+
|
|
2626
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
2627
|
+
_params = kwargs.pop("params", {}) or {}
|
|
2628
|
+
|
|
2629
|
+
cls: ClsType[_models.RedTeam] = kwargs.pop("cls", None)
|
|
2630
|
+
|
|
2631
|
+
_request = build_red_teams_get_request(
|
|
2632
|
+
name=name,
|
|
2633
|
+
api_version=self._config.api_version,
|
|
2634
|
+
headers=_headers,
|
|
2635
|
+
params=_params,
|
|
2636
|
+
)
|
|
2637
|
+
path_format_arguments = {
|
|
2638
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
2639
|
+
}
|
|
2640
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2641
|
+
|
|
2642
|
+
_stream = kwargs.pop("stream", False)
|
|
2643
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
2644
|
+
_request, stream=_stream, **kwargs
|
|
2645
|
+
)
|
|
2646
|
+
|
|
2647
|
+
response = pipeline_response.http_response
|
|
2648
|
+
|
|
2649
|
+
if response.status_code not in [200]:
|
|
2650
|
+
if _stream:
|
|
2651
|
+
try:
|
|
2652
|
+
await response.read() # Load the body in memory and close the socket
|
|
2653
|
+
except (StreamConsumedError, StreamClosedError):
|
|
2654
|
+
pass
|
|
2655
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
2656
|
+
raise HttpResponseError(response=response)
|
|
2657
|
+
|
|
2658
|
+
response_headers = {}
|
|
2659
|
+
response_headers["x-ms-client-request-id"] = self._deserialize(
|
|
2660
|
+
"str", response.headers.get("x-ms-client-request-id")
|
|
2661
|
+
)
|
|
2662
|
+
|
|
2663
|
+
if _stream:
|
|
2664
|
+
deserialized = response.iter_bytes()
|
|
2665
|
+
else:
|
|
2666
|
+
deserialized = _deserialize(_models.RedTeam, response.json())
|
|
2667
|
+
|
|
2668
|
+
if cls:
|
|
2669
|
+
return cls(pipeline_response, deserialized, response_headers) # type: ignore
|
|
2670
|
+
|
|
2671
|
+
return deserialized # type: ignore
|
|
2672
|
+
|
|
2673
|
+
@distributed_trace
|
|
2674
|
+
@api_version_validation(
|
|
2675
|
+
method_added_on="2025-05-15-preview",
|
|
2676
|
+
params_added_on={
|
|
2677
|
+
"2025-05-15-preview": ["api_version", "top", "skip", "maxpagesize", "client_request_id", "accept"]
|
|
2678
|
+
},
|
|
2679
|
+
)
|
|
2680
|
+
def list(
|
|
2681
|
+
self, *, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any
|
|
2682
|
+
) -> AsyncIterable["_models.RedTeam"]:
|
|
2683
|
+
"""List a redteam by name.
|
|
2684
|
+
|
|
2685
|
+
:keyword top: The number of result items to return. Default value is None.
|
|
2686
|
+
:paramtype top: int
|
|
2687
|
+
:keyword skip: The number of result items to skip. Default value is None.
|
|
2688
|
+
:paramtype skip: int
|
|
2689
|
+
:return: An iterator like instance of RedTeam
|
|
2690
|
+
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.onedp.models.RedTeam]
|
|
2691
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2692
|
+
"""
|
|
2693
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
2694
|
+
_params = kwargs.pop("params", {}) or {}
|
|
2695
|
+
|
|
2696
|
+
maxpagesize = kwargs.pop("maxpagesize", None)
|
|
2697
|
+
cls: ClsType[List[_models.RedTeam]] = kwargs.pop("cls", None)
|
|
2698
|
+
|
|
2699
|
+
error_map: MutableMapping = {
|
|
2700
|
+
401: ClientAuthenticationError,
|
|
2701
|
+
404: ResourceNotFoundError,
|
|
2702
|
+
409: ResourceExistsError,
|
|
2703
|
+
304: ResourceNotModifiedError,
|
|
2704
|
+
}
|
|
2705
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
2706
|
+
|
|
2707
|
+
def prepare_request(next_link=None):
|
|
2708
|
+
if not next_link:
|
|
2709
|
+
|
|
2710
|
+
_request = build_red_teams_list_request(
|
|
2711
|
+
top=top,
|
|
2712
|
+
skip=skip,
|
|
2713
|
+
maxpagesize=maxpagesize,
|
|
2714
|
+
api_version=self._config.api_version,
|
|
2715
|
+
headers=_headers,
|
|
2716
|
+
params=_params,
|
|
2717
|
+
)
|
|
2718
|
+
path_format_arguments = {
|
|
2719
|
+
"endpoint": self._serialize.url(
|
|
2720
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
2721
|
+
),
|
|
2722
|
+
}
|
|
2723
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2724
|
+
|
|
2725
|
+
else:
|
|
2726
|
+
# make call to next link with the client's api-version
|
|
2727
|
+
_parsed_next_link = urllib.parse.urlparse(next_link)
|
|
2728
|
+
_next_request_params = case_insensitive_dict(
|
|
2729
|
+
{
|
|
2730
|
+
key: [urllib.parse.quote(v) for v in value]
|
|
2731
|
+
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
|
|
2732
|
+
}
|
|
2733
|
+
)
|
|
2734
|
+
_next_request_params["api-version"] = self._config.api_version
|
|
2735
|
+
_request = HttpRequest(
|
|
2736
|
+
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
|
|
2737
|
+
)
|
|
2738
|
+
path_format_arguments = {
|
|
2739
|
+
"endpoint": self._serialize.url(
|
|
2740
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
2741
|
+
),
|
|
2742
|
+
}
|
|
2743
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2744
|
+
|
|
2745
|
+
return _request
|
|
2746
|
+
|
|
2747
|
+
async def extract_data(pipeline_response):
|
|
2748
|
+
deserialized = pipeline_response.http_response.json()
|
|
2749
|
+
list_of_elem = _deserialize(List[_models.RedTeam], deserialized.get("value", []))
|
|
2750
|
+
if cls:
|
|
2751
|
+
list_of_elem = cls(list_of_elem) # type: ignore
|
|
2752
|
+
return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
|
|
2753
|
+
|
|
2754
|
+
async def get_next(next_link=None):
|
|
2755
|
+
_request = prepare_request(next_link)
|
|
2756
|
+
|
|
2757
|
+
_stream = False
|
|
2758
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
2759
|
+
_request, stream=_stream, **kwargs
|
|
2760
|
+
)
|
|
2761
|
+
response = pipeline_response.http_response
|
|
2762
|
+
|
|
2763
|
+
if response.status_code not in [200]:
|
|
2764
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
2765
|
+
raise HttpResponseError(response=response)
|
|
2766
|
+
|
|
2767
|
+
return pipeline_response
|
|
2768
|
+
|
|
2769
|
+
return AsyncItemPaged(get_next, extract_data)
|
|
2770
|
+
|
|
2771
|
+
@overload
|
|
2772
|
+
async def create_run(
|
|
2773
|
+
self, red_team: _models.RedTeam, *, content_type: str = "application/json", **kwargs: Any
|
|
2774
|
+
) -> _models.RedTeam:
|
|
2775
|
+
"""Creates a redteam run.
|
|
2776
|
+
|
|
2777
|
+
:param red_team: Redteam to be run. Required.
|
|
2778
|
+
:type red_team: ~azure.ai.projects.onedp.models.RedTeam
|
|
2779
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
2780
|
+
Default value is "application/json".
|
|
2781
|
+
:paramtype content_type: str
|
|
2782
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
2783
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
2784
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2785
|
+
"""
|
|
2786
|
+
|
|
2787
|
+
@overload
|
|
2788
|
+
async def create_run(
|
|
2789
|
+
self, red_team: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
2790
|
+
) -> _models.RedTeam:
|
|
2791
|
+
"""Creates a redteam run.
|
|
2792
|
+
|
|
2793
|
+
:param red_team: Redteam to be run. Required.
|
|
2794
|
+
:type red_team: JSON
|
|
2795
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
2796
|
+
Default value is "application/json".
|
|
2797
|
+
:paramtype content_type: str
|
|
2798
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
2799
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
2800
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2801
|
+
"""
|
|
2802
|
+
|
|
2803
|
+
@overload
|
|
2804
|
+
async def create_run(
|
|
2805
|
+
self, red_team: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
2806
|
+
) -> _models.RedTeam:
|
|
2807
|
+
"""Creates a redteam run.
|
|
2808
|
+
|
|
2809
|
+
:param red_team: Redteam to be run. Required.
|
|
2810
|
+
:type red_team: IO[bytes]
|
|
2811
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
2812
|
+
Default value is "application/json".
|
|
2813
|
+
:paramtype content_type: str
|
|
2814
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
2815
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
2816
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2817
|
+
"""
|
|
2818
|
+
|
|
2819
|
+
@distributed_trace_async
|
|
2820
|
+
@api_version_validation(
|
|
2821
|
+
method_added_on="2025-05-15-preview",
|
|
2822
|
+
params_added_on={"2025-05-15-preview": ["api_version", "content_type", "accept"]},
|
|
2823
|
+
)
|
|
2824
|
+
async def create_run(self, red_team: Union[_models.RedTeam, JSON, IO[bytes]], **kwargs: Any) -> _models.RedTeam:
|
|
2825
|
+
"""Creates a redteam run.
|
|
2826
|
+
|
|
2827
|
+
:param red_team: Redteam to be run. Is one of the following types: RedTeam, JSON, IO[bytes]
|
|
2828
|
+
Required.
|
|
2829
|
+
:type red_team: ~azure.ai.projects.onedp.models.RedTeam or JSON or IO[bytes]
|
|
2830
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
2831
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
2832
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2833
|
+
"""
|
|
2834
|
+
error_map: MutableMapping = {
|
|
2835
|
+
401: ClientAuthenticationError,
|
|
2836
|
+
404: ResourceNotFoundError,
|
|
2837
|
+
409: ResourceExistsError,
|
|
2838
|
+
304: ResourceNotModifiedError,
|
|
2839
|
+
}
|
|
2840
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
2841
|
+
|
|
2842
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
2843
|
+
_params = kwargs.pop("params", {}) or {}
|
|
2844
|
+
|
|
2845
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
2846
|
+
cls: ClsType[_models.RedTeam] = kwargs.pop("cls", None)
|
|
2847
|
+
|
|
2848
|
+
content_type = content_type or "application/json"
|
|
2849
|
+
_content = None
|
|
2850
|
+
if isinstance(red_team, (IOBase, bytes)):
|
|
2851
|
+
_content = red_team
|
|
2852
|
+
else:
|
|
2853
|
+
_content = json.dumps(red_team, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
2854
|
+
|
|
2855
|
+
_request = build_red_teams_create_run_request(
|
|
2856
|
+
content_type=content_type,
|
|
2857
|
+
api_version=self._config.api_version,
|
|
2858
|
+
content=_content,
|
|
2859
|
+
headers=_headers,
|
|
2860
|
+
params=_params,
|
|
2861
|
+
)
|
|
2862
|
+
path_format_arguments = {
|
|
2863
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
2864
|
+
}
|
|
2865
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2866
|
+
|
|
2867
|
+
_stream = kwargs.pop("stream", False)
|
|
2868
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
2869
|
+
_request, stream=_stream, **kwargs
|
|
2870
|
+
)
|
|
2871
|
+
|
|
2872
|
+
response = pipeline_response.http_response
|
|
2873
|
+
|
|
2874
|
+
if response.status_code not in [200]:
|
|
2875
|
+
if _stream:
|
|
2876
|
+
try:
|
|
2877
|
+
await response.read() # Load the body in memory and close the socket
|
|
2878
|
+
except (StreamConsumedError, StreamClosedError):
|
|
2879
|
+
pass
|
|
2880
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
2881
|
+
raise HttpResponseError(response=response)
|
|
2882
|
+
|
|
2883
|
+
if _stream:
|
|
2884
|
+
deserialized = response.iter_bytes()
|
|
2885
|
+
else:
|
|
2886
|
+
deserialized = _deserialize(_models.RedTeam, response.json())
|
|
2887
|
+
|
|
2888
|
+
if cls:
|
|
2889
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
2890
|
+
|
|
2891
|
+
return deserialized # type: ignore
|
|
2892
|
+
|
|
2893
|
+
@overload
|
|
2894
|
+
async def upload_run(
|
|
2895
|
+
self, redteam: _models.RedTeamUpload, *, content_type: str = "application/json", **kwargs: Any
|
|
2896
|
+
) -> _models.RedTeam:
|
|
2897
|
+
"""Upload the result to a redteam run.
|
|
2898
|
+
|
|
2899
|
+
:param redteam: Redteam to upload. Required.
|
|
2900
|
+
:type redteam: ~azure.ai.projects.onedp.models.RedTeamUpload
|
|
2901
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
2902
|
+
Default value is "application/json".
|
|
2903
|
+
:paramtype content_type: str
|
|
2904
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
2905
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
2906
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2907
|
+
"""
|
|
2908
|
+
|
|
2909
|
+
@overload
|
|
2910
|
+
async def upload_run(
|
|
2911
|
+
self, redteam: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
2912
|
+
) -> _models.RedTeam:
|
|
2913
|
+
"""Upload the result to a redteam run.
|
|
2914
|
+
|
|
2915
|
+
:param redteam: Redteam to upload. Required.
|
|
2916
|
+
:type redteam: JSON
|
|
2917
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
2918
|
+
Default value is "application/json".
|
|
2919
|
+
:paramtype content_type: str
|
|
2920
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
2921
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
2922
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2923
|
+
"""
|
|
2924
|
+
|
|
2925
|
+
@overload
|
|
2926
|
+
async def upload_run(
|
|
2927
|
+
self, redteam: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
2928
|
+
) -> _models.RedTeam:
|
|
2929
|
+
"""Upload the result to a redteam run.
|
|
2930
|
+
|
|
2931
|
+
:param redteam: Redteam to upload. Required.
|
|
2932
|
+
:type redteam: IO[bytes]
|
|
2933
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
2934
|
+
Default value is "application/json".
|
|
2935
|
+
:paramtype content_type: str
|
|
2936
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
2937
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
2938
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2939
|
+
"""
|
|
2940
|
+
|
|
2941
|
+
@distributed_trace_async
|
|
2942
|
+
@api_version_validation(
|
|
2943
|
+
method_added_on="2025-05-15-preview",
|
|
2944
|
+
params_added_on={"2025-05-15-preview": ["api_version", "content_type", "accept"]},
|
|
2945
|
+
)
|
|
2946
|
+
async def upload_run(
|
|
2947
|
+
self, redteam: Union[_models.RedTeamUpload, JSON, IO[bytes]], **kwargs: Any
|
|
2948
|
+
) -> _models.RedTeam:
|
|
2949
|
+
"""Upload the result to a redteam run.
|
|
2950
|
+
|
|
2951
|
+
:param redteam: Redteam to upload. Is one of the following types: RedTeamUpload, JSON,
|
|
2952
|
+
IO[bytes] Required.
|
|
2953
|
+
:type redteam: ~azure.ai.projects.onedp.models.RedTeamUpload or JSON or IO[bytes]
|
|
2954
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
2955
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
2956
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2957
|
+
"""
|
|
2958
|
+
error_map: MutableMapping = {
|
|
2959
|
+
401: ClientAuthenticationError,
|
|
2960
|
+
404: ResourceNotFoundError,
|
|
2961
|
+
409: ResourceExistsError,
|
|
2962
|
+
304: ResourceNotModifiedError,
|
|
2963
|
+
}
|
|
2964
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
2965
|
+
|
|
2966
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
2967
|
+
_params = kwargs.pop("params", {}) or {}
|
|
2968
|
+
|
|
2969
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
2970
|
+
cls: ClsType[_models.RedTeam] = kwargs.pop("cls", None)
|
|
2971
|
+
|
|
2972
|
+
content_type = content_type or "application/json"
|
|
2973
|
+
_content = None
|
|
2974
|
+
if isinstance(redteam, (IOBase, bytes)):
|
|
2975
|
+
_content = redteam
|
|
2976
|
+
else:
|
|
2977
|
+
_content = json.dumps(redteam, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
2978
|
+
|
|
2979
|
+
_request = build_red_teams_upload_run_request(
|
|
2980
|
+
content_type=content_type,
|
|
2981
|
+
api_version=self._config.api_version,
|
|
2982
|
+
content=_content,
|
|
2983
|
+
headers=_headers,
|
|
2984
|
+
params=_params,
|
|
2985
|
+
)
|
|
2986
|
+
path_format_arguments = {
|
|
2987
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
2988
|
+
}
|
|
2989
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
2990
|
+
|
|
2991
|
+
_stream = kwargs.pop("stream", False)
|
|
2992
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
2993
|
+
_request, stream=_stream, **kwargs
|
|
2994
|
+
)
|
|
2995
|
+
|
|
2996
|
+
response = pipeline_response.http_response
|
|
2997
|
+
|
|
2998
|
+
if response.status_code not in [200]:
|
|
2999
|
+
if _stream:
|
|
3000
|
+
try:
|
|
3001
|
+
await response.read() # Load the body in memory and close the socket
|
|
3002
|
+
except (StreamConsumedError, StreamClosedError):
|
|
3003
|
+
pass
|
|
3004
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
3005
|
+
raise HttpResponseError(response=response)
|
|
3006
|
+
|
|
3007
|
+
if _stream:
|
|
3008
|
+
deserialized = response.iter_bytes()
|
|
3009
|
+
else:
|
|
3010
|
+
deserialized = _deserialize(_models.RedTeam, response.json())
|
|
3011
|
+
|
|
3012
|
+
if cls:
|
|
3013
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
3014
|
+
|
|
3015
|
+
return deserialized # type: ignore
|
|
3016
|
+
|
|
3017
|
+
@overload
|
|
3018
|
+
async def upload_update_run(
|
|
3019
|
+
self, name: str, redteam: _models.RedTeamUpload, *, content_type: str = "application/json", **kwargs: Any
|
|
3020
|
+
) -> _models.RedTeam:
|
|
3021
|
+
"""Update the uploaded the result to an redteam run.
|
|
3022
|
+
|
|
3023
|
+
:param name: Name of the redteam run to update. Required.
|
|
3024
|
+
:type name: str
|
|
3025
|
+
:param redteam: Redteam upload to update. Required.
|
|
3026
|
+
:type redteam: ~azure.ai.projects.onedp.models.RedTeamUpload
|
|
3027
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
3028
|
+
Default value is "application/json".
|
|
3029
|
+
:paramtype content_type: str
|
|
3030
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
3031
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
3032
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3033
|
+
"""
|
|
3034
|
+
|
|
3035
|
+
@overload
|
|
3036
|
+
async def upload_update_run(
|
|
3037
|
+
self, name: str, redteam: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
3038
|
+
) -> _models.RedTeam:
|
|
3039
|
+
"""Update the uploaded the result to an redteam run.
|
|
3040
|
+
|
|
3041
|
+
:param name: Name of the redteam run to update. Required.
|
|
3042
|
+
:type name: str
|
|
3043
|
+
:param redteam: Redteam upload to update. Required.
|
|
3044
|
+
:type redteam: JSON
|
|
3045
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
3046
|
+
Default value is "application/json".
|
|
3047
|
+
:paramtype content_type: str
|
|
3048
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
3049
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
3050
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3051
|
+
"""
|
|
3052
|
+
|
|
3053
|
+
@overload
|
|
3054
|
+
async def upload_update_run(
|
|
3055
|
+
self, name: str, redteam: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
3056
|
+
) -> _models.RedTeam:
|
|
3057
|
+
"""Update the uploaded the result to an redteam run.
|
|
3058
|
+
|
|
3059
|
+
:param name: Name of the redteam run to update. Required.
|
|
3060
|
+
:type name: str
|
|
3061
|
+
:param redteam: Redteam upload to update. Required.
|
|
3062
|
+
:type redteam: IO[bytes]
|
|
3063
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
3064
|
+
Default value is "application/json".
|
|
3065
|
+
:paramtype content_type: str
|
|
3066
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
3067
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
3068
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3069
|
+
"""
|
|
3070
|
+
|
|
3071
|
+
@distributed_trace_async
|
|
3072
|
+
@api_version_validation(
|
|
3073
|
+
method_added_on="2025-05-15-preview",
|
|
3074
|
+
params_added_on={"2025-05-15-preview": ["api_version", "name", "content_type", "accept"]},
|
|
3075
|
+
)
|
|
3076
|
+
async def upload_update_run(
|
|
3077
|
+
self, name: str, redteam: Union[_models.RedTeamUpload, JSON, IO[bytes]], **kwargs: Any
|
|
3078
|
+
) -> _models.RedTeam:
|
|
3079
|
+
"""Update the uploaded the result to an redteam run.
|
|
3080
|
+
|
|
3081
|
+
:param name: Name of the redteam run to update. Required.
|
|
3082
|
+
:type name: str
|
|
3083
|
+
:param redteam: Redteam upload to update. Is one of the following types: RedTeamUpload, JSON,
|
|
3084
|
+
IO[bytes] Required.
|
|
3085
|
+
:type redteam: ~azure.ai.projects.onedp.models.RedTeamUpload or JSON or IO[bytes]
|
|
3086
|
+
:return: RedTeam. The RedTeam is compatible with MutableMapping
|
|
3087
|
+
:rtype: ~azure.ai.projects.onedp.models.RedTeam
|
|
3088
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3089
|
+
"""
|
|
3090
|
+
error_map: MutableMapping = {
|
|
3091
|
+
401: ClientAuthenticationError,
|
|
3092
|
+
404: ResourceNotFoundError,
|
|
3093
|
+
409: ResourceExistsError,
|
|
3094
|
+
304: ResourceNotModifiedError,
|
|
3095
|
+
}
|
|
3096
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
3097
|
+
|
|
3098
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
3099
|
+
_params = kwargs.pop("params", {}) or {}
|
|
3100
|
+
|
|
3101
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
3102
|
+
cls: ClsType[_models.RedTeam] = kwargs.pop("cls", None)
|
|
3103
|
+
|
|
3104
|
+
content_type = content_type or "application/json"
|
|
3105
|
+
_content = None
|
|
3106
|
+
if isinstance(redteam, (IOBase, bytes)):
|
|
3107
|
+
_content = redteam
|
|
3108
|
+
else:
|
|
3109
|
+
_content = json.dumps(redteam, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
3110
|
+
|
|
3111
|
+
_request = build_red_teams_upload_update_run_request(
|
|
3112
|
+
name=name,
|
|
3113
|
+
content_type=content_type,
|
|
3114
|
+
api_version=self._config.api_version,
|
|
3115
|
+
content=_content,
|
|
3116
|
+
headers=_headers,
|
|
3117
|
+
params=_params,
|
|
3118
|
+
)
|
|
3119
|
+
path_format_arguments = {
|
|
3120
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
3121
|
+
}
|
|
3122
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3123
|
+
|
|
3124
|
+
_stream = kwargs.pop("stream", False)
|
|
3125
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
3126
|
+
_request, stream=_stream, **kwargs
|
|
3127
|
+
)
|
|
3128
|
+
|
|
3129
|
+
response = pipeline_response.http_response
|
|
3130
|
+
|
|
3131
|
+
if response.status_code not in [200]:
|
|
3132
|
+
if _stream:
|
|
3133
|
+
try:
|
|
3134
|
+
await response.read() # Load the body in memory and close the socket
|
|
3135
|
+
except (StreamConsumedError, StreamClosedError):
|
|
3136
|
+
pass
|
|
3137
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
3138
|
+
raise HttpResponseError(response=response)
|
|
3139
|
+
|
|
3140
|
+
if _stream:
|
|
3141
|
+
deserialized = response.iter_bytes()
|
|
3142
|
+
else:
|
|
3143
|
+
deserialized = _deserialize(_models.RedTeam, response.json())
|
|
3144
|
+
|
|
3145
|
+
if cls:
|
|
3146
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
3147
|
+
|
|
3148
|
+
return deserialized # type: ignore
|
|
3149
|
+
|
|
3150
|
+
@distributed_trace_async
|
|
3151
|
+
@api_version_validation(
|
|
3152
|
+
method_added_on="2025-05-15-preview",
|
|
3153
|
+
params_added_on={"2025-05-15-preview": ["api_version", "type", "accept"]},
|
|
3154
|
+
)
|
|
3155
|
+
async def get_jail_break_dataset_with_type(self, type: str, **kwargs: Any) -> List[str]:
|
|
3156
|
+
"""Get the jailbreak dataset with type.
|
|
3157
|
+
|
|
3158
|
+
:param type: Type of jailbreak dataset. Required.
|
|
3159
|
+
:type type: str
|
|
3160
|
+
:return: list of str
|
|
3161
|
+
:rtype: list[str]
|
|
3162
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3163
|
+
"""
|
|
3164
|
+
error_map: MutableMapping = {
|
|
3165
|
+
401: ClientAuthenticationError,
|
|
3166
|
+
404: ResourceNotFoundError,
|
|
3167
|
+
409: ResourceExistsError,
|
|
3168
|
+
304: ResourceNotModifiedError,
|
|
3169
|
+
}
|
|
3170
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
3171
|
+
|
|
3172
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
3173
|
+
_params = kwargs.pop("params", {}) or {}
|
|
3174
|
+
|
|
3175
|
+
cls: ClsType[List[str]] = kwargs.pop("cls", None)
|
|
3176
|
+
|
|
3177
|
+
_request = build_red_teams_get_jail_break_dataset_with_type_request(
|
|
3178
|
+
type=type,
|
|
3179
|
+
api_version=self._config.api_version,
|
|
3180
|
+
headers=_headers,
|
|
3181
|
+
params=_params,
|
|
3182
|
+
)
|
|
3183
|
+
path_format_arguments = {
|
|
3184
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
3185
|
+
}
|
|
3186
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3187
|
+
|
|
3188
|
+
_stream = kwargs.pop("stream", False)
|
|
3189
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
3190
|
+
_request, stream=_stream, **kwargs
|
|
3191
|
+
)
|
|
3192
|
+
|
|
3193
|
+
response = pipeline_response.http_response
|
|
3194
|
+
|
|
3195
|
+
if response.status_code not in [200]:
|
|
3196
|
+
if _stream:
|
|
3197
|
+
try:
|
|
3198
|
+
await response.read() # Load the body in memory and close the socket
|
|
3199
|
+
except (StreamConsumedError, StreamClosedError):
|
|
3200
|
+
pass
|
|
3201
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
3202
|
+
raise HttpResponseError(response=response)
|
|
3203
|
+
|
|
3204
|
+
if _stream:
|
|
3205
|
+
deserialized = response.iter_bytes()
|
|
3206
|
+
else:
|
|
3207
|
+
deserialized = _deserialize(List[str], response.json())
|
|
3208
|
+
|
|
3209
|
+
if cls:
|
|
3210
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
3211
|
+
|
|
3212
|
+
return deserialized # type: ignore
|
|
3213
|
+
|
|
3214
|
+
@distributed_trace_async
|
|
3215
|
+
@api_version_validation(
|
|
3216
|
+
method_added_on="2025-05-15-preview",
|
|
3217
|
+
params_added_on={"2025-05-15-preview": ["api_version", "risk_types", "lang", "strategy", "accept"]},
|
|
3218
|
+
)
|
|
3219
|
+
async def get_attack_objectives(
|
|
3220
|
+
self,
|
|
3221
|
+
*,
|
|
3222
|
+
risk_types: Optional[List[str]] = None,
|
|
3223
|
+
lang: Optional[str] = None,
|
|
3224
|
+
strategy: Optional[str] = None,
|
|
3225
|
+
**kwargs: Any
|
|
3226
|
+
) -> List[_models.AttackObjective]:
|
|
3227
|
+
"""Get the attack objectives.
|
|
3228
|
+
|
|
3229
|
+
:keyword risk_types: Risk types for the attack objectives dataset. Default value is None.
|
|
3230
|
+
:paramtype risk_types: list[str]
|
|
3231
|
+
:keyword lang: The language for the attack objectives dataset, defaults to 'en'. Default value
|
|
3232
|
+
is None.
|
|
3233
|
+
:paramtype lang: str
|
|
3234
|
+
:keyword strategy: The strategy. Default value is None.
|
|
3235
|
+
:paramtype strategy: str
|
|
3236
|
+
:return: list of AttackObjective
|
|
3237
|
+
:rtype: list[~azure.ai.projects.onedp.models.AttackObjective]
|
|
3238
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3239
|
+
"""
|
|
3240
|
+
error_map: MutableMapping = {
|
|
3241
|
+
401: ClientAuthenticationError,
|
|
3242
|
+
404: ResourceNotFoundError,
|
|
3243
|
+
409: ResourceExistsError,
|
|
3244
|
+
304: ResourceNotModifiedError,
|
|
3245
|
+
}
|
|
3246
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
3247
|
+
|
|
3248
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
3249
|
+
_params = kwargs.pop("params", {}) or {}
|
|
3250
|
+
|
|
3251
|
+
cls: ClsType[List[_models.AttackObjective]] = kwargs.pop("cls", None)
|
|
3252
|
+
|
|
3253
|
+
_request = build_red_teams_get_attack_objectives_request(
|
|
3254
|
+
risk_types=risk_types,
|
|
3255
|
+
lang=lang,
|
|
3256
|
+
strategy=strategy,
|
|
3257
|
+
api_version=self._config.api_version,
|
|
3258
|
+
headers=_headers,
|
|
3259
|
+
params=_params,
|
|
3260
|
+
)
|
|
3261
|
+
path_format_arguments = {
|
|
3262
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
3263
|
+
}
|
|
3264
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3265
|
+
|
|
3266
|
+
_stream = kwargs.pop("stream", False)
|
|
3267
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
3268
|
+
_request, stream=_stream, **kwargs
|
|
3269
|
+
)
|
|
3270
|
+
|
|
3271
|
+
response = pipeline_response.http_response
|
|
3272
|
+
|
|
3273
|
+
if response.status_code not in [200]:
|
|
3274
|
+
if _stream:
|
|
3275
|
+
try:
|
|
3276
|
+
await response.read() # Load the body in memory and close the socket
|
|
3277
|
+
except (StreamConsumedError, StreamClosedError):
|
|
3278
|
+
pass
|
|
3279
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
3280
|
+
raise HttpResponseError(response=response)
|
|
3281
|
+
|
|
3282
|
+
if _stream:
|
|
3283
|
+
deserialized = response.iter_bytes()
|
|
3284
|
+
else:
|
|
3285
|
+
deserialized = _deserialize(List[_models.AttackObjective], response.json())
|
|
3286
|
+
|
|
3287
|
+
if cls:
|
|
3288
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
3289
|
+
|
|
3290
|
+
return deserialized # type: ignore
|
|
3291
|
+
|
|
3292
|
+
@distributed_trace_async
|
|
3293
|
+
@api_version_validation(
|
|
3294
|
+
method_added_on="2025-05-15-preview",
|
|
3295
|
+
params_added_on={"2025-05-15-preview": ["api_version", "accept"]},
|
|
3296
|
+
)
|
|
3297
|
+
async def get_jail_break_dataset(self, **kwargs: Any) -> List[str]:
|
|
3298
|
+
"""Get the jailbreak dataset.
|
|
3299
|
+
|
|
3300
|
+
:return: list of str
|
|
3301
|
+
:rtype: list[str]
|
|
3302
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3303
|
+
"""
|
|
3304
|
+
error_map: MutableMapping = {
|
|
3305
|
+
401: ClientAuthenticationError,
|
|
3306
|
+
404: ResourceNotFoundError,
|
|
3307
|
+
409: ResourceExistsError,
|
|
3308
|
+
304: ResourceNotModifiedError,
|
|
3309
|
+
}
|
|
3310
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
3311
|
+
|
|
3312
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
3313
|
+
_params = kwargs.pop("params", {}) or {}
|
|
3314
|
+
|
|
3315
|
+
cls: ClsType[List[str]] = kwargs.pop("cls", None)
|
|
3316
|
+
|
|
3317
|
+
_request = build_red_teams_get_jail_break_dataset_request(
|
|
3318
|
+
api_version=self._config.api_version,
|
|
3319
|
+
headers=_headers,
|
|
3320
|
+
params=_params,
|
|
3321
|
+
)
|
|
3322
|
+
path_format_arguments = {
|
|
3323
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
3324
|
+
}
|
|
3325
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3326
|
+
|
|
3327
|
+
_stream = kwargs.pop("stream", False)
|
|
3328
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
3329
|
+
_request, stream=_stream, **kwargs
|
|
3330
|
+
)
|
|
3331
|
+
|
|
3332
|
+
response = pipeline_response.http_response
|
|
3333
|
+
|
|
3334
|
+
if response.status_code not in [200]:
|
|
3335
|
+
if _stream:
|
|
3336
|
+
try:
|
|
3337
|
+
await response.read() # Load the body in memory and close the socket
|
|
3338
|
+
except (StreamConsumedError, StreamClosedError):
|
|
3339
|
+
pass
|
|
3340
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
3341
|
+
raise HttpResponseError(response=response)
|
|
3342
|
+
|
|
3343
|
+
if _stream:
|
|
3344
|
+
deserialized = response.iter_bytes()
|
|
3345
|
+
else:
|
|
3346
|
+
deserialized = _deserialize(List[str], response.json())
|
|
3347
|
+
|
|
3348
|
+
if cls:
|
|
3349
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
3350
|
+
|
|
3351
|
+
return deserialized # type: ignore
|
|
3352
|
+
|
|
3353
|
+
@distributed_trace_async
|
|
3354
|
+
@api_version_validation(
|
|
3355
|
+
method_added_on="2025-05-15-preview",
|
|
3356
|
+
params_added_on={"2025-05-15-preview": ["api_version", "type", "accept"]},
|
|
3357
|
+
)
|
|
3358
|
+
async def get_template_parameters_with_type(self, type: str, **kwargs: Any) -> str:
|
|
3359
|
+
"""Get template parameters with type.
|
|
3360
|
+
|
|
3361
|
+
:param type: Type for the template parameters. Required.
|
|
3362
|
+
:type type: str
|
|
3363
|
+
:return: str
|
|
3364
|
+
:rtype: str
|
|
3365
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3366
|
+
"""
|
|
3367
|
+
error_map: MutableMapping = {
|
|
3368
|
+
401: ClientAuthenticationError,
|
|
3369
|
+
404: ResourceNotFoundError,
|
|
3370
|
+
409: ResourceExistsError,
|
|
3371
|
+
304: ResourceNotModifiedError,
|
|
3372
|
+
}
|
|
3373
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
3374
|
+
|
|
3375
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
3376
|
+
_params = kwargs.pop("params", {}) or {}
|
|
3377
|
+
|
|
3378
|
+
cls: ClsType[str] = kwargs.pop("cls", None)
|
|
3379
|
+
|
|
3380
|
+
_request = build_red_teams_get_template_parameters_with_type_request(
|
|
3381
|
+
type=type,
|
|
3382
|
+
api_version=self._config.api_version,
|
|
3383
|
+
headers=_headers,
|
|
3384
|
+
params=_params,
|
|
3385
|
+
)
|
|
3386
|
+
path_format_arguments = {
|
|
3387
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
3388
|
+
}
|
|
3389
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3390
|
+
|
|
3391
|
+
_stream = kwargs.pop("stream", False)
|
|
3392
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
3393
|
+
_request, stream=_stream, **kwargs
|
|
3394
|
+
)
|
|
3395
|
+
|
|
3396
|
+
response = pipeline_response.http_response
|
|
3397
|
+
|
|
3398
|
+
if response.status_code not in [200]:
|
|
3399
|
+
if _stream:
|
|
3400
|
+
try:
|
|
3401
|
+
await response.read() # Load the body in memory and close the socket
|
|
3402
|
+
except (StreamConsumedError, StreamClosedError):
|
|
3403
|
+
pass
|
|
3404
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
3405
|
+
raise HttpResponseError(response=response)
|
|
3406
|
+
|
|
3407
|
+
if _stream:
|
|
3408
|
+
deserialized = response.iter_bytes()
|
|
3409
|
+
else:
|
|
3410
|
+
deserialized = _deserialize(str, response.text())
|
|
3411
|
+
|
|
3412
|
+
if cls:
|
|
3413
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
3414
|
+
|
|
3415
|
+
return deserialized # type: ignore
|
|
3416
|
+
|
|
3417
|
+
@distributed_trace_async
|
|
3418
|
+
@api_version_validation(
|
|
3419
|
+
method_added_on="2025-05-15-preview",
|
|
3420
|
+
params_added_on={"2025-05-15-preview": ["api_version", "accept"]},
|
|
3421
|
+
)
|
|
3422
|
+
async def get_template_parameters(self, **kwargs: Any) -> str:
|
|
3423
|
+
"""Get template parameters.
|
|
3424
|
+
|
|
3425
|
+
:return: str
|
|
3426
|
+
:rtype: str
|
|
3427
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3428
|
+
"""
|
|
3429
|
+
error_map: MutableMapping = {
|
|
3430
|
+
401: ClientAuthenticationError,
|
|
3431
|
+
404: ResourceNotFoundError,
|
|
3432
|
+
409: ResourceExistsError,
|
|
3433
|
+
304: ResourceNotModifiedError,
|
|
3434
|
+
}
|
|
3435
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
3436
|
+
|
|
3437
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
3438
|
+
_params = kwargs.pop("params", {}) or {}
|
|
3439
|
+
|
|
3440
|
+
cls: ClsType[str] = kwargs.pop("cls", None)
|
|
3441
|
+
|
|
3442
|
+
_request = build_red_teams_get_template_parameters_request(
|
|
3443
|
+
api_version=self._config.api_version,
|
|
3444
|
+
headers=_headers,
|
|
3445
|
+
params=_params,
|
|
3446
|
+
)
|
|
3447
|
+
path_format_arguments = {
|
|
3448
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
3449
|
+
}
|
|
3450
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3451
|
+
|
|
3452
|
+
_stream = kwargs.pop("stream", False)
|
|
3453
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
3454
|
+
_request, stream=_stream, **kwargs
|
|
3455
|
+
)
|
|
3456
|
+
|
|
3457
|
+
response = pipeline_response.http_response
|
|
3458
|
+
|
|
3459
|
+
if response.status_code not in [200]:
|
|
3460
|
+
if _stream:
|
|
3461
|
+
try:
|
|
3462
|
+
await response.read() # Load the body in memory and close the socket
|
|
3463
|
+
except (StreamConsumedError, StreamClosedError):
|
|
3464
|
+
pass
|
|
3465
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
3466
|
+
raise HttpResponseError(response=response)
|
|
3467
|
+
|
|
3468
|
+
if _stream:
|
|
3469
|
+
deserialized = response.iter_bytes()
|
|
3470
|
+
else:
|
|
3471
|
+
deserialized = _deserialize(str, response.text())
|
|
3472
|
+
|
|
3473
|
+
if cls:
|
|
3474
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
3475
|
+
|
|
3476
|
+
return deserialized # type: ignore
|
|
3477
|
+
|
|
3478
|
+
@distributed_trace_async
|
|
3479
|
+
@api_version_validation(
|
|
3480
|
+
method_added_on="2025-05-15-preview",
|
|
3481
|
+
params_added_on={"2025-05-15-preview": ["api_version", "path", "accept"]},
|
|
3482
|
+
)
|
|
3483
|
+
async def get_template_parameters_image(self, *, path: str, **kwargs: Any) -> str:
|
|
3484
|
+
"""Get the template parameters image.
|
|
3485
|
+
|
|
3486
|
+
:keyword path: Image path. Required.
|
|
3487
|
+
:paramtype path: str
|
|
3488
|
+
:return: str
|
|
3489
|
+
:rtype: str
|
|
3490
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3491
|
+
"""
|
|
3492
|
+
error_map: MutableMapping = {
|
|
3493
|
+
401: ClientAuthenticationError,
|
|
3494
|
+
404: ResourceNotFoundError,
|
|
3495
|
+
409: ResourceExistsError,
|
|
3496
|
+
304: ResourceNotModifiedError,
|
|
3497
|
+
}
|
|
3498
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
3499
|
+
|
|
3500
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
3501
|
+
_params = kwargs.pop("params", {}) or {}
|
|
3502
|
+
|
|
3503
|
+
cls: ClsType[str] = kwargs.pop("cls", None)
|
|
3504
|
+
|
|
3505
|
+
_request = build_red_teams_get_template_parameters_image_request(
|
|
3506
|
+
path=path,
|
|
3507
|
+
api_version=self._config.api_version,
|
|
3508
|
+
headers=_headers,
|
|
3509
|
+
params=_params,
|
|
3510
|
+
)
|
|
3511
|
+
path_format_arguments = {
|
|
3512
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
3513
|
+
}
|
|
3514
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3515
|
+
|
|
3516
|
+
_stream = kwargs.pop("stream", False)
|
|
3517
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
3518
|
+
_request, stream=_stream, **kwargs
|
|
3519
|
+
)
|
|
3520
|
+
|
|
3521
|
+
response = pipeline_response.http_response
|
|
3522
|
+
|
|
3523
|
+
if response.status_code not in [200]:
|
|
3524
|
+
if _stream:
|
|
3525
|
+
try:
|
|
3526
|
+
await response.read() # Load the body in memory and close the socket
|
|
3527
|
+
except (StreamConsumedError, StreamClosedError):
|
|
3528
|
+
pass
|
|
3529
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
3530
|
+
raise HttpResponseError(response=response)
|
|
3531
|
+
|
|
3532
|
+
if _stream:
|
|
3533
|
+
deserialized = response.iter_bytes()
|
|
3534
|
+
else:
|
|
3535
|
+
deserialized = _deserialize(str, response.text())
|
|
3536
|
+
|
|
3537
|
+
if cls:
|
|
3538
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
3539
|
+
|
|
3540
|
+
return deserialized # type: ignore
|
|
3541
|
+
|
|
3542
|
+
@overload
|
|
3543
|
+
async def submit_simulation(
|
|
3544
|
+
self, body: _models.SimulationDTO, *, content_type: str = "application/json", **kwargs: Any
|
|
3545
|
+
) -> _models.LongRunningResponse:
|
|
3546
|
+
"""Submit a request for simulation.
|
|
3547
|
+
|
|
3548
|
+
:param body: Properties of a Prompt Version. Required.
|
|
3549
|
+
:type body: ~azure.ai.projects.onedp.models.SimulationDTO
|
|
3550
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
3551
|
+
Default value is "application/json".
|
|
3552
|
+
:paramtype content_type: str
|
|
3553
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
3554
|
+
:rtype: ~azure.ai.projects.onedp.models.LongRunningResponse
|
|
3555
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3556
|
+
"""
|
|
3557
|
+
|
|
3558
|
+
@overload
|
|
3559
|
+
async def submit_simulation(
|
|
3560
|
+
self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
3561
|
+
) -> _models.LongRunningResponse:
|
|
3562
|
+
"""Submit a request for simulation.
|
|
3563
|
+
|
|
3564
|
+
:param body: Properties of a Prompt Version. Required.
|
|
3565
|
+
:type body: JSON
|
|
3566
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
3567
|
+
Default value is "application/json".
|
|
3568
|
+
:paramtype content_type: str
|
|
3569
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
3570
|
+
:rtype: ~azure.ai.projects.onedp.models.LongRunningResponse
|
|
3571
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3572
|
+
"""
|
|
3573
|
+
|
|
3574
|
+
@overload
|
|
3575
|
+
async def submit_simulation(
|
|
3576
|
+
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
3577
|
+
) -> _models.LongRunningResponse:
|
|
3578
|
+
"""Submit a request for simulation.
|
|
3579
|
+
|
|
3580
|
+
:param body: Properties of a Prompt Version. Required.
|
|
3581
|
+
:type body: IO[bytes]
|
|
3582
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
3583
|
+
Default value is "application/json".
|
|
3584
|
+
:paramtype content_type: str
|
|
3585
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
3586
|
+
:rtype: ~azure.ai.projects.onedp.models.LongRunningResponse
|
|
3587
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3588
|
+
"""
|
|
3589
|
+
|
|
3590
|
+
@distributed_trace_async
|
|
3591
|
+
@api_version_validation(
|
|
3592
|
+
method_added_on="2025-05-15-preview",
|
|
3593
|
+
params_added_on={"2025-05-15-preview": ["api_version", "content_type", "accept"]},
|
|
3594
|
+
)
|
|
3595
|
+
async def submit_simulation(
|
|
3596
|
+
self, body: Union[_models.SimulationDTO, JSON, IO[bytes]], **kwargs: Any
|
|
3597
|
+
) -> _models.LongRunningResponse:
|
|
3598
|
+
"""Submit a request for simulation.
|
|
3599
|
+
|
|
3600
|
+
:param body: Properties of a Prompt Version. Is one of the following types: SimulationDTO,
|
|
3601
|
+
JSON, IO[bytes] Required.
|
|
3602
|
+
:type body: ~azure.ai.projects.onedp.models.SimulationDTO or JSON or IO[bytes]
|
|
3603
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
3604
|
+
:rtype: ~azure.ai.projects.onedp.models.LongRunningResponse
|
|
3605
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3606
|
+
"""
|
|
3607
|
+
error_map: MutableMapping = {
|
|
3608
|
+
401: ClientAuthenticationError,
|
|
3609
|
+
404: ResourceNotFoundError,
|
|
3610
|
+
409: ResourceExistsError,
|
|
3611
|
+
304: ResourceNotModifiedError,
|
|
3612
|
+
}
|
|
3613
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
3614
|
+
|
|
3615
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
3616
|
+
_params = kwargs.pop("params", {}) or {}
|
|
3617
|
+
|
|
3618
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
3619
|
+
cls: ClsType[_models.LongRunningResponse] = kwargs.pop("cls", None)
|
|
3620
|
+
|
|
3621
|
+
content_type = content_type or "application/json"
|
|
3622
|
+
_content = None
|
|
3623
|
+
if isinstance(body, (IOBase, bytes)):
|
|
3624
|
+
_content = body
|
|
3625
|
+
else:
|
|
3626
|
+
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
3627
|
+
|
|
3628
|
+
_request = build_red_teams_submit_simulation_request(
|
|
3629
|
+
content_type=content_type,
|
|
3630
|
+
api_version=self._config.api_version,
|
|
3631
|
+
content=_content,
|
|
3632
|
+
headers=_headers,
|
|
3633
|
+
params=_params,
|
|
3634
|
+
)
|
|
3635
|
+
path_format_arguments = {
|
|
3636
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
3637
|
+
}
|
|
3638
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3639
|
+
|
|
3640
|
+
_stream = kwargs.pop("stream", False)
|
|
3641
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
3642
|
+
_request, stream=_stream, **kwargs
|
|
3643
|
+
)
|
|
3644
|
+
|
|
3645
|
+
response = pipeline_response.http_response
|
|
3646
|
+
|
|
3647
|
+
if response.status_code not in [202]:
|
|
3648
|
+
if _stream:
|
|
3649
|
+
try:
|
|
3650
|
+
await response.read() # Load the body in memory and close the socket
|
|
3651
|
+
except (StreamConsumedError, StreamClosedError):
|
|
3652
|
+
pass
|
|
3653
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
3654
|
+
raise HttpResponseError(response=response)
|
|
3655
|
+
|
|
3656
|
+
if _stream:
|
|
3657
|
+
deserialized = response.iter_bytes()
|
|
3658
|
+
else:
|
|
3659
|
+
deserialized = _deserialize(_models.LongRunningResponse, response.json())
|
|
3660
|
+
|
|
3661
|
+
if cls:
|
|
3662
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
3663
|
+
|
|
3664
|
+
return deserialized # type: ignore
|
|
3665
|
+
|
|
3666
|
+
|
|
3667
|
+
class EvaluationResultsOperations:
|
|
3668
|
+
"""
|
|
3669
|
+
.. warning::
|
|
3670
|
+
**DO NOT** instantiate this class directly.
|
|
3671
|
+
|
|
3672
|
+
Instead, you should access the following operations through
|
|
3673
|
+
:class:`~azure.ai.projects.onedp.aio.AIProjectClient`'s
|
|
3674
|
+
:attr:`evaluation_results` attribute.
|
|
3675
|
+
"""
|
|
3676
|
+
|
|
3677
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
3678
|
+
input_args = list(args)
|
|
3679
|
+
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
3680
|
+
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
3681
|
+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
3682
|
+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
3683
|
+
|
|
3684
|
+
@distributed_trace
|
|
3685
|
+
@api_version_validation(
|
|
3686
|
+
method_added_on="2025-05-15-preview",
|
|
3687
|
+
params_added_on={
|
|
3688
|
+
"2025-05-15-preview": ["api_version", "name", "top", "skip", "tags", "list_view_type", "accept"]
|
|
3689
|
+
},
|
|
3690
|
+
)
|
|
3691
|
+
def list_versions(
|
|
3692
|
+
self,
|
|
3693
|
+
name: str,
|
|
3694
|
+
*,
|
|
3695
|
+
top: Optional[int] = None,
|
|
3696
|
+
skip: Optional[str] = None,
|
|
3697
|
+
tags: Optional[str] = None,
|
|
3698
|
+
list_view_type: Optional[Union[str, _models.ListViewType]] = None,
|
|
3699
|
+
**kwargs: Any
|
|
3700
|
+
) -> AsyncIterable["_models.EvaluationResult"]:
|
|
3701
|
+
"""List all versions of the given EvaluationResult.
|
|
3702
|
+
|
|
3703
|
+
:param name: The name of the resource. Required.
|
|
3704
|
+
:type name: str
|
|
3705
|
+
:keyword top: Top count of results, top count cannot be greater than the page size. If topCount
|
|
3706
|
+
> page size, results with be default page size count will be returned. Default value is None.
|
|
3707
|
+
:paramtype top: int
|
|
3708
|
+
:keyword skip: Continuation token for pagination. Default value is None.
|
|
3709
|
+
:paramtype skip: str
|
|
3710
|
+
:keyword tags: Comma-separated list of tag names (and optionally values). Example:
|
|
3711
|
+
tag1,tag2=value2. Default value is None.
|
|
3712
|
+
:paramtype tags: str
|
|
3713
|
+
:keyword list_view_type: [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All]
|
|
3714
|
+
View type for including/excluding (for example) archived entities. Known values are:
|
|
3715
|
+
"ActiveOnly", "ArchivedOnly", and "All". Default value is None.
|
|
3716
|
+
:paramtype list_view_type: str or ~azure.ai.projects.onedp.models.ListViewType
|
|
3717
|
+
:return: An iterator like instance of EvaluationResult
|
|
3718
|
+
:rtype:
|
|
3719
|
+
~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.onedp.models.EvaluationResult]
|
|
3720
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3721
|
+
"""
|
|
3722
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
3723
|
+
_params = kwargs.pop("params", {}) or {}
|
|
3724
|
+
|
|
3725
|
+
cls: ClsType[List[_models.EvaluationResult]] = kwargs.pop("cls", None)
|
|
3726
|
+
|
|
3727
|
+
error_map: MutableMapping = {
|
|
3728
|
+
401: ClientAuthenticationError,
|
|
3729
|
+
404: ResourceNotFoundError,
|
|
3730
|
+
409: ResourceExistsError,
|
|
3731
|
+
304: ResourceNotModifiedError,
|
|
3732
|
+
}
|
|
3733
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
3734
|
+
|
|
3735
|
+
def prepare_request(next_link=None):
|
|
3736
|
+
if not next_link:
|
|
3737
|
+
|
|
3738
|
+
_request = build_evaluation_results_list_versions_request(
|
|
3739
|
+
name=name,
|
|
3740
|
+
top=top,
|
|
3741
|
+
skip=skip,
|
|
3742
|
+
tags=tags,
|
|
3743
|
+
list_view_type=list_view_type,
|
|
3744
|
+
api_version=self._config.api_version,
|
|
3745
|
+
headers=_headers,
|
|
3746
|
+
params=_params,
|
|
3747
|
+
)
|
|
3748
|
+
path_format_arguments = {
|
|
3749
|
+
"endpoint": self._serialize.url(
|
|
3750
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
3751
|
+
),
|
|
3752
|
+
}
|
|
3753
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3754
|
+
|
|
3755
|
+
else:
|
|
3756
|
+
# make call to next link with the client's api-version
|
|
3757
|
+
_parsed_next_link = urllib.parse.urlparse(next_link)
|
|
3758
|
+
_next_request_params = case_insensitive_dict(
|
|
3759
|
+
{
|
|
3760
|
+
key: [urllib.parse.quote(v) for v in value]
|
|
3761
|
+
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
|
|
3762
|
+
}
|
|
3763
|
+
)
|
|
3764
|
+
_next_request_params["api-version"] = self._config.api_version
|
|
3765
|
+
_request = HttpRequest(
|
|
3766
|
+
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
|
|
3767
|
+
)
|
|
3768
|
+
path_format_arguments = {
|
|
3769
|
+
"endpoint": self._serialize.url(
|
|
3770
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
3771
|
+
),
|
|
3772
|
+
}
|
|
3773
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3774
|
+
|
|
3775
|
+
return _request
|
|
3776
|
+
|
|
3777
|
+
async def extract_data(pipeline_response):
|
|
3778
|
+
deserialized = pipeline_response.http_response.json()
|
|
3779
|
+
list_of_elem = _deserialize(List[_models.EvaluationResult], deserialized.get("value", []))
|
|
3780
|
+
if cls:
|
|
3781
|
+
list_of_elem = cls(list_of_elem) # type: ignore
|
|
3782
|
+
return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
|
|
3783
|
+
|
|
3784
|
+
async def get_next(next_link=None):
|
|
3785
|
+
_request = prepare_request(next_link)
|
|
3786
|
+
|
|
3787
|
+
_stream = False
|
|
3788
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
3789
|
+
_request, stream=_stream, **kwargs
|
|
3790
|
+
)
|
|
3791
|
+
response = pipeline_response.http_response
|
|
3792
|
+
|
|
3793
|
+
if response.status_code not in [200]:
|
|
3794
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
3795
|
+
raise HttpResponseError(response=response)
|
|
3796
|
+
|
|
3797
|
+
return pipeline_response
|
|
3798
|
+
|
|
3799
|
+
return AsyncItemPaged(get_next, extract_data)
|
|
3800
|
+
|
|
3801
|
+
@distributed_trace
|
|
3802
|
+
@api_version_validation(
|
|
3803
|
+
method_added_on="2025-05-15-preview",
|
|
3804
|
+
params_added_on={"2025-05-15-preview": ["api_version", "top", "skip", "tags", "list_view_type", "accept"]},
|
|
3805
|
+
)
|
|
3806
|
+
def list_latest(
|
|
3807
|
+
self,
|
|
3808
|
+
*,
|
|
3809
|
+
top: Optional[int] = None,
|
|
3810
|
+
skip: Optional[str] = None,
|
|
3811
|
+
tags: Optional[str] = None,
|
|
3812
|
+
list_view_type: Optional[Union[str, _models.ListViewType]] = None,
|
|
3813
|
+
**kwargs: Any
|
|
3814
|
+
) -> AsyncIterable["_models.EvaluationResult"]:
|
|
3815
|
+
"""List the latest version of each EvaluationResult.
|
|
3816
|
+
|
|
3817
|
+
:keyword top: Top count of results, top count cannot be greater than the page size. If topCount
|
|
3818
|
+
> page size, results with be default page size count will be returned. Default value is None.
|
|
3819
|
+
:paramtype top: int
|
|
3820
|
+
:keyword skip: Continuation token for pagination. Default value is None.
|
|
3821
|
+
:paramtype skip: str
|
|
3822
|
+
:keyword tags: Comma-separated list of tag names (and optionally values). Example:
|
|
3823
|
+
tag1,tag2=value2. Default value is None.
|
|
3824
|
+
:paramtype tags: str
|
|
3825
|
+
:keyword list_view_type: [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All]
|
|
3826
|
+
View type for including/excluding (for example) archived entities. Known values are:
|
|
3827
|
+
"ActiveOnly", "ArchivedOnly", and "All". Default value is None.
|
|
3828
|
+
:paramtype list_view_type: str or ~azure.ai.projects.onedp.models.ListViewType
|
|
3829
|
+
:return: An iterator like instance of EvaluationResult
|
|
3830
|
+
:rtype:
|
|
3831
|
+
~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.onedp.models.EvaluationResult]
|
|
3832
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3833
|
+
"""
|
|
3834
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
3835
|
+
_params = kwargs.pop("params", {}) or {}
|
|
3836
|
+
|
|
3837
|
+
cls: ClsType[List[_models.EvaluationResult]] = kwargs.pop("cls", None)
|
|
3838
|
+
|
|
3839
|
+
error_map: MutableMapping = {
|
|
3840
|
+
401: ClientAuthenticationError,
|
|
3841
|
+
404: ResourceNotFoundError,
|
|
3842
|
+
409: ResourceExistsError,
|
|
3843
|
+
304: ResourceNotModifiedError,
|
|
3844
|
+
}
|
|
3845
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
3846
|
+
|
|
3847
|
+
def prepare_request(next_link=None):
|
|
3848
|
+
if not next_link:
|
|
3849
|
+
|
|
3850
|
+
_request = build_evaluation_results_list_latest_request(
|
|
3851
|
+
top=top,
|
|
3852
|
+
skip=skip,
|
|
3853
|
+
tags=tags,
|
|
3854
|
+
list_view_type=list_view_type,
|
|
3855
|
+
api_version=self._config.api_version,
|
|
3856
|
+
headers=_headers,
|
|
3857
|
+
params=_params,
|
|
3858
|
+
)
|
|
3859
|
+
path_format_arguments = {
|
|
3860
|
+
"endpoint": self._serialize.url(
|
|
3861
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
3862
|
+
),
|
|
3863
|
+
}
|
|
3864
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3865
|
+
|
|
3866
|
+
else:
|
|
3867
|
+
# make call to next link with the client's api-version
|
|
3868
|
+
_parsed_next_link = urllib.parse.urlparse(next_link)
|
|
3869
|
+
_next_request_params = case_insensitive_dict(
|
|
3870
|
+
{
|
|
3871
|
+
key: [urllib.parse.quote(v) for v in value]
|
|
3872
|
+
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
|
|
3873
|
+
}
|
|
3874
|
+
)
|
|
3875
|
+
_next_request_params["api-version"] = self._config.api_version
|
|
3876
|
+
_request = HttpRequest(
|
|
3877
|
+
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
|
|
3878
|
+
)
|
|
3879
|
+
path_format_arguments = {
|
|
3880
|
+
"endpoint": self._serialize.url(
|
|
3881
|
+
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
|
|
3882
|
+
),
|
|
3883
|
+
}
|
|
3884
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3885
|
+
|
|
3886
|
+
return _request
|
|
3887
|
+
|
|
3888
|
+
async def extract_data(pipeline_response):
|
|
3889
|
+
deserialized = pipeline_response.http_response.json()
|
|
3890
|
+
list_of_elem = _deserialize(List[_models.EvaluationResult], deserialized.get("value", []))
|
|
3891
|
+
if cls:
|
|
3892
|
+
list_of_elem = cls(list_of_elem) # type: ignore
|
|
3893
|
+
return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
|
|
3894
|
+
|
|
3895
|
+
async def get_next(next_link=None):
|
|
3896
|
+
_request = prepare_request(next_link)
|
|
3897
|
+
|
|
3898
|
+
_stream = False
|
|
3899
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
3900
|
+
_request, stream=_stream, **kwargs
|
|
3901
|
+
)
|
|
3902
|
+
response = pipeline_response.http_response
|
|
3903
|
+
|
|
3904
|
+
if response.status_code not in [200]:
|
|
3905
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
3906
|
+
raise HttpResponseError(response=response)
|
|
3907
|
+
|
|
3908
|
+
return pipeline_response
|
|
3909
|
+
|
|
3910
|
+
return AsyncItemPaged(get_next, extract_data)
|
|
3911
|
+
|
|
3912
|
+
@distributed_trace_async
|
|
3913
|
+
@api_version_validation(
|
|
3914
|
+
method_added_on="2025-05-15-preview",
|
|
3915
|
+
params_added_on={"2025-05-15-preview": ["api_version", "name", "version", "accept"]},
|
|
3916
|
+
)
|
|
3917
|
+
async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.EvaluationResult:
|
|
3918
|
+
"""Get the specific version of the EvaluationResult.
|
|
3919
|
+
|
|
3920
|
+
:param name: The name of the resource. Required.
|
|
3921
|
+
:type name: str
|
|
3922
|
+
:param version: The specific version id of the EvaluationResult to retrieve. Required.
|
|
3923
|
+
:type version: str
|
|
3924
|
+
:return: EvaluationResult. The EvaluationResult is compatible with MutableMapping
|
|
3925
|
+
:rtype: ~azure.ai.projects.onedp.models.EvaluationResult
|
|
3926
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3927
|
+
"""
|
|
3928
|
+
error_map: MutableMapping = {
|
|
3929
|
+
401: ClientAuthenticationError,
|
|
3930
|
+
404: ResourceNotFoundError,
|
|
3931
|
+
409: ResourceExistsError,
|
|
3932
|
+
304: ResourceNotModifiedError,
|
|
3933
|
+
}
|
|
3934
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
3935
|
+
|
|
3936
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
3937
|
+
_params = kwargs.pop("params", {}) or {}
|
|
3938
|
+
|
|
3939
|
+
cls: ClsType[_models.EvaluationResult] = kwargs.pop("cls", None)
|
|
3940
|
+
|
|
3941
|
+
_request = build_evaluation_results_get_version_request(
|
|
3942
|
+
name=name,
|
|
3943
|
+
version=version,
|
|
3944
|
+
api_version=self._config.api_version,
|
|
3945
|
+
headers=_headers,
|
|
3946
|
+
params=_params,
|
|
3947
|
+
)
|
|
3948
|
+
path_format_arguments = {
|
|
3949
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
3950
|
+
}
|
|
3951
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
3952
|
+
|
|
3953
|
+
_stream = kwargs.pop("stream", False)
|
|
3954
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
3955
|
+
_request, stream=_stream, **kwargs
|
|
3956
|
+
)
|
|
3957
|
+
|
|
3958
|
+
response = pipeline_response.http_response
|
|
3959
|
+
|
|
3960
|
+
if response.status_code not in [200]:
|
|
3961
|
+
if _stream:
|
|
3962
|
+
try:
|
|
3963
|
+
await response.read() # Load the body in memory and close the socket
|
|
3964
|
+
except (StreamConsumedError, StreamClosedError):
|
|
3965
|
+
pass
|
|
3966
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
3967
|
+
raise HttpResponseError(response=response)
|
|
3968
|
+
|
|
3969
|
+
if _stream:
|
|
3970
|
+
deserialized = response.iter_bytes()
|
|
3971
|
+
else:
|
|
3972
|
+
deserialized = _deserialize(_models.EvaluationResult, response.json())
|
|
3973
|
+
|
|
3974
|
+
if cls:
|
|
3975
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
3976
|
+
|
|
3977
|
+
return deserialized # type: ignore
|
|
3978
|
+
|
|
3979
|
+
@distributed_trace_async
|
|
3980
|
+
@api_version_validation(
|
|
3981
|
+
method_added_on="2025-05-15-preview",
|
|
3982
|
+
params_added_on={"2025-05-15-preview": ["api_version", "name", "version", "accept"]},
|
|
3983
|
+
)
|
|
3984
|
+
async def delete_version(self, name: str, version: str, **kwargs: Any) -> None:
|
|
3985
|
+
"""Delete the specific version of the EvaluationResult.
|
|
3986
|
+
|
|
3987
|
+
:param name: The name of the resource. Required.
|
|
3988
|
+
:type name: str
|
|
3989
|
+
:param version: The version of the EvaluationResult to delete. Required.
|
|
3990
|
+
:type version: str
|
|
3991
|
+
:return: None
|
|
3992
|
+
:rtype: None
|
|
3993
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
3994
|
+
"""
|
|
3995
|
+
error_map: MutableMapping = {
|
|
3996
|
+
401: ClientAuthenticationError,
|
|
3997
|
+
404: ResourceNotFoundError,
|
|
3998
|
+
409: ResourceExistsError,
|
|
3999
|
+
304: ResourceNotModifiedError,
|
|
4000
|
+
}
|
|
4001
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
4002
|
+
|
|
4003
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
4004
|
+
_params = kwargs.pop("params", {}) or {}
|
|
4005
|
+
|
|
4006
|
+
cls: ClsType[None] = kwargs.pop("cls", None)
|
|
4007
|
+
|
|
4008
|
+
_request = build_evaluation_results_delete_version_request(
|
|
4009
|
+
name=name,
|
|
4010
|
+
version=version,
|
|
4011
|
+
api_version=self._config.api_version,
|
|
4012
|
+
headers=_headers,
|
|
4013
|
+
params=_params,
|
|
4014
|
+
)
|
|
4015
|
+
path_format_arguments = {
|
|
4016
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
4017
|
+
}
|
|
4018
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
4019
|
+
|
|
4020
|
+
_stream = False
|
|
4021
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
4022
|
+
_request, stream=_stream, **kwargs
|
|
4023
|
+
)
|
|
4024
|
+
|
|
4025
|
+
response = pipeline_response.http_response
|
|
4026
|
+
|
|
4027
|
+
if response.status_code not in [204]:
|
|
4028
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
4029
|
+
raise HttpResponseError(response=response)
|
|
4030
|
+
|
|
4031
|
+
if cls:
|
|
4032
|
+
return cls(pipeline_response, None, {}) # type: ignore
|
|
4033
|
+
|
|
4034
|
+
@overload
|
|
4035
|
+
async def create_or_update_version(
|
|
4036
|
+
self,
|
|
4037
|
+
name: str,
|
|
4038
|
+
version: str,
|
|
4039
|
+
body: _models.EvaluationResult,
|
|
4040
|
+
*,
|
|
4041
|
+
content_type: str = "application/json",
|
|
4042
|
+
**kwargs: Any
|
|
4043
|
+
) -> _models.EvaluationResult:
|
|
4044
|
+
"""Create a new or update an existing EvaluationResult with the given version id.
|
|
4045
|
+
|
|
4046
|
+
:param name: The name of the resource. Required.
|
|
4047
|
+
:type name: str
|
|
4048
|
+
:param version: The specific version id of the EvaluationResult to create or replace. Required.
|
|
4049
|
+
:type version: str
|
|
4050
|
+
:param body: The definition of the EvaluationResult to create or update. Required.
|
|
4051
|
+
:type body: ~azure.ai.projects.onedp.models.EvaluationResult
|
|
4052
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
4053
|
+
Default value is "application/json".
|
|
4054
|
+
:paramtype content_type: str
|
|
4055
|
+
:return: EvaluationResult. The EvaluationResult is compatible with MutableMapping
|
|
4056
|
+
:rtype: ~azure.ai.projects.onedp.models.EvaluationResult
|
|
4057
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4058
|
+
"""
|
|
4059
|
+
|
|
4060
|
+
@overload
|
|
4061
|
+
async def create_or_update_version(
|
|
4062
|
+
self, name: str, version: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
4063
|
+
) -> _models.EvaluationResult:
|
|
4064
|
+
"""Create a new or update an existing EvaluationResult with the given version id.
|
|
4065
|
+
|
|
4066
|
+
:param name: The name of the resource. Required.
|
|
4067
|
+
:type name: str
|
|
4068
|
+
:param version: The specific version id of the EvaluationResult to create or replace. Required.
|
|
4069
|
+
:type version: str
|
|
4070
|
+
:param body: The definition of the EvaluationResult to create or update. Required.
|
|
4071
|
+
:type body: JSON
|
|
4072
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
4073
|
+
Default value is "application/json".
|
|
4074
|
+
:paramtype content_type: str
|
|
4075
|
+
:return: EvaluationResult. The EvaluationResult is compatible with MutableMapping
|
|
4076
|
+
:rtype: ~azure.ai.projects.onedp.models.EvaluationResult
|
|
4077
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4078
|
+
"""
|
|
4079
|
+
|
|
4080
|
+
@overload
|
|
4081
|
+
async def create_or_update_version(
|
|
4082
|
+
self, name: str, version: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
4083
|
+
) -> _models.EvaluationResult:
|
|
4084
|
+
"""Create a new or update an existing EvaluationResult with the given version id.
|
|
4085
|
+
|
|
4086
|
+
:param name: The name of the resource. Required.
|
|
4087
|
+
:type name: str
|
|
4088
|
+
:param version: The specific version id of the EvaluationResult to create or replace. Required.
|
|
4089
|
+
:type version: str
|
|
4090
|
+
:param body: The definition of the EvaluationResult to create or update. Required.
|
|
4091
|
+
:type body: IO[bytes]
|
|
4092
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
4093
|
+
Default value is "application/json".
|
|
4094
|
+
:paramtype content_type: str
|
|
4095
|
+
:return: EvaluationResult. The EvaluationResult is compatible with MutableMapping
|
|
4096
|
+
:rtype: ~azure.ai.projects.onedp.models.EvaluationResult
|
|
4097
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4098
|
+
"""
|
|
4099
|
+
|
|
4100
|
+
@distributed_trace_async
|
|
4101
|
+
@api_version_validation(
|
|
4102
|
+
method_added_on="2025-05-15-preview",
|
|
4103
|
+
params_added_on={"2025-05-15-preview": ["api_version", "name", "version", "content_type", "accept"]},
|
|
4104
|
+
)
|
|
4105
|
+
async def create_or_update_version(
|
|
4106
|
+
self, name: str, version: str, body: Union[_models.EvaluationResult, JSON, IO[bytes]], **kwargs: Any
|
|
4107
|
+
) -> _models.EvaluationResult:
|
|
4108
|
+
"""Create a new or update an existing EvaluationResult with the given version id.
|
|
4109
|
+
|
|
4110
|
+
:param name: The name of the resource. Required.
|
|
4111
|
+
:type name: str
|
|
4112
|
+
:param version: The specific version id of the EvaluationResult to create or replace. Required.
|
|
4113
|
+
:type version: str
|
|
4114
|
+
:param body: The definition of the EvaluationResult to create or update. Is one of the
|
|
4115
|
+
following types: EvaluationResult, JSON, IO[bytes] Required.
|
|
4116
|
+
:type body: ~azure.ai.projects.onedp.models.EvaluationResult or JSON or IO[bytes]
|
|
4117
|
+
:return: EvaluationResult. The EvaluationResult is compatible with MutableMapping
|
|
4118
|
+
:rtype: ~azure.ai.projects.onedp.models.EvaluationResult
|
|
4119
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4120
|
+
"""
|
|
4121
|
+
error_map: MutableMapping = {
|
|
4122
|
+
401: ClientAuthenticationError,
|
|
4123
|
+
404: ResourceNotFoundError,
|
|
4124
|
+
409: ResourceExistsError,
|
|
4125
|
+
304: ResourceNotModifiedError,
|
|
4126
|
+
}
|
|
4127
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
4128
|
+
|
|
4129
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
4130
|
+
_params = kwargs.pop("params", {}) or {}
|
|
4131
|
+
|
|
4132
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
4133
|
+
cls: ClsType[_models.EvaluationResult] = kwargs.pop("cls", None)
|
|
4134
|
+
|
|
4135
|
+
content_type = content_type or "application/json"
|
|
4136
|
+
_content = None
|
|
4137
|
+
if isinstance(body, (IOBase, bytes)):
|
|
4138
|
+
_content = body
|
|
4139
|
+
else:
|
|
4140
|
+
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
4141
|
+
|
|
4142
|
+
_request = build_evaluation_results_create_or_update_version_request(
|
|
4143
|
+
name=name,
|
|
4144
|
+
version=version,
|
|
4145
|
+
content_type=content_type,
|
|
4146
|
+
api_version=self._config.api_version,
|
|
4147
|
+
content=_content,
|
|
4148
|
+
headers=_headers,
|
|
4149
|
+
params=_params,
|
|
4150
|
+
)
|
|
4151
|
+
path_format_arguments = {
|
|
4152
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
4153
|
+
}
|
|
4154
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
4155
|
+
|
|
4156
|
+
_stream = kwargs.pop("stream", False)
|
|
4157
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
4158
|
+
_request, stream=_stream, **kwargs
|
|
4159
|
+
)
|
|
4160
|
+
|
|
4161
|
+
response = pipeline_response.http_response
|
|
4162
|
+
|
|
4163
|
+
if response.status_code not in [200, 201]:
|
|
4164
|
+
if _stream:
|
|
4165
|
+
try:
|
|
4166
|
+
await response.read() # Load the body in memory and close the socket
|
|
4167
|
+
except (StreamConsumedError, StreamClosedError):
|
|
4168
|
+
pass
|
|
4169
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
4170
|
+
raise HttpResponseError(response=response)
|
|
4171
|
+
|
|
4172
|
+
if _stream:
|
|
4173
|
+
deserialized = response.iter_bytes()
|
|
4174
|
+
else:
|
|
4175
|
+
deserialized = _deserialize(_models.EvaluationResult, response.json())
|
|
4176
|
+
|
|
4177
|
+
if cls:
|
|
4178
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
4179
|
+
|
|
4180
|
+
return deserialized # type: ignore
|
|
4181
|
+
|
|
4182
|
+
@overload
|
|
4183
|
+
async def start_pending_upload(
|
|
4184
|
+
self,
|
|
4185
|
+
name: str,
|
|
4186
|
+
version: str,
|
|
4187
|
+
body: _models.PendingUploadRequest,
|
|
4188
|
+
*,
|
|
4189
|
+
content_type: str = "application/json",
|
|
4190
|
+
**kwargs: Any
|
|
4191
|
+
) -> _models.PendingUploadResponse:
|
|
4192
|
+
"""Create or start a pending upload of a evaluation results for a specific version.
|
|
4193
|
+
|
|
4194
|
+
:param name: The name of the resource. Required.
|
|
4195
|
+
:type name: str
|
|
4196
|
+
:param version: The specific version id of the EvaluationResult to operate on. Required.
|
|
4197
|
+
:type version: str
|
|
4198
|
+
:param body: Parameters for the action. Required.
|
|
4199
|
+
:type body: ~azure.ai.projects.onedp.models.PendingUploadRequest
|
|
4200
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
4201
|
+
Default value is "application/json".
|
|
4202
|
+
:paramtype content_type: str
|
|
4203
|
+
:return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping
|
|
4204
|
+
:rtype: ~azure.ai.projects.onedp.models.PendingUploadResponse
|
|
4205
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4206
|
+
"""
|
|
4207
|
+
|
|
4208
|
+
@overload
|
|
4209
|
+
async def start_pending_upload(
|
|
4210
|
+
self, name: str, version: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
4211
|
+
) -> _models.PendingUploadResponse:
|
|
4212
|
+
"""Create or start a pending upload of a evaluation results for a specific version.
|
|
4213
|
+
|
|
4214
|
+
:param name: The name of the resource. Required.
|
|
4215
|
+
:type name: str
|
|
4216
|
+
:param version: The specific version id of the EvaluationResult to operate on. Required.
|
|
4217
|
+
:type version: str
|
|
4218
|
+
:param body: Parameters for the action. Required.
|
|
4219
|
+
:type body: JSON
|
|
4220
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
4221
|
+
Default value is "application/json".
|
|
4222
|
+
:paramtype content_type: str
|
|
4223
|
+
:return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping
|
|
4224
|
+
:rtype: ~azure.ai.projects.onedp.models.PendingUploadResponse
|
|
4225
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4226
|
+
"""
|
|
4227
|
+
|
|
4228
|
+
@overload
|
|
4229
|
+
async def start_pending_upload(
|
|
4230
|
+
self, name: str, version: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
4231
|
+
) -> _models.PendingUploadResponse:
|
|
4232
|
+
"""Create or start a pending upload of a evaluation results for a specific version.
|
|
4233
|
+
|
|
4234
|
+
:param name: The name of the resource. Required.
|
|
4235
|
+
:type name: str
|
|
4236
|
+
:param version: The specific version id of the EvaluationResult to operate on. Required.
|
|
4237
|
+
:type version: str
|
|
4238
|
+
:param body: Parameters for the action. Required.
|
|
4239
|
+
:type body: IO[bytes]
|
|
4240
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
4241
|
+
Default value is "application/json".
|
|
4242
|
+
:paramtype content_type: str
|
|
4243
|
+
:return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping
|
|
4244
|
+
:rtype: ~azure.ai.projects.onedp.models.PendingUploadResponse
|
|
4245
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4246
|
+
"""
|
|
4247
|
+
|
|
4248
|
+
@distributed_trace_async
|
|
4249
|
+
@api_version_validation(
|
|
4250
|
+
method_added_on="2025-05-15-preview",
|
|
4251
|
+
params_added_on={"2025-05-15-preview": ["api_version", "name", "version", "content_type", "accept"]},
|
|
4252
|
+
)
|
|
4253
|
+
async def start_pending_upload(
|
|
4254
|
+
self, name: str, version: str, body: Union[_models.PendingUploadRequest, JSON, IO[bytes]], **kwargs: Any
|
|
4255
|
+
) -> _models.PendingUploadResponse:
|
|
4256
|
+
"""Create or start a pending upload of a evaluation results for a specific version.
|
|
4257
|
+
|
|
4258
|
+
:param name: The name of the resource. Required.
|
|
4259
|
+
:type name: str
|
|
4260
|
+
:param version: The specific version id of the EvaluationResult to operate on. Required.
|
|
4261
|
+
:type version: str
|
|
4262
|
+
:param body: Parameters for the action. Is one of the following types: PendingUploadRequest,
|
|
4263
|
+
JSON, IO[bytes] Required.
|
|
4264
|
+
:type body: ~azure.ai.projects.onedp.models.PendingUploadRequest or JSON or IO[bytes]
|
|
4265
|
+
:return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping
|
|
4266
|
+
:rtype: ~azure.ai.projects.onedp.models.PendingUploadResponse
|
|
4267
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4268
|
+
"""
|
|
4269
|
+
error_map: MutableMapping = {
|
|
4270
|
+
401: ClientAuthenticationError,
|
|
4271
|
+
404: ResourceNotFoundError,
|
|
4272
|
+
409: ResourceExistsError,
|
|
4273
|
+
304: ResourceNotModifiedError,
|
|
4274
|
+
}
|
|
4275
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
4276
|
+
|
|
4277
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
4278
|
+
_params = kwargs.pop("params", {}) or {}
|
|
4279
|
+
|
|
4280
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
4281
|
+
cls: ClsType[_models.PendingUploadResponse] = kwargs.pop("cls", None)
|
|
4282
|
+
|
|
4283
|
+
content_type = content_type or "application/json"
|
|
4284
|
+
_content = None
|
|
4285
|
+
if isinstance(body, (IOBase, bytes)):
|
|
4286
|
+
_content = body
|
|
4287
|
+
else:
|
|
4288
|
+
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
4289
|
+
|
|
4290
|
+
_request = build_evaluation_results_start_pending_upload_request(
|
|
4291
|
+
name=name,
|
|
4292
|
+
version=version,
|
|
4293
|
+
content_type=content_type,
|
|
4294
|
+
api_version=self._config.api_version,
|
|
4295
|
+
content=_content,
|
|
4296
|
+
headers=_headers,
|
|
4297
|
+
params=_params,
|
|
4298
|
+
)
|
|
4299
|
+
path_format_arguments = {
|
|
4300
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
4301
|
+
}
|
|
4302
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
4303
|
+
|
|
4304
|
+
_stream = kwargs.pop("stream", False)
|
|
4305
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
4306
|
+
_request, stream=_stream, **kwargs
|
|
4307
|
+
)
|
|
4308
|
+
|
|
4309
|
+
response = pipeline_response.http_response
|
|
4310
|
+
|
|
4311
|
+
if response.status_code not in [200]:
|
|
4312
|
+
if _stream:
|
|
4313
|
+
try:
|
|
4314
|
+
await response.read() # Load the body in memory and close the socket
|
|
4315
|
+
except (StreamConsumedError, StreamClosedError):
|
|
4316
|
+
pass
|
|
4317
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
4318
|
+
raise HttpResponseError(response=response)
|
|
4319
|
+
|
|
4320
|
+
if _stream:
|
|
4321
|
+
deserialized = response.iter_bytes()
|
|
4322
|
+
else:
|
|
4323
|
+
deserialized = _deserialize(_models.PendingUploadResponse, response.json())
|
|
4324
|
+
|
|
4325
|
+
if cls:
|
|
4326
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
4327
|
+
|
|
4328
|
+
return deserialized # type: ignore
|
|
4329
|
+
|
|
4330
|
+
@overload
|
|
4331
|
+
async def get_credentials(
|
|
4332
|
+
self,
|
|
4333
|
+
name: str,
|
|
4334
|
+
version: str,
|
|
4335
|
+
body: _models.AssetCredentialRequest,
|
|
4336
|
+
*,
|
|
4337
|
+
content_type: str = "application/json",
|
|
4338
|
+
**kwargs: Any
|
|
4339
|
+
) -> _models.AssetCredentialResponse:
|
|
4340
|
+
"""Enable downloading json.
|
|
4341
|
+
|
|
4342
|
+
:param name: The name of the resource. Required.
|
|
4343
|
+
:type name: str
|
|
4344
|
+
:param version: The specific version id of the EvaluationResult to operate on. Required.
|
|
4345
|
+
:type version: str
|
|
4346
|
+
:param body: Parameters for the action. Required.
|
|
4347
|
+
:type body: ~azure.ai.projects.onedp.models.AssetCredentialRequest
|
|
4348
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
4349
|
+
Default value is "application/json".
|
|
4350
|
+
:paramtype content_type: str
|
|
4351
|
+
:return: AssetCredentialResponse. The AssetCredentialResponse is compatible with MutableMapping
|
|
4352
|
+
:rtype: ~azure.ai.projects.onedp.models.AssetCredentialResponse
|
|
4353
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4354
|
+
"""
|
|
4355
|
+
|
|
4356
|
+
@overload
|
|
4357
|
+
async def get_credentials(
|
|
4358
|
+
self, name: str, version: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
4359
|
+
) -> _models.AssetCredentialResponse:
|
|
4360
|
+
"""Enable downloading json.
|
|
4361
|
+
|
|
4362
|
+
:param name: The name of the resource. Required.
|
|
4363
|
+
:type name: str
|
|
4364
|
+
:param version: The specific version id of the EvaluationResult to operate on. Required.
|
|
4365
|
+
:type version: str
|
|
4366
|
+
:param body: Parameters for the action. Required.
|
|
4367
|
+
:type body: JSON
|
|
4368
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
4369
|
+
Default value is "application/json".
|
|
4370
|
+
:paramtype content_type: str
|
|
4371
|
+
:return: AssetCredentialResponse. The AssetCredentialResponse is compatible with MutableMapping
|
|
4372
|
+
:rtype: ~azure.ai.projects.onedp.models.AssetCredentialResponse
|
|
4373
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4374
|
+
"""
|
|
4375
|
+
|
|
4376
|
+
@overload
|
|
4377
|
+
async def get_credentials(
|
|
4378
|
+
self, name: str, version: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
4379
|
+
) -> _models.AssetCredentialResponse:
|
|
4380
|
+
"""Enable downloading json.
|
|
4381
|
+
|
|
4382
|
+
:param name: The name of the resource. Required.
|
|
4383
|
+
:type name: str
|
|
4384
|
+
:param version: The specific version id of the EvaluationResult to operate on. Required.
|
|
4385
|
+
:type version: str
|
|
4386
|
+
:param body: Parameters for the action. Required.
|
|
4387
|
+
:type body: IO[bytes]
|
|
4388
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
4389
|
+
Default value is "application/json".
|
|
4390
|
+
:paramtype content_type: str
|
|
4391
|
+
:return: AssetCredentialResponse. The AssetCredentialResponse is compatible with MutableMapping
|
|
4392
|
+
:rtype: ~azure.ai.projects.onedp.models.AssetCredentialResponse
|
|
4393
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4394
|
+
"""
|
|
4395
|
+
|
|
4396
|
+
@distributed_trace_async
|
|
4397
|
+
@api_version_validation(
|
|
4398
|
+
method_added_on="2025-05-15-preview",
|
|
4399
|
+
params_added_on={"2025-05-15-preview": ["api_version", "name", "version", "content_type", "accept"]},
|
|
4400
|
+
)
|
|
4401
|
+
async def get_credentials(
|
|
4402
|
+
self, name: str, version: str, body: Union[_models.AssetCredentialRequest, JSON, IO[bytes]], **kwargs: Any
|
|
4403
|
+
) -> _models.AssetCredentialResponse:
|
|
4404
|
+
"""Enable downloading json.
|
|
4405
|
+
|
|
4406
|
+
:param name: The name of the resource. Required.
|
|
4407
|
+
:type name: str
|
|
4408
|
+
:param version: The specific version id of the EvaluationResult to operate on. Required.
|
|
4409
|
+
:type version: str
|
|
4410
|
+
:param body: Parameters for the action. Is one of the following types: AssetCredentialRequest,
|
|
4411
|
+
JSON, IO[bytes] Required.
|
|
4412
|
+
:type body: ~azure.ai.projects.onedp.models.AssetCredentialRequest or JSON or IO[bytes]
|
|
4413
|
+
:return: AssetCredentialResponse. The AssetCredentialResponse is compatible with MutableMapping
|
|
4414
|
+
:rtype: ~azure.ai.projects.onedp.models.AssetCredentialResponse
|
|
4415
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4416
|
+
"""
|
|
4417
|
+
error_map: MutableMapping = {
|
|
4418
|
+
401: ClientAuthenticationError,
|
|
4419
|
+
404: ResourceNotFoundError,
|
|
4420
|
+
409: ResourceExistsError,
|
|
4421
|
+
304: ResourceNotModifiedError,
|
|
4422
|
+
}
|
|
4423
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
4424
|
+
|
|
4425
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
4426
|
+
_params = kwargs.pop("params", {}) or {}
|
|
4427
|
+
|
|
4428
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
4429
|
+
cls: ClsType[_models.AssetCredentialResponse] = kwargs.pop("cls", None)
|
|
4430
|
+
|
|
4431
|
+
content_type = content_type or "application/json"
|
|
4432
|
+
_content = None
|
|
4433
|
+
if isinstance(body, (IOBase, bytes)):
|
|
4434
|
+
_content = body
|
|
4435
|
+
else:
|
|
4436
|
+
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
4437
|
+
|
|
4438
|
+
_request = build_evaluation_results_get_credentials_request(
|
|
4439
|
+
name=name,
|
|
4440
|
+
version=version,
|
|
4441
|
+
content_type=content_type,
|
|
4442
|
+
api_version=self._config.api_version,
|
|
4443
|
+
content=_content,
|
|
4444
|
+
headers=_headers,
|
|
4445
|
+
params=_params,
|
|
4446
|
+
)
|
|
4447
|
+
path_format_arguments = {
|
|
4448
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
4449
|
+
}
|
|
4450
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
4451
|
+
|
|
4452
|
+
_stream = kwargs.pop("stream", False)
|
|
4453
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
4454
|
+
_request, stream=_stream, **kwargs
|
|
4455
|
+
)
|
|
4456
|
+
|
|
4457
|
+
response = pipeline_response.http_response
|
|
4458
|
+
|
|
4459
|
+
if response.status_code not in [200]:
|
|
4460
|
+
if _stream:
|
|
4461
|
+
try:
|
|
4462
|
+
await response.read() # Load the body in memory and close the socket
|
|
4463
|
+
except (StreamConsumedError, StreamClosedError):
|
|
4464
|
+
pass
|
|
4465
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
4466
|
+
raise HttpResponseError(response=response)
|
|
4467
|
+
|
|
4468
|
+
if _stream:
|
|
4469
|
+
deserialized = response.iter_bytes()
|
|
4470
|
+
else:
|
|
4471
|
+
deserialized = _deserialize(_models.AssetCredentialResponse, response.json())
|
|
4472
|
+
|
|
4473
|
+
if cls:
|
|
4474
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
4475
|
+
|
|
4476
|
+
return deserialized # type: ignore
|
|
4477
|
+
|
|
4478
|
+
|
|
4479
|
+
class ServicePatternsBuildingBlocksOperations:
|
|
4480
|
+
"""
|
|
4481
|
+
.. warning::
|
|
4482
|
+
**DO NOT** instantiate this class directly.
|
|
4483
|
+
|
|
4484
|
+
Instead, you should access the following operations through
|
|
4485
|
+
:class:`~azure.ai.projects.onedp.aio.AIProjectClient`'s
|
|
4486
|
+
:attr:`building_blocks` attribute.
|
|
4487
|
+
"""
|
|
4488
|
+
|
|
4489
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
4490
|
+
input_args = list(args)
|
|
4491
|
+
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
4492
|
+
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
4493
|
+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
4494
|
+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|