agenta 0.36.3__py3-none-any.whl → 0.36.5__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 +5 -5
- agenta/client/Readme.md +3 -3
- agenta/client/__init__.py +294 -0
- agenta/client/client.py +3192 -466
- agenta/sdk/__init__.py +5 -5
- agenta/sdk/agenta_init.py +28 -54
- agenta/sdk/client.py +1 -1
- agenta/sdk/managers/shared.py +3 -3
- agenta/sdk/middleware/auth.py +18 -9
- agenta/sdk/middleware/config.py +0 -2
- agenta/sdk/middleware/vault.py +3 -3
- agenta/sdk/types.py +2 -2
- {agenta-0.36.3.dist-info → agenta-0.36.5.dist-info}/METADATA +1 -2
- agenta-0.36.5.dist-info/RECORD +236 -0
- agenta/cli/helper.py +0 -202
- agenta/cli/main.py +0 -229
- agenta/cli/telemetry.py +0 -50
- agenta/cli/variant_commands.py +0 -526
- agenta/cli/variant_configs.py +0 -49
- agenta/client/api.py +0 -74
- agenta/client/api_models.py +0 -34
- agenta/client/backend/__init__.py +0 -294
- agenta/client/backend/client.py +0 -3289
- agenta/client/exceptions.py +0 -2
- agenta/docker/docker-assets/Dockerfile.cloud.template +0 -9
- agenta/docker/docker-assets/Dockerfile.oss.template +0 -13
- agenta/docker/docker-assets/Dockerfile.template +0 -13
- agenta/docker/docker-assets/README.md +0 -1
- agenta/docker/docker-assets/entrypoint.sh +0 -7
- agenta/docker/docker-assets/lambda_function.py +0 -6
- agenta/docker/docker-assets/main.py +0 -13
- agenta/docker/docker_utils.py +0 -100
- agenta-0.36.3.dist-info/RECORD +0 -255
- agenta-0.36.3.dist-info/entry_points.txt +0 -3
- /agenta/client/{backend/access_control → access_control}/__init__.py +0 -0
- /agenta/client/{backend/access_control → access_control}/client.py +0 -0
- /agenta/client/{backend/admin → admin}/__init__.py +0 -0
- /agenta/client/{backend/admin → admin}/client.py +0 -0
- /agenta/client/{backend/apps → apps}/__init__.py +0 -0
- /agenta/client/{backend/apps → apps}/client.py +0 -0
- /agenta/client/{backend/bases → bases}/__init__.py +0 -0
- /agenta/client/{backend/bases → bases}/client.py +0 -0
- /agenta/client/{backend/configs → configs}/__init__.py +0 -0
- /agenta/client/{backend/configs → configs}/client.py +0 -0
- /agenta/client/{backend/containers → containers}/__init__.py +0 -0
- /agenta/client/{backend/containers → containers}/client.py +0 -0
- /agenta/client/{backend/containers → containers}/types/__init__.py +0 -0
- /agenta/client/{backend/containers → containers}/types/container_templates_response.py +0 -0
- /agenta/client/{backend/core → core}/__init__.py +0 -0
- /agenta/client/{backend/core → core}/api_error.py +0 -0
- /agenta/client/{backend/core → core}/client_wrapper.py +0 -0
- /agenta/client/{backend/core → core}/datetime_utils.py +0 -0
- /agenta/client/{backend/core → core}/file.py +0 -0
- /agenta/client/{backend/core → core}/http_client.py +0 -0
- /agenta/client/{backend/core → core}/jsonable_encoder.py +0 -0
- /agenta/client/{backend/core → core}/pydantic_utilities.py +0 -0
- /agenta/client/{backend/core → core}/query_encoder.py +0 -0
- /agenta/client/{backend/core → core}/remove_none_from_dict.py +0 -0
- /agenta/client/{backend/core → core}/request_options.py +0 -0
- /agenta/client/{backend/core → core}/serialization.py +0 -0
- /agenta/client/{backend/environments → environments}/__init__.py +0 -0
- /agenta/client/{backend/environments → environments}/client.py +0 -0
- /agenta/client/{backend/errors → errors}/__init__.py +0 -0
- /agenta/client/{backend/errors → errors}/unprocessable_entity_error.py +0 -0
- /agenta/client/{backend/evaluations → evaluations}/__init__.py +0 -0
- /agenta/client/{backend/evaluations → evaluations}/client.py +0 -0
- /agenta/client/{backend/evaluators → evaluators}/__init__.py +0 -0
- /agenta/client/{backend/evaluators → evaluators}/client.py +0 -0
- /agenta/client/{backend/human_evaluations → human_evaluations}/__init__.py +0 -0
- /agenta/client/{backend/human_evaluations → human_evaluations}/client.py +0 -0
- /agenta/client/{backend/observability → observability}/__init__.py +0 -0
- /agenta/client/{backend/observability → observability}/client.py +0 -0
- /agenta/client/{backend/observability → observability}/types/__init__.py +0 -0
- /agenta/client/{backend/observability → observability}/types/format.py +0 -0
- /agenta/client/{backend/observability → observability}/types/query_analytics_response.py +0 -0
- /agenta/client/{backend/observability → observability}/types/query_traces_response.py +0 -0
- /agenta/client/{backend/scopes → scopes}/__init__.py +0 -0
- /agenta/client/{backend/scopes → scopes}/client.py +0 -0
- /agenta/client/{backend/testsets → testsets}/__init__.py +0 -0
- /agenta/client/{backend/testsets → testsets}/client.py +0 -0
- /agenta/client/{backend/types → types}/__init__.py +0 -0
- /agenta/client/{backend/types → types}/account_response.py +0 -0
- /agenta/client/{backend/types → types}/agenta_node_dto.py +0 -0
- /agenta/client/{backend/types → types}/agenta_node_dto_nodes_value.py +0 -0
- /agenta/client/{backend/types → types}/agenta_nodes_response.py +0 -0
- /agenta/client/{backend/types → types}/agenta_root_dto.py +0 -0
- /agenta/client/{backend/types → types}/agenta_roots_response.py +0 -0
- /agenta/client/{backend/types → types}/agenta_tree_dto.py +0 -0
- /agenta/client/{backend/types → types}/agenta_trees_response.py +0 -0
- /agenta/client/{backend/types → types}/aggregated_result.py +0 -0
- /agenta/client/{backend/types → types}/aggregated_result_evaluator_config.py +0 -0
- /agenta/client/{backend/types → types}/analytics_response.py +0 -0
- /agenta/client/{backend/types → types}/app.py +0 -0
- /agenta/client/{backend/types → types}/app_variant_response.py +0 -0
- /agenta/client/{backend/types → types}/app_variant_revision.py +0 -0
- /agenta/client/{backend/types → types}/base_output.py +0 -0
- /agenta/client/{backend/types → types}/body_import_testset.py +0 -0
- /agenta/client/{backend/types → types}/bucket_dto.py +0 -0
- /agenta/client/{backend/types → types}/collect_status_response.py +0 -0
- /agenta/client/{backend/types → types}/config_db.py +0 -0
- /agenta/client/{backend/types → types}/config_dto.py +0 -0
- /agenta/client/{backend/types → types}/config_response_model.py +0 -0
- /agenta/client/{backend/types → types}/correct_answer.py +0 -0
- /agenta/client/{backend/types → types}/create_app_output.py +0 -0
- /agenta/client/{backend/types → types}/delete_evaluation.py +0 -0
- /agenta/client/{backend/types → types}/docker_env_vars.py +0 -0
- /agenta/client/{backend/types → types}/environment_output.py +0 -0
- /agenta/client/{backend/types → types}/environment_output_extended.py +0 -0
- /agenta/client/{backend/types → types}/environment_revision.py +0 -0
- /agenta/client/{backend/types → types}/error.py +0 -0
- /agenta/client/{backend/types → types}/evaluation.py +0 -0
- /agenta/client/{backend/types → types}/evaluation_scenario.py +0 -0
- /agenta/client/{backend/types → types}/evaluation_scenario_input.py +0 -0
- /agenta/client/{backend/types → types}/evaluation_scenario_output.py +0 -0
- /agenta/client/{backend/types → types}/evaluation_scenario_result.py +0 -0
- /agenta/client/{backend/types → types}/evaluation_status_enum.py +0 -0
- /agenta/client/{backend/types → types}/evaluation_type.py +0 -0
- /agenta/client/{backend/types → types}/evaluator.py +0 -0
- /agenta/client/{backend/types → types}/evaluator_config.py +0 -0
- /agenta/client/{backend/types → types}/evaluator_mapping_output_interface.py +0 -0
- /agenta/client/{backend/types → types}/evaluator_output_interface.py +0 -0
- /agenta/client/{backend/types → types}/exception_dto.py +0 -0
- /agenta/client/{backend/types → types}/get_config_response.py +0 -0
- /agenta/client/{backend/types → types}/header_dto.py +0 -0
- /agenta/client/{backend/types → types}/http_validation_error.py +0 -0
- /agenta/client/{backend/types → types}/human_evaluation.py +0 -0
- /agenta/client/{backend/types → types}/human_evaluation_scenario.py +0 -0
- /agenta/client/{backend/types → types}/human_evaluation_scenario_input.py +0 -0
- /agenta/client/{backend/types → types}/human_evaluation_scenario_output.py +0 -0
- /agenta/client/{backend/types → types}/image.py +0 -0
- /agenta/client/{backend/types → types}/invite_request.py +0 -0
- /agenta/client/{backend/types → types}/legacy_analytics_response.py +0 -0
- /agenta/client/{backend/types → types}/legacy_data_point.py +0 -0
- /agenta/client/{backend/types → types}/legacy_scope_request.py +0 -0
- /agenta/client/{backend/types → types}/legacy_scopes_response.py +0 -0
- /agenta/client/{backend/types → types}/legacy_user_request.py +0 -0
- /agenta/client/{backend/types → types}/legacy_user_response.py +0 -0
- /agenta/client/{backend/types → types}/lifecycle_dto.py +0 -0
- /agenta/client/{backend/types → types}/link_dto.py +0 -0
- /agenta/client/{backend/types → types}/list_api_keys_response.py +0 -0
- /agenta/client/{backend/types → types}/llm_run_rate_limit.py +0 -0
- /agenta/client/{backend/types → types}/metrics_dto.py +0 -0
- /agenta/client/{backend/types → types}/new_testset.py +0 -0
- /agenta/client/{backend/types → types}/node_dto.py +0 -0
- /agenta/client/{backend/types → types}/node_type.py +0 -0
- /agenta/client/{backend/types → types}/o_tel_context_dto.py +0 -0
- /agenta/client/{backend/types → types}/o_tel_event_dto.py +0 -0
- /agenta/client/{backend/types → types}/o_tel_extra_dto.py +0 -0
- /agenta/client/{backend/types → types}/o_tel_link_dto.py +0 -0
- /agenta/client/{backend/types → types}/o_tel_span_dto.py +0 -0
- /agenta/client/{backend/types → types}/o_tel_span_kind.py +0 -0
- /agenta/client/{backend/types → types}/o_tel_spans_response.py +0 -0
- /agenta/client/{backend/types → types}/o_tel_status_code.py +0 -0
- /agenta/client/{backend/types → types}/organization.py +0 -0
- /agenta/client/{backend/types → types}/organization_membership_request.py +0 -0
- /agenta/client/{backend/types → types}/organization_output.py +0 -0
- /agenta/client/{backend/types → types}/organization_request.py +0 -0
- /agenta/client/{backend/types → types}/parent_dto.py +0 -0
- /agenta/client/{backend/types → types}/permission.py +0 -0
- /agenta/client/{backend/types → types}/project_membership_request.py +0 -0
- /agenta/client/{backend/types → types}/project_request.py +0 -0
- /agenta/client/{backend/types → types}/project_scope.py +0 -0
- /agenta/client/{backend/types → types}/projects_response.py +0 -0
- /agenta/client/{backend/types → types}/provider_key_dto.py +0 -0
- /agenta/client/{backend/types → types}/provider_kind.py +0 -0
- /agenta/client/{backend/types → types}/reference.py +0 -0
- /agenta/client/{backend/types → types}/reference_dto.py +0 -0
- /agenta/client/{backend/types → types}/reference_request_model.py +0 -0
- /agenta/client/{backend/types → types}/result.py +0 -0
- /agenta/client/{backend/types → types}/role.py +0 -0
- /agenta/client/{backend/types → types}/root_dto.py +0 -0
- /agenta/client/{backend/types → types}/scopes_response_model.py +0 -0
- /agenta/client/{backend/types → types}/score.py +0 -0
- /agenta/client/{backend/types → types}/secret_dto.py +0 -0
- /agenta/client/{backend/types → types}/secret_kind.py +0 -0
- /agenta/client/{backend/types → types}/secret_response_dto.py +0 -0
- /agenta/client/{backend/types → types}/simple_evaluation_output.py +0 -0
- /agenta/client/{backend/types → types}/span_dto.py +0 -0
- /agenta/client/{backend/types → types}/span_dto_nodes_value.py +0 -0
- /agenta/client/{backend/types → types}/status_code.py +0 -0
- /agenta/client/{backend/types → types}/status_dto.py +0 -0
- /agenta/client/{backend/types → types}/template.py +0 -0
- /agenta/client/{backend/types → types}/template_image_info.py +0 -0
- /agenta/client/{backend/types → types}/test_set_output_response.py +0 -0
- /agenta/client/{backend/types → types}/test_set_simple_response.py +0 -0
- /agenta/client/{backend/types → types}/time_dto.py +0 -0
- /agenta/client/{backend/types → types}/tree_dto.py +0 -0
- /agenta/client/{backend/types → types}/tree_type.py +0 -0
- /agenta/client/{backend/types → types}/update_app_output.py +0 -0
- /agenta/client/{backend/types → types}/uri.py +0 -0
- /agenta/client/{backend/types → types}/user_request.py +0 -0
- /agenta/client/{backend/types → types}/validation_error.py +0 -0
- /agenta/client/{backend/types → types}/validation_error_loc_item.py +0 -0
- /agenta/client/{backend/types → types}/variant_action.py +0 -0
- /agenta/client/{backend/types → types}/variant_action_enum.py +0 -0
- /agenta/client/{backend/types → types}/workspace_member_response.py +0 -0
- /agenta/client/{backend/types → types}/workspace_membership_request.py +0 -0
- /agenta/client/{backend/types → types}/workspace_permission.py +0 -0
- /agenta/client/{backend/types → types}/workspace_request.py +0 -0
- /agenta/client/{backend/types → types}/workspace_response.py +0 -0
- /agenta/client/{backend/types → types}/workspace_role.py +0 -0
- /agenta/client/{backend/types → types}/workspace_role_response.py +0 -0
- /agenta/client/{backend/variants → variants}/__init__.py +0 -0
- /agenta/client/{backend/variants → variants}/client.py +0 -0
- /agenta/client/{backend/variants → variants}/types/__init__.py +0 -0
- /agenta/client/{backend/variants → variants}/types/add_variant_from_base_and_config_response.py +0 -0
- /agenta/client/{backend/vault → vault}/__init__.py +0 -0
- /agenta/client/{backend/vault → vault}/client.py +0 -0
- {agenta-0.36.3.dist-info → agenta-0.36.5.dist-info}/WHEEL +0 -0
agenta/client/client.py
CHANGED
|
@@ -1,563 +1,3289 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
from
|
|
6
|
-
from
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
import httpx
|
|
5
|
+
from .core.client_wrapper import SyncClientWrapper
|
|
6
|
+
from .admin.client import AdminClient
|
|
7
|
+
from .vault.client import VaultClient
|
|
8
|
+
from .access_control.client import AccessControlClient
|
|
9
|
+
from .scopes.client import ScopesClient
|
|
10
|
+
from .apps.client import AppsClient
|
|
11
|
+
from .variants.client import VariantsClient
|
|
12
|
+
from .evaluations.client import EvaluationsClient
|
|
13
|
+
from .human_evaluations.client import HumanEvaluationsClient
|
|
14
|
+
from .evaluators.client import EvaluatorsClient
|
|
15
|
+
from .testsets.client import TestsetsClient
|
|
16
|
+
from .containers.client import ContainersClient
|
|
17
|
+
from .environments.client import EnvironmentsClient
|
|
18
|
+
from .bases.client import BasesClient
|
|
19
|
+
from .configs.client import ConfigsClient
|
|
20
|
+
from .observability.client import ObservabilityClient
|
|
21
|
+
from .core.request_options import RequestOptions
|
|
22
|
+
from .types.list_api_keys_response import ListApiKeysResponse
|
|
23
|
+
from .core.pydantic_utilities import parse_obj_as
|
|
24
|
+
from json.decoder import JSONDecodeError
|
|
25
|
+
from .core.api_error import ApiError
|
|
26
|
+
from .core.jsonable_encoder import jsonable_encoder
|
|
27
|
+
from .errors.unprocessable_entity_error import UnprocessableEntityError
|
|
28
|
+
from .types.http_validation_error import HttpValidationError
|
|
29
|
+
from .types.organization import Organization
|
|
30
|
+
from .types.organization_output import OrganizationOutput
|
|
31
|
+
from .types.invite_request import InviteRequest
|
|
32
|
+
from .core.serialization import convert_and_respect_annotation_metadata
|
|
33
|
+
from .types.workspace_response import WorkspaceResponse
|
|
34
|
+
import datetime as dt
|
|
35
|
+
from .types.workspace_role_response import WorkspaceRoleResponse
|
|
36
|
+
from .types.permission import Permission
|
|
37
|
+
from .core.client_wrapper import AsyncClientWrapper
|
|
38
|
+
from .admin.client import AsyncAdminClient
|
|
39
|
+
from .vault.client import AsyncVaultClient
|
|
40
|
+
from .access_control.client import AsyncAccessControlClient
|
|
41
|
+
from .scopes.client import AsyncScopesClient
|
|
42
|
+
from .apps.client import AsyncAppsClient
|
|
43
|
+
from .variants.client import AsyncVariantsClient
|
|
44
|
+
from .evaluations.client import AsyncEvaluationsClient
|
|
45
|
+
from .human_evaluations.client import AsyncHumanEvaluationsClient
|
|
46
|
+
from .evaluators.client import AsyncEvaluatorsClient
|
|
47
|
+
from .testsets.client import AsyncTestsetsClient
|
|
48
|
+
from .containers.client import AsyncContainersClient
|
|
49
|
+
from .environments.client import AsyncEnvironmentsClient
|
|
50
|
+
from .bases.client import AsyncBasesClient
|
|
51
|
+
from .configs.client import AsyncConfigsClient
|
|
52
|
+
from .observability.client import AsyncObservabilityClient
|
|
53
|
+
|
|
54
|
+
# this is used as the default value for optional parameters
|
|
55
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class AgentaApi:
|
|
59
|
+
"""
|
|
60
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
7
61
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
62
|
+
Parameters
|
|
63
|
+
----------
|
|
64
|
+
base_url : str
|
|
65
|
+
The base url to use for requests from the client.
|
|
12
66
|
|
|
13
|
-
|
|
67
|
+
api_key : str
|
|
68
|
+
timeout : typing.Optional[float]
|
|
69
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
14
70
|
|
|
71
|
+
follow_redirects : typing.Optional[bool]
|
|
72
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
15
73
|
|
|
16
|
-
|
|
17
|
-
|
|
74
|
+
httpx_client : typing.Optional[httpx.Client]
|
|
75
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
18
76
|
|
|
77
|
+
Examples
|
|
78
|
+
--------
|
|
79
|
+
from agenta import AgentaApi
|
|
19
80
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
81
|
+
client = AgentaApi(
|
|
82
|
+
api_key="YOUR_API_KEY",
|
|
83
|
+
base_url="https://yourhost.com/path/to/api",
|
|
84
|
+
)
|
|
23
85
|
"""
|
|
24
|
-
Get the base ID for a given app ID and base name.
|
|
25
86
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
api_key
|
|
87
|
+
def __init__(
|
|
88
|
+
self,
|
|
89
|
+
*,
|
|
90
|
+
base_url: str,
|
|
91
|
+
api_key: str,
|
|
92
|
+
timeout: typing.Optional[float] = None,
|
|
93
|
+
follow_redirects: typing.Optional[bool] = True,
|
|
94
|
+
httpx_client: typing.Optional[httpx.Client] = None,
|
|
95
|
+
):
|
|
96
|
+
_defaulted_timeout = (
|
|
97
|
+
timeout if timeout is not None else 60 if httpx_client is None else None
|
|
98
|
+
)
|
|
99
|
+
self._client_wrapper = SyncClientWrapper(
|
|
100
|
+
base_url=base_url,
|
|
101
|
+
api_key=api_key,
|
|
102
|
+
httpx_client=httpx_client
|
|
103
|
+
if httpx_client is not None
|
|
104
|
+
else httpx.Client(
|
|
105
|
+
timeout=_defaulted_timeout, follow_redirects=follow_redirects
|
|
106
|
+
)
|
|
107
|
+
if follow_redirects is not None
|
|
108
|
+
else httpx.Client(timeout=_defaulted_timeout),
|
|
109
|
+
timeout=_defaulted_timeout,
|
|
110
|
+
)
|
|
111
|
+
self.admin = AdminClient(client_wrapper=self._client_wrapper)
|
|
112
|
+
self.vault = VaultClient(client_wrapper=self._client_wrapper)
|
|
113
|
+
self.access_control = AccessControlClient(client_wrapper=self._client_wrapper)
|
|
114
|
+
self.scopes = ScopesClient(client_wrapper=self._client_wrapper)
|
|
115
|
+
self.apps = AppsClient(client_wrapper=self._client_wrapper)
|
|
116
|
+
self.variants = VariantsClient(client_wrapper=self._client_wrapper)
|
|
117
|
+
self.evaluations = EvaluationsClient(client_wrapper=self._client_wrapper)
|
|
118
|
+
self.human_evaluations = HumanEvaluationsClient(
|
|
119
|
+
client_wrapper=self._client_wrapper
|
|
120
|
+
)
|
|
121
|
+
self.evaluators = EvaluatorsClient(client_wrapper=self._client_wrapper)
|
|
122
|
+
self.testsets = TestsetsClient(client_wrapper=self._client_wrapper)
|
|
123
|
+
self.containers = ContainersClient(client_wrapper=self._client_wrapper)
|
|
124
|
+
self.environments = EnvironmentsClient(client_wrapper=self._client_wrapper)
|
|
125
|
+
self.bases = BasesClient(client_wrapper=self._client_wrapper)
|
|
126
|
+
self.configs = ConfigsClient(client_wrapper=self._client_wrapper)
|
|
127
|
+
self.observability = ObservabilityClient(client_wrapper=self._client_wrapper)
|
|
128
|
+
|
|
129
|
+
def list_api_keys(
|
|
130
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
131
|
+
) -> typing.List[ListApiKeysResponse]:
|
|
132
|
+
"""
|
|
133
|
+
List all API keys associated with the authenticated user.
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
request (Request): The incoming request object.
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
List[ListAPIKeysResponse]: A list of API Keys associated with the user.
|
|
140
|
+
|
|
141
|
+
Parameters
|
|
142
|
+
----------
|
|
143
|
+
request_options : typing.Optional[RequestOptions]
|
|
144
|
+
Request-specific configuration.
|
|
145
|
+
|
|
146
|
+
Returns
|
|
147
|
+
-------
|
|
148
|
+
typing.List[ListApiKeysResponse]
|
|
149
|
+
Successful Response
|
|
150
|
+
|
|
151
|
+
Examples
|
|
152
|
+
--------
|
|
153
|
+
from agenta import AgentaApi
|
|
154
|
+
|
|
155
|
+
client = AgentaApi(
|
|
156
|
+
api_key="YOUR_API_KEY",
|
|
157
|
+
base_url="https://yourhost.com/path/to/api",
|
|
158
|
+
)
|
|
159
|
+
client.list_api_keys()
|
|
160
|
+
"""
|
|
161
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
162
|
+
"keys",
|
|
163
|
+
method="GET",
|
|
164
|
+
request_options=request_options,
|
|
165
|
+
)
|
|
166
|
+
try:
|
|
167
|
+
if 200 <= _response.status_code < 300:
|
|
168
|
+
return typing.cast(
|
|
169
|
+
typing.List[ListApiKeysResponse],
|
|
170
|
+
parse_obj_as(
|
|
171
|
+
type_=typing.List[ListApiKeysResponse], # type: ignore
|
|
172
|
+
object_=_response.json(),
|
|
173
|
+
),
|
|
174
|
+
)
|
|
175
|
+
_response_json = _response.json()
|
|
176
|
+
except JSONDecodeError:
|
|
177
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
178
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
179
|
+
|
|
180
|
+
def create_api_key(
|
|
181
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
182
|
+
) -> str:
|
|
183
|
+
"""
|
|
184
|
+
Creates an API key for a user.
|
|
185
|
+
|
|
186
|
+
Args:
|
|
187
|
+
request (Request): The request object containing the user ID in the request state.
|
|
188
|
+
|
|
189
|
+
Returns:
|
|
190
|
+
str: The created API key.
|
|
191
|
+
|
|
192
|
+
Parameters
|
|
193
|
+
----------
|
|
194
|
+
request_options : typing.Optional[RequestOptions]
|
|
195
|
+
Request-specific configuration.
|
|
196
|
+
|
|
197
|
+
Returns
|
|
198
|
+
-------
|
|
199
|
+
str
|
|
200
|
+
Successful Response
|
|
201
|
+
|
|
202
|
+
Examples
|
|
203
|
+
--------
|
|
204
|
+
from agenta import AgentaApi
|
|
205
|
+
|
|
206
|
+
client = AgentaApi(
|
|
207
|
+
api_key="YOUR_API_KEY",
|
|
208
|
+
base_url="https://yourhost.com/path/to/api",
|
|
209
|
+
)
|
|
210
|
+
client.create_api_key()
|
|
211
|
+
"""
|
|
212
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
213
|
+
"keys",
|
|
214
|
+
method="POST",
|
|
215
|
+
request_options=request_options,
|
|
216
|
+
)
|
|
217
|
+
try:
|
|
218
|
+
if 200 <= _response.status_code < 300:
|
|
219
|
+
return typing.cast(
|
|
220
|
+
str,
|
|
221
|
+
parse_obj_as(
|
|
222
|
+
type_=str, # type: ignore
|
|
223
|
+
object_=_response.json(),
|
|
224
|
+
),
|
|
225
|
+
)
|
|
226
|
+
_response_json = _response.json()
|
|
227
|
+
except JSONDecodeError:
|
|
228
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
229
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
230
|
+
|
|
231
|
+
def delete_api_key(
|
|
232
|
+
self,
|
|
233
|
+
key_prefix: str,
|
|
234
|
+
*,
|
|
235
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
236
|
+
) -> typing.Dict[str, typing.Optional[typing.Any]]:
|
|
237
|
+
"""
|
|
238
|
+
Delete an API key with the given key prefix for the authenticated user.
|
|
239
|
+
|
|
240
|
+
Args:
|
|
241
|
+
key_prefix (str): The prefix of the API key to be deleted.
|
|
242
|
+
request (Request): The incoming request object.
|
|
243
|
+
|
|
244
|
+
Returns:
|
|
245
|
+
dict: A dictionary containing a success message upon successful deletion.
|
|
246
|
+
|
|
247
|
+
Raises:
|
|
248
|
+
HTTPException: If the API key is not found or does not belong to the user.
|
|
249
|
+
|
|
250
|
+
Parameters
|
|
251
|
+
----------
|
|
252
|
+
key_prefix : str
|
|
253
|
+
|
|
254
|
+
request_options : typing.Optional[RequestOptions]
|
|
255
|
+
Request-specific configuration.
|
|
256
|
+
|
|
257
|
+
Returns
|
|
258
|
+
-------
|
|
259
|
+
typing.Dict[str, typing.Optional[typing.Any]]
|
|
260
|
+
Successful Response
|
|
261
|
+
|
|
262
|
+
Examples
|
|
263
|
+
--------
|
|
264
|
+
from agenta import AgentaApi
|
|
265
|
+
|
|
266
|
+
client = AgentaApi(
|
|
267
|
+
api_key="YOUR_API_KEY",
|
|
268
|
+
base_url="https://yourhost.com/path/to/api",
|
|
269
|
+
)
|
|
270
|
+
client.delete_api_key(
|
|
271
|
+
key_prefix="key_prefix",
|
|
272
|
+
)
|
|
273
|
+
"""
|
|
274
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
275
|
+
f"keys/{jsonable_encoder(key_prefix)}",
|
|
276
|
+
method="DELETE",
|
|
277
|
+
request_options=request_options,
|
|
278
|
+
)
|
|
279
|
+
try:
|
|
280
|
+
if 200 <= _response.status_code < 300:
|
|
281
|
+
return typing.cast(
|
|
282
|
+
typing.Dict[str, typing.Optional[typing.Any]],
|
|
283
|
+
parse_obj_as(
|
|
284
|
+
type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore
|
|
285
|
+
object_=_response.json(),
|
|
286
|
+
),
|
|
287
|
+
)
|
|
288
|
+
if _response.status_code == 422:
|
|
289
|
+
raise UnprocessableEntityError(
|
|
290
|
+
typing.cast(
|
|
291
|
+
HttpValidationError,
|
|
292
|
+
parse_obj_as(
|
|
293
|
+
type_=HttpValidationError, # type: ignore
|
|
294
|
+
object_=_response.json(),
|
|
295
|
+
),
|
|
296
|
+
)
|
|
297
|
+
)
|
|
298
|
+
_response_json = _response.json()
|
|
299
|
+
except JSONDecodeError:
|
|
300
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
301
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
302
|
+
|
|
303
|
+
def validate_api_key(
|
|
304
|
+
self,
|
|
305
|
+
key_prefix: str,
|
|
306
|
+
*,
|
|
307
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
308
|
+
) -> bool:
|
|
309
|
+
"""
|
|
310
|
+
This Function is called by the CLI and is used to validate an API key provided by a user in agenta init setup.
|
|
311
|
+
Returns:
|
|
312
|
+
bool: True. If the request reaches this point, the API key is valid.
|
|
313
|
+
|
|
314
|
+
Parameters
|
|
315
|
+
----------
|
|
316
|
+
key_prefix : str
|
|
317
|
+
|
|
318
|
+
request_options : typing.Optional[RequestOptions]
|
|
319
|
+
Request-specific configuration.
|
|
320
|
+
|
|
321
|
+
Returns
|
|
322
|
+
-------
|
|
323
|
+
bool
|
|
324
|
+
Successful Response
|
|
325
|
+
|
|
326
|
+
Examples
|
|
327
|
+
--------
|
|
328
|
+
from agenta import AgentaApi
|
|
329
|
+
|
|
330
|
+
client = AgentaApi(
|
|
331
|
+
api_key="YOUR_API_KEY",
|
|
332
|
+
base_url="https://yourhost.com/path/to/api",
|
|
333
|
+
)
|
|
334
|
+
client.validate_api_key(
|
|
335
|
+
key_prefix="key_prefix",
|
|
336
|
+
)
|
|
337
|
+
"""
|
|
338
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
339
|
+
f"keys/{jsonable_encoder(key_prefix)}/validate",
|
|
340
|
+
method="GET",
|
|
341
|
+
request_options=request_options,
|
|
342
|
+
)
|
|
343
|
+
try:
|
|
344
|
+
if 200 <= _response.status_code < 300:
|
|
345
|
+
return typing.cast(
|
|
346
|
+
bool,
|
|
347
|
+
parse_obj_as(
|
|
348
|
+
type_=bool, # type: ignore
|
|
349
|
+
object_=_response.json(),
|
|
350
|
+
),
|
|
351
|
+
)
|
|
352
|
+
if _response.status_code == 422:
|
|
353
|
+
raise UnprocessableEntityError(
|
|
354
|
+
typing.cast(
|
|
355
|
+
HttpValidationError,
|
|
356
|
+
parse_obj_as(
|
|
357
|
+
type_=HttpValidationError, # type: ignore
|
|
358
|
+
object_=_response.json(),
|
|
359
|
+
),
|
|
360
|
+
)
|
|
361
|
+
)
|
|
362
|
+
_response_json = _response.json()
|
|
363
|
+
except JSONDecodeError:
|
|
364
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
365
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
366
|
+
|
|
367
|
+
def list_organizations(
|
|
368
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
369
|
+
) -> typing.List[Organization]:
|
|
370
|
+
"""
|
|
371
|
+
Returns a list of organizations associated with the user's session.
|
|
372
|
+
|
|
373
|
+
Args:
|
|
374
|
+
stoken_session (SessionContainer): The user's session token.
|
|
375
|
+
|
|
376
|
+
Returns:
|
|
377
|
+
list[Organization]: A list of organizations associated with the user's session.
|
|
378
|
+
|
|
379
|
+
Raises:
|
|
380
|
+
HTTPException: If there is an error retrieving the organizations from the database.
|
|
381
|
+
|
|
382
|
+
Parameters
|
|
383
|
+
----------
|
|
384
|
+
request_options : typing.Optional[RequestOptions]
|
|
385
|
+
Request-specific configuration.
|
|
386
|
+
|
|
387
|
+
Returns
|
|
388
|
+
-------
|
|
389
|
+
typing.List[Organization]
|
|
390
|
+
Successful Response
|
|
391
|
+
|
|
392
|
+
Examples
|
|
393
|
+
--------
|
|
394
|
+
from agenta import AgentaApi
|
|
395
|
+
|
|
396
|
+
client = AgentaApi(
|
|
397
|
+
api_key="YOUR_API_KEY",
|
|
398
|
+
base_url="https://yourhost.com/path/to/api",
|
|
399
|
+
)
|
|
400
|
+
client.list_organizations()
|
|
401
|
+
"""
|
|
402
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
403
|
+
"organizations",
|
|
404
|
+
method="GET",
|
|
405
|
+
request_options=request_options,
|
|
406
|
+
)
|
|
407
|
+
try:
|
|
408
|
+
if 200 <= _response.status_code < 300:
|
|
409
|
+
return typing.cast(
|
|
410
|
+
typing.List[Organization],
|
|
411
|
+
parse_obj_as(
|
|
412
|
+
type_=typing.List[Organization], # type: ignore
|
|
413
|
+
object_=_response.json(),
|
|
414
|
+
),
|
|
415
|
+
)
|
|
416
|
+
_response_json = _response.json()
|
|
417
|
+
except JSONDecodeError:
|
|
418
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
419
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
420
|
+
|
|
421
|
+
def create_organization(
|
|
422
|
+
self,
|
|
423
|
+
*,
|
|
424
|
+
name: str,
|
|
425
|
+
owner: str,
|
|
426
|
+
description: typing.Optional[str] = OMIT,
|
|
427
|
+
type: typing.Optional[str] = OMIT,
|
|
428
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
429
|
+
) -> typing.Optional[typing.Any]:
|
|
430
|
+
"""
|
|
431
|
+
Parameters
|
|
432
|
+
----------
|
|
433
|
+
name : str
|
|
434
|
+
|
|
435
|
+
owner : str
|
|
436
|
+
|
|
437
|
+
description : typing.Optional[str]
|
|
438
|
+
|
|
439
|
+
type : typing.Optional[str]
|
|
440
|
+
|
|
441
|
+
request_options : typing.Optional[RequestOptions]
|
|
442
|
+
Request-specific configuration.
|
|
443
|
+
|
|
444
|
+
Returns
|
|
445
|
+
-------
|
|
446
|
+
typing.Optional[typing.Any]
|
|
447
|
+
Successful Response
|
|
448
|
+
|
|
449
|
+
Examples
|
|
450
|
+
--------
|
|
451
|
+
from agenta import AgentaApi
|
|
452
|
+
|
|
453
|
+
client = AgentaApi(
|
|
454
|
+
api_key="YOUR_API_KEY",
|
|
455
|
+
base_url="https://yourhost.com/path/to/api",
|
|
456
|
+
)
|
|
457
|
+
client.create_organization(
|
|
458
|
+
name="name",
|
|
459
|
+
owner="owner",
|
|
460
|
+
)
|
|
461
|
+
"""
|
|
462
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
463
|
+
"organizations",
|
|
464
|
+
method="POST",
|
|
465
|
+
json={
|
|
466
|
+
"name": name,
|
|
467
|
+
"owner": owner,
|
|
468
|
+
"description": description,
|
|
469
|
+
"type": type,
|
|
470
|
+
},
|
|
471
|
+
headers={
|
|
472
|
+
"content-type": "application/json",
|
|
473
|
+
},
|
|
474
|
+
request_options=request_options,
|
|
475
|
+
omit=OMIT,
|
|
476
|
+
)
|
|
477
|
+
try:
|
|
478
|
+
if 200 <= _response.status_code < 300:
|
|
479
|
+
return typing.cast(
|
|
480
|
+
typing.Optional[typing.Any],
|
|
481
|
+
parse_obj_as(
|
|
482
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
483
|
+
object_=_response.json(),
|
|
484
|
+
),
|
|
485
|
+
)
|
|
486
|
+
if _response.status_code == 422:
|
|
487
|
+
raise UnprocessableEntityError(
|
|
488
|
+
typing.cast(
|
|
489
|
+
HttpValidationError,
|
|
490
|
+
parse_obj_as(
|
|
491
|
+
type_=HttpValidationError, # type: ignore
|
|
492
|
+
object_=_response.json(),
|
|
493
|
+
),
|
|
494
|
+
)
|
|
495
|
+
)
|
|
496
|
+
_response_json = _response.json()
|
|
497
|
+
except JSONDecodeError:
|
|
498
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
499
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
500
|
+
|
|
501
|
+
def get_own_org(
|
|
502
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
503
|
+
) -> OrganizationOutput:
|
|
504
|
+
"""
|
|
505
|
+
Parameters
|
|
506
|
+
----------
|
|
507
|
+
request_options : typing.Optional[RequestOptions]
|
|
508
|
+
Request-specific configuration.
|
|
509
|
+
|
|
510
|
+
Returns
|
|
511
|
+
-------
|
|
512
|
+
OrganizationOutput
|
|
513
|
+
Successful Response
|
|
514
|
+
|
|
515
|
+
Examples
|
|
516
|
+
--------
|
|
517
|
+
from agenta import AgentaApi
|
|
518
|
+
|
|
519
|
+
client = AgentaApi(
|
|
520
|
+
api_key="YOUR_API_KEY",
|
|
521
|
+
base_url="https://yourhost.com/path/to/api",
|
|
522
|
+
)
|
|
523
|
+
client.get_own_org()
|
|
524
|
+
"""
|
|
525
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
526
|
+
"organizations/own",
|
|
527
|
+
method="GET",
|
|
528
|
+
request_options=request_options,
|
|
529
|
+
)
|
|
530
|
+
try:
|
|
531
|
+
if 200 <= _response.status_code < 300:
|
|
532
|
+
return typing.cast(
|
|
533
|
+
OrganizationOutput,
|
|
534
|
+
parse_obj_as(
|
|
535
|
+
type_=OrganizationOutput, # type: ignore
|
|
536
|
+
object_=_response.json(),
|
|
537
|
+
),
|
|
538
|
+
)
|
|
539
|
+
_response_json = _response.json()
|
|
540
|
+
except JSONDecodeError:
|
|
541
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
542
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
543
|
+
|
|
544
|
+
def fetch_organization_details(
|
|
545
|
+
self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
546
|
+
) -> typing.Optional[typing.Any]:
|
|
547
|
+
"""
|
|
548
|
+
Get an organization's details.
|
|
549
|
+
|
|
550
|
+
Raises:
|
|
551
|
+
HTTPException: _description_
|
|
552
|
+
Permission Denied
|
|
553
|
+
|
|
554
|
+
Returns:
|
|
555
|
+
OrganizationDB Instance
|
|
556
|
+
|
|
557
|
+
Parameters
|
|
558
|
+
----------
|
|
559
|
+
org_id : str
|
|
560
|
+
|
|
561
|
+
request_options : typing.Optional[RequestOptions]
|
|
562
|
+
Request-specific configuration.
|
|
563
|
+
|
|
564
|
+
Returns
|
|
565
|
+
-------
|
|
566
|
+
typing.Optional[typing.Any]
|
|
567
|
+
Successful Response
|
|
568
|
+
|
|
569
|
+
Examples
|
|
570
|
+
--------
|
|
571
|
+
from agenta import AgentaApi
|
|
572
|
+
|
|
573
|
+
client = AgentaApi(
|
|
574
|
+
api_key="YOUR_API_KEY",
|
|
575
|
+
base_url="https://yourhost.com/path/to/api",
|
|
576
|
+
)
|
|
577
|
+
client.fetch_organization_details(
|
|
578
|
+
org_id="org_id",
|
|
579
|
+
)
|
|
580
|
+
"""
|
|
581
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
582
|
+
f"organizations/{jsonable_encoder(org_id)}",
|
|
583
|
+
method="GET",
|
|
584
|
+
request_options=request_options,
|
|
585
|
+
)
|
|
586
|
+
try:
|
|
587
|
+
if 200 <= _response.status_code < 300:
|
|
588
|
+
return typing.cast(
|
|
589
|
+
typing.Optional[typing.Any],
|
|
590
|
+
parse_obj_as(
|
|
591
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
592
|
+
object_=_response.json(),
|
|
593
|
+
),
|
|
594
|
+
)
|
|
595
|
+
if _response.status_code == 422:
|
|
596
|
+
raise UnprocessableEntityError(
|
|
597
|
+
typing.cast(
|
|
598
|
+
HttpValidationError,
|
|
599
|
+
parse_obj_as(
|
|
600
|
+
type_=HttpValidationError, # type: ignore
|
|
601
|
+
object_=_response.json(),
|
|
602
|
+
),
|
|
603
|
+
)
|
|
604
|
+
)
|
|
605
|
+
_response_json = _response.json()
|
|
606
|
+
except JSONDecodeError:
|
|
607
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
608
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
609
|
+
|
|
610
|
+
def update_organization(
|
|
611
|
+
self,
|
|
612
|
+
org_id: str,
|
|
613
|
+
*,
|
|
614
|
+
name: typing.Optional[str] = OMIT,
|
|
615
|
+
description: typing.Optional[str] = OMIT,
|
|
616
|
+
updated_at: typing.Optional[str] = OMIT,
|
|
617
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
618
|
+
) -> typing.Optional[typing.Any]:
|
|
619
|
+
"""
|
|
620
|
+
Parameters
|
|
621
|
+
----------
|
|
622
|
+
org_id : str
|
|
623
|
+
|
|
624
|
+
name : typing.Optional[str]
|
|
625
|
+
|
|
626
|
+
description : typing.Optional[str]
|
|
627
|
+
|
|
628
|
+
updated_at : typing.Optional[str]
|
|
629
|
+
|
|
630
|
+
request_options : typing.Optional[RequestOptions]
|
|
631
|
+
Request-specific configuration.
|
|
632
|
+
|
|
633
|
+
Returns
|
|
634
|
+
-------
|
|
635
|
+
typing.Optional[typing.Any]
|
|
636
|
+
Successful Response
|
|
637
|
+
|
|
638
|
+
Examples
|
|
639
|
+
--------
|
|
640
|
+
from agenta import AgentaApi
|
|
641
|
+
|
|
642
|
+
client = AgentaApi(
|
|
643
|
+
api_key="YOUR_API_KEY",
|
|
644
|
+
base_url="https://yourhost.com/path/to/api",
|
|
645
|
+
)
|
|
646
|
+
client.update_organization(
|
|
647
|
+
org_id="org_id",
|
|
648
|
+
)
|
|
649
|
+
"""
|
|
650
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
651
|
+
f"organizations/{jsonable_encoder(org_id)}",
|
|
652
|
+
method="PUT",
|
|
653
|
+
json={
|
|
654
|
+
"name": name,
|
|
655
|
+
"description": description,
|
|
656
|
+
"updated_at": updated_at,
|
|
657
|
+
},
|
|
658
|
+
headers={
|
|
659
|
+
"content-type": "application/json",
|
|
660
|
+
},
|
|
661
|
+
request_options=request_options,
|
|
662
|
+
omit=OMIT,
|
|
663
|
+
)
|
|
664
|
+
try:
|
|
665
|
+
if 200 <= _response.status_code < 300:
|
|
666
|
+
return typing.cast(
|
|
667
|
+
typing.Optional[typing.Any],
|
|
668
|
+
parse_obj_as(
|
|
669
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
670
|
+
object_=_response.json(),
|
|
671
|
+
),
|
|
672
|
+
)
|
|
673
|
+
if _response.status_code == 422:
|
|
674
|
+
raise UnprocessableEntityError(
|
|
675
|
+
typing.cast(
|
|
676
|
+
HttpValidationError,
|
|
677
|
+
parse_obj_as(
|
|
678
|
+
type_=HttpValidationError, # type: ignore
|
|
679
|
+
object_=_response.json(),
|
|
680
|
+
),
|
|
681
|
+
)
|
|
682
|
+
)
|
|
683
|
+
_response_json = _response.json()
|
|
684
|
+
except JSONDecodeError:
|
|
685
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
686
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
687
|
+
|
|
688
|
+
def invite_user_to_workspace(
|
|
689
|
+
self,
|
|
690
|
+
org_id: str,
|
|
691
|
+
workspace_id: str,
|
|
692
|
+
*,
|
|
693
|
+
request: typing.Sequence[InviteRequest],
|
|
694
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
695
|
+
) -> typing.Optional[typing.Any]:
|
|
696
|
+
"""
|
|
697
|
+
Parameters
|
|
698
|
+
----------
|
|
699
|
+
org_id : str
|
|
700
|
+
|
|
701
|
+
workspace_id : str
|
|
702
|
+
|
|
703
|
+
request : typing.Sequence[InviteRequest]
|
|
704
|
+
|
|
705
|
+
request_options : typing.Optional[RequestOptions]
|
|
706
|
+
Request-specific configuration.
|
|
707
|
+
|
|
708
|
+
Returns
|
|
709
|
+
-------
|
|
710
|
+
typing.Optional[typing.Any]
|
|
711
|
+
Successful Response
|
|
712
|
+
|
|
713
|
+
Examples
|
|
714
|
+
--------
|
|
715
|
+
from agenta import AgentaApi, InviteRequest
|
|
716
|
+
|
|
717
|
+
client = AgentaApi(
|
|
718
|
+
api_key="YOUR_API_KEY",
|
|
719
|
+
base_url="https://yourhost.com/path/to/api",
|
|
720
|
+
)
|
|
721
|
+
client.invite_user_to_workspace(
|
|
722
|
+
org_id="org_id",
|
|
723
|
+
workspace_id="workspace_id",
|
|
724
|
+
request=[
|
|
725
|
+
InviteRequest(
|
|
726
|
+
email="email",
|
|
727
|
+
roles=["roles"],
|
|
728
|
+
)
|
|
729
|
+
],
|
|
730
|
+
)
|
|
731
|
+
"""
|
|
732
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
733
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite",
|
|
734
|
+
method="POST",
|
|
735
|
+
json=convert_and_respect_annotation_metadata(
|
|
736
|
+
object_=request,
|
|
737
|
+
annotation=typing.Sequence[InviteRequest],
|
|
738
|
+
direction="write",
|
|
739
|
+
),
|
|
740
|
+
request_options=request_options,
|
|
741
|
+
omit=OMIT,
|
|
742
|
+
)
|
|
743
|
+
try:
|
|
744
|
+
if 200 <= _response.status_code < 300:
|
|
745
|
+
return typing.cast(
|
|
746
|
+
typing.Optional[typing.Any],
|
|
747
|
+
parse_obj_as(
|
|
748
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
749
|
+
object_=_response.json(),
|
|
750
|
+
),
|
|
751
|
+
)
|
|
752
|
+
if _response.status_code == 422:
|
|
753
|
+
raise UnprocessableEntityError(
|
|
754
|
+
typing.cast(
|
|
755
|
+
HttpValidationError,
|
|
756
|
+
parse_obj_as(
|
|
757
|
+
type_=HttpValidationError, # type: ignore
|
|
758
|
+
object_=_response.json(),
|
|
759
|
+
),
|
|
760
|
+
)
|
|
761
|
+
)
|
|
762
|
+
_response_json = _response.json()
|
|
763
|
+
except JSONDecodeError:
|
|
764
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
765
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
766
|
+
|
|
767
|
+
def resend_invitation(
|
|
768
|
+
self,
|
|
769
|
+
org_id: str,
|
|
770
|
+
workspace_id: str,
|
|
771
|
+
*,
|
|
772
|
+
email: str,
|
|
773
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
774
|
+
) -> typing.Optional[typing.Any]:
|
|
775
|
+
"""
|
|
776
|
+
Resend an invitation to a user to an Organization.
|
|
777
|
+
|
|
778
|
+
Raises:
|
|
779
|
+
HTTPException: _description_; status_code: 500
|
|
780
|
+
HTTPException: Invitation not found or has expired; status_code: 400
|
|
781
|
+
HTTPException: You already belong to this organization; status_code: 400
|
|
782
|
+
|
|
783
|
+
Returns:
|
|
784
|
+
JSONResponse: Resent invitation to user; status_code: 200
|
|
785
|
+
|
|
786
|
+
Parameters
|
|
787
|
+
----------
|
|
788
|
+
org_id : str
|
|
789
|
+
|
|
790
|
+
workspace_id : str
|
|
791
|
+
|
|
792
|
+
email : str
|
|
793
|
+
|
|
794
|
+
request_options : typing.Optional[RequestOptions]
|
|
795
|
+
Request-specific configuration.
|
|
796
|
+
|
|
797
|
+
Returns
|
|
798
|
+
-------
|
|
799
|
+
typing.Optional[typing.Any]
|
|
800
|
+
Successful Response
|
|
801
|
+
|
|
802
|
+
Examples
|
|
803
|
+
--------
|
|
804
|
+
from agenta import AgentaApi
|
|
805
|
+
|
|
806
|
+
client = AgentaApi(
|
|
807
|
+
api_key="YOUR_API_KEY",
|
|
808
|
+
base_url="https://yourhost.com/path/to/api",
|
|
809
|
+
)
|
|
810
|
+
client.resend_invitation(
|
|
811
|
+
org_id="org_id",
|
|
812
|
+
workspace_id="workspace_id",
|
|
813
|
+
email="email",
|
|
814
|
+
)
|
|
815
|
+
"""
|
|
816
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
817
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/resend",
|
|
818
|
+
method="POST",
|
|
819
|
+
json={
|
|
820
|
+
"email": email,
|
|
821
|
+
},
|
|
822
|
+
headers={
|
|
823
|
+
"content-type": "application/json",
|
|
824
|
+
},
|
|
825
|
+
request_options=request_options,
|
|
826
|
+
omit=OMIT,
|
|
827
|
+
)
|
|
828
|
+
try:
|
|
829
|
+
if 200 <= _response.status_code < 300:
|
|
830
|
+
return typing.cast(
|
|
831
|
+
typing.Optional[typing.Any],
|
|
832
|
+
parse_obj_as(
|
|
833
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
834
|
+
object_=_response.json(),
|
|
835
|
+
),
|
|
836
|
+
)
|
|
837
|
+
if _response.status_code == 422:
|
|
838
|
+
raise UnprocessableEntityError(
|
|
839
|
+
typing.cast(
|
|
840
|
+
HttpValidationError,
|
|
841
|
+
parse_obj_as(
|
|
842
|
+
type_=HttpValidationError, # type: ignore
|
|
843
|
+
object_=_response.json(),
|
|
844
|
+
),
|
|
845
|
+
)
|
|
846
|
+
)
|
|
847
|
+
_response_json = _response.json()
|
|
848
|
+
except JSONDecodeError:
|
|
849
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
850
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
851
|
+
|
|
852
|
+
def accept_invitation(
|
|
853
|
+
self,
|
|
854
|
+
org_id: str,
|
|
855
|
+
workspace_id: str,
|
|
856
|
+
*,
|
|
857
|
+
project_id: str,
|
|
858
|
+
token: str,
|
|
859
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
860
|
+
) -> typing.Optional[typing.Any]:
|
|
861
|
+
"""
|
|
862
|
+
Accept an invitation to a workspace.
|
|
863
|
+
|
|
864
|
+
Raises:
|
|
865
|
+
HTTPException: _description_; status_code: 500
|
|
866
|
+
HTTPException: Invitation not found or has expired; status_code: 400
|
|
867
|
+
HTTPException: You already belong to this organization; status_code: 400
|
|
868
|
+
|
|
869
|
+
Returns:
|
|
870
|
+
JSONResponse: Accepted invitation to workspace; status_code: 200
|
|
871
|
+
|
|
872
|
+
Parameters
|
|
873
|
+
----------
|
|
874
|
+
org_id : str
|
|
875
|
+
|
|
876
|
+
workspace_id : str
|
|
877
|
+
|
|
878
|
+
project_id : str
|
|
879
|
+
|
|
880
|
+
token : str
|
|
881
|
+
|
|
882
|
+
request_options : typing.Optional[RequestOptions]
|
|
883
|
+
Request-specific configuration.
|
|
884
|
+
|
|
885
|
+
Returns
|
|
886
|
+
-------
|
|
887
|
+
typing.Optional[typing.Any]
|
|
888
|
+
Successful Response
|
|
889
|
+
|
|
890
|
+
Examples
|
|
891
|
+
--------
|
|
892
|
+
from agenta import AgentaApi
|
|
893
|
+
|
|
894
|
+
client = AgentaApi(
|
|
895
|
+
api_key="YOUR_API_KEY",
|
|
896
|
+
base_url="https://yourhost.com/path/to/api",
|
|
897
|
+
)
|
|
898
|
+
client.accept_invitation(
|
|
899
|
+
org_id="org_id",
|
|
900
|
+
workspace_id="workspace_id",
|
|
901
|
+
project_id="project_id",
|
|
902
|
+
token="token",
|
|
903
|
+
)
|
|
904
|
+
"""
|
|
905
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
906
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/accept",
|
|
907
|
+
method="POST",
|
|
908
|
+
params={
|
|
909
|
+
"project_id": project_id,
|
|
910
|
+
},
|
|
911
|
+
json={
|
|
912
|
+
"token": token,
|
|
913
|
+
},
|
|
914
|
+
headers={
|
|
915
|
+
"content-type": "application/json",
|
|
916
|
+
},
|
|
917
|
+
request_options=request_options,
|
|
918
|
+
omit=OMIT,
|
|
919
|
+
)
|
|
920
|
+
try:
|
|
921
|
+
if 200 <= _response.status_code < 300:
|
|
922
|
+
return typing.cast(
|
|
923
|
+
typing.Optional[typing.Any],
|
|
924
|
+
parse_obj_as(
|
|
925
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
926
|
+
object_=_response.json(),
|
|
927
|
+
),
|
|
928
|
+
)
|
|
929
|
+
if _response.status_code == 422:
|
|
930
|
+
raise UnprocessableEntityError(
|
|
931
|
+
typing.cast(
|
|
932
|
+
HttpValidationError,
|
|
933
|
+
parse_obj_as(
|
|
934
|
+
type_=HttpValidationError, # type: ignore
|
|
935
|
+
object_=_response.json(),
|
|
936
|
+
),
|
|
937
|
+
)
|
|
938
|
+
)
|
|
939
|
+
_response_json = _response.json()
|
|
940
|
+
except JSONDecodeError:
|
|
941
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
942
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
943
|
+
|
|
944
|
+
def create_workspace(
|
|
945
|
+
self,
|
|
946
|
+
org_id: str,
|
|
947
|
+
*,
|
|
948
|
+
name: str,
|
|
949
|
+
description: typing.Optional[str] = OMIT,
|
|
950
|
+
type: typing.Optional[str] = OMIT,
|
|
951
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
952
|
+
) -> WorkspaceResponse:
|
|
953
|
+
"""
|
|
954
|
+
Parameters
|
|
955
|
+
----------
|
|
956
|
+
org_id : str
|
|
957
|
+
|
|
958
|
+
name : str
|
|
959
|
+
|
|
960
|
+
description : typing.Optional[str]
|
|
961
|
+
|
|
962
|
+
type : typing.Optional[str]
|
|
963
|
+
|
|
964
|
+
request_options : typing.Optional[RequestOptions]
|
|
965
|
+
Request-specific configuration.
|
|
966
|
+
|
|
967
|
+
Returns
|
|
968
|
+
-------
|
|
969
|
+
WorkspaceResponse
|
|
970
|
+
Successful Response
|
|
971
|
+
|
|
972
|
+
Examples
|
|
973
|
+
--------
|
|
974
|
+
from agenta import AgentaApi
|
|
975
|
+
|
|
976
|
+
client = AgentaApi(
|
|
977
|
+
api_key="YOUR_API_KEY",
|
|
978
|
+
base_url="https://yourhost.com/path/to/api",
|
|
979
|
+
)
|
|
980
|
+
client.create_workspace(
|
|
981
|
+
org_id="org_id",
|
|
982
|
+
name="name",
|
|
983
|
+
)
|
|
984
|
+
"""
|
|
985
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
986
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces",
|
|
987
|
+
method="POST",
|
|
988
|
+
json={
|
|
989
|
+
"name": name,
|
|
990
|
+
"description": description,
|
|
991
|
+
"type": type,
|
|
992
|
+
},
|
|
993
|
+
headers={
|
|
994
|
+
"content-type": "application/json",
|
|
995
|
+
},
|
|
996
|
+
request_options=request_options,
|
|
997
|
+
omit=OMIT,
|
|
998
|
+
)
|
|
999
|
+
try:
|
|
1000
|
+
if 200 <= _response.status_code < 300:
|
|
1001
|
+
return typing.cast(
|
|
1002
|
+
WorkspaceResponse,
|
|
1003
|
+
parse_obj_as(
|
|
1004
|
+
type_=WorkspaceResponse, # type: ignore
|
|
1005
|
+
object_=_response.json(),
|
|
1006
|
+
),
|
|
1007
|
+
)
|
|
1008
|
+
if _response.status_code == 422:
|
|
1009
|
+
raise UnprocessableEntityError(
|
|
1010
|
+
typing.cast(
|
|
1011
|
+
HttpValidationError,
|
|
1012
|
+
parse_obj_as(
|
|
1013
|
+
type_=HttpValidationError, # type: ignore
|
|
1014
|
+
object_=_response.json(),
|
|
1015
|
+
),
|
|
1016
|
+
)
|
|
1017
|
+
)
|
|
1018
|
+
_response_json = _response.json()
|
|
1019
|
+
except JSONDecodeError:
|
|
1020
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1021
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1022
|
+
|
|
1023
|
+
def update_workspace(
|
|
1024
|
+
self,
|
|
1025
|
+
org_id: str,
|
|
1026
|
+
workspace_id: str,
|
|
1027
|
+
*,
|
|
1028
|
+
name: typing.Optional[str] = OMIT,
|
|
1029
|
+
description: typing.Optional[str] = OMIT,
|
|
1030
|
+
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
1031
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1032
|
+
) -> WorkspaceResponse:
|
|
1033
|
+
"""
|
|
1034
|
+
Parameters
|
|
1035
|
+
----------
|
|
1036
|
+
org_id : str
|
|
1037
|
+
|
|
1038
|
+
workspace_id : str
|
|
1039
|
+
|
|
1040
|
+
name : typing.Optional[str]
|
|
1041
|
+
|
|
1042
|
+
description : typing.Optional[str]
|
|
1043
|
+
|
|
1044
|
+
updated_at : typing.Optional[dt.datetime]
|
|
1045
|
+
|
|
1046
|
+
request_options : typing.Optional[RequestOptions]
|
|
1047
|
+
Request-specific configuration.
|
|
1048
|
+
|
|
1049
|
+
Returns
|
|
1050
|
+
-------
|
|
1051
|
+
WorkspaceResponse
|
|
1052
|
+
Successful Response
|
|
1053
|
+
|
|
1054
|
+
Examples
|
|
1055
|
+
--------
|
|
1056
|
+
from agenta import AgentaApi
|
|
1057
|
+
|
|
1058
|
+
client = AgentaApi(
|
|
1059
|
+
api_key="YOUR_API_KEY",
|
|
1060
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1061
|
+
)
|
|
1062
|
+
client.update_workspace(
|
|
1063
|
+
org_id="org_id",
|
|
1064
|
+
workspace_id="workspace_id",
|
|
1065
|
+
)
|
|
1066
|
+
"""
|
|
1067
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1068
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}",
|
|
1069
|
+
method="PUT",
|
|
1070
|
+
json={
|
|
1071
|
+
"name": name,
|
|
1072
|
+
"description": description,
|
|
1073
|
+
"updated_at": updated_at,
|
|
1074
|
+
},
|
|
1075
|
+
headers={
|
|
1076
|
+
"content-type": "application/json",
|
|
1077
|
+
},
|
|
1078
|
+
request_options=request_options,
|
|
1079
|
+
omit=OMIT,
|
|
1080
|
+
)
|
|
1081
|
+
try:
|
|
1082
|
+
if 200 <= _response.status_code < 300:
|
|
1083
|
+
return typing.cast(
|
|
1084
|
+
WorkspaceResponse,
|
|
1085
|
+
parse_obj_as(
|
|
1086
|
+
type_=WorkspaceResponse, # type: ignore
|
|
1087
|
+
object_=_response.json(),
|
|
1088
|
+
),
|
|
1089
|
+
)
|
|
1090
|
+
if _response.status_code == 422:
|
|
1091
|
+
raise UnprocessableEntityError(
|
|
1092
|
+
typing.cast(
|
|
1093
|
+
HttpValidationError,
|
|
1094
|
+
parse_obj_as(
|
|
1095
|
+
type_=HttpValidationError, # type: ignore
|
|
1096
|
+
object_=_response.json(),
|
|
1097
|
+
),
|
|
1098
|
+
)
|
|
1099
|
+
)
|
|
1100
|
+
_response_json = _response.json()
|
|
1101
|
+
except JSONDecodeError:
|
|
1102
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1103
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1104
|
+
|
|
1105
|
+
def get_all_workspace_roles(
|
|
1106
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
1107
|
+
) -> typing.List[WorkspaceRoleResponse]:
|
|
1108
|
+
"""
|
|
1109
|
+
Get all workspace roles.
|
|
1110
|
+
|
|
1111
|
+
Returns a list of all available workspace roles.
|
|
1112
|
+
|
|
1113
|
+
Returns:
|
|
1114
|
+
List[WorkspaceRoleResponse]: A list of WorkspaceRole objects representing the available workspace roles.
|
|
1115
|
+
|
|
1116
|
+
Raises:
|
|
1117
|
+
HTTPException: If an error occurs while retrieving the workspace roles.
|
|
1118
|
+
|
|
1119
|
+
Parameters
|
|
1120
|
+
----------
|
|
1121
|
+
request_options : typing.Optional[RequestOptions]
|
|
1122
|
+
Request-specific configuration.
|
|
1123
|
+
|
|
1124
|
+
Returns
|
|
1125
|
+
-------
|
|
1126
|
+
typing.List[WorkspaceRoleResponse]
|
|
1127
|
+
Successful Response
|
|
1128
|
+
|
|
1129
|
+
Examples
|
|
1130
|
+
--------
|
|
1131
|
+
from agenta import AgentaApi
|
|
1132
|
+
|
|
1133
|
+
client = AgentaApi(
|
|
1134
|
+
api_key="YOUR_API_KEY",
|
|
1135
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1136
|
+
)
|
|
1137
|
+
client.get_all_workspace_roles()
|
|
1138
|
+
"""
|
|
1139
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1140
|
+
"workspaces/roles",
|
|
1141
|
+
method="GET",
|
|
1142
|
+
request_options=request_options,
|
|
1143
|
+
)
|
|
1144
|
+
try:
|
|
1145
|
+
if 200 <= _response.status_code < 300:
|
|
1146
|
+
return typing.cast(
|
|
1147
|
+
typing.List[WorkspaceRoleResponse],
|
|
1148
|
+
parse_obj_as(
|
|
1149
|
+
type_=typing.List[WorkspaceRoleResponse], # type: ignore
|
|
1150
|
+
object_=_response.json(),
|
|
1151
|
+
),
|
|
1152
|
+
)
|
|
1153
|
+
_response_json = _response.json()
|
|
1154
|
+
except JSONDecodeError:
|
|
1155
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1156
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1157
|
+
|
|
1158
|
+
def get_all_workspace_permissions(
|
|
1159
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
1160
|
+
) -> typing.List[Permission]:
|
|
1161
|
+
"""
|
|
1162
|
+
Get all workspace permissions.
|
|
1163
|
+
|
|
1164
|
+
Returns a list of all available workspace permissions.
|
|
1165
|
+
|
|
1166
|
+
Returns:
|
|
1167
|
+
List[Permission]: A list of Permission objects representing the available workspace permissions.
|
|
1168
|
+
|
|
1169
|
+
Raises:
|
|
1170
|
+
HTTPException: If there is an error retrieving the workspace permissions.
|
|
1171
|
+
|
|
1172
|
+
Parameters
|
|
1173
|
+
----------
|
|
1174
|
+
request_options : typing.Optional[RequestOptions]
|
|
1175
|
+
Request-specific configuration.
|
|
1176
|
+
|
|
1177
|
+
Returns
|
|
1178
|
+
-------
|
|
1179
|
+
typing.List[Permission]
|
|
1180
|
+
Successful Response
|
|
1181
|
+
|
|
1182
|
+
Examples
|
|
1183
|
+
--------
|
|
1184
|
+
from agenta import AgentaApi
|
|
1185
|
+
|
|
1186
|
+
client = AgentaApi(
|
|
1187
|
+
api_key="YOUR_API_KEY",
|
|
1188
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1189
|
+
)
|
|
1190
|
+
client.get_all_workspace_permissions()
|
|
1191
|
+
"""
|
|
1192
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1193
|
+
"workspaces/permissions",
|
|
1194
|
+
method="GET",
|
|
1195
|
+
request_options=request_options,
|
|
1196
|
+
)
|
|
1197
|
+
try:
|
|
1198
|
+
if 200 <= _response.status_code < 300:
|
|
1199
|
+
return typing.cast(
|
|
1200
|
+
typing.List[Permission],
|
|
1201
|
+
parse_obj_as(
|
|
1202
|
+
type_=typing.List[Permission], # type: ignore
|
|
1203
|
+
object_=_response.json(),
|
|
1204
|
+
),
|
|
1205
|
+
)
|
|
1206
|
+
_response_json = _response.json()
|
|
1207
|
+
except JSONDecodeError:
|
|
1208
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1209
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1210
|
+
|
|
1211
|
+
def assign_role_to_user(
|
|
1212
|
+
self,
|
|
1213
|
+
workspace_id: str,
|
|
1214
|
+
*,
|
|
1215
|
+
email: str,
|
|
1216
|
+
organization_id: str,
|
|
1217
|
+
role: typing.Optional[str] = OMIT,
|
|
1218
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1219
|
+
) -> bool:
|
|
1220
|
+
"""
|
|
1221
|
+
Assigns a role to a user in a workspace.
|
|
1222
|
+
|
|
1223
|
+
Args:
|
|
1224
|
+
payload (UserRole): The payload containing the organization id, user email, and role to assign.
|
|
1225
|
+
workspace_id (str): The ID of the workspace.
|
|
1226
|
+
request (Request): The FastAPI request object.
|
|
1227
|
+
|
|
1228
|
+
Returns:
|
|
1229
|
+
bool: True if the role was successfully assigned, False otherwise.
|
|
1230
|
+
|
|
1231
|
+
Raises:
|
|
1232
|
+
HTTPException: If the user does not have permission to perform this action.
|
|
1233
|
+
HTTPException: If there is an error assigning the role to the user.
|
|
1234
|
+
|
|
1235
|
+
Parameters
|
|
1236
|
+
----------
|
|
1237
|
+
workspace_id : str
|
|
1238
|
+
|
|
1239
|
+
email : str
|
|
1240
|
+
|
|
1241
|
+
organization_id : str
|
|
1242
|
+
|
|
1243
|
+
role : typing.Optional[str]
|
|
1244
|
+
|
|
1245
|
+
request_options : typing.Optional[RequestOptions]
|
|
1246
|
+
Request-specific configuration.
|
|
1247
|
+
|
|
1248
|
+
Returns
|
|
1249
|
+
-------
|
|
1250
|
+
bool
|
|
1251
|
+
Successful Response
|
|
1252
|
+
|
|
1253
|
+
Examples
|
|
1254
|
+
--------
|
|
1255
|
+
from agenta import AgentaApi
|
|
1256
|
+
|
|
1257
|
+
client = AgentaApi(
|
|
1258
|
+
api_key="YOUR_API_KEY",
|
|
1259
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1260
|
+
)
|
|
1261
|
+
client.assign_role_to_user(
|
|
1262
|
+
workspace_id="workspace_id",
|
|
1263
|
+
email="email",
|
|
1264
|
+
organization_id="organization_id",
|
|
1265
|
+
)
|
|
1266
|
+
"""
|
|
1267
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1268
|
+
f"workspaces/{jsonable_encoder(workspace_id)}/roles",
|
|
1269
|
+
method="POST",
|
|
1270
|
+
json={
|
|
1271
|
+
"email": email,
|
|
1272
|
+
"organization_id": organization_id,
|
|
1273
|
+
"role": role,
|
|
1274
|
+
},
|
|
1275
|
+
headers={
|
|
1276
|
+
"content-type": "application/json",
|
|
1277
|
+
},
|
|
1278
|
+
request_options=request_options,
|
|
1279
|
+
omit=OMIT,
|
|
1280
|
+
)
|
|
1281
|
+
try:
|
|
1282
|
+
if 200 <= _response.status_code < 300:
|
|
1283
|
+
return typing.cast(
|
|
1284
|
+
bool,
|
|
1285
|
+
parse_obj_as(
|
|
1286
|
+
type_=bool, # type: ignore
|
|
1287
|
+
object_=_response.json(),
|
|
1288
|
+
),
|
|
1289
|
+
)
|
|
1290
|
+
if _response.status_code == 422:
|
|
1291
|
+
raise UnprocessableEntityError(
|
|
1292
|
+
typing.cast(
|
|
1293
|
+
HttpValidationError,
|
|
1294
|
+
parse_obj_as(
|
|
1295
|
+
type_=HttpValidationError, # type: ignore
|
|
1296
|
+
object_=_response.json(),
|
|
1297
|
+
),
|
|
1298
|
+
)
|
|
1299
|
+
)
|
|
1300
|
+
_response_json = _response.json()
|
|
1301
|
+
except JSONDecodeError:
|
|
1302
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1303
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1304
|
+
|
|
1305
|
+
def unassign_role_from_user(
|
|
1306
|
+
self,
|
|
1307
|
+
workspace_id: str,
|
|
1308
|
+
*,
|
|
1309
|
+
email: str,
|
|
1310
|
+
org_id: str,
|
|
1311
|
+
role: str,
|
|
1312
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1313
|
+
) -> typing.Optional[typing.Any]:
|
|
1314
|
+
"""
|
|
1315
|
+
Delete a role assignment from a user in a workspace.
|
|
1316
|
+
|
|
1317
|
+
Args:
|
|
1318
|
+
workspace_id (str): The ID of the workspace.
|
|
1319
|
+
email (str): The email of the user to remove the role from.
|
|
1320
|
+
org_id (str): The ID of the organization.
|
|
1321
|
+
role (str): The role to remove from the user.
|
|
1322
|
+
request (Request): The FastAPI request object.
|
|
1323
|
+
|
|
1324
|
+
Returns:
|
|
1325
|
+
bool: True if the role assignment was successfully deleted.
|
|
1326
|
+
|
|
1327
|
+
Raises:
|
|
1328
|
+
HTTPException: If there is an error in the request or the user does not have permission to perform the action.
|
|
1329
|
+
HTTPException: If there is an error in updating the user's roles.
|
|
1330
|
+
|
|
1331
|
+
Parameters
|
|
1332
|
+
----------
|
|
1333
|
+
workspace_id : str
|
|
1334
|
+
|
|
1335
|
+
email : str
|
|
1336
|
+
|
|
1337
|
+
org_id : str
|
|
1338
|
+
|
|
1339
|
+
role : str
|
|
1340
|
+
|
|
1341
|
+
request_options : typing.Optional[RequestOptions]
|
|
1342
|
+
Request-specific configuration.
|
|
1343
|
+
|
|
1344
|
+
Returns
|
|
1345
|
+
-------
|
|
1346
|
+
typing.Optional[typing.Any]
|
|
1347
|
+
Successful Response
|
|
1348
|
+
|
|
1349
|
+
Examples
|
|
1350
|
+
--------
|
|
1351
|
+
from agenta import AgentaApi
|
|
1352
|
+
|
|
1353
|
+
client = AgentaApi(
|
|
1354
|
+
api_key="YOUR_API_KEY",
|
|
1355
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1356
|
+
)
|
|
1357
|
+
client.unassign_role_from_user(
|
|
1358
|
+
workspace_id="workspace_id",
|
|
1359
|
+
email="email",
|
|
1360
|
+
org_id="org_id",
|
|
1361
|
+
role="role",
|
|
1362
|
+
)
|
|
1363
|
+
"""
|
|
1364
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1365
|
+
f"workspaces/{jsonable_encoder(workspace_id)}/roles",
|
|
1366
|
+
method="DELETE",
|
|
1367
|
+
params={
|
|
1368
|
+
"email": email,
|
|
1369
|
+
"org_id": org_id,
|
|
1370
|
+
"role": role,
|
|
1371
|
+
},
|
|
1372
|
+
request_options=request_options,
|
|
1373
|
+
)
|
|
1374
|
+
try:
|
|
1375
|
+
if 200 <= _response.status_code < 300:
|
|
1376
|
+
return typing.cast(
|
|
1377
|
+
typing.Optional[typing.Any],
|
|
1378
|
+
parse_obj_as(
|
|
1379
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1380
|
+
object_=_response.json(),
|
|
1381
|
+
),
|
|
1382
|
+
)
|
|
1383
|
+
if _response.status_code == 422:
|
|
1384
|
+
raise UnprocessableEntityError(
|
|
1385
|
+
typing.cast(
|
|
1386
|
+
HttpValidationError,
|
|
1387
|
+
parse_obj_as(
|
|
1388
|
+
type_=HttpValidationError, # type: ignore
|
|
1389
|
+
object_=_response.json(),
|
|
1390
|
+
),
|
|
1391
|
+
)
|
|
1392
|
+
)
|
|
1393
|
+
_response_json = _response.json()
|
|
1394
|
+
except JSONDecodeError:
|
|
1395
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1396
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1397
|
+
|
|
1398
|
+
def remove_user_from_workspace(
|
|
1399
|
+
self,
|
|
1400
|
+
workspace_id: str,
|
|
1401
|
+
*,
|
|
1402
|
+
org_id: str,
|
|
1403
|
+
email: str,
|
|
1404
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1405
|
+
) -> WorkspaceResponse:
|
|
1406
|
+
"""
|
|
1407
|
+
Remove a user from a workspace.
|
|
1408
|
+
|
|
1409
|
+
Parameters:
|
|
1410
|
+
- payload (UserRole): The payload containing the user email and organization ID.
|
|
1411
|
+
- workspace_id (str): The ID of the workspace.
|
|
1412
|
+
- request (Request): The FastAPI request object.
|
|
1413
|
+
|
|
1414
|
+
Returns:
|
|
1415
|
+
- WorkspaceResponse: The updated workspace.
|
|
1416
|
+
|
|
1417
|
+
Raises:
|
|
1418
|
+
- HTTPException: If the user does not have permission to perform this action.
|
|
1419
|
+
- HTTPException: If there is an error during the removal process.
|
|
1420
|
+
|
|
1421
|
+
Parameters
|
|
1422
|
+
----------
|
|
1423
|
+
workspace_id : str
|
|
1424
|
+
|
|
1425
|
+
org_id : str
|
|
1426
|
+
|
|
1427
|
+
email : str
|
|
1428
|
+
|
|
1429
|
+
request_options : typing.Optional[RequestOptions]
|
|
1430
|
+
Request-specific configuration.
|
|
1431
|
+
|
|
1432
|
+
Returns
|
|
1433
|
+
-------
|
|
1434
|
+
WorkspaceResponse
|
|
1435
|
+
Successful Response
|
|
1436
|
+
|
|
1437
|
+
Examples
|
|
1438
|
+
--------
|
|
1439
|
+
from agenta import AgentaApi
|
|
1440
|
+
|
|
1441
|
+
client = AgentaApi(
|
|
1442
|
+
api_key="YOUR_API_KEY",
|
|
1443
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1444
|
+
)
|
|
1445
|
+
client.remove_user_from_workspace(
|
|
1446
|
+
workspace_id="workspace_id",
|
|
1447
|
+
org_id="org_id",
|
|
1448
|
+
email="email",
|
|
1449
|
+
)
|
|
1450
|
+
"""
|
|
1451
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1452
|
+
f"workspaces/{jsonable_encoder(workspace_id)}/users",
|
|
1453
|
+
method="DELETE",
|
|
1454
|
+
params={
|
|
1455
|
+
"org_id": org_id,
|
|
1456
|
+
"email": email,
|
|
1457
|
+
},
|
|
1458
|
+
request_options=request_options,
|
|
1459
|
+
)
|
|
1460
|
+
try:
|
|
1461
|
+
if 200 <= _response.status_code < 300:
|
|
1462
|
+
return typing.cast(
|
|
1463
|
+
WorkspaceResponse,
|
|
1464
|
+
parse_obj_as(
|
|
1465
|
+
type_=WorkspaceResponse, # type: ignore
|
|
1466
|
+
object_=_response.json(),
|
|
1467
|
+
),
|
|
1468
|
+
)
|
|
1469
|
+
if _response.status_code == 422:
|
|
1470
|
+
raise UnprocessableEntityError(
|
|
1471
|
+
typing.cast(
|
|
1472
|
+
HttpValidationError,
|
|
1473
|
+
parse_obj_as(
|
|
1474
|
+
type_=HttpValidationError, # type: ignore
|
|
1475
|
+
object_=_response.json(),
|
|
1476
|
+
),
|
|
1477
|
+
)
|
|
1478
|
+
)
|
|
1479
|
+
_response_json = _response.json()
|
|
1480
|
+
except JSONDecodeError:
|
|
1481
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1482
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1483
|
+
|
|
1484
|
+
def health_check(
|
|
1485
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
1486
|
+
) -> typing.Optional[typing.Any]:
|
|
1487
|
+
"""
|
|
1488
|
+
Parameters
|
|
1489
|
+
----------
|
|
1490
|
+
request_options : typing.Optional[RequestOptions]
|
|
1491
|
+
Request-specific configuration.
|
|
1492
|
+
|
|
1493
|
+
Returns
|
|
1494
|
+
-------
|
|
1495
|
+
typing.Optional[typing.Any]
|
|
1496
|
+
Successful Response
|
|
1497
|
+
|
|
1498
|
+
Examples
|
|
1499
|
+
--------
|
|
1500
|
+
from agenta import AgentaApi
|
|
1501
|
+
|
|
1502
|
+
client = AgentaApi(
|
|
1503
|
+
api_key="YOUR_API_KEY",
|
|
1504
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1505
|
+
)
|
|
1506
|
+
client.health_check()
|
|
1507
|
+
"""
|
|
1508
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1509
|
+
"health",
|
|
1510
|
+
method="GET",
|
|
1511
|
+
request_options=request_options,
|
|
1512
|
+
)
|
|
1513
|
+
try:
|
|
1514
|
+
if 200 <= _response.status_code < 300:
|
|
1515
|
+
return typing.cast(
|
|
1516
|
+
typing.Optional[typing.Any],
|
|
1517
|
+
parse_obj_as(
|
|
1518
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1519
|
+
object_=_response.json(),
|
|
1520
|
+
),
|
|
1521
|
+
)
|
|
1522
|
+
_response_json = _response.json()
|
|
1523
|
+
except JSONDecodeError:
|
|
1524
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1525
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1526
|
+
|
|
1527
|
+
def fetch_user_profile(
|
|
1528
|
+
self,
|
|
1529
|
+
*,
|
|
1530
|
+
user_id: typing.Optional[str] = None,
|
|
1531
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1532
|
+
) -> typing.Optional[typing.Any]:
|
|
1533
|
+
"""
|
|
1534
|
+
Parameters
|
|
1535
|
+
----------
|
|
1536
|
+
user_id : typing.Optional[str]
|
|
1537
|
+
|
|
1538
|
+
request_options : typing.Optional[RequestOptions]
|
|
1539
|
+
Request-specific configuration.
|
|
1540
|
+
|
|
1541
|
+
Returns
|
|
1542
|
+
-------
|
|
1543
|
+
typing.Optional[typing.Any]
|
|
1544
|
+
Successful Response
|
|
1545
|
+
|
|
1546
|
+
Examples
|
|
1547
|
+
--------
|
|
1548
|
+
from agenta import AgentaApi
|
|
1549
|
+
|
|
1550
|
+
client = AgentaApi(
|
|
1551
|
+
api_key="YOUR_API_KEY",
|
|
1552
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1553
|
+
)
|
|
1554
|
+
client.fetch_user_profile()
|
|
1555
|
+
"""
|
|
1556
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1557
|
+
"profile",
|
|
1558
|
+
method="GET",
|
|
1559
|
+
params={
|
|
1560
|
+
"user_id": user_id,
|
|
1561
|
+
},
|
|
1562
|
+
request_options=request_options,
|
|
1563
|
+
)
|
|
1564
|
+
try:
|
|
1565
|
+
if 200 <= _response.status_code < 300:
|
|
1566
|
+
return typing.cast(
|
|
1567
|
+
typing.Optional[typing.Any],
|
|
1568
|
+
parse_obj_as(
|
|
1569
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1570
|
+
object_=_response.json(),
|
|
1571
|
+
),
|
|
1572
|
+
)
|
|
1573
|
+
if _response.status_code == 422:
|
|
1574
|
+
raise UnprocessableEntityError(
|
|
1575
|
+
typing.cast(
|
|
1576
|
+
HttpValidationError,
|
|
1577
|
+
parse_obj_as(
|
|
1578
|
+
type_=HttpValidationError, # type: ignore
|
|
1579
|
+
object_=_response.json(),
|
|
1580
|
+
),
|
|
1581
|
+
)
|
|
1582
|
+
)
|
|
1583
|
+
_response_json = _response.json()
|
|
1584
|
+
except JSONDecodeError:
|
|
1585
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1586
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
31
1587
|
|
|
32
|
-
Returns:
|
|
33
|
-
str: The ID of the base.
|
|
34
1588
|
|
|
35
|
-
|
|
36
|
-
APIRequestError: If the request to get the base fails or the base does not exist on the server.
|
|
1589
|
+
class AsyncAgentaApi:
|
|
37
1590
|
"""
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1591
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
1592
|
+
|
|
1593
|
+
Parameters
|
|
1594
|
+
----------
|
|
1595
|
+
base_url : str
|
|
1596
|
+
The base url to use for requests from the client.
|
|
1597
|
+
|
|
1598
|
+
api_key : str
|
|
1599
|
+
timeout : typing.Optional[float]
|
|
1600
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
1601
|
+
|
|
1602
|
+
follow_redirects : typing.Optional[bool]
|
|
1603
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
1604
|
+
|
|
1605
|
+
httpx_client : typing.Optional[httpx.AsyncClient]
|
|
1606
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
1607
|
+
|
|
1608
|
+
Examples
|
|
1609
|
+
--------
|
|
1610
|
+
from agenta import AsyncAgentaApi
|
|
1611
|
+
|
|
1612
|
+
client = AsyncAgentaApi(
|
|
1613
|
+
api_key="YOUR_API_KEY",
|
|
1614
|
+
base_url="https://yourhost.com/path/to/api",
|
|
42
1615
|
)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1616
|
+
"""
|
|
1617
|
+
|
|
1618
|
+
def __init__(
|
|
1619
|
+
self,
|
|
1620
|
+
*,
|
|
1621
|
+
base_url: str,
|
|
1622
|
+
api_key: str,
|
|
1623
|
+
timeout: typing.Optional[float] = None,
|
|
1624
|
+
follow_redirects: typing.Optional[bool] = True,
|
|
1625
|
+
httpx_client: typing.Optional[httpx.AsyncClient] = None,
|
|
1626
|
+
):
|
|
1627
|
+
_defaulted_timeout = (
|
|
1628
|
+
timeout if timeout is not None else 60 if httpx_client is None else None
|
|
1629
|
+
)
|
|
1630
|
+
self._client_wrapper = AsyncClientWrapper(
|
|
1631
|
+
base_url=base_url,
|
|
1632
|
+
api_key=api_key,
|
|
1633
|
+
httpx_client=httpx_client
|
|
1634
|
+
if httpx_client is not None
|
|
1635
|
+
else httpx.AsyncClient(
|
|
1636
|
+
timeout=_defaulted_timeout, follow_redirects=follow_redirects
|
|
1637
|
+
)
|
|
1638
|
+
if follow_redirects is not None
|
|
1639
|
+
else httpx.AsyncClient(timeout=_defaulted_timeout),
|
|
1640
|
+
timeout=_defaulted_timeout,
|
|
1641
|
+
)
|
|
1642
|
+
self.admin = AsyncAdminClient(client_wrapper=self._client_wrapper)
|
|
1643
|
+
self.vault = AsyncVaultClient(client_wrapper=self._client_wrapper)
|
|
1644
|
+
self.access_control = AsyncAccessControlClient(
|
|
1645
|
+
client_wrapper=self._client_wrapper
|
|
1646
|
+
)
|
|
1647
|
+
self.scopes = AsyncScopesClient(client_wrapper=self._client_wrapper)
|
|
1648
|
+
self.apps = AsyncAppsClient(client_wrapper=self._client_wrapper)
|
|
1649
|
+
self.variants = AsyncVariantsClient(client_wrapper=self._client_wrapper)
|
|
1650
|
+
self.evaluations = AsyncEvaluationsClient(client_wrapper=self._client_wrapper)
|
|
1651
|
+
self.human_evaluations = AsyncHumanEvaluationsClient(
|
|
1652
|
+
client_wrapper=self._client_wrapper
|
|
47
1653
|
)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1654
|
+
self.evaluators = AsyncEvaluatorsClient(client_wrapper=self._client_wrapper)
|
|
1655
|
+
self.testsets = AsyncTestsetsClient(client_wrapper=self._client_wrapper)
|
|
1656
|
+
self.containers = AsyncContainersClient(client_wrapper=self._client_wrapper)
|
|
1657
|
+
self.environments = AsyncEnvironmentsClient(client_wrapper=self._client_wrapper)
|
|
1658
|
+
self.bases = AsyncBasesClient(client_wrapper=self._client_wrapper)
|
|
1659
|
+
self.configs = AsyncConfigsClient(client_wrapper=self._client_wrapper)
|
|
1660
|
+
self.observability = AsyncObservabilityClient(
|
|
1661
|
+
client_wrapper=self._client_wrapper
|
|
51
1662
|
)
|
|
52
|
-
else:
|
|
53
|
-
return response.json()[0]["base_id"]
|
|
54
1663
|
|
|
1664
|
+
async def list_api_keys(
|
|
1665
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
1666
|
+
) -> typing.List[ListApiKeysResponse]:
|
|
1667
|
+
"""
|
|
1668
|
+
List all API keys associated with the authenticated user.
|
|
55
1669
|
|
|
56
|
-
|
|
57
|
-
|
|
1670
|
+
Args:
|
|
1671
|
+
request (Request): The incoming request object.
|
|
58
1672
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
host (str): Hostname of the server
|
|
62
|
-
api_key (str): The API key to use for the request.
|
|
63
|
-
"""
|
|
1673
|
+
Returns:
|
|
1674
|
+
List[ListAPIKeysResponse]: A list of API Keys associated with the user.
|
|
64
1675
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
1676
|
+
Parameters
|
|
1677
|
+
----------
|
|
1678
|
+
request_options : typing.Optional[RequestOptions]
|
|
1679
|
+
Request-specific configuration.
|
|
1680
|
+
|
|
1681
|
+
Returns
|
|
1682
|
+
-------
|
|
1683
|
+
typing.List[ListApiKeysResponse]
|
|
1684
|
+
Successful Response
|
|
1685
|
+
|
|
1686
|
+
Examples
|
|
1687
|
+
--------
|
|
1688
|
+
import asyncio
|
|
1689
|
+
|
|
1690
|
+
from agenta import AsyncAgentaApi
|
|
1691
|
+
|
|
1692
|
+
client = AsyncAgentaApi(
|
|
1693
|
+
api_key="YOUR_API_KEY",
|
|
1694
|
+
base_url="https://yourhost.com/path/to/api",
|
|
74
1695
|
)
|
|
75
|
-
if len(response.json()) == 0:
|
|
76
|
-
raise APIRequestError(f"App with name {app_name} does not exist on the server.")
|
|
77
|
-
else:
|
|
78
|
-
return response.json()[0]["app_id"] # only one app should exist for that name
|
|
79
1696
|
|
|
80
1697
|
|
|
81
|
-
def
|
|
82
|
-
|
|
1698
|
+
async def main() -> None:
|
|
1699
|
+
await client.list_api_keys()
|
|
83
1700
|
|
|
84
|
-
Args:
|
|
85
|
-
app_name (str): Name of the app
|
|
86
|
-
host (str): Hostname of the server
|
|
87
|
-
api_key (str): The API key to use for the request.
|
|
88
|
-
"""
|
|
89
1701
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
1702
|
+
asyncio.run(main())
|
|
1703
|
+
"""
|
|
1704
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1705
|
+
"keys",
|
|
1706
|
+
method="GET",
|
|
1707
|
+
request_options=request_options,
|
|
1708
|
+
)
|
|
1709
|
+
try:
|
|
1710
|
+
if 200 <= _response.status_code < 300:
|
|
1711
|
+
return typing.cast(
|
|
1712
|
+
typing.List[ListApiKeysResponse],
|
|
1713
|
+
parse_obj_as(
|
|
1714
|
+
type_=typing.List[ListApiKeysResponse], # type: ignore
|
|
1715
|
+
object_=_response.json(),
|
|
1716
|
+
),
|
|
1717
|
+
)
|
|
1718
|
+
_response_json = _response.json()
|
|
1719
|
+
except JSONDecodeError:
|
|
1720
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1721
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1722
|
+
|
|
1723
|
+
async def create_api_key(
|
|
1724
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
1725
|
+
) -> str:
|
|
1726
|
+
"""
|
|
1727
|
+
Creates an API key for a user.
|
|
1728
|
+
|
|
1729
|
+
Args:
|
|
1730
|
+
request (Request): The request object containing the user ID in the request state.
|
|
1731
|
+
|
|
1732
|
+
Returns:
|
|
1733
|
+
str: The created API key.
|
|
1734
|
+
|
|
1735
|
+
Parameters
|
|
1736
|
+
----------
|
|
1737
|
+
request_options : typing.Optional[RequestOptions]
|
|
1738
|
+
Request-specific configuration.
|
|
1739
|
+
|
|
1740
|
+
Returns
|
|
1741
|
+
-------
|
|
1742
|
+
str
|
|
1743
|
+
Successful Response
|
|
1744
|
+
|
|
1745
|
+
Examples
|
|
1746
|
+
--------
|
|
1747
|
+
import asyncio
|
|
1748
|
+
|
|
1749
|
+
from agenta import AsyncAgentaApi
|
|
1750
|
+
|
|
1751
|
+
client = AsyncAgentaApi(
|
|
1752
|
+
api_key="YOUR_API_KEY",
|
|
1753
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1754
|
+
)
|
|
1755
|
+
|
|
1756
|
+
|
|
1757
|
+
async def main() -> None:
|
|
1758
|
+
await client.create_api_key()
|
|
1759
|
+
|
|
143
1760
|
|
|
144
|
-
|
|
1761
|
+
asyncio.run(main())
|
|
1762
|
+
"""
|
|
1763
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1764
|
+
"keys",
|
|
1765
|
+
method="POST",
|
|
1766
|
+
request_options=request_options,
|
|
1767
|
+
)
|
|
145
1768
|
try:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1769
|
+
if 200 <= _response.status_code < 300:
|
|
1770
|
+
return typing.cast(
|
|
1771
|
+
str,
|
|
1772
|
+
parse_obj_as(
|
|
1773
|
+
type_=str, # type: ignore
|
|
1774
|
+
object_=_response.json(),
|
|
1775
|
+
),
|
|
1776
|
+
)
|
|
1777
|
+
_response_json = _response.json()
|
|
1778
|
+
except JSONDecodeError:
|
|
1779
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1780
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1781
|
+
|
|
1782
|
+
async def delete_api_key(
|
|
1783
|
+
self,
|
|
1784
|
+
key_prefix: str,
|
|
1785
|
+
*,
|
|
1786
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1787
|
+
) -> typing.Dict[str, typing.Optional[typing.Any]]:
|
|
1788
|
+
"""
|
|
1789
|
+
Delete an API key with the given key prefix for the authenticated user.
|
|
1790
|
+
|
|
1791
|
+
Args:
|
|
1792
|
+
key_prefix (str): The prefix of the API key to be deleted.
|
|
1793
|
+
request (Request): The incoming request object.
|
|
1794
|
+
|
|
1795
|
+
Returns:
|
|
1796
|
+
dict: A dictionary containing a success message upon successful deletion.
|
|
1797
|
+
|
|
1798
|
+
Raises:
|
|
1799
|
+
HTTPException: If the API key is not found or does not belong to the user.
|
|
1800
|
+
|
|
1801
|
+
Parameters
|
|
1802
|
+
----------
|
|
1803
|
+
key_prefix : str
|
|
1804
|
+
|
|
1805
|
+
request_options : typing.Optional[RequestOptions]
|
|
1806
|
+
Request-specific configuration.
|
|
1807
|
+
|
|
1808
|
+
Returns
|
|
1809
|
+
-------
|
|
1810
|
+
typing.Dict[str, typing.Optional[typing.Any]]
|
|
1811
|
+
Successful Response
|
|
1812
|
+
|
|
1813
|
+
Examples
|
|
1814
|
+
--------
|
|
1815
|
+
import asyncio
|
|
1816
|
+
|
|
1817
|
+
from agenta import AsyncAgentaApi
|
|
1818
|
+
|
|
1819
|
+
client = AsyncAgentaApi(
|
|
1820
|
+
api_key="YOUR_API_KEY",
|
|
1821
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1822
|
+
)
|
|
1823
|
+
|
|
1824
|
+
|
|
1825
|
+
async def main() -> None:
|
|
1826
|
+
await client.delete_api_key(
|
|
1827
|
+
key_prefix="key_prefix",
|
|
151
1828
|
)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
1829
|
+
|
|
1830
|
+
|
|
1831
|
+
asyncio.run(main())
|
|
1832
|
+
"""
|
|
1833
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1834
|
+
f"keys/{jsonable_encoder(key_prefix)}",
|
|
1835
|
+
method="DELETE",
|
|
1836
|
+
request_options=request_options,
|
|
1837
|
+
)
|
|
1838
|
+
try:
|
|
1839
|
+
if 200 <= _response.status_code < 300:
|
|
1840
|
+
return typing.cast(
|
|
1841
|
+
typing.Dict[str, typing.Optional[typing.Any]],
|
|
1842
|
+
parse_obj_as(
|
|
1843
|
+
type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore
|
|
1844
|
+
object_=_response.json(),
|
|
1845
|
+
),
|
|
1846
|
+
)
|
|
1847
|
+
if _response.status_code == 422:
|
|
1848
|
+
raise UnprocessableEntityError(
|
|
1849
|
+
typing.cast(
|
|
1850
|
+
HttpValidationError,
|
|
1851
|
+
parse_obj_as(
|
|
1852
|
+
type_=HttpValidationError, # type: ignore
|
|
1853
|
+
object_=_response.json(),
|
|
1854
|
+
),
|
|
164
1855
|
)
|
|
165
1856
|
)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
1857
|
+
_response_json = _response.json()
|
|
1858
|
+
except JSONDecodeError:
|
|
1859
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1860
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1861
|
+
|
|
1862
|
+
async def validate_api_key(
|
|
1863
|
+
self,
|
|
1864
|
+
key_prefix: str,
|
|
1865
|
+
*,
|
|
1866
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1867
|
+
) -> bool:
|
|
1868
|
+
"""
|
|
1869
|
+
This Function is called by the CLI and is used to validate an API key provided by a user in agenta init setup.
|
|
1870
|
+
Returns:
|
|
1871
|
+
bool: True. If the request reaches this point, the API key is valid.
|
|
1872
|
+
|
|
1873
|
+
Parameters
|
|
1874
|
+
----------
|
|
1875
|
+
key_prefix : str
|
|
1876
|
+
|
|
1877
|
+
request_options : typing.Optional[RequestOptions]
|
|
1878
|
+
Request-specific configuration.
|
|
1879
|
+
|
|
1880
|
+
Returns
|
|
1881
|
+
-------
|
|
1882
|
+
bool
|
|
1883
|
+
Successful Response
|
|
1884
|
+
|
|
1885
|
+
Examples
|
|
1886
|
+
--------
|
|
1887
|
+
import asyncio
|
|
1888
|
+
|
|
1889
|
+
from agenta import AsyncAgentaApi
|
|
1890
|
+
|
|
1891
|
+
client = AsyncAgentaApi(
|
|
1892
|
+
api_key="YOUR_API_KEY",
|
|
1893
|
+
base_url="https://yourhost.com/path/to/api",
|
|
1894
|
+
)
|
|
1895
|
+
|
|
1896
|
+
|
|
1897
|
+
async def main() -> None:
|
|
1898
|
+
await client.validate_api_key(
|
|
1899
|
+
key_prefix="key_prefix",
|
|
169
1900
|
)
|
|
170
1901
|
|
|
171
1902
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
1903
|
+
asyncio.run(main())
|
|
1904
|
+
"""
|
|
1905
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1906
|
+
f"keys/{jsonable_encoder(key_prefix)}/validate",
|
|
1907
|
+
method="GET",
|
|
1908
|
+
request_options=request_options,
|
|
1909
|
+
)
|
|
1910
|
+
try:
|
|
1911
|
+
if 200 <= _response.status_code < 300:
|
|
1912
|
+
return typing.cast(
|
|
1913
|
+
bool,
|
|
1914
|
+
parse_obj_as(
|
|
1915
|
+
type_=bool, # type: ignore
|
|
1916
|
+
object_=_response.json(),
|
|
1917
|
+
),
|
|
1918
|
+
)
|
|
1919
|
+
if _response.status_code == 422:
|
|
1920
|
+
raise UnprocessableEntityError(
|
|
1921
|
+
typing.cast(
|
|
1922
|
+
HttpValidationError,
|
|
1923
|
+
parse_obj_as(
|
|
1924
|
+
type_=HttpValidationError, # type: ignore
|
|
1925
|
+
object_=_response.json(),
|
|
1926
|
+
),
|
|
1927
|
+
)
|
|
1928
|
+
)
|
|
1929
|
+
_response_json = _response.json()
|
|
1930
|
+
except JSONDecodeError:
|
|
1931
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1932
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
180
1933
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
1934
|
+
async def list_organizations(
|
|
1935
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
1936
|
+
) -> typing.List[Organization]:
|
|
1937
|
+
"""
|
|
1938
|
+
Returns a list of organizations associated with the user's session.
|
|
186
1939
|
|
|
187
|
-
|
|
188
|
-
|
|
1940
|
+
Args:
|
|
1941
|
+
stoken_session (SessionContainer): The user's session token.
|
|
189
1942
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
"""
|
|
193
|
-
payload = {}
|
|
194
|
-
payload["action"] = {"action": "START"}
|
|
195
|
-
if env_vars:
|
|
196
|
-
payload["env_vars"] = env_vars
|
|
197
|
-
try:
|
|
198
|
-
response = requests.put(
|
|
199
|
-
f"{host}/{BACKEND_URL_SUFFIX}/variants/{variant_id}/",
|
|
200
|
-
json=payload,
|
|
201
|
-
headers={"Authorization": api_key} if api_key is not None else None,
|
|
202
|
-
timeout=600,
|
|
203
|
-
)
|
|
204
|
-
if response.status_code == 404:
|
|
205
|
-
raise APIRequestError(
|
|
206
|
-
f"404: Variant with ID {variant_id} does not exist on the server."
|
|
207
|
-
)
|
|
208
|
-
elif response.status_code != 200:
|
|
209
|
-
error_message = response.text
|
|
210
|
-
raise APIRequestError(
|
|
211
|
-
f"Request to start variant endpoint failed with status code {response.status_code} and error message: {error_message}."
|
|
212
|
-
)
|
|
213
|
-
return response.json().get("uri", "")
|
|
1943
|
+
Returns:
|
|
1944
|
+
list[Organization]: A list of organizations associated with the user's session.
|
|
214
1945
|
|
|
215
|
-
|
|
216
|
-
|
|
1946
|
+
Raises:
|
|
1947
|
+
HTTPException: If there is an error retrieving the organizations from the database.
|
|
217
1948
|
|
|
1949
|
+
Parameters
|
|
1950
|
+
----------
|
|
1951
|
+
request_options : typing.Optional[RequestOptions]
|
|
1952
|
+
Request-specific configuration.
|
|
218
1953
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
1954
|
+
Returns
|
|
1955
|
+
-------
|
|
1956
|
+
typing.List[Organization]
|
|
1957
|
+
Successful Response
|
|
222
1958
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
api_key (str): The API key to use for the request.
|
|
1959
|
+
Examples
|
|
1960
|
+
--------
|
|
1961
|
+
import asyncio
|
|
227
1962
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
headers={"Authorization": api_key} if api_key is not None else None,
|
|
234
|
-
timeout=600,
|
|
235
|
-
)
|
|
236
|
-
# Check for successful request
|
|
237
|
-
if response.status_code == 403:
|
|
238
|
-
raise APIRequestError(
|
|
239
|
-
f"No app by id {app_id} exists or you do not have access to it."
|
|
1963
|
+
from agenta import AsyncAgentaApi
|
|
1964
|
+
|
|
1965
|
+
client = AsyncAgentaApi(
|
|
1966
|
+
api_key="YOUR_API_KEY",
|
|
1967
|
+
base_url="https://yourhost.com/path/to/api",
|
|
240
1968
|
)
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
1969
|
+
|
|
1970
|
+
|
|
1971
|
+
async def main() -> None:
|
|
1972
|
+
await client.list_organizations()
|
|
1973
|
+
|
|
1974
|
+
|
|
1975
|
+
asyncio.run(main())
|
|
1976
|
+
"""
|
|
1977
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1978
|
+
"organizations",
|
|
1979
|
+
method="GET",
|
|
1980
|
+
request_options=request_options,
|
|
244
1981
|
)
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
1982
|
+
try:
|
|
1983
|
+
if 200 <= _response.status_code < 300:
|
|
1984
|
+
return typing.cast(
|
|
1985
|
+
typing.List[Organization],
|
|
1986
|
+
parse_obj_as(
|
|
1987
|
+
type_=typing.List[Organization], # type: ignore
|
|
1988
|
+
object_=_response.json(),
|
|
1989
|
+
),
|
|
1990
|
+
)
|
|
1991
|
+
_response_json = _response.json()
|
|
1992
|
+
except JSONDecodeError:
|
|
1993
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1994
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1995
|
+
|
|
1996
|
+
async def create_organization(
|
|
1997
|
+
self,
|
|
1998
|
+
*,
|
|
1999
|
+
name: str,
|
|
2000
|
+
owner: str,
|
|
2001
|
+
description: typing.Optional[str] = OMIT,
|
|
2002
|
+
type: typing.Optional[str] = OMIT,
|
|
2003
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2004
|
+
) -> typing.Optional[typing.Any]:
|
|
2005
|
+
"""
|
|
2006
|
+
Parameters
|
|
2007
|
+
----------
|
|
2008
|
+
name : str
|
|
2009
|
+
|
|
2010
|
+
owner : str
|
|
2011
|
+
|
|
2012
|
+
description : typing.Optional[str]
|
|
2013
|
+
|
|
2014
|
+
type : typing.Optional[str]
|
|
2015
|
+
|
|
2016
|
+
request_options : typing.Optional[RequestOptions]
|
|
2017
|
+
Request-specific configuration.
|
|
2018
|
+
|
|
2019
|
+
Returns
|
|
2020
|
+
-------
|
|
2021
|
+
typing.Optional[typing.Any]
|
|
2022
|
+
Successful Response
|
|
2023
|
+
|
|
2024
|
+
Examples
|
|
2025
|
+
--------
|
|
2026
|
+
import asyncio
|
|
2027
|
+
|
|
2028
|
+
from agenta import AsyncAgentaApi
|
|
2029
|
+
|
|
2030
|
+
client = AsyncAgentaApi(
|
|
2031
|
+
api_key="YOUR_API_KEY",
|
|
2032
|
+
base_url="https://yourhost.com/path/to/api",
|
|
249
2033
|
)
|
|
250
2034
|
|
|
251
|
-
|
|
252
|
-
|
|
2035
|
+
|
|
2036
|
+
async def main() -> None:
|
|
2037
|
+
await client.create_organization(
|
|
2038
|
+
name="name",
|
|
2039
|
+
owner="owner",
|
|
2040
|
+
)
|
|
253
2041
|
|
|
254
2042
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
2043
|
+
asyncio.run(main())
|
|
2044
|
+
"""
|
|
2045
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2046
|
+
"organizations",
|
|
2047
|
+
method="POST",
|
|
2048
|
+
json={
|
|
2049
|
+
"name": name,
|
|
2050
|
+
"owner": owner,
|
|
2051
|
+
"description": description,
|
|
2052
|
+
"type": type,
|
|
2053
|
+
},
|
|
2054
|
+
headers={
|
|
2055
|
+
"content-type": "application/json",
|
|
2056
|
+
},
|
|
2057
|
+
request_options=request_options,
|
|
2058
|
+
omit=OMIT,
|
|
2059
|
+
)
|
|
2060
|
+
try:
|
|
2061
|
+
if 200 <= _response.status_code < 300:
|
|
2062
|
+
return typing.cast(
|
|
2063
|
+
typing.Optional[typing.Any],
|
|
2064
|
+
parse_obj_as(
|
|
2065
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2066
|
+
object_=_response.json(),
|
|
2067
|
+
),
|
|
2068
|
+
)
|
|
2069
|
+
if _response.status_code == 422:
|
|
2070
|
+
raise UnprocessableEntityError(
|
|
2071
|
+
typing.cast(
|
|
2072
|
+
HttpValidationError,
|
|
2073
|
+
parse_obj_as(
|
|
2074
|
+
type_=HttpValidationError, # type: ignore
|
|
2075
|
+
object_=_response.json(),
|
|
2076
|
+
),
|
|
2077
|
+
)
|
|
2078
|
+
)
|
|
2079
|
+
_response_json = _response.json()
|
|
2080
|
+
except JSONDecodeError:
|
|
2081
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2082
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2083
|
+
|
|
2084
|
+
async def get_own_org(
|
|
2085
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
2086
|
+
) -> OrganizationOutput:
|
|
2087
|
+
"""
|
|
2088
|
+
Parameters
|
|
2089
|
+
----------
|
|
2090
|
+
request_options : typing.Optional[RequestOptions]
|
|
2091
|
+
Request-specific configuration.
|
|
2092
|
+
|
|
2093
|
+
Returns
|
|
2094
|
+
-------
|
|
2095
|
+
OrganizationOutput
|
|
2096
|
+
Successful Response
|
|
2097
|
+
|
|
2098
|
+
Examples
|
|
2099
|
+
--------
|
|
2100
|
+
import asyncio
|
|
2101
|
+
|
|
2102
|
+
from agenta import AsyncAgentaApi
|
|
2103
|
+
|
|
2104
|
+
client = AsyncAgentaApi(
|
|
2105
|
+
api_key="YOUR_API_KEY",
|
|
2106
|
+
base_url="https://yourhost.com/path/to/api",
|
|
2107
|
+
)
|
|
258
2108
|
|
|
259
|
-
Args:
|
|
260
|
-
variant_id (str): The ID of the variant to be removed.
|
|
261
|
-
host (str): The URL of the Agenta backend.
|
|
262
|
-
api_key (str): The API key to use for the request.
|
|
263
2109
|
|
|
264
|
-
|
|
265
|
-
|
|
2110
|
+
async def main() -> None:
|
|
2111
|
+
await client.get_own_org()
|
|
266
2112
|
|
|
267
|
-
Returns:
|
|
268
|
-
None
|
|
269
|
-
"""
|
|
270
|
-
response = requests.delete(
|
|
271
|
-
f"{host}/{BACKEND_URL_SUFFIX}/variants/{variant_id}",
|
|
272
|
-
headers={
|
|
273
|
-
"Content-Type": "application/json",
|
|
274
|
-
"Authorization": api_key if api_key is not None else None,
|
|
275
|
-
},
|
|
276
|
-
timeout=600,
|
|
277
|
-
)
|
|
278
2113
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
2114
|
+
asyncio.run(main())
|
|
2115
|
+
"""
|
|
2116
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2117
|
+
"organizations/own",
|
|
2118
|
+
method="GET",
|
|
2119
|
+
request_options=request_options,
|
|
284
2120
|
)
|
|
2121
|
+
try:
|
|
2122
|
+
if 200 <= _response.status_code < 300:
|
|
2123
|
+
return typing.cast(
|
|
2124
|
+
OrganizationOutput,
|
|
2125
|
+
parse_obj_as(
|
|
2126
|
+
type_=OrganizationOutput, # type: ignore
|
|
2127
|
+
object_=_response.json(),
|
|
2128
|
+
),
|
|
2129
|
+
)
|
|
2130
|
+
_response_json = _response.json()
|
|
2131
|
+
except JSONDecodeError:
|
|
2132
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2133
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
285
2134
|
|
|
2135
|
+
async def fetch_organization_details(
|
|
2136
|
+
self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
2137
|
+
) -> typing.Optional[typing.Any]:
|
|
2138
|
+
"""
|
|
2139
|
+
Get an organization's details.
|
|
286
2140
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
2141
|
+
Raises:
|
|
2142
|
+
HTTPException: _description_
|
|
2143
|
+
Permission Denied
|
|
290
2144
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
image (Image): The new image to set for the variant.
|
|
294
|
-
host (str): The URL of the host to send the request to.
|
|
295
|
-
api_key (str): The API key to use for the request.
|
|
2145
|
+
Returns:
|
|
2146
|
+
OrganizationDB Instance
|
|
296
2147
|
|
|
297
|
-
|
|
298
|
-
|
|
2148
|
+
Parameters
|
|
2149
|
+
----------
|
|
2150
|
+
org_id : str
|
|
299
2151
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
2152
|
+
request_options : typing.Optional[RequestOptions]
|
|
2153
|
+
Request-specific configuration.
|
|
2154
|
+
|
|
2155
|
+
Returns
|
|
2156
|
+
-------
|
|
2157
|
+
typing.Optional[typing.Any]
|
|
2158
|
+
Successful Response
|
|
2159
|
+
|
|
2160
|
+
Examples
|
|
2161
|
+
--------
|
|
2162
|
+
import asyncio
|
|
2163
|
+
|
|
2164
|
+
from agenta import AsyncAgentaApi
|
|
2165
|
+
|
|
2166
|
+
client = AsyncAgentaApi(
|
|
2167
|
+
api_key="YOUR_API_KEY",
|
|
2168
|
+
base_url="https://yourhost.com/path/to/api",
|
|
313
2169
|
)
|
|
314
2170
|
|
|
315
2171
|
|
|
316
|
-
def
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
2172
|
+
async def main() -> None:
|
|
2173
|
+
await client.fetch_organization_details(
|
|
2174
|
+
org_id="org_id",
|
|
2175
|
+
)
|
|
2176
|
+
|
|
321
2177
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
2178
|
+
asyncio.run(main())
|
|
2179
|
+
"""
|
|
2180
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2181
|
+
f"organizations/{jsonable_encoder(org_id)}",
|
|
2182
|
+
method="GET",
|
|
2183
|
+
request_options=request_options,
|
|
2184
|
+
)
|
|
2185
|
+
try:
|
|
2186
|
+
if 200 <= _response.status_code < 300:
|
|
2187
|
+
return typing.cast(
|
|
2188
|
+
typing.Optional[typing.Any],
|
|
2189
|
+
parse_obj_as(
|
|
2190
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2191
|
+
object_=_response.json(),
|
|
2192
|
+
),
|
|
2193
|
+
)
|
|
2194
|
+
if _response.status_code == 422:
|
|
2195
|
+
raise UnprocessableEntityError(
|
|
2196
|
+
typing.cast(
|
|
2197
|
+
HttpValidationError,
|
|
2198
|
+
parse_obj_as(
|
|
2199
|
+
type_=HttpValidationError, # type: ignore
|
|
2200
|
+
object_=_response.json(),
|
|
2201
|
+
),
|
|
2202
|
+
)
|
|
2203
|
+
)
|
|
2204
|
+
_response_json = _response.json()
|
|
2205
|
+
except JSONDecodeError:
|
|
2206
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2207
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2208
|
+
|
|
2209
|
+
async def update_organization(
|
|
2210
|
+
self,
|
|
2211
|
+
org_id: str,
|
|
2212
|
+
*,
|
|
2213
|
+
name: typing.Optional[str] = OMIT,
|
|
2214
|
+
description: typing.Optional[str] = OMIT,
|
|
2215
|
+
updated_at: typing.Optional[str] = OMIT,
|
|
2216
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2217
|
+
) -> typing.Optional[typing.Any]:
|
|
2218
|
+
"""
|
|
2219
|
+
Parameters
|
|
2220
|
+
----------
|
|
2221
|
+
org_id : str
|
|
2222
|
+
|
|
2223
|
+
name : typing.Optional[str]
|
|
2224
|
+
|
|
2225
|
+
description : typing.Optional[str]
|
|
2226
|
+
|
|
2227
|
+
updated_at : typing.Optional[str]
|
|
2228
|
+
|
|
2229
|
+
request_options : typing.Optional[RequestOptions]
|
|
2230
|
+
Request-specific configuration.
|
|
2231
|
+
|
|
2232
|
+
Returns
|
|
2233
|
+
-------
|
|
2234
|
+
typing.Optional[typing.Any]
|
|
2235
|
+
Successful Response
|
|
2236
|
+
|
|
2237
|
+
Examples
|
|
2238
|
+
--------
|
|
2239
|
+
import asyncio
|
|
2240
|
+
|
|
2241
|
+
from agenta import AsyncAgentaApi
|
|
2242
|
+
|
|
2243
|
+
client = AsyncAgentaApi(
|
|
2244
|
+
api_key="YOUR_API_KEY",
|
|
2245
|
+
base_url="https://yourhost.com/path/to/api",
|
|
2246
|
+
)
|
|
328
2247
|
|
|
329
|
-
Returns:
|
|
330
|
-
Image: The built Docker image.
|
|
331
2248
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
with tar_path.open("rb") as tar_file:
|
|
336
|
-
response = requests.post(
|
|
337
|
-
f"{host}/{BACKEND_URL_SUFFIX}/containers/build_image/?app_id={app_id}&base_name={base_name}",
|
|
338
|
-
files={
|
|
339
|
-
"tar_file": tar_file,
|
|
340
|
-
},
|
|
341
|
-
headers={"Authorization": api_key} if api_key is not None else None,
|
|
342
|
-
timeout=1200,
|
|
343
|
-
)
|
|
344
|
-
|
|
345
|
-
if response.status_code == 500:
|
|
346
|
-
response_error = response.json()
|
|
347
|
-
error_msg = "Serving the variant failed.\n"
|
|
348
|
-
error_msg += f"Log: {response_error}\n"
|
|
349
|
-
error_msg += "Here's how you may be able to solve the issue:\n"
|
|
350
|
-
error_msg += "- First, make sure that the requirements.txt file has all the dependencies that you need.\n"
|
|
351
|
-
error_msg += "- Second, check the Docker logs for the backend image to see the error when running the Docker container."
|
|
352
|
-
raise Exception(error_msg)
|
|
353
|
-
|
|
354
|
-
response.raise_for_status()
|
|
355
|
-
image = Image.parse_obj(response.json())
|
|
356
|
-
return image
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
def save_variant_config(
|
|
360
|
-
base_id: str,
|
|
361
|
-
config_name: str,
|
|
362
|
-
parameters: Dict[str, Any],
|
|
363
|
-
overwrite: bool,
|
|
364
|
-
host: str,
|
|
365
|
-
api_key: Optional[str] = None,
|
|
366
|
-
) -> None:
|
|
367
|
-
"""
|
|
368
|
-
Saves a variant configuration to the Agenta backend.
|
|
369
|
-
If the config already exists, it will be overwritten if the overwrite argument is set to True.
|
|
370
|
-
If the config does does not exist, a new variant will be created.
|
|
371
|
-
|
|
372
|
-
Args:
|
|
373
|
-
base_id (str): The ID of the base configuration.
|
|
374
|
-
config_name (str): The name of the variant configuration.
|
|
375
|
-
parameters (Dict[str, Any]): The parameters of the variant configuration.
|
|
376
|
-
overwrite (bool): Whether to overwrite an existing variant configuration with the same name.
|
|
377
|
-
host (str): The URL of the Agenta backend.
|
|
378
|
-
api_key (Optional[str], optional): The API key to use for authentication. Defaults to None.
|
|
379
|
-
|
|
380
|
-
Raises:
|
|
381
|
-
ValueError: If the 'host' argument is not specified.
|
|
382
|
-
APIRequestError: If the request to the Agenta backend fails.
|
|
383
|
-
|
|
384
|
-
Returns:
|
|
385
|
-
None
|
|
386
|
-
"""
|
|
387
|
-
if host is None:
|
|
388
|
-
raise ValueError("The 'host' is not specified in save_variant_config")
|
|
389
|
-
|
|
390
|
-
variant_config = VariantConfigPayload(
|
|
391
|
-
base_id=base_id,
|
|
392
|
-
config_name=config_name,
|
|
393
|
-
parameters=parameters,
|
|
394
|
-
overwrite=overwrite,
|
|
395
|
-
)
|
|
396
|
-
try:
|
|
397
|
-
response = requests.post(
|
|
398
|
-
f"{host}/{BACKEND_URL_SUFFIX}/configs/",
|
|
399
|
-
json=variant_config.dict(),
|
|
400
|
-
headers={"Authorization": api_key} if api_key is not None else None,
|
|
401
|
-
timeout=600,
|
|
402
|
-
)
|
|
403
|
-
request = f"POST {host}/{BACKEND_URL_SUFFIX}/configs/ {variant_config.dict()}"
|
|
404
|
-
# Check for successful request
|
|
405
|
-
if response.status_code != 200:
|
|
406
|
-
error_message = response.json().get("detail", "Unknown error")
|
|
407
|
-
raise APIRequestError(
|
|
408
|
-
f"Request {request} to save_variant_config endpoint failed with status code {response.status_code}. Error message: {error_message}"
|
|
2249
|
+
async def main() -> None:
|
|
2250
|
+
await client.update_organization(
|
|
2251
|
+
org_id="org_id",
|
|
409
2252
|
)
|
|
410
|
-
except RequestException as e:
|
|
411
|
-
raise APIRequestError(f"Request failed: {str(e)}")
|
|
412
2253
|
|
|
413
2254
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
2255
|
+
asyncio.run(main())
|
|
2256
|
+
"""
|
|
2257
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2258
|
+
f"organizations/{jsonable_encoder(org_id)}",
|
|
2259
|
+
method="PUT",
|
|
2260
|
+
json={
|
|
2261
|
+
"name": name,
|
|
2262
|
+
"description": description,
|
|
2263
|
+
"updated_at": updated_at,
|
|
2264
|
+
},
|
|
2265
|
+
headers={
|
|
2266
|
+
"content-type": "application/json",
|
|
2267
|
+
},
|
|
2268
|
+
request_options=request_options,
|
|
2269
|
+
omit=OMIT,
|
|
2270
|
+
)
|
|
2271
|
+
try:
|
|
2272
|
+
if 200 <= _response.status_code < 300:
|
|
2273
|
+
return typing.cast(
|
|
2274
|
+
typing.Optional[typing.Any],
|
|
2275
|
+
parse_obj_as(
|
|
2276
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2277
|
+
object_=_response.json(),
|
|
2278
|
+
),
|
|
2279
|
+
)
|
|
2280
|
+
if _response.status_code == 422:
|
|
2281
|
+
raise UnprocessableEntityError(
|
|
2282
|
+
typing.cast(
|
|
2283
|
+
HttpValidationError,
|
|
2284
|
+
parse_obj_as(
|
|
2285
|
+
type_=HttpValidationError, # type: ignore
|
|
2286
|
+
object_=_response.json(),
|
|
2287
|
+
),
|
|
2288
|
+
)
|
|
2289
|
+
)
|
|
2290
|
+
_response_json = _response.json()
|
|
2291
|
+
except JSONDecodeError:
|
|
2292
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2293
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2294
|
+
|
|
2295
|
+
async def invite_user_to_workspace(
|
|
2296
|
+
self,
|
|
2297
|
+
org_id: str,
|
|
2298
|
+
workspace_id: str,
|
|
2299
|
+
*,
|
|
2300
|
+
request: typing.Sequence[InviteRequest],
|
|
2301
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2302
|
+
) -> typing.Optional[typing.Any]:
|
|
2303
|
+
"""
|
|
2304
|
+
Parameters
|
|
2305
|
+
----------
|
|
2306
|
+
org_id : str
|
|
2307
|
+
|
|
2308
|
+
workspace_id : str
|
|
2309
|
+
|
|
2310
|
+
request : typing.Sequence[InviteRequest]
|
|
2311
|
+
|
|
2312
|
+
request_options : typing.Optional[RequestOptions]
|
|
2313
|
+
Request-specific configuration.
|
|
2314
|
+
|
|
2315
|
+
Returns
|
|
2316
|
+
-------
|
|
2317
|
+
typing.Optional[typing.Any]
|
|
2318
|
+
Successful Response
|
|
2319
|
+
|
|
2320
|
+
Examples
|
|
2321
|
+
--------
|
|
2322
|
+
import asyncio
|
|
2323
|
+
|
|
2324
|
+
from agenta import AsyncAgentaApi, InviteRequest
|
|
2325
|
+
|
|
2326
|
+
client = AsyncAgentaApi(
|
|
2327
|
+
api_key="YOUR_API_KEY",
|
|
2328
|
+
base_url="https://yourhost.com/path/to/api",
|
|
2329
|
+
)
|
|
2330
|
+
|
|
423
2331
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
2332
|
+
async def main() -> None:
|
|
2333
|
+
await client.invite_user_to_workspace(
|
|
2334
|
+
org_id="org_id",
|
|
2335
|
+
workspace_id="workspace_id",
|
|
2336
|
+
request=[
|
|
2337
|
+
InviteRequest(
|
|
2338
|
+
email="email",
|
|
2339
|
+
roles=["roles"],
|
|
2340
|
+
)
|
|
2341
|
+
],
|
|
2342
|
+
)
|
|
430
2343
|
|
|
431
|
-
Raises:
|
|
432
|
-
APIRequestError: If the API request fails.
|
|
433
2344
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
2345
|
+
asyncio.run(main())
|
|
2346
|
+
"""
|
|
2347
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2348
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite",
|
|
2349
|
+
method="POST",
|
|
2350
|
+
json=convert_and_respect_annotation_metadata(
|
|
2351
|
+
object_=request,
|
|
2352
|
+
annotation=typing.Sequence[InviteRequest],
|
|
2353
|
+
direction="write",
|
|
2354
|
+
),
|
|
2355
|
+
request_options=request_options,
|
|
2356
|
+
omit=OMIT,
|
|
2357
|
+
)
|
|
2358
|
+
try:
|
|
2359
|
+
if 200 <= _response.status_code < 300:
|
|
2360
|
+
return typing.cast(
|
|
2361
|
+
typing.Optional[typing.Any],
|
|
2362
|
+
parse_obj_as(
|
|
2363
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2364
|
+
object_=_response.json(),
|
|
2365
|
+
),
|
|
2366
|
+
)
|
|
2367
|
+
if _response.status_code == 422:
|
|
2368
|
+
raise UnprocessableEntityError(
|
|
2369
|
+
typing.cast(
|
|
2370
|
+
HttpValidationError,
|
|
2371
|
+
parse_obj_as(
|
|
2372
|
+
type_=HttpValidationError, # type: ignore
|
|
2373
|
+
object_=_response.json(),
|
|
2374
|
+
),
|
|
2375
|
+
)
|
|
2376
|
+
)
|
|
2377
|
+
_response_json = _response.json()
|
|
2378
|
+
except JSONDecodeError:
|
|
2379
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2380
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2381
|
+
|
|
2382
|
+
async def resend_invitation(
|
|
2383
|
+
self,
|
|
2384
|
+
org_id: str,
|
|
2385
|
+
workspace_id: str,
|
|
2386
|
+
*,
|
|
2387
|
+
email: str,
|
|
2388
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2389
|
+
) -> typing.Optional[typing.Any]:
|
|
2390
|
+
"""
|
|
2391
|
+
Resend an invitation to a user to an Organization.
|
|
2392
|
+
|
|
2393
|
+
Raises:
|
|
2394
|
+
HTTPException: _description_; status_code: 500
|
|
2395
|
+
HTTPException: Invitation not found or has expired; status_code: 400
|
|
2396
|
+
HTTPException: You already belong to this organization; status_code: 400
|
|
2397
|
+
|
|
2398
|
+
Returns:
|
|
2399
|
+
JSONResponse: Resent invitation to user; status_code: 200
|
|
2400
|
+
|
|
2401
|
+
Parameters
|
|
2402
|
+
----------
|
|
2403
|
+
org_id : str
|
|
2404
|
+
|
|
2405
|
+
workspace_id : str
|
|
2406
|
+
|
|
2407
|
+
email : str
|
|
2408
|
+
|
|
2409
|
+
request_options : typing.Optional[RequestOptions]
|
|
2410
|
+
Request-specific configuration.
|
|
2411
|
+
|
|
2412
|
+
Returns
|
|
2413
|
+
-------
|
|
2414
|
+
typing.Optional[typing.Any]
|
|
2415
|
+
Successful Response
|
|
2416
|
+
|
|
2417
|
+
Examples
|
|
2418
|
+
--------
|
|
2419
|
+
import asyncio
|
|
2420
|
+
|
|
2421
|
+
from agenta import AsyncAgentaApi
|
|
2422
|
+
|
|
2423
|
+
client = AsyncAgentaApi(
|
|
2424
|
+
api_key="YOUR_API_KEY",
|
|
2425
|
+
base_url="https://yourhost.com/path/to/api",
|
|
2426
|
+
)
|
|
2427
|
+
|
|
437
2428
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
endpoint_params = f"?base_id={base_id}&environment_name={environment_name}"
|
|
444
|
-
elif config_name:
|
|
445
|
-
endpoint_params = f"?base_id={base_id}&config_name={config_name}"
|
|
446
|
-
else:
|
|
447
|
-
raise ValueError(
|
|
448
|
-
"Either 'config_name' or 'environment_name' must be specified in fetch_variant_config"
|
|
2429
|
+
async def main() -> None:
|
|
2430
|
+
await client.resend_invitation(
|
|
2431
|
+
org_id="org_id",
|
|
2432
|
+
workspace_id="workspace_id",
|
|
2433
|
+
email="email",
|
|
449
2434
|
)
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
2435
|
+
|
|
2436
|
+
|
|
2437
|
+
asyncio.run(main())
|
|
2438
|
+
"""
|
|
2439
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2440
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/resend",
|
|
2441
|
+
method="POST",
|
|
2442
|
+
json={
|
|
2443
|
+
"email": email,
|
|
2444
|
+
},
|
|
2445
|
+
headers={
|
|
2446
|
+
"content-type": "application/json",
|
|
2447
|
+
},
|
|
2448
|
+
request_options=request_options,
|
|
2449
|
+
omit=OMIT,
|
|
2450
|
+
)
|
|
2451
|
+
try:
|
|
2452
|
+
if 200 <= _response.status_code < 300:
|
|
2453
|
+
return typing.cast(
|
|
2454
|
+
typing.Optional[typing.Any],
|
|
2455
|
+
parse_obj_as(
|
|
2456
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2457
|
+
object_=_response.json(),
|
|
2458
|
+
),
|
|
2459
|
+
)
|
|
2460
|
+
if _response.status_code == 422:
|
|
2461
|
+
raise UnprocessableEntityError(
|
|
2462
|
+
typing.cast(
|
|
2463
|
+
HttpValidationError,
|
|
2464
|
+
parse_obj_as(
|
|
2465
|
+
type_=HttpValidationError, # type: ignore
|
|
2466
|
+
object_=_response.json(),
|
|
2467
|
+
),
|
|
2468
|
+
)
|
|
2469
|
+
)
|
|
2470
|
+
_response_json = _response.json()
|
|
2471
|
+
except JSONDecodeError:
|
|
2472
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2473
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2474
|
+
|
|
2475
|
+
async def accept_invitation(
|
|
2476
|
+
self,
|
|
2477
|
+
org_id: str,
|
|
2478
|
+
workspace_id: str,
|
|
2479
|
+
*,
|
|
2480
|
+
project_id: str,
|
|
2481
|
+
token: str,
|
|
2482
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2483
|
+
) -> typing.Optional[typing.Any]:
|
|
2484
|
+
"""
|
|
2485
|
+
Accept an invitation to a workspace.
|
|
2486
|
+
|
|
2487
|
+
Raises:
|
|
2488
|
+
HTTPException: _description_; status_code: 500
|
|
2489
|
+
HTTPException: Invitation not found or has expired; status_code: 400
|
|
2490
|
+
HTTPException: You already belong to this organization; status_code: 400
|
|
2491
|
+
|
|
2492
|
+
Returns:
|
|
2493
|
+
JSONResponse: Accepted invitation to workspace; status_code: 200
|
|
2494
|
+
|
|
2495
|
+
Parameters
|
|
2496
|
+
----------
|
|
2497
|
+
org_id : str
|
|
2498
|
+
|
|
2499
|
+
workspace_id : str
|
|
2500
|
+
|
|
2501
|
+
project_id : str
|
|
2502
|
+
|
|
2503
|
+
token : str
|
|
2504
|
+
|
|
2505
|
+
request_options : typing.Optional[RequestOptions]
|
|
2506
|
+
Request-specific configuration.
|
|
2507
|
+
|
|
2508
|
+
Returns
|
|
2509
|
+
-------
|
|
2510
|
+
typing.Optional[typing.Any]
|
|
2511
|
+
Successful Response
|
|
2512
|
+
|
|
2513
|
+
Examples
|
|
2514
|
+
--------
|
|
2515
|
+
import asyncio
|
|
2516
|
+
|
|
2517
|
+
from agenta import AsyncAgentaApi
|
|
2518
|
+
|
|
2519
|
+
client = AsyncAgentaApi(
|
|
2520
|
+
api_key="YOUR_API_KEY",
|
|
2521
|
+
base_url="https://yourhost.com/path/to/api",
|
|
454
2522
|
)
|
|
455
2523
|
|
|
456
|
-
request = f"GET {host}/{BACKEND_URL_SUFFIX}/configs/ {base_id} {config_name} {environment_name}"
|
|
457
2524
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
2525
|
+
async def main() -> None:
|
|
2526
|
+
await client.accept_invitation(
|
|
2527
|
+
org_id="org_id",
|
|
2528
|
+
workspace_id="workspace_id",
|
|
2529
|
+
project_id="project_id",
|
|
2530
|
+
token="token",
|
|
463
2531
|
)
|
|
464
2532
|
|
|
465
|
-
return response.json()
|
|
466
2533
|
|
|
467
|
-
|
|
468
|
-
|
|
2534
|
+
asyncio.run(main())
|
|
2535
|
+
"""
|
|
2536
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2537
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}/invite/accept",
|
|
2538
|
+
method="POST",
|
|
2539
|
+
params={
|
|
2540
|
+
"project_id": project_id,
|
|
2541
|
+
},
|
|
2542
|
+
json={
|
|
2543
|
+
"token": token,
|
|
2544
|
+
},
|
|
2545
|
+
headers={
|
|
2546
|
+
"content-type": "application/json",
|
|
2547
|
+
},
|
|
2548
|
+
request_options=request_options,
|
|
2549
|
+
omit=OMIT,
|
|
2550
|
+
)
|
|
2551
|
+
try:
|
|
2552
|
+
if 200 <= _response.status_code < 300:
|
|
2553
|
+
return typing.cast(
|
|
2554
|
+
typing.Optional[typing.Any],
|
|
2555
|
+
parse_obj_as(
|
|
2556
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2557
|
+
object_=_response.json(),
|
|
2558
|
+
),
|
|
2559
|
+
)
|
|
2560
|
+
if _response.status_code == 422:
|
|
2561
|
+
raise UnprocessableEntityError(
|
|
2562
|
+
typing.cast(
|
|
2563
|
+
HttpValidationError,
|
|
2564
|
+
parse_obj_as(
|
|
2565
|
+
type_=HttpValidationError, # type: ignore
|
|
2566
|
+
object_=_response.json(),
|
|
2567
|
+
),
|
|
2568
|
+
)
|
|
2569
|
+
)
|
|
2570
|
+
_response_json = _response.json()
|
|
2571
|
+
except JSONDecodeError:
|
|
2572
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2573
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2574
|
+
|
|
2575
|
+
async def create_workspace(
|
|
2576
|
+
self,
|
|
2577
|
+
org_id: str,
|
|
2578
|
+
*,
|
|
2579
|
+
name: str,
|
|
2580
|
+
description: typing.Optional[str] = OMIT,
|
|
2581
|
+
type: typing.Optional[str] = OMIT,
|
|
2582
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2583
|
+
) -> WorkspaceResponse:
|
|
2584
|
+
"""
|
|
2585
|
+
Parameters
|
|
2586
|
+
----------
|
|
2587
|
+
org_id : str
|
|
2588
|
+
|
|
2589
|
+
name : str
|
|
2590
|
+
|
|
2591
|
+
description : typing.Optional[str]
|
|
2592
|
+
|
|
2593
|
+
type : typing.Optional[str]
|
|
2594
|
+
|
|
2595
|
+
request_options : typing.Optional[RequestOptions]
|
|
2596
|
+
Request-specific configuration.
|
|
2597
|
+
|
|
2598
|
+
Returns
|
|
2599
|
+
-------
|
|
2600
|
+
WorkspaceResponse
|
|
2601
|
+
Successful Response
|
|
2602
|
+
|
|
2603
|
+
Examples
|
|
2604
|
+
--------
|
|
2605
|
+
import asyncio
|
|
2606
|
+
|
|
2607
|
+
from agenta import AsyncAgentaApi
|
|
2608
|
+
|
|
2609
|
+
client = AsyncAgentaApi(
|
|
2610
|
+
api_key="YOUR_API_KEY",
|
|
2611
|
+
base_url="https://yourhost.com/path/to/api",
|
|
2612
|
+
)
|
|
469
2613
|
|
|
470
2614
|
|
|
471
|
-
def
|
|
472
|
-
|
|
473
|
-
|
|
2615
|
+
async def main() -> None:
|
|
2616
|
+
await client.create_workspace(
|
|
2617
|
+
org_id="org_id",
|
|
2618
|
+
name="name",
|
|
2619
|
+
)
|
|
474
2620
|
|
|
475
|
-
Args:
|
|
476
|
-
api_key (str): The API key to validate.
|
|
477
|
-
host (str): The URL of the Agenta backend.
|
|
478
2621
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
2622
|
+
asyncio.run(main())
|
|
2623
|
+
"""
|
|
2624
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2625
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces",
|
|
2626
|
+
method="POST",
|
|
2627
|
+
json={
|
|
2628
|
+
"name": name,
|
|
2629
|
+
"description": description,
|
|
2630
|
+
"type": type,
|
|
2631
|
+
},
|
|
2632
|
+
headers={
|
|
2633
|
+
"content-type": "application/json",
|
|
2634
|
+
},
|
|
2635
|
+
request_options=request_options,
|
|
2636
|
+
omit=OMIT,
|
|
2637
|
+
)
|
|
2638
|
+
try:
|
|
2639
|
+
if 200 <= _response.status_code < 300:
|
|
2640
|
+
return typing.cast(
|
|
2641
|
+
WorkspaceResponse,
|
|
2642
|
+
parse_obj_as(
|
|
2643
|
+
type_=WorkspaceResponse, # type: ignore
|
|
2644
|
+
object_=_response.json(),
|
|
2645
|
+
),
|
|
2646
|
+
)
|
|
2647
|
+
if _response.status_code == 422:
|
|
2648
|
+
raise UnprocessableEntityError(
|
|
2649
|
+
typing.cast(
|
|
2650
|
+
HttpValidationError,
|
|
2651
|
+
parse_obj_as(
|
|
2652
|
+
type_=HttpValidationError, # type: ignore
|
|
2653
|
+
object_=_response.json(),
|
|
2654
|
+
),
|
|
2655
|
+
)
|
|
2656
|
+
)
|
|
2657
|
+
_response_json = _response.json()
|
|
2658
|
+
except JSONDecodeError:
|
|
2659
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2660
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2661
|
+
|
|
2662
|
+
async def update_workspace(
|
|
2663
|
+
self,
|
|
2664
|
+
org_id: str,
|
|
2665
|
+
workspace_id: str,
|
|
2666
|
+
*,
|
|
2667
|
+
name: typing.Optional[str] = OMIT,
|
|
2668
|
+
description: typing.Optional[str] = OMIT,
|
|
2669
|
+
updated_at: typing.Optional[dt.datetime] = OMIT,
|
|
2670
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2671
|
+
) -> WorkspaceResponse:
|
|
2672
|
+
"""
|
|
2673
|
+
Parameters
|
|
2674
|
+
----------
|
|
2675
|
+
org_id : str
|
|
2676
|
+
|
|
2677
|
+
workspace_id : str
|
|
2678
|
+
|
|
2679
|
+
name : typing.Optional[str]
|
|
2680
|
+
|
|
2681
|
+
description : typing.Optional[str]
|
|
2682
|
+
|
|
2683
|
+
updated_at : typing.Optional[dt.datetime]
|
|
2684
|
+
|
|
2685
|
+
request_options : typing.Optional[RequestOptions]
|
|
2686
|
+
Request-specific configuration.
|
|
2687
|
+
|
|
2688
|
+
Returns
|
|
2689
|
+
-------
|
|
2690
|
+
WorkspaceResponse
|
|
2691
|
+
Successful Response
|
|
2692
|
+
|
|
2693
|
+
Examples
|
|
2694
|
+
--------
|
|
2695
|
+
import asyncio
|
|
2696
|
+
|
|
2697
|
+
from agenta import AsyncAgentaApi
|
|
2698
|
+
|
|
2699
|
+
client = AsyncAgentaApi(
|
|
2700
|
+
api_key="YOUR_API_KEY",
|
|
2701
|
+
base_url="https://yourhost.com/path/to/api",
|
|
2702
|
+
)
|
|
2703
|
+
|
|
2704
|
+
|
|
2705
|
+
async def main() -> None:
|
|
2706
|
+
await client.update_workspace(
|
|
2707
|
+
org_id="org_id",
|
|
2708
|
+
workspace_id="workspace_id",
|
|
2709
|
+
)
|
|
2710
|
+
|
|
2711
|
+
|
|
2712
|
+
asyncio.run(main())
|
|
2713
|
+
"""
|
|
2714
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2715
|
+
f"organizations/{jsonable_encoder(org_id)}/workspaces/{jsonable_encoder(workspace_id)}",
|
|
2716
|
+
method="PUT",
|
|
2717
|
+
json={
|
|
2718
|
+
"name": name,
|
|
2719
|
+
"description": description,
|
|
2720
|
+
"updated_at": updated_at,
|
|
2721
|
+
},
|
|
2722
|
+
headers={
|
|
2723
|
+
"content-type": "application/json",
|
|
2724
|
+
},
|
|
2725
|
+
request_options=request_options,
|
|
2726
|
+
omit=OMIT,
|
|
2727
|
+
)
|
|
2728
|
+
try:
|
|
2729
|
+
if 200 <= _response.status_code < 300:
|
|
2730
|
+
return typing.cast(
|
|
2731
|
+
WorkspaceResponse,
|
|
2732
|
+
parse_obj_as(
|
|
2733
|
+
type_=WorkspaceResponse, # type: ignore
|
|
2734
|
+
object_=_response.json(),
|
|
2735
|
+
),
|
|
2736
|
+
)
|
|
2737
|
+
if _response.status_code == 422:
|
|
2738
|
+
raise UnprocessableEntityError(
|
|
2739
|
+
typing.cast(
|
|
2740
|
+
HttpValidationError,
|
|
2741
|
+
parse_obj_as(
|
|
2742
|
+
type_=HttpValidationError, # type: ignore
|
|
2743
|
+
object_=_response.json(),
|
|
2744
|
+
),
|
|
2745
|
+
)
|
|
2746
|
+
)
|
|
2747
|
+
_response_json = _response.json()
|
|
2748
|
+
except JSONDecodeError:
|
|
2749
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2750
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2751
|
+
|
|
2752
|
+
async def get_all_workspace_roles(
|
|
2753
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
2754
|
+
) -> typing.List[WorkspaceRoleResponse]:
|
|
2755
|
+
"""
|
|
2756
|
+
Get all workspace roles.
|
|
2757
|
+
|
|
2758
|
+
Returns a list of all available workspace roles.
|
|
2759
|
+
|
|
2760
|
+
Returns:
|
|
2761
|
+
List[WorkspaceRoleResponse]: A list of WorkspaceRole objects representing the available workspace roles.
|
|
2762
|
+
|
|
2763
|
+
Raises:
|
|
2764
|
+
HTTPException: If an error occurs while retrieving the workspace roles.
|
|
484
2765
|
|
|
485
|
-
|
|
2766
|
+
Parameters
|
|
2767
|
+
----------
|
|
2768
|
+
request_options : typing.Optional[RequestOptions]
|
|
2769
|
+
Request-specific configuration.
|
|
486
2770
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
2771
|
+
Returns
|
|
2772
|
+
-------
|
|
2773
|
+
typing.List[WorkspaceRoleResponse]
|
|
2774
|
+
Successful Response
|
|
2775
|
+
|
|
2776
|
+
Examples
|
|
2777
|
+
--------
|
|
2778
|
+
import asyncio
|
|
2779
|
+
|
|
2780
|
+
from agenta import AsyncAgentaApi
|
|
2781
|
+
|
|
2782
|
+
client = AsyncAgentaApi(
|
|
2783
|
+
api_key="YOUR_API_KEY",
|
|
2784
|
+
base_url="https://yourhost.com/path/to/api",
|
|
2785
|
+
)
|
|
2786
|
+
|
|
2787
|
+
|
|
2788
|
+
async def main() -> None:
|
|
2789
|
+
await client.get_all_workspace_roles()
|
|
2790
|
+
|
|
2791
|
+
|
|
2792
|
+
asyncio.run(main())
|
|
2793
|
+
"""
|
|
2794
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2795
|
+
"workspaces/roles",
|
|
2796
|
+
method="GET",
|
|
2797
|
+
request_options=request_options,
|
|
2798
|
+
)
|
|
2799
|
+
try:
|
|
2800
|
+
if 200 <= _response.status_code < 300:
|
|
2801
|
+
return typing.cast(
|
|
2802
|
+
typing.List[WorkspaceRoleResponse],
|
|
2803
|
+
parse_obj_as(
|
|
2804
|
+
type_=typing.List[WorkspaceRoleResponse], # type: ignore
|
|
2805
|
+
object_=_response.json(),
|
|
2806
|
+
),
|
|
2807
|
+
)
|
|
2808
|
+
_response_json = _response.json()
|
|
2809
|
+
except JSONDecodeError:
|
|
2810
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2811
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2812
|
+
|
|
2813
|
+
async def get_all_workspace_permissions(
|
|
2814
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
2815
|
+
) -> typing.List[Permission]:
|
|
2816
|
+
"""
|
|
2817
|
+
Get all workspace permissions.
|
|
2818
|
+
|
|
2819
|
+
Returns a list of all available workspace permissions.
|
|
2820
|
+
|
|
2821
|
+
Returns:
|
|
2822
|
+
List[Permission]: A list of Permission objects representing the available workspace permissions.
|
|
2823
|
+
|
|
2824
|
+
Raises:
|
|
2825
|
+
HTTPException: If there is an error retrieving the workspace permissions.
|
|
2826
|
+
|
|
2827
|
+
Parameters
|
|
2828
|
+
----------
|
|
2829
|
+
request_options : typing.Optional[RequestOptions]
|
|
2830
|
+
Request-specific configuration.
|
|
2831
|
+
|
|
2832
|
+
Returns
|
|
2833
|
+
-------
|
|
2834
|
+
typing.List[Permission]
|
|
2835
|
+
Successful Response
|
|
2836
|
+
|
|
2837
|
+
Examples
|
|
2838
|
+
--------
|
|
2839
|
+
import asyncio
|
|
2840
|
+
|
|
2841
|
+
from agenta import AsyncAgentaApi
|
|
2842
|
+
|
|
2843
|
+
client = AsyncAgentaApi(
|
|
2844
|
+
api_key="YOUR_API_KEY",
|
|
2845
|
+
base_url="https://yourhost.com/path/to/api",
|
|
491
2846
|
)
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
2847
|
+
|
|
2848
|
+
|
|
2849
|
+
async def main() -> None:
|
|
2850
|
+
await client.get_all_workspace_permissions()
|
|
2851
|
+
|
|
2852
|
+
|
|
2853
|
+
asyncio.run(main())
|
|
2854
|
+
"""
|
|
2855
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2856
|
+
"workspaces/permissions",
|
|
2857
|
+
method="GET",
|
|
2858
|
+
request_options=request_options,
|
|
2859
|
+
)
|
|
2860
|
+
try:
|
|
2861
|
+
if 200 <= _response.status_code < 300:
|
|
2862
|
+
return typing.cast(
|
|
2863
|
+
typing.List[Permission],
|
|
2864
|
+
parse_obj_as(
|
|
2865
|
+
type_=typing.List[Permission], # type: ignore
|
|
2866
|
+
object_=_response.json(),
|
|
2867
|
+
),
|
|
2868
|
+
)
|
|
2869
|
+
_response_json = _response.json()
|
|
2870
|
+
except JSONDecodeError:
|
|
2871
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2872
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2873
|
+
|
|
2874
|
+
async def assign_role_to_user(
|
|
2875
|
+
self,
|
|
2876
|
+
workspace_id: str,
|
|
2877
|
+
*,
|
|
2878
|
+
email: str,
|
|
2879
|
+
organization_id: str,
|
|
2880
|
+
role: typing.Optional[str] = OMIT,
|
|
2881
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2882
|
+
) -> bool:
|
|
2883
|
+
"""
|
|
2884
|
+
Assigns a role to a user in a workspace.
|
|
2885
|
+
|
|
2886
|
+
Args:
|
|
2887
|
+
payload (UserRole): The payload containing the organization id, user email, and role to assign.
|
|
2888
|
+
workspace_id (str): The ID of the workspace.
|
|
2889
|
+
request (Request): The FastAPI request object.
|
|
2890
|
+
|
|
2891
|
+
Returns:
|
|
2892
|
+
bool: True if the role was successfully assigned, False otherwise.
|
|
2893
|
+
|
|
2894
|
+
Raises:
|
|
2895
|
+
HTTPException: If the user does not have permission to perform this action.
|
|
2896
|
+
HTTPException: If there is an error assigning the role to the user.
|
|
2897
|
+
|
|
2898
|
+
Parameters
|
|
2899
|
+
----------
|
|
2900
|
+
workspace_id : str
|
|
2901
|
+
|
|
2902
|
+
email : str
|
|
2903
|
+
|
|
2904
|
+
organization_id : str
|
|
2905
|
+
|
|
2906
|
+
role : typing.Optional[str]
|
|
2907
|
+
|
|
2908
|
+
request_options : typing.Optional[RequestOptions]
|
|
2909
|
+
Request-specific configuration.
|
|
2910
|
+
|
|
2911
|
+
Returns
|
|
2912
|
+
-------
|
|
2913
|
+
bool
|
|
2914
|
+
Successful Response
|
|
2915
|
+
|
|
2916
|
+
Examples
|
|
2917
|
+
--------
|
|
2918
|
+
import asyncio
|
|
2919
|
+
|
|
2920
|
+
from agenta import AsyncAgentaApi
|
|
2921
|
+
|
|
2922
|
+
client = AsyncAgentaApi(
|
|
2923
|
+
api_key="YOUR_API_KEY",
|
|
2924
|
+
base_url="https://yourhost.com/path/to/api",
|
|
2925
|
+
)
|
|
2926
|
+
|
|
2927
|
+
|
|
2928
|
+
async def main() -> None:
|
|
2929
|
+
await client.assign_role_to_user(
|
|
2930
|
+
workspace_id="workspace_id",
|
|
2931
|
+
email="email",
|
|
2932
|
+
organization_id="organization_id",
|
|
496
2933
|
)
|
|
497
|
-
return True
|
|
498
|
-
except RequestException as e:
|
|
499
|
-
raise APIRequestError(f"An error occurred while making the request: {e}")
|
|
500
2934
|
|
|
501
2935
|
|
|
502
|
-
|
|
503
|
-
|
|
2936
|
+
asyncio.run(main())
|
|
2937
|
+
"""
|
|
2938
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2939
|
+
f"workspaces/{jsonable_encoder(workspace_id)}/roles",
|
|
2940
|
+
method="POST",
|
|
2941
|
+
json={
|
|
2942
|
+
"email": email,
|
|
2943
|
+
"organization_id": organization_id,
|
|
2944
|
+
"role": role,
|
|
2945
|
+
},
|
|
2946
|
+
headers={
|
|
2947
|
+
"content-type": "application/json",
|
|
2948
|
+
},
|
|
2949
|
+
request_options=request_options,
|
|
2950
|
+
omit=OMIT,
|
|
2951
|
+
)
|
|
2952
|
+
try:
|
|
2953
|
+
if 200 <= _response.status_code < 300:
|
|
2954
|
+
return typing.cast(
|
|
2955
|
+
bool,
|
|
2956
|
+
parse_obj_as(
|
|
2957
|
+
type_=bool, # type: ignore
|
|
2958
|
+
object_=_response.json(),
|
|
2959
|
+
),
|
|
2960
|
+
)
|
|
2961
|
+
if _response.status_code == 422:
|
|
2962
|
+
raise UnprocessableEntityError(
|
|
2963
|
+
typing.cast(
|
|
2964
|
+
HttpValidationError,
|
|
2965
|
+
parse_obj_as(
|
|
2966
|
+
type_=HttpValidationError, # type: ignore
|
|
2967
|
+
object_=_response.json(),
|
|
2968
|
+
),
|
|
2969
|
+
)
|
|
2970
|
+
)
|
|
2971
|
+
_response_json = _response.json()
|
|
2972
|
+
except JSONDecodeError:
|
|
2973
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2974
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2975
|
+
|
|
2976
|
+
async def unassign_role_from_user(
|
|
2977
|
+
self,
|
|
2978
|
+
workspace_id: str,
|
|
2979
|
+
*,
|
|
2980
|
+
email: str,
|
|
2981
|
+
org_id: str,
|
|
2982
|
+
role: str,
|
|
2983
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2984
|
+
) -> typing.Optional[typing.Any]:
|
|
2985
|
+
"""
|
|
2986
|
+
Delete a role assignment from a user in a workspace.
|
|
2987
|
+
|
|
2988
|
+
Args:
|
|
2989
|
+
workspace_id (str): The ID of the workspace.
|
|
2990
|
+
email (str): The email of the user to remove the role from.
|
|
2991
|
+
org_id (str): The ID of the organization.
|
|
2992
|
+
role (str): The role to remove from the user.
|
|
2993
|
+
request (Request): The FastAPI request object.
|
|
2994
|
+
|
|
2995
|
+
Returns:
|
|
2996
|
+
bool: True if the role assignment was successfully deleted.
|
|
2997
|
+
|
|
2998
|
+
Raises:
|
|
2999
|
+
HTTPException: If there is an error in the request or the user does not have permission to perform the action.
|
|
3000
|
+
HTTPException: If there is an error in updating the user's roles.
|
|
3001
|
+
|
|
3002
|
+
Parameters
|
|
3003
|
+
----------
|
|
3004
|
+
workspace_id : str
|
|
3005
|
+
|
|
3006
|
+
email : str
|
|
3007
|
+
|
|
3008
|
+
org_id : str
|
|
3009
|
+
|
|
3010
|
+
role : str
|
|
3011
|
+
|
|
3012
|
+
request_options : typing.Optional[RequestOptions]
|
|
3013
|
+
Request-specific configuration.
|
|
3014
|
+
|
|
3015
|
+
Returns
|
|
3016
|
+
-------
|
|
3017
|
+
typing.Optional[typing.Any]
|
|
3018
|
+
Successful Response
|
|
3019
|
+
|
|
3020
|
+
Examples
|
|
3021
|
+
--------
|
|
3022
|
+
import asyncio
|
|
3023
|
+
|
|
3024
|
+
from agenta import AsyncAgentaApi
|
|
3025
|
+
|
|
3026
|
+
client = AsyncAgentaApi(
|
|
3027
|
+
api_key="YOUR_API_KEY",
|
|
3028
|
+
base_url="https://yourhost.com/path/to/api",
|
|
3029
|
+
)
|
|
3030
|
+
|
|
504
3031
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
3032
|
+
async def main() -> None:
|
|
3033
|
+
await client.unassign_role_from_user(
|
|
3034
|
+
workspace_id="workspace_id",
|
|
3035
|
+
email="email",
|
|
3036
|
+
org_id="org_id",
|
|
3037
|
+
role="role",
|
|
3038
|
+
)
|
|
508
3039
|
|
|
509
|
-
Returns:
|
|
510
|
-
str: the user ID
|
|
511
|
-
"""
|
|
512
3040
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
3041
|
+
asyncio.run(main())
|
|
3042
|
+
"""
|
|
3043
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3044
|
+
f"workspaces/{jsonable_encoder(workspace_id)}/roles",
|
|
3045
|
+
method="DELETE",
|
|
3046
|
+
params={
|
|
3047
|
+
"email": email,
|
|
3048
|
+
"org_id": org_id,
|
|
3049
|
+
"role": role,
|
|
3050
|
+
},
|
|
3051
|
+
request_options=request_options,
|
|
518
3052
|
)
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
3053
|
+
try:
|
|
3054
|
+
if 200 <= _response.status_code < 300:
|
|
3055
|
+
return typing.cast(
|
|
3056
|
+
typing.Optional[typing.Any],
|
|
3057
|
+
parse_obj_as(
|
|
3058
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3059
|
+
object_=_response.json(),
|
|
3060
|
+
),
|
|
3061
|
+
)
|
|
3062
|
+
if _response.status_code == 422:
|
|
3063
|
+
raise UnprocessableEntityError(
|
|
3064
|
+
typing.cast(
|
|
3065
|
+
HttpValidationError,
|
|
3066
|
+
parse_obj_as(
|
|
3067
|
+
type_=HttpValidationError, # type: ignore
|
|
3068
|
+
object_=_response.json(),
|
|
3069
|
+
),
|
|
3070
|
+
)
|
|
3071
|
+
)
|
|
3072
|
+
_response_json = _response.json()
|
|
3073
|
+
except JSONDecodeError:
|
|
3074
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
3075
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
3076
|
+
|
|
3077
|
+
async def remove_user_from_workspace(
|
|
3078
|
+
self,
|
|
3079
|
+
workspace_id: str,
|
|
3080
|
+
*,
|
|
3081
|
+
org_id: str,
|
|
3082
|
+
email: str,
|
|
3083
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
3084
|
+
) -> WorkspaceResponse:
|
|
3085
|
+
"""
|
|
3086
|
+
Remove a user from a workspace.
|
|
3087
|
+
|
|
3088
|
+
Parameters:
|
|
3089
|
+
- payload (UserRole): The payload containing the user email and organization ID.
|
|
3090
|
+
- workspace_id (str): The ID of the workspace.
|
|
3091
|
+
- request (Request): The FastAPI request object.
|
|
3092
|
+
|
|
3093
|
+
Returns:
|
|
3094
|
+
- WorkspaceResponse: The updated workspace.
|
|
3095
|
+
|
|
3096
|
+
Raises:
|
|
3097
|
+
- HTTPException: If the user does not have permission to perform this action.
|
|
3098
|
+
- HTTPException: If there is an error during the removal process.
|
|
3099
|
+
|
|
3100
|
+
Parameters
|
|
3101
|
+
----------
|
|
3102
|
+
workspace_id : str
|
|
3103
|
+
|
|
3104
|
+
org_id : str
|
|
3105
|
+
|
|
3106
|
+
email : str
|
|
3107
|
+
|
|
3108
|
+
request_options : typing.Optional[RequestOptions]
|
|
3109
|
+
Request-specific configuration.
|
|
3110
|
+
|
|
3111
|
+
Returns
|
|
3112
|
+
-------
|
|
3113
|
+
WorkspaceResponse
|
|
3114
|
+
Successful Response
|
|
3115
|
+
|
|
3116
|
+
Examples
|
|
3117
|
+
--------
|
|
3118
|
+
import asyncio
|
|
3119
|
+
|
|
3120
|
+
from agenta import AsyncAgentaApi
|
|
3121
|
+
|
|
3122
|
+
client = AsyncAgentaApi(
|
|
3123
|
+
api_key="YOUR_API_KEY",
|
|
3124
|
+
base_url="https://yourhost.com/path/to/api",
|
|
3125
|
+
)
|
|
3126
|
+
|
|
3127
|
+
|
|
3128
|
+
async def main() -> None:
|
|
3129
|
+
await client.remove_user_from_workspace(
|
|
3130
|
+
workspace_id="workspace_id",
|
|
3131
|
+
org_id="org_id",
|
|
3132
|
+
email="email",
|
|
523
3133
|
)
|
|
524
|
-
return response.json()["id"]
|
|
525
|
-
except RequestException as e:
|
|
526
|
-
raise APIRequestError(f"Request failed: {str(e)}")
|
|
527
3134
|
|
|
528
3135
|
|
|
529
|
-
|
|
3136
|
+
asyncio.run(main())
|
|
3137
|
+
"""
|
|
3138
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3139
|
+
f"workspaces/{jsonable_encoder(workspace_id)}/users",
|
|
3140
|
+
method="DELETE",
|
|
3141
|
+
params={
|
|
3142
|
+
"org_id": org_id,
|
|
3143
|
+
"email": email,
|
|
3144
|
+
},
|
|
3145
|
+
request_options=request_options,
|
|
3146
|
+
)
|
|
3147
|
+
try:
|
|
3148
|
+
if 200 <= _response.status_code < 300:
|
|
3149
|
+
return typing.cast(
|
|
3150
|
+
WorkspaceResponse,
|
|
3151
|
+
parse_obj_as(
|
|
3152
|
+
type_=WorkspaceResponse, # type: ignore
|
|
3153
|
+
object_=_response.json(),
|
|
3154
|
+
),
|
|
3155
|
+
)
|
|
3156
|
+
if _response.status_code == 422:
|
|
3157
|
+
raise UnprocessableEntityError(
|
|
3158
|
+
typing.cast(
|
|
3159
|
+
HttpValidationError,
|
|
3160
|
+
parse_obj_as(
|
|
3161
|
+
type_=HttpValidationError, # type: ignore
|
|
3162
|
+
object_=_response.json(),
|
|
3163
|
+
),
|
|
3164
|
+
)
|
|
3165
|
+
)
|
|
3166
|
+
_response_json = _response.json()
|
|
3167
|
+
except JSONDecodeError:
|
|
3168
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
3169
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
3170
|
+
|
|
3171
|
+
async def health_check(
|
|
3172
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
3173
|
+
) -> typing.Optional[typing.Any]:
|
|
3174
|
+
"""
|
|
3175
|
+
Parameters
|
|
3176
|
+
----------
|
|
3177
|
+
request_options : typing.Optional[RequestOptions]
|
|
3178
|
+
Request-specific configuration.
|
|
3179
|
+
|
|
3180
|
+
Returns
|
|
3181
|
+
-------
|
|
3182
|
+
typing.Optional[typing.Any]
|
|
3183
|
+
Successful Response
|
|
3184
|
+
|
|
3185
|
+
Examples
|
|
3186
|
+
--------
|
|
3187
|
+
import asyncio
|
|
3188
|
+
|
|
3189
|
+
from agenta import AsyncAgentaApi
|
|
3190
|
+
|
|
3191
|
+
client = AsyncAgentaApi(
|
|
3192
|
+
api_key="YOUR_API_KEY",
|
|
3193
|
+
base_url="https://yourhost.com/path/to/api",
|
|
3194
|
+
)
|
|
3195
|
+
|
|
530
3196
|
|
|
3197
|
+
async def main() -> None:
|
|
3198
|
+
await client.health_check()
|
|
531
3199
|
|
|
532
|
-
# def run_evaluation(app_name: str, host: str, api_key: str = None) -> str:
|
|
533
|
-
def run_evaluation(app_name: str, host: str, api_key: str = None) -> str:
|
|
534
|
-
"""Creates new app on the server.
|
|
535
|
-
Args:
|
|
536
|
-
app_name (str): Name of the app
|
|
537
|
-
host (str): Hostname of the server
|
|
538
|
-
api_key (str): The API key to use for the request.
|
|
539
|
-
"""
|
|
540
3200
|
|
|
541
|
-
|
|
542
|
-
"
|
|
543
|
-
|
|
544
|
-
"
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
"evaluators_configs": ["65856b2b11d53fcce5894ab6"],
|
|
548
|
-
"testset_id": "6583e552eb855930ec6b1be4",
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
response = requests.post(
|
|
552
|
-
f"{host}/api/evaluations/",
|
|
553
|
-
json=new_evaluation,
|
|
554
|
-
# headers={"Authorization": api_key} if api_key is not None else None,
|
|
555
|
-
timeout=600,
|
|
556
|
-
)
|
|
557
|
-
if response.status_code != 200:
|
|
558
|
-
error_message = response.json()
|
|
559
|
-
raise APIRequestError(
|
|
560
|
-
f"Request to run evaluations failed with status code {response.status_code} and error message: {error_message}."
|
|
3201
|
+
asyncio.run(main())
|
|
3202
|
+
"""
|
|
3203
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3204
|
+
"health",
|
|
3205
|
+
method="GET",
|
|
3206
|
+
request_options=request_options,
|
|
561
3207
|
)
|
|
3208
|
+
try:
|
|
3209
|
+
if 200 <= _response.status_code < 300:
|
|
3210
|
+
return typing.cast(
|
|
3211
|
+
typing.Optional[typing.Any],
|
|
3212
|
+
parse_obj_as(
|
|
3213
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3214
|
+
object_=_response.json(),
|
|
3215
|
+
),
|
|
3216
|
+
)
|
|
3217
|
+
_response_json = _response.json()
|
|
3218
|
+
except JSONDecodeError:
|
|
3219
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
3220
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
3221
|
+
|
|
3222
|
+
async def fetch_user_profile(
|
|
3223
|
+
self,
|
|
3224
|
+
*,
|
|
3225
|
+
user_id: typing.Optional[str] = None,
|
|
3226
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
3227
|
+
) -> typing.Optional[typing.Any]:
|
|
3228
|
+
"""
|
|
3229
|
+
Parameters
|
|
3230
|
+
----------
|
|
3231
|
+
user_id : typing.Optional[str]
|
|
3232
|
+
|
|
3233
|
+
request_options : typing.Optional[RequestOptions]
|
|
3234
|
+
Request-specific configuration.
|
|
3235
|
+
|
|
3236
|
+
Returns
|
|
3237
|
+
-------
|
|
3238
|
+
typing.Optional[typing.Any]
|
|
3239
|
+
Successful Response
|
|
3240
|
+
|
|
3241
|
+
Examples
|
|
3242
|
+
--------
|
|
3243
|
+
import asyncio
|
|
3244
|
+
|
|
3245
|
+
from agenta import AsyncAgentaApi
|
|
3246
|
+
|
|
3247
|
+
client = AsyncAgentaApi(
|
|
3248
|
+
api_key="YOUR_API_KEY",
|
|
3249
|
+
base_url="https://yourhost.com/path/to/api",
|
|
3250
|
+
)
|
|
3251
|
+
|
|
562
3252
|
|
|
563
|
-
|
|
3253
|
+
async def main() -> None:
|
|
3254
|
+
await client.fetch_user_profile()
|
|
3255
|
+
|
|
3256
|
+
|
|
3257
|
+
asyncio.run(main())
|
|
3258
|
+
"""
|
|
3259
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3260
|
+
"profile",
|
|
3261
|
+
method="GET",
|
|
3262
|
+
params={
|
|
3263
|
+
"user_id": user_id,
|
|
3264
|
+
},
|
|
3265
|
+
request_options=request_options,
|
|
3266
|
+
)
|
|
3267
|
+
try:
|
|
3268
|
+
if 200 <= _response.status_code < 300:
|
|
3269
|
+
return typing.cast(
|
|
3270
|
+
typing.Optional[typing.Any],
|
|
3271
|
+
parse_obj_as(
|
|
3272
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3273
|
+
object_=_response.json(),
|
|
3274
|
+
),
|
|
3275
|
+
)
|
|
3276
|
+
if _response.status_code == 422:
|
|
3277
|
+
raise UnprocessableEntityError(
|
|
3278
|
+
typing.cast(
|
|
3279
|
+
HttpValidationError,
|
|
3280
|
+
parse_obj_as(
|
|
3281
|
+
type_=HttpValidationError, # type: ignore
|
|
3282
|
+
object_=_response.json(),
|
|
3283
|
+
),
|
|
3284
|
+
)
|
|
3285
|
+
)
|
|
3286
|
+
_response_json = _response.json()
|
|
3287
|
+
except JSONDecodeError:
|
|
3288
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
3289
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|