agenta 0.36.5__py3-none-any.whl → 0.37.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 agenta might be problematic. Click here for more details.
- agenta/__init__.py +1 -2
- agenta/client/__init__.py +6 -10
- agenta/client/{admin → backend/admin}/client.py +2 -0
- agenta/client/backend/api_keys/client.py +531 -0
- agenta/client/{apps → backend/apps}/client.py +0 -222
- agenta/client/{containers → backend/containers}/client.py +10 -70
- agenta/client/{core → backend/core}/http_client.py +6 -6
- agenta/client/{core → backend/core}/pydantic_utilities.py +2 -2
- agenta/client/{environments → backend/environments}/client.py +0 -2
- agenta/client/{human_evaluations → backend/human_evaluations}/client.py +0 -2
- agenta/client/{observability → backend/observability}/client.py +98 -0
- agenta/client/backend/organization/client.py +839 -0
- agenta/client/backend/testsets/__init__.py +1 -0
- agenta/client/{types → backend/types}/__init__.py +22 -6
- agenta/client/{types → backend/types}/agenta_nodes_response.py +0 -5
- agenta/client/{types → backend/types}/agenta_root_dto.py +0 -5
- agenta/client/{types → backend/types}/agenta_roots_response.py +0 -5
- agenta/client/{types → backend/types}/agenta_tree_dto.py +0 -5
- agenta/client/{types → backend/types}/agenta_trees_response.py +0 -5
- agenta/client/backend/types/custom_model_settings_dto.py +22 -0
- agenta/client/backend/types/custom_provider_dto.py +29 -0
- agenta/client/backend/types/custom_provider_kind.py +26 -0
- agenta/client/backend/types/custom_provider_settings_dto.py +24 -0
- agenta/client/backend/types/data.py +7 -0
- agenta/client/{types → backend/types}/organization.py +1 -4
- agenta/client/backend/types/organization_details.py +29 -0
- agenta/client/{types → backend/types}/organization_membership_request.py +3 -2
- agenta/client/{types → backend/types}/permission.py +1 -0
- agenta/client/backend/types/provider_key_dto.py +21 -0
- agenta/client/backend/types/provider_kind.py +21 -0
- agenta/client/backend/types/score.py +3 -0
- agenta/client/{types → backend/types}/secret_dto.py +3 -3
- agenta/client/backend/types/secret_kind.py +5 -0
- agenta/client/backend/types/standard_provider_dto.py +24 -0
- agenta/client/backend/types/standard_provider_kind.py +21 -0
- agenta/client/backend/types/standard_provider_settings_dto.py +21 -0
- agenta/client/backend/types/workspace.py +24 -0
- agenta/client/{variants → backend/variants}/client.py +18 -24
- agenta/client/backend/vault/__init__.py +1 -0
- agenta/client/{vault → backend/vault}/client.py +26 -8
- agenta/client/backend/workspace/__init__.py +1 -0
- agenta/client/backend/workspace/client.py +405 -0
- agenta/client/client.py +46 -46
- agenta/client/types/provider_key_dto.py~feat_model-registry +21 -0
- agenta/client/types/provider_kind.py~feat_model-registry +21 -0
- agenta/sdk/__init__.py +1 -1
- agenta/sdk/managers/secrets.py +175 -11
- agenta/sdk/managers/shared.py +3 -3
- agenta/sdk/middleware/vault.py +29 -37
- agenta/sdk/types.py +4 -7
- {agenta-0.36.5.dist-info → agenta-0.37.0.dist-info}/METADATA +2 -6
- agenta-0.37.0.dist-info/RECORD +255 -0
- agenta/client/types/score.py +0 -5
- agenta/client/types/secret_kind.py +0 -5
- agenta/sdk/client.py +0 -56
- agenta-0.36.5.dist-info/RECORD +0 -236
- /agenta/client/{access_control → backend/access_control}/__init__.py +0 -0
- /agenta/client/{access_control → backend/access_control}/client.py +0 -0
- /agenta/client/{admin → backend/admin}/__init__.py +0 -0
- /agenta/client/{apps → backend/api_keys}/__init__.py +0 -0
- /agenta/client/{bases → backend/apps}/__init__.py +0 -0
- /agenta/client/{configs → backend/bases}/__init__.py +0 -0
- /agenta/client/{bases → backend/bases}/client.py +0 -0
- /agenta/client/{environments → backend/configs}/__init__.py +0 -0
- /agenta/client/{configs → backend/configs}/client.py +0 -0
- /agenta/client/{containers → backend/containers}/__init__.py +0 -0
- /agenta/client/{containers → backend/containers}/types/__init__.py +0 -0
- /agenta/client/{containers → backend/containers}/types/container_templates_response.py +0 -0
- /agenta/client/{core → backend/core}/__init__.py +0 -0
- /agenta/client/{core → backend/core}/api_error.py +0 -0
- /agenta/client/{core → backend/core}/client_wrapper.py +0 -0
- /agenta/client/{core → backend/core}/datetime_utils.py +0 -0
- /agenta/client/{core → backend/core}/file.py +0 -0
- /agenta/client/{core → backend/core}/jsonable_encoder.py +0 -0
- /agenta/client/{core → backend/core}/query_encoder.py +0 -0
- /agenta/client/{core → backend/core}/remove_none_from_dict.py +0 -0
- /agenta/client/{core → backend/core}/request_options.py +0 -0
- /agenta/client/{core → backend/core}/serialization.py +0 -0
- /agenta/client/{evaluations → backend/environments}/__init__.py +0 -0
- /agenta/client/{errors → backend/errors}/__init__.py +0 -0
- /agenta/client/{errors → backend/errors}/unprocessable_entity_error.py +0 -0
- /agenta/client/{evaluators → backend/evaluations}/__init__.py +0 -0
- /agenta/client/{evaluations → backend/evaluations}/client.py +0 -0
- /agenta/client/{human_evaluations → backend/evaluators}/__init__.py +0 -0
- /agenta/client/{evaluators → backend/evaluators}/client.py +0 -0
- /agenta/client/{scopes → backend/human_evaluations}/__init__.py +0 -0
- /agenta/client/{observability → backend/observability}/__init__.py +0 -0
- /agenta/client/{observability → backend/observability}/types/__init__.py +0 -0
- /agenta/client/{observability → backend/observability}/types/format.py +0 -0
- /agenta/client/{observability → backend/observability}/types/query_analytics_response.py +0 -0
- /agenta/client/{observability → backend/observability}/types/query_traces_response.py +0 -0
- /agenta/client/{testsets → backend/organization}/__init__.py +0 -0
- /agenta/client/{vault → backend/scopes}/__init__.py +0 -0
- /agenta/client/{scopes → backend/scopes}/client.py +0 -0
- /agenta/client/{testsets → backend/testsets}/client.py +0 -0
- /agenta/client/{types → backend/types}/account_response.py +0 -0
- /agenta/client/{types → backend/types}/agenta_node_dto.py +0 -0
- /agenta/client/{types → backend/types}/agenta_node_dto_nodes_value.py +0 -0
- /agenta/client/{types → backend/types}/aggregated_result.py +0 -0
- /agenta/client/{types → backend/types}/aggregated_result_evaluator_config.py +0 -0
- /agenta/client/{types → backend/types}/analytics_response.py +0 -0
- /agenta/client/{types → backend/types}/app.py +0 -0
- /agenta/client/{types → backend/types}/app_variant_response.py +0 -0
- /agenta/client/{types → backend/types}/app_variant_revision.py +0 -0
- /agenta/client/{types → backend/types}/base_output.py +0 -0
- /agenta/client/{types → backend/types}/body_import_testset.py +0 -0
- /agenta/client/{types → backend/types}/bucket_dto.py +0 -0
- /agenta/client/{types → backend/types}/collect_status_response.py +0 -0
- /agenta/client/{types → backend/types}/config_db.py +0 -0
- /agenta/client/{types → backend/types}/config_dto.py +0 -0
- /agenta/client/{types → backend/types}/config_response_model.py +0 -0
- /agenta/client/{types → backend/types}/correct_answer.py +0 -0
- /agenta/client/{types → backend/types}/create_app_output.py +0 -0
- /agenta/client/{types → backend/types}/delete_evaluation.py +0 -0
- /agenta/client/{types → backend/types}/docker_env_vars.py +0 -0
- /agenta/client/{types → backend/types}/environment_output.py +0 -0
- /agenta/client/{types → backend/types}/environment_output_extended.py +0 -0
- /agenta/client/{types → backend/types}/environment_revision.py +0 -0
- /agenta/client/{types → backend/types}/error.py +0 -0
- /agenta/client/{types → backend/types}/evaluation.py +0 -0
- /agenta/client/{types → backend/types}/evaluation_scenario.py +0 -0
- /agenta/client/{types → backend/types}/evaluation_scenario_input.py +0 -0
- /agenta/client/{types → backend/types}/evaluation_scenario_output.py +0 -0
- /agenta/client/{types → backend/types}/evaluation_scenario_result.py +0 -0
- /agenta/client/{types → backend/types}/evaluation_status_enum.py +0 -0
- /agenta/client/{types → backend/types}/evaluation_type.py +0 -0
- /agenta/client/{types → backend/types}/evaluator.py +0 -0
- /agenta/client/{types → backend/types}/evaluator_config.py +0 -0
- /agenta/client/{types → backend/types}/evaluator_mapping_output_interface.py +0 -0
- /agenta/client/{types → backend/types}/evaluator_output_interface.py +0 -0
- /agenta/client/{types → backend/types}/exception_dto.py +0 -0
- /agenta/client/{types → backend/types}/get_config_response.py +0 -0
- /agenta/client/{types → backend/types}/header_dto.py +0 -0
- /agenta/client/{types → backend/types}/http_validation_error.py +0 -0
- /agenta/client/{types → backend/types}/human_evaluation.py +0 -0
- /agenta/client/{types → backend/types}/human_evaluation_scenario.py +0 -0
- /agenta/client/{types → backend/types}/human_evaluation_scenario_input.py +0 -0
- /agenta/client/{types → backend/types}/human_evaluation_scenario_output.py +0 -0
- /agenta/client/{types → backend/types}/image.py +0 -0
- /agenta/client/{types → backend/types}/invite_request.py +0 -0
- /agenta/client/{types → backend/types}/legacy_analytics_response.py +0 -0
- /agenta/client/{types → backend/types}/legacy_data_point.py +0 -0
- /agenta/client/{types → backend/types}/legacy_scope_request.py +0 -0
- /agenta/client/{types → backend/types}/legacy_scopes_response.py +0 -0
- /agenta/client/{types → backend/types}/legacy_user_request.py +0 -0
- /agenta/client/{types → backend/types}/legacy_user_response.py +0 -0
- /agenta/client/{types → backend/types}/lifecycle_dto.py +0 -0
- /agenta/client/{types → backend/types}/link_dto.py +0 -0
- /agenta/client/{types → backend/types}/list_api_keys_response.py +0 -0
- /agenta/client/{types → backend/types}/llm_run_rate_limit.py +0 -0
- /agenta/client/{types → backend/types}/metrics_dto.py +0 -0
- /agenta/client/{types → backend/types}/new_testset.py +0 -0
- /agenta/client/{types → backend/types}/node_dto.py +0 -0
- /agenta/client/{types → backend/types}/node_type.py +0 -0
- /agenta/client/{types → backend/types}/o_tel_context_dto.py +0 -0
- /agenta/client/{types → backend/types}/o_tel_event_dto.py +0 -0
- /agenta/client/{types → backend/types}/o_tel_extra_dto.py +0 -0
- /agenta/client/{types → backend/types}/o_tel_link_dto.py +0 -0
- /agenta/client/{types → backend/types}/o_tel_span_dto.py +0 -0
- /agenta/client/{types → backend/types}/o_tel_span_kind.py +0 -0
- /agenta/client/{types → backend/types}/o_tel_spans_response.py +0 -0
- /agenta/client/{types → backend/types}/o_tel_status_code.py +0 -0
- /agenta/client/{types → backend/types}/organization_output.py +0 -0
- /agenta/client/{types → backend/types}/organization_request.py +0 -0
- /agenta/client/{types → backend/types}/parent_dto.py +0 -0
- /agenta/client/{types → backend/types}/project_membership_request.py +0 -0
- /agenta/client/{types → backend/types}/project_request.py +0 -0
- /agenta/client/{types → backend/types}/project_scope.py +0 -0
- /agenta/client/{types → backend/types}/projects_response.py +0 -0
- /agenta/client/{types → backend/types}/reference.py +0 -0
- /agenta/client/{types → backend/types}/reference_dto.py +0 -0
- /agenta/client/{types → backend/types}/reference_request_model.py +0 -0
- /agenta/client/{types → backend/types}/result.py +0 -0
- /agenta/client/{types → backend/types}/role.py +0 -0
- /agenta/client/{types → backend/types}/root_dto.py +0 -0
- /agenta/client/{types → backend/types}/scopes_response_model.py +0 -0
- /agenta/client/{types → backend/types}/secret_response_dto.py +0 -0
- /agenta/client/{types → backend/types}/simple_evaluation_output.py +0 -0
- /agenta/client/{types → backend/types}/span_dto.py +0 -0
- /agenta/client/{types → backend/types}/span_dto_nodes_value.py +0 -0
- /agenta/client/{types → backend/types}/status_code.py +0 -0
- /agenta/client/{types → backend/types}/status_dto.py +0 -0
- /agenta/client/{types → backend/types}/template.py +0 -0
- /agenta/client/{types → backend/types}/template_image_info.py +0 -0
- /agenta/client/{types → backend/types}/test_set_output_response.py +0 -0
- /agenta/client/{types → backend/types}/test_set_simple_response.py +0 -0
- /agenta/client/{types → backend/types}/time_dto.py +0 -0
- /agenta/client/{types → backend/types}/tree_dto.py +0 -0
- /agenta/client/{types → backend/types}/tree_type.py +0 -0
- /agenta/client/{types → backend/types}/update_app_output.py +0 -0
- /agenta/client/{types → backend/types}/uri.py +0 -0
- /agenta/client/{types → backend/types}/user_request.py +0 -0
- /agenta/client/{types → backend/types}/validation_error.py +0 -0
- /agenta/client/{types → backend/types}/validation_error_loc_item.py +0 -0
- /agenta/client/{types → backend/types}/variant_action.py +0 -0
- /agenta/client/{types → backend/types}/variant_action_enum.py +0 -0
- /agenta/client/{types → backend/types}/workspace_member_response.py +0 -0
- /agenta/client/{types → backend/types}/workspace_membership_request.py +0 -0
- /agenta/client/{types → backend/types}/workspace_permission.py +0 -0
- /agenta/client/{types → backend/types}/workspace_request.py +0 -0
- /agenta/client/{types → backend/types}/workspace_response.py +0 -0
- /agenta/client/{types → backend/types}/workspace_role.py +0 -0
- /agenta/client/{types → backend/types}/workspace_role_response.py +0 -0
- /agenta/client/{variants → backend/variants}/__init__.py +0 -0
- /agenta/client/{variants → backend/variants}/types/__init__.py +0 -0
- /agenta/client/{variants → backend/variants}/types/add_variant_from_base_and_config_response.py +0 -0
- /agenta/client/types/{provider_key_dto.py → provider_key_dto.py~HEAD} +0 -0
- /agenta/client/types/{provider_kind.py → provider_kind.py~HEAD} +0 -0
- {agenta-0.36.5.dist-info → agenta-0.37.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,839 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from ..core.client_wrapper import SyncClientWrapper
|
|
5
|
+
from ..core.request_options import RequestOptions
|
|
6
|
+
from ..types.organization import Organization
|
|
7
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
8
|
+
from json.decoder import JSONDecodeError
|
|
9
|
+
from ..core.api_error import ApiError
|
|
10
|
+
from ..types.organization_details import OrganizationDetails
|
|
11
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
12
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
13
|
+
from ..types.http_validation_error import HttpValidationError
|
|
14
|
+
from ..types.invite_request import InviteRequest
|
|
15
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
16
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
17
|
+
|
|
18
|
+
# this is used as the default value for optional parameters
|
|
19
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class OrganizationClient:
|
|
23
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
24
|
+
self._client_wrapper = client_wrapper
|
|
25
|
+
|
|
26
|
+
def list_organizations(
|
|
27
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
28
|
+
) -> typing.List[Organization]:
|
|
29
|
+
"""
|
|
30
|
+
Returns a list of organizations associated with the user's session.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
list[Organization]: A list of organizations associated with the user's session.
|
|
34
|
+
|
|
35
|
+
Raises:
|
|
36
|
+
HTTPException: If there is an error retrieving the organizations from the database.
|
|
37
|
+
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
request_options : typing.Optional[RequestOptions]
|
|
41
|
+
Request-specific configuration.
|
|
42
|
+
|
|
43
|
+
Returns
|
|
44
|
+
-------
|
|
45
|
+
typing.List[Organization]
|
|
46
|
+
Successful Response
|
|
47
|
+
|
|
48
|
+
Examples
|
|
49
|
+
--------
|
|
50
|
+
from agenta import AgentaApi
|
|
51
|
+
|
|
52
|
+
client = AgentaApi(
|
|
53
|
+
api_key="YOUR_API_KEY",
|
|
54
|
+
base_url="https://yourhost.com/path/to/api",
|
|
55
|
+
)
|
|
56
|
+
client.organization.list_organizations()
|
|
57
|
+
"""
|
|
58
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
59
|
+
"organizations",
|
|
60
|
+
method="GET",
|
|
61
|
+
request_options=request_options,
|
|
62
|
+
)
|
|
63
|
+
try:
|
|
64
|
+
if 200 <= _response.status_code < 300:
|
|
65
|
+
return typing.cast(
|
|
66
|
+
typing.List[Organization],
|
|
67
|
+
parse_obj_as(
|
|
68
|
+
type_=typing.List[Organization], # type: ignore
|
|
69
|
+
object_=_response.json(),
|
|
70
|
+
),
|
|
71
|
+
)
|
|
72
|
+
_response_json = _response.json()
|
|
73
|
+
except JSONDecodeError:
|
|
74
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
75
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
76
|
+
|
|
77
|
+
def fetch_organization_details(
|
|
78
|
+
self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
79
|
+
) -> OrganizationDetails:
|
|
80
|
+
"""
|
|
81
|
+
Return the details of the organization.
|
|
82
|
+
|
|
83
|
+
Parameters
|
|
84
|
+
----------
|
|
85
|
+
org_id : str
|
|
86
|
+
|
|
87
|
+
request_options : typing.Optional[RequestOptions]
|
|
88
|
+
Request-specific configuration.
|
|
89
|
+
|
|
90
|
+
Returns
|
|
91
|
+
-------
|
|
92
|
+
OrganizationDetails
|
|
93
|
+
Successful Response
|
|
94
|
+
|
|
95
|
+
Examples
|
|
96
|
+
--------
|
|
97
|
+
from agenta import AgentaApi
|
|
98
|
+
|
|
99
|
+
client = AgentaApi(
|
|
100
|
+
api_key="YOUR_API_KEY",
|
|
101
|
+
base_url="https://yourhost.com/path/to/api",
|
|
102
|
+
)
|
|
103
|
+
client.organization.fetch_organization_details(
|
|
104
|
+
org_id="org_id",
|
|
105
|
+
)
|
|
106
|
+
"""
|
|
107
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
108
|
+
f"organizations/{jsonable_encoder(org_id)}",
|
|
109
|
+
method="GET",
|
|
110
|
+
request_options=request_options,
|
|
111
|
+
)
|
|
112
|
+
try:
|
|
113
|
+
if 200 <= _response.status_code < 300:
|
|
114
|
+
return typing.cast(
|
|
115
|
+
OrganizationDetails,
|
|
116
|
+
parse_obj_as(
|
|
117
|
+
type_=OrganizationDetails, # type: ignore
|
|
118
|
+
object_=_response.json(),
|
|
119
|
+
),
|
|
120
|
+
)
|
|
121
|
+
if _response.status_code == 422:
|
|
122
|
+
raise UnprocessableEntityError(
|
|
123
|
+
typing.cast(
|
|
124
|
+
HttpValidationError,
|
|
125
|
+
parse_obj_as(
|
|
126
|
+
type_=HttpValidationError, # type: ignore
|
|
127
|
+
object_=_response.json(),
|
|
128
|
+
),
|
|
129
|
+
)
|
|
130
|
+
)
|
|
131
|
+
_response_json = _response.json()
|
|
132
|
+
except JSONDecodeError:
|
|
133
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
134
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
135
|
+
|
|
136
|
+
def invite_user_to_workspace(
|
|
137
|
+
self,
|
|
138
|
+
org_id: str,
|
|
139
|
+
workspace_id: str,
|
|
140
|
+
*,
|
|
141
|
+
request: typing.Sequence[InviteRequest],
|
|
142
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
143
|
+
) -> typing.Optional[typing.Any]:
|
|
144
|
+
"""
|
|
145
|
+
Assigns a role to a user in an organization.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
org_id (str): The ID of the organization.
|
|
149
|
+
payload (InviteRequest): The payload containing the organization id, user email, and role to assign.
|
|
150
|
+
workspace_id (str): The ID of the workspace.
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
bool: True if the role was successfully assigned, False otherwise.
|
|
154
|
+
|
|
155
|
+
Raises:
|
|
156
|
+
HTTPException: If the user does not have permission to perform this action.
|
|
157
|
+
HTTPException: If there is an error assigning the role to the user.
|
|
158
|
+
|
|
159
|
+
Parameters
|
|
160
|
+
----------
|
|
161
|
+
org_id : str
|
|
162
|
+
|
|
163
|
+
workspace_id : str
|
|
164
|
+
|
|
165
|
+
request : typing.Sequence[InviteRequest]
|
|
166
|
+
|
|
167
|
+
request_options : typing.Optional[RequestOptions]
|
|
168
|
+
Request-specific configuration.
|
|
169
|
+
|
|
170
|
+
Returns
|
|
171
|
+
-------
|
|
172
|
+
typing.Optional[typing.Any]
|
|
173
|
+
Successful Response
|
|
174
|
+
|
|
175
|
+
Examples
|
|
176
|
+
--------
|
|
177
|
+
from agenta import AgentaApi, InviteRequest
|
|
178
|
+
|
|
179
|
+
client = AgentaApi(
|
|
180
|
+
api_key="YOUR_API_KEY",
|
|
181
|
+
base_url="https://yourhost.com/path/to/api",
|
|
182
|
+
)
|
|
183
|
+
client.organization.invite_user_to_workspace(
|
|
184
|
+
org_id="org_id",
|
|
185
|
+
workspace_id="workspace_id",
|
|
186
|
+
request=[
|
|
187
|
+
InviteRequest(
|
|
188
|
+
email="email",
|
|
189
|
+
roles=["roles"],
|
|
190
|
+
)
|
|
191
|
+
],
|
|
192
|
+
)
|
|
193
|
+
"""
|
|
194
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
195
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite",
|
|
196
|
+
method="POST",
|
|
197
|
+
json=convert_and_respect_annotation_metadata(
|
|
198
|
+
object_=request,
|
|
199
|
+
annotation=typing.Sequence[InviteRequest],
|
|
200
|
+
direction="write",
|
|
201
|
+
),
|
|
202
|
+
request_options=request_options,
|
|
203
|
+
omit=OMIT,
|
|
204
|
+
)
|
|
205
|
+
try:
|
|
206
|
+
if 200 <= _response.status_code < 300:
|
|
207
|
+
return typing.cast(
|
|
208
|
+
typing.Optional[typing.Any],
|
|
209
|
+
parse_obj_as(
|
|
210
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
211
|
+
object_=_response.json(),
|
|
212
|
+
),
|
|
213
|
+
)
|
|
214
|
+
if _response.status_code == 422:
|
|
215
|
+
raise UnprocessableEntityError(
|
|
216
|
+
typing.cast(
|
|
217
|
+
HttpValidationError,
|
|
218
|
+
parse_obj_as(
|
|
219
|
+
type_=HttpValidationError, # type: ignore
|
|
220
|
+
object_=_response.json(),
|
|
221
|
+
),
|
|
222
|
+
)
|
|
223
|
+
)
|
|
224
|
+
_response_json = _response.json()
|
|
225
|
+
except JSONDecodeError:
|
|
226
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
227
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
228
|
+
|
|
229
|
+
def resend_invitation(
|
|
230
|
+
self,
|
|
231
|
+
org_id: str,
|
|
232
|
+
workspace_id: str,
|
|
233
|
+
*,
|
|
234
|
+
email: str,
|
|
235
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
236
|
+
) -> typing.Optional[typing.Any]:
|
|
237
|
+
"""
|
|
238
|
+
Resend an invitation to a user to an Organization.
|
|
239
|
+
|
|
240
|
+
Raises:
|
|
241
|
+
HTTPException: _description_; status_code: 500
|
|
242
|
+
HTTPException: Invitation not found or has expired; status_code: 400
|
|
243
|
+
HTTPException: You already belong to this organization; status_code: 400
|
|
244
|
+
|
|
245
|
+
Returns:
|
|
246
|
+
JSONResponse: Resent invitation to user; status_code: 200
|
|
247
|
+
|
|
248
|
+
Parameters
|
|
249
|
+
----------
|
|
250
|
+
org_id : str
|
|
251
|
+
|
|
252
|
+
workspace_id : str
|
|
253
|
+
|
|
254
|
+
email : str
|
|
255
|
+
|
|
256
|
+
request_options : typing.Optional[RequestOptions]
|
|
257
|
+
Request-specific configuration.
|
|
258
|
+
|
|
259
|
+
Returns
|
|
260
|
+
-------
|
|
261
|
+
typing.Optional[typing.Any]
|
|
262
|
+
Successful Response
|
|
263
|
+
|
|
264
|
+
Examples
|
|
265
|
+
--------
|
|
266
|
+
from agenta import AgentaApi
|
|
267
|
+
|
|
268
|
+
client = AgentaApi(
|
|
269
|
+
api_key="YOUR_API_KEY",
|
|
270
|
+
base_url="https://yourhost.com/path/to/api",
|
|
271
|
+
)
|
|
272
|
+
client.organization.resend_invitation(
|
|
273
|
+
org_id="org_id",
|
|
274
|
+
workspace_id="workspace_id",
|
|
275
|
+
email="email",
|
|
276
|
+
)
|
|
277
|
+
"""
|
|
278
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
279
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/resend",
|
|
280
|
+
method="POST",
|
|
281
|
+
json={
|
|
282
|
+
"email": email,
|
|
283
|
+
},
|
|
284
|
+
headers={
|
|
285
|
+
"content-type": "application/json",
|
|
286
|
+
},
|
|
287
|
+
request_options=request_options,
|
|
288
|
+
omit=OMIT,
|
|
289
|
+
)
|
|
290
|
+
try:
|
|
291
|
+
if 200 <= _response.status_code < 300:
|
|
292
|
+
return typing.cast(
|
|
293
|
+
typing.Optional[typing.Any],
|
|
294
|
+
parse_obj_as(
|
|
295
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
296
|
+
object_=_response.json(),
|
|
297
|
+
),
|
|
298
|
+
)
|
|
299
|
+
if _response.status_code == 422:
|
|
300
|
+
raise UnprocessableEntityError(
|
|
301
|
+
typing.cast(
|
|
302
|
+
HttpValidationError,
|
|
303
|
+
parse_obj_as(
|
|
304
|
+
type_=HttpValidationError, # type: ignore
|
|
305
|
+
object_=_response.json(),
|
|
306
|
+
),
|
|
307
|
+
)
|
|
308
|
+
)
|
|
309
|
+
_response_json = _response.json()
|
|
310
|
+
except JSONDecodeError:
|
|
311
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
312
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
313
|
+
|
|
314
|
+
def accept_invitation(
|
|
315
|
+
self,
|
|
316
|
+
org_id: str,
|
|
317
|
+
workspace_id: str,
|
|
318
|
+
*,
|
|
319
|
+
project_id: str,
|
|
320
|
+
token: str,
|
|
321
|
+
email: str,
|
|
322
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
323
|
+
) -> typing.Optional[typing.Any]:
|
|
324
|
+
"""
|
|
325
|
+
Accept an invitation to an organization.
|
|
326
|
+
|
|
327
|
+
Raises:
|
|
328
|
+
HTTPException: _description_; status_code: 500
|
|
329
|
+
HTTPException: Invitation not found or has expired; status_code: 400
|
|
330
|
+
HTTPException: You already belong to this organization; status_code: 400
|
|
331
|
+
|
|
332
|
+
Returns:
|
|
333
|
+
JSONResponse: Accepted invitation to workspace; status_code: 200
|
|
334
|
+
|
|
335
|
+
Parameters
|
|
336
|
+
----------
|
|
337
|
+
org_id : str
|
|
338
|
+
|
|
339
|
+
workspace_id : str
|
|
340
|
+
|
|
341
|
+
project_id : str
|
|
342
|
+
|
|
343
|
+
token : str
|
|
344
|
+
|
|
345
|
+
email : str
|
|
346
|
+
|
|
347
|
+
request_options : typing.Optional[RequestOptions]
|
|
348
|
+
Request-specific configuration.
|
|
349
|
+
|
|
350
|
+
Returns
|
|
351
|
+
-------
|
|
352
|
+
typing.Optional[typing.Any]
|
|
353
|
+
Successful Response
|
|
354
|
+
|
|
355
|
+
Examples
|
|
356
|
+
--------
|
|
357
|
+
from agenta import AgentaApi
|
|
358
|
+
|
|
359
|
+
client = AgentaApi(
|
|
360
|
+
api_key="YOUR_API_KEY",
|
|
361
|
+
base_url="https://yourhost.com/path/to/api",
|
|
362
|
+
)
|
|
363
|
+
client.organization.accept_invitation(
|
|
364
|
+
org_id="org_id",
|
|
365
|
+
workspace_id="workspace_id",
|
|
366
|
+
project_id="project_id",
|
|
367
|
+
token="token",
|
|
368
|
+
email="email",
|
|
369
|
+
)
|
|
370
|
+
"""
|
|
371
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
372
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/accept",
|
|
373
|
+
method="POST",
|
|
374
|
+
params={
|
|
375
|
+
"project_id": project_id,
|
|
376
|
+
},
|
|
377
|
+
json={
|
|
378
|
+
"token": token,
|
|
379
|
+
"email": email,
|
|
380
|
+
},
|
|
381
|
+
headers={
|
|
382
|
+
"content-type": "application/json",
|
|
383
|
+
},
|
|
384
|
+
request_options=request_options,
|
|
385
|
+
omit=OMIT,
|
|
386
|
+
)
|
|
387
|
+
try:
|
|
388
|
+
if 200 <= _response.status_code < 300:
|
|
389
|
+
return typing.cast(
|
|
390
|
+
typing.Optional[typing.Any],
|
|
391
|
+
parse_obj_as(
|
|
392
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
393
|
+
object_=_response.json(),
|
|
394
|
+
),
|
|
395
|
+
)
|
|
396
|
+
if _response.status_code == 422:
|
|
397
|
+
raise UnprocessableEntityError(
|
|
398
|
+
typing.cast(
|
|
399
|
+
HttpValidationError,
|
|
400
|
+
parse_obj_as(
|
|
401
|
+
type_=HttpValidationError, # type: ignore
|
|
402
|
+
object_=_response.json(),
|
|
403
|
+
),
|
|
404
|
+
)
|
|
405
|
+
)
|
|
406
|
+
_response_json = _response.json()
|
|
407
|
+
except JSONDecodeError:
|
|
408
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
409
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
class AsyncOrganizationClient:
|
|
413
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
414
|
+
self._client_wrapper = client_wrapper
|
|
415
|
+
|
|
416
|
+
async def list_organizations(
|
|
417
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
418
|
+
) -> typing.List[Organization]:
|
|
419
|
+
"""
|
|
420
|
+
Returns a list of organizations associated with the user's session.
|
|
421
|
+
|
|
422
|
+
Returns:
|
|
423
|
+
list[Organization]: A list of organizations associated with the user's session.
|
|
424
|
+
|
|
425
|
+
Raises:
|
|
426
|
+
HTTPException: If there is an error retrieving the organizations from the database.
|
|
427
|
+
|
|
428
|
+
Parameters
|
|
429
|
+
----------
|
|
430
|
+
request_options : typing.Optional[RequestOptions]
|
|
431
|
+
Request-specific configuration.
|
|
432
|
+
|
|
433
|
+
Returns
|
|
434
|
+
-------
|
|
435
|
+
typing.List[Organization]
|
|
436
|
+
Successful Response
|
|
437
|
+
|
|
438
|
+
Examples
|
|
439
|
+
--------
|
|
440
|
+
import asyncio
|
|
441
|
+
|
|
442
|
+
from agenta import AsyncAgentaApi
|
|
443
|
+
|
|
444
|
+
client = AsyncAgentaApi(
|
|
445
|
+
api_key="YOUR_API_KEY",
|
|
446
|
+
base_url="https://yourhost.com/path/to/api",
|
|
447
|
+
)
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
async def main() -> None:
|
|
451
|
+
await client.organization.list_organizations()
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
asyncio.run(main())
|
|
455
|
+
"""
|
|
456
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
457
|
+
"organizations",
|
|
458
|
+
method="GET",
|
|
459
|
+
request_options=request_options,
|
|
460
|
+
)
|
|
461
|
+
try:
|
|
462
|
+
if 200 <= _response.status_code < 300:
|
|
463
|
+
return typing.cast(
|
|
464
|
+
typing.List[Organization],
|
|
465
|
+
parse_obj_as(
|
|
466
|
+
type_=typing.List[Organization], # type: ignore
|
|
467
|
+
object_=_response.json(),
|
|
468
|
+
),
|
|
469
|
+
)
|
|
470
|
+
_response_json = _response.json()
|
|
471
|
+
except JSONDecodeError:
|
|
472
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
473
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
474
|
+
|
|
475
|
+
async def fetch_organization_details(
|
|
476
|
+
self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
477
|
+
) -> OrganizationDetails:
|
|
478
|
+
"""
|
|
479
|
+
Return the details of the organization.
|
|
480
|
+
|
|
481
|
+
Parameters
|
|
482
|
+
----------
|
|
483
|
+
org_id : str
|
|
484
|
+
|
|
485
|
+
request_options : typing.Optional[RequestOptions]
|
|
486
|
+
Request-specific configuration.
|
|
487
|
+
|
|
488
|
+
Returns
|
|
489
|
+
-------
|
|
490
|
+
OrganizationDetails
|
|
491
|
+
Successful Response
|
|
492
|
+
|
|
493
|
+
Examples
|
|
494
|
+
--------
|
|
495
|
+
import asyncio
|
|
496
|
+
|
|
497
|
+
from agenta import AsyncAgentaApi
|
|
498
|
+
|
|
499
|
+
client = AsyncAgentaApi(
|
|
500
|
+
api_key="YOUR_API_KEY",
|
|
501
|
+
base_url="https://yourhost.com/path/to/api",
|
|
502
|
+
)
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
async def main() -> None:
|
|
506
|
+
await client.organization.fetch_organization_details(
|
|
507
|
+
org_id="org_id",
|
|
508
|
+
)
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
asyncio.run(main())
|
|
512
|
+
"""
|
|
513
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
514
|
+
f"organizations/{jsonable_encoder(org_id)}",
|
|
515
|
+
method="GET",
|
|
516
|
+
request_options=request_options,
|
|
517
|
+
)
|
|
518
|
+
try:
|
|
519
|
+
if 200 <= _response.status_code < 300:
|
|
520
|
+
return typing.cast(
|
|
521
|
+
OrganizationDetails,
|
|
522
|
+
parse_obj_as(
|
|
523
|
+
type_=OrganizationDetails, # type: ignore
|
|
524
|
+
object_=_response.json(),
|
|
525
|
+
),
|
|
526
|
+
)
|
|
527
|
+
if _response.status_code == 422:
|
|
528
|
+
raise UnprocessableEntityError(
|
|
529
|
+
typing.cast(
|
|
530
|
+
HttpValidationError,
|
|
531
|
+
parse_obj_as(
|
|
532
|
+
type_=HttpValidationError, # type: ignore
|
|
533
|
+
object_=_response.json(),
|
|
534
|
+
),
|
|
535
|
+
)
|
|
536
|
+
)
|
|
537
|
+
_response_json = _response.json()
|
|
538
|
+
except JSONDecodeError:
|
|
539
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
540
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
541
|
+
|
|
542
|
+
async def invite_user_to_workspace(
|
|
543
|
+
self,
|
|
544
|
+
org_id: str,
|
|
545
|
+
workspace_id: str,
|
|
546
|
+
*,
|
|
547
|
+
request: typing.Sequence[InviteRequest],
|
|
548
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
549
|
+
) -> typing.Optional[typing.Any]:
|
|
550
|
+
"""
|
|
551
|
+
Assigns a role to a user in an organization.
|
|
552
|
+
|
|
553
|
+
Args:
|
|
554
|
+
org_id (str): The ID of the organization.
|
|
555
|
+
payload (InviteRequest): The payload containing the organization id, user email, and role to assign.
|
|
556
|
+
workspace_id (str): The ID of the workspace.
|
|
557
|
+
|
|
558
|
+
Returns:
|
|
559
|
+
bool: True if the role was successfully assigned, False otherwise.
|
|
560
|
+
|
|
561
|
+
Raises:
|
|
562
|
+
HTTPException: If the user does not have permission to perform this action.
|
|
563
|
+
HTTPException: If there is an error assigning the role to the user.
|
|
564
|
+
|
|
565
|
+
Parameters
|
|
566
|
+
----------
|
|
567
|
+
org_id : str
|
|
568
|
+
|
|
569
|
+
workspace_id : str
|
|
570
|
+
|
|
571
|
+
request : typing.Sequence[InviteRequest]
|
|
572
|
+
|
|
573
|
+
request_options : typing.Optional[RequestOptions]
|
|
574
|
+
Request-specific configuration.
|
|
575
|
+
|
|
576
|
+
Returns
|
|
577
|
+
-------
|
|
578
|
+
typing.Optional[typing.Any]
|
|
579
|
+
Successful Response
|
|
580
|
+
|
|
581
|
+
Examples
|
|
582
|
+
--------
|
|
583
|
+
import asyncio
|
|
584
|
+
|
|
585
|
+
from agenta import AsyncAgentaApi, InviteRequest
|
|
586
|
+
|
|
587
|
+
client = AsyncAgentaApi(
|
|
588
|
+
api_key="YOUR_API_KEY",
|
|
589
|
+
base_url="https://yourhost.com/path/to/api",
|
|
590
|
+
)
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
async def main() -> None:
|
|
594
|
+
await client.organization.invite_user_to_workspace(
|
|
595
|
+
org_id="org_id",
|
|
596
|
+
workspace_id="workspace_id",
|
|
597
|
+
request=[
|
|
598
|
+
InviteRequest(
|
|
599
|
+
email="email",
|
|
600
|
+
roles=["roles"],
|
|
601
|
+
)
|
|
602
|
+
],
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
asyncio.run(main())
|
|
607
|
+
"""
|
|
608
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
609
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite",
|
|
610
|
+
method="POST",
|
|
611
|
+
json=convert_and_respect_annotation_metadata(
|
|
612
|
+
object_=request,
|
|
613
|
+
annotation=typing.Sequence[InviteRequest],
|
|
614
|
+
direction="write",
|
|
615
|
+
),
|
|
616
|
+
request_options=request_options,
|
|
617
|
+
omit=OMIT,
|
|
618
|
+
)
|
|
619
|
+
try:
|
|
620
|
+
if 200 <= _response.status_code < 300:
|
|
621
|
+
return typing.cast(
|
|
622
|
+
typing.Optional[typing.Any],
|
|
623
|
+
parse_obj_as(
|
|
624
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
625
|
+
object_=_response.json(),
|
|
626
|
+
),
|
|
627
|
+
)
|
|
628
|
+
if _response.status_code == 422:
|
|
629
|
+
raise UnprocessableEntityError(
|
|
630
|
+
typing.cast(
|
|
631
|
+
HttpValidationError,
|
|
632
|
+
parse_obj_as(
|
|
633
|
+
type_=HttpValidationError, # type: ignore
|
|
634
|
+
object_=_response.json(),
|
|
635
|
+
),
|
|
636
|
+
)
|
|
637
|
+
)
|
|
638
|
+
_response_json = _response.json()
|
|
639
|
+
except JSONDecodeError:
|
|
640
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
641
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
642
|
+
|
|
643
|
+
async def resend_invitation(
|
|
644
|
+
self,
|
|
645
|
+
org_id: str,
|
|
646
|
+
workspace_id: str,
|
|
647
|
+
*,
|
|
648
|
+
email: str,
|
|
649
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
650
|
+
) -> typing.Optional[typing.Any]:
|
|
651
|
+
"""
|
|
652
|
+
Resend an invitation to a user to an Organization.
|
|
653
|
+
|
|
654
|
+
Raises:
|
|
655
|
+
HTTPException: _description_; status_code: 500
|
|
656
|
+
HTTPException: Invitation not found or has expired; status_code: 400
|
|
657
|
+
HTTPException: You already belong to this organization; status_code: 400
|
|
658
|
+
|
|
659
|
+
Returns:
|
|
660
|
+
JSONResponse: Resent invitation to user; status_code: 200
|
|
661
|
+
|
|
662
|
+
Parameters
|
|
663
|
+
----------
|
|
664
|
+
org_id : str
|
|
665
|
+
|
|
666
|
+
workspace_id : str
|
|
667
|
+
|
|
668
|
+
email : str
|
|
669
|
+
|
|
670
|
+
request_options : typing.Optional[RequestOptions]
|
|
671
|
+
Request-specific configuration.
|
|
672
|
+
|
|
673
|
+
Returns
|
|
674
|
+
-------
|
|
675
|
+
typing.Optional[typing.Any]
|
|
676
|
+
Successful Response
|
|
677
|
+
|
|
678
|
+
Examples
|
|
679
|
+
--------
|
|
680
|
+
import asyncio
|
|
681
|
+
|
|
682
|
+
from agenta import AsyncAgentaApi
|
|
683
|
+
|
|
684
|
+
client = AsyncAgentaApi(
|
|
685
|
+
api_key="YOUR_API_KEY",
|
|
686
|
+
base_url="https://yourhost.com/path/to/api",
|
|
687
|
+
)
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
async def main() -> None:
|
|
691
|
+
await client.organization.resend_invitation(
|
|
692
|
+
org_id="org_id",
|
|
693
|
+
workspace_id="workspace_id",
|
|
694
|
+
email="email",
|
|
695
|
+
)
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
asyncio.run(main())
|
|
699
|
+
"""
|
|
700
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
701
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/resend",
|
|
702
|
+
method="POST",
|
|
703
|
+
json={
|
|
704
|
+
"email": email,
|
|
705
|
+
},
|
|
706
|
+
headers={
|
|
707
|
+
"content-type": "application/json",
|
|
708
|
+
},
|
|
709
|
+
request_options=request_options,
|
|
710
|
+
omit=OMIT,
|
|
711
|
+
)
|
|
712
|
+
try:
|
|
713
|
+
if 200 <= _response.status_code < 300:
|
|
714
|
+
return typing.cast(
|
|
715
|
+
typing.Optional[typing.Any],
|
|
716
|
+
parse_obj_as(
|
|
717
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
718
|
+
object_=_response.json(),
|
|
719
|
+
),
|
|
720
|
+
)
|
|
721
|
+
if _response.status_code == 422:
|
|
722
|
+
raise UnprocessableEntityError(
|
|
723
|
+
typing.cast(
|
|
724
|
+
HttpValidationError,
|
|
725
|
+
parse_obj_as(
|
|
726
|
+
type_=HttpValidationError, # type: ignore
|
|
727
|
+
object_=_response.json(),
|
|
728
|
+
),
|
|
729
|
+
)
|
|
730
|
+
)
|
|
731
|
+
_response_json = _response.json()
|
|
732
|
+
except JSONDecodeError:
|
|
733
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
734
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
735
|
+
|
|
736
|
+
async def accept_invitation(
|
|
737
|
+
self,
|
|
738
|
+
org_id: str,
|
|
739
|
+
workspace_id: str,
|
|
740
|
+
*,
|
|
741
|
+
project_id: str,
|
|
742
|
+
token: str,
|
|
743
|
+
email: str,
|
|
744
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
745
|
+
) -> typing.Optional[typing.Any]:
|
|
746
|
+
"""
|
|
747
|
+
Accept an invitation to an organization.
|
|
748
|
+
|
|
749
|
+
Raises:
|
|
750
|
+
HTTPException: _description_; status_code: 500
|
|
751
|
+
HTTPException: Invitation not found or has expired; status_code: 400
|
|
752
|
+
HTTPException: You already belong to this organization; status_code: 400
|
|
753
|
+
|
|
754
|
+
Returns:
|
|
755
|
+
JSONResponse: Accepted invitation to workspace; status_code: 200
|
|
756
|
+
|
|
757
|
+
Parameters
|
|
758
|
+
----------
|
|
759
|
+
org_id : str
|
|
760
|
+
|
|
761
|
+
workspace_id : str
|
|
762
|
+
|
|
763
|
+
project_id : str
|
|
764
|
+
|
|
765
|
+
token : str
|
|
766
|
+
|
|
767
|
+
email : str
|
|
768
|
+
|
|
769
|
+
request_options : typing.Optional[RequestOptions]
|
|
770
|
+
Request-specific configuration.
|
|
771
|
+
|
|
772
|
+
Returns
|
|
773
|
+
-------
|
|
774
|
+
typing.Optional[typing.Any]
|
|
775
|
+
Successful Response
|
|
776
|
+
|
|
777
|
+
Examples
|
|
778
|
+
--------
|
|
779
|
+
import asyncio
|
|
780
|
+
|
|
781
|
+
from agenta import AsyncAgentaApi
|
|
782
|
+
|
|
783
|
+
client = AsyncAgentaApi(
|
|
784
|
+
api_key="YOUR_API_KEY",
|
|
785
|
+
base_url="https://yourhost.com/path/to/api",
|
|
786
|
+
)
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
async def main() -> None:
|
|
790
|
+
await client.organization.accept_invitation(
|
|
791
|
+
org_id="org_id",
|
|
792
|
+
workspace_id="workspace_id",
|
|
793
|
+
project_id="project_id",
|
|
794
|
+
token="token",
|
|
795
|
+
email="email",
|
|
796
|
+
)
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
asyncio.run(main())
|
|
800
|
+
"""
|
|
801
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
802
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/accept",
|
|
803
|
+
method="POST",
|
|
804
|
+
params={
|
|
805
|
+
"project_id": project_id,
|
|
806
|
+
},
|
|
807
|
+
json={
|
|
808
|
+
"token": token,
|
|
809
|
+
"email": email,
|
|
810
|
+
},
|
|
811
|
+
headers={
|
|
812
|
+
"content-type": "application/json",
|
|
813
|
+
},
|
|
814
|
+
request_options=request_options,
|
|
815
|
+
omit=OMIT,
|
|
816
|
+
)
|
|
817
|
+
try:
|
|
818
|
+
if 200 <= _response.status_code < 300:
|
|
819
|
+
return typing.cast(
|
|
820
|
+
typing.Optional[typing.Any],
|
|
821
|
+
parse_obj_as(
|
|
822
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
823
|
+
object_=_response.json(),
|
|
824
|
+
),
|
|
825
|
+
)
|
|
826
|
+
if _response.status_code == 422:
|
|
827
|
+
raise UnprocessableEntityError(
|
|
828
|
+
typing.cast(
|
|
829
|
+
HttpValidationError,
|
|
830
|
+
parse_obj_as(
|
|
831
|
+
type_=HttpValidationError, # type: ignore
|
|
832
|
+
object_=_response.json(),
|
|
833
|
+
),
|
|
834
|
+
)
|
|
835
|
+
)
|
|
836
|
+
_response_json = _response.json()
|
|
837
|
+
except JSONDecodeError:
|
|
838
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
839
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|