hackagent 0.3.1__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.
- hackagent/__init__.py +12 -0
- hackagent/agent.py +214 -0
- hackagent/api/__init__.py +1 -0
- hackagent/api/agent/__init__.py +1 -0
- hackagent/api/agent/agent_create.py +347 -0
- hackagent/api/agent/agent_destroy.py +140 -0
- hackagent/api/agent/agent_list.py +242 -0
- hackagent/api/agent/agent_partial_update.py +361 -0
- hackagent/api/agent/agent_retrieve.py +235 -0
- hackagent/api/agent/agent_update.py +361 -0
- hackagent/api/apilogs/__init__.py +1 -0
- hackagent/api/apilogs/apilogs_list.py +170 -0
- hackagent/api/apilogs/apilogs_retrieve.py +162 -0
- hackagent/api/attack/__init__.py +1 -0
- hackagent/api/attack/attack_create.py +275 -0
- hackagent/api/attack/attack_destroy.py +146 -0
- hackagent/api/attack/attack_list.py +254 -0
- hackagent/api/attack/attack_partial_update.py +289 -0
- hackagent/api/attack/attack_retrieve.py +247 -0
- hackagent/api/attack/attack_update.py +289 -0
- hackagent/api/checkout/__init__.py +1 -0
- hackagent/api/checkout/checkout_create.py +225 -0
- hackagent/api/generate/__init__.py +1 -0
- hackagent/api/generate/generate_create.py +253 -0
- hackagent/api/judge/__init__.py +1 -0
- hackagent/api/judge/judge_create.py +253 -0
- hackagent/api/key/__init__.py +1 -0
- hackagent/api/key/key_create.py +179 -0
- hackagent/api/key/key_destroy.py +103 -0
- hackagent/api/key/key_list.py +170 -0
- hackagent/api/key/key_retrieve.py +162 -0
- hackagent/api/organization/__init__.py +1 -0
- hackagent/api/organization/organization_create.py +208 -0
- hackagent/api/organization/organization_destroy.py +104 -0
- hackagent/api/organization/organization_list.py +170 -0
- hackagent/api/organization/organization_me_retrieve.py +126 -0
- hackagent/api/organization/organization_partial_update.py +222 -0
- hackagent/api/organization/organization_retrieve.py +163 -0
- hackagent/api/organization/organization_update.py +222 -0
- hackagent/api/prompt/__init__.py +1 -0
- hackagent/api/prompt/prompt_create.py +171 -0
- hackagent/api/prompt/prompt_destroy.py +104 -0
- hackagent/api/prompt/prompt_list.py +185 -0
- hackagent/api/prompt/prompt_partial_update.py +185 -0
- hackagent/api/prompt/prompt_retrieve.py +163 -0
- hackagent/api/prompt/prompt_update.py +185 -0
- hackagent/api/result/__init__.py +1 -0
- hackagent/api/result/result_create.py +175 -0
- hackagent/api/result/result_destroy.py +106 -0
- hackagent/api/result/result_list.py +249 -0
- hackagent/api/result/result_partial_update.py +193 -0
- hackagent/api/result/result_retrieve.py +167 -0
- hackagent/api/result/result_trace_create.py +177 -0
- hackagent/api/result/result_update.py +189 -0
- hackagent/api/run/__init__.py +1 -0
- hackagent/api/run/run_create.py +187 -0
- hackagent/api/run/run_destroy.py +112 -0
- hackagent/api/run/run_list.py +291 -0
- hackagent/api/run/run_partial_update.py +201 -0
- hackagent/api/run/run_result_create.py +177 -0
- hackagent/api/run/run_retrieve.py +179 -0
- hackagent/api/run/run_run_tests_create.py +187 -0
- hackagent/api/run/run_update.py +201 -0
- hackagent/api/user/__init__.py +1 -0
- hackagent/api/user/user_create.py +212 -0
- hackagent/api/user/user_destroy.py +106 -0
- hackagent/api/user/user_list.py +174 -0
- hackagent/api/user/user_me_retrieve.py +126 -0
- hackagent/api/user/user_me_update.py +196 -0
- hackagent/api/user/user_partial_update.py +226 -0
- hackagent/api/user/user_retrieve.py +167 -0
- hackagent/api/user/user_update.py +226 -0
- hackagent/attacks/AdvPrefix/__init__.py +41 -0
- hackagent/attacks/AdvPrefix/completions.py +416 -0
- hackagent/attacks/AdvPrefix/config.py +259 -0
- hackagent/attacks/AdvPrefix/evaluation.py +745 -0
- hackagent/attacks/AdvPrefix/evaluators.py +564 -0
- hackagent/attacks/AdvPrefix/generate.py +711 -0
- hackagent/attacks/AdvPrefix/utils.py +307 -0
- hackagent/attacks/__init__.py +35 -0
- hackagent/attacks/advprefix.py +507 -0
- hackagent/attacks/base.py +106 -0
- hackagent/attacks/strategies.py +906 -0
- hackagent/cli/__init__.py +19 -0
- hackagent/cli/commands/__init__.py +20 -0
- hackagent/cli/commands/agent.py +100 -0
- hackagent/cli/commands/attack.py +417 -0
- hackagent/cli/commands/config.py +301 -0
- hackagent/cli/commands/results.py +327 -0
- hackagent/cli/config.py +249 -0
- hackagent/cli/main.py +515 -0
- hackagent/cli/tui/__init__.py +31 -0
- hackagent/cli/tui/actions_logger.py +200 -0
- hackagent/cli/tui/app.py +288 -0
- hackagent/cli/tui/base.py +137 -0
- hackagent/cli/tui/logger.py +318 -0
- hackagent/cli/tui/views/__init__.py +33 -0
- hackagent/cli/tui/views/agents.py +488 -0
- hackagent/cli/tui/views/attacks.py +624 -0
- hackagent/cli/tui/views/config.py +244 -0
- hackagent/cli/tui/views/dashboard.py +307 -0
- hackagent/cli/tui/views/results.py +1210 -0
- hackagent/cli/tui/widgets/__init__.py +24 -0
- hackagent/cli/tui/widgets/actions.py +346 -0
- hackagent/cli/tui/widgets/logs.py +435 -0
- hackagent/cli/utils.py +276 -0
- hackagent/client.py +286 -0
- hackagent/errors.py +37 -0
- hackagent/logger.py +83 -0
- hackagent/models/__init__.py +109 -0
- hackagent/models/agent.py +223 -0
- hackagent/models/agent_request.py +129 -0
- hackagent/models/api_token_log.py +184 -0
- hackagent/models/attack.py +154 -0
- hackagent/models/attack_request.py +82 -0
- hackagent/models/checkout_session_request_request.py +76 -0
- hackagent/models/checkout_session_response.py +59 -0
- hackagent/models/choice.py +81 -0
- hackagent/models/choice_message.py +67 -0
- hackagent/models/evaluation_status_enum.py +14 -0
- hackagent/models/generate_error_response.py +59 -0
- hackagent/models/generate_request_request.py +212 -0
- hackagent/models/generate_success_response.py +115 -0
- hackagent/models/generic_error_response.py +70 -0
- hackagent/models/message_request.py +67 -0
- hackagent/models/organization.py +102 -0
- hackagent/models/organization_minimal.py +68 -0
- hackagent/models/organization_request.py +71 -0
- hackagent/models/paginated_agent_list.py +123 -0
- hackagent/models/paginated_api_token_log_list.py +123 -0
- hackagent/models/paginated_attack_list.py +123 -0
- hackagent/models/paginated_organization_list.py +123 -0
- hackagent/models/paginated_prompt_list.py +123 -0
- hackagent/models/paginated_result_list.py +123 -0
- hackagent/models/paginated_run_list.py +123 -0
- hackagent/models/paginated_user_api_key_list.py +123 -0
- hackagent/models/paginated_user_profile_list.py +123 -0
- hackagent/models/patched_agent_request.py +128 -0
- hackagent/models/patched_attack_request.py +92 -0
- hackagent/models/patched_organization_request.py +71 -0
- hackagent/models/patched_prompt_request.py +125 -0
- hackagent/models/patched_result_request.py +237 -0
- hackagent/models/patched_run_request.py +138 -0
- hackagent/models/patched_user_profile_request.py +99 -0
- hackagent/models/prompt.py +220 -0
- hackagent/models/prompt_request.py +126 -0
- hackagent/models/result.py +294 -0
- hackagent/models/result_list_evaluation_status.py +14 -0
- hackagent/models/result_request.py +232 -0
- hackagent/models/run.py +233 -0
- hackagent/models/run_list_status.py +12 -0
- hackagent/models/run_request.py +133 -0
- hackagent/models/status_enum.py +12 -0
- hackagent/models/step_type_enum.py +14 -0
- hackagent/models/trace.py +121 -0
- hackagent/models/trace_request.py +94 -0
- hackagent/models/usage.py +75 -0
- hackagent/models/user_api_key.py +201 -0
- hackagent/models/user_api_key_request.py +73 -0
- hackagent/models/user_profile.py +135 -0
- hackagent/models/user_profile_minimal.py +76 -0
- hackagent/models/user_profile_request.py +99 -0
- hackagent/router/__init__.py +25 -0
- hackagent/router/adapters/__init__.py +20 -0
- hackagent/router/adapters/base.py +63 -0
- hackagent/router/adapters/google_adk.py +671 -0
- hackagent/router/adapters/litellm_adapter.py +524 -0
- hackagent/router/adapters/openai_adapter.py +426 -0
- hackagent/router/router.py +969 -0
- hackagent/router/types.py +54 -0
- hackagent/tracking/__init__.py +42 -0
- hackagent/tracking/context.py +163 -0
- hackagent/tracking/decorators.py +299 -0
- hackagent/tracking/tracker.py +441 -0
- hackagent/types.py +54 -0
- hackagent/utils.py +194 -0
- hackagent/vulnerabilities/__init__.py +13 -0
- hackagent/vulnerabilities/prompts.py +81 -0
- hackagent-0.3.1.dist-info/METADATA +122 -0
- hackagent-0.3.1.dist-info/RECORD +183 -0
- hackagent-0.3.1.dist-info/WHEEL +4 -0
- hackagent-0.3.1.dist-info/entry_points.txt +2 -0
- hackagent-0.3.1.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from collections.abc import Mapping
|
|
3
|
+
from typing import Any, TypeVar, Union
|
|
4
|
+
from uuid import UUID
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
from dateutil.parser import isoparse
|
|
9
|
+
|
|
10
|
+
from ..models.step_type_enum import StepTypeEnum
|
|
11
|
+
from ..types import UNSET, Unset
|
|
12
|
+
|
|
13
|
+
T = TypeVar("T", bound="Trace")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@_attrs_define
|
|
17
|
+
class Trace:
|
|
18
|
+
"""Serializer for the Trace model.
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
id (int):
|
|
22
|
+
result (UUID):
|
|
23
|
+
sequence (int):
|
|
24
|
+
timestamp (datetime.datetime):
|
|
25
|
+
step_type (Union[Unset, StepTypeEnum]): * `TOOL_CALL` - Tool Call
|
|
26
|
+
* `TOOL_RESPONSE` - Tool Response
|
|
27
|
+
* `AGENT_THOUGHT` - Agent Thought/Reasoning
|
|
28
|
+
* `AGENT_RESPONSE_CHUNK` - Agent Response Chunk
|
|
29
|
+
* `OTHER` - Other
|
|
30
|
+
* `MCP_STEP` - Multi-Context Prompting Step
|
|
31
|
+
* `A2A_COMM` - Agent-to-Agent Communication
|
|
32
|
+
content (Union[Unset, Any]):
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
id: int
|
|
36
|
+
result: UUID
|
|
37
|
+
sequence: int
|
|
38
|
+
timestamp: datetime.datetime
|
|
39
|
+
step_type: Union[Unset, StepTypeEnum] = UNSET
|
|
40
|
+
content: Union[Unset, Any] = UNSET
|
|
41
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
42
|
+
|
|
43
|
+
def to_dict(self) -> dict[str, Any]:
|
|
44
|
+
id = self.id
|
|
45
|
+
|
|
46
|
+
result = str(self.result)
|
|
47
|
+
|
|
48
|
+
sequence = self.sequence
|
|
49
|
+
|
|
50
|
+
timestamp = self.timestamp.isoformat()
|
|
51
|
+
|
|
52
|
+
step_type: Union[Unset, str] = UNSET
|
|
53
|
+
if not isinstance(self.step_type, Unset):
|
|
54
|
+
step_type = self.step_type.value
|
|
55
|
+
|
|
56
|
+
content = self.content
|
|
57
|
+
|
|
58
|
+
field_dict: dict[str, Any] = {}
|
|
59
|
+
field_dict.update(self.additional_properties)
|
|
60
|
+
field_dict.update(
|
|
61
|
+
{
|
|
62
|
+
"id": id,
|
|
63
|
+
"result": result,
|
|
64
|
+
"sequence": sequence,
|
|
65
|
+
"timestamp": timestamp,
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
if step_type is not UNSET:
|
|
69
|
+
field_dict["step_type"] = step_type
|
|
70
|
+
if content is not UNSET:
|
|
71
|
+
field_dict["content"] = content
|
|
72
|
+
|
|
73
|
+
return field_dict
|
|
74
|
+
|
|
75
|
+
@classmethod
|
|
76
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
77
|
+
d = dict(src_dict)
|
|
78
|
+
id = d.pop("id")
|
|
79
|
+
|
|
80
|
+
result = UUID(d.pop("result"))
|
|
81
|
+
|
|
82
|
+
sequence = d.pop("sequence")
|
|
83
|
+
|
|
84
|
+
timestamp = isoparse(d.pop("timestamp"))
|
|
85
|
+
|
|
86
|
+
_step_type = d.pop("step_type", UNSET)
|
|
87
|
+
step_type: Union[Unset, StepTypeEnum]
|
|
88
|
+
if isinstance(_step_type, Unset):
|
|
89
|
+
step_type = UNSET
|
|
90
|
+
else:
|
|
91
|
+
step_type = StepTypeEnum(_step_type)
|
|
92
|
+
|
|
93
|
+
content = d.pop("content", UNSET)
|
|
94
|
+
|
|
95
|
+
trace = cls(
|
|
96
|
+
id=id,
|
|
97
|
+
result=result,
|
|
98
|
+
sequence=sequence,
|
|
99
|
+
timestamp=timestamp,
|
|
100
|
+
step_type=step_type,
|
|
101
|
+
content=content,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
trace.additional_properties = d
|
|
105
|
+
return trace
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def additional_keys(self) -> list[str]:
|
|
109
|
+
return list(self.additional_properties.keys())
|
|
110
|
+
|
|
111
|
+
def __getitem__(self, key: str) -> Any:
|
|
112
|
+
return self.additional_properties[key]
|
|
113
|
+
|
|
114
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
115
|
+
self.additional_properties[key] = value
|
|
116
|
+
|
|
117
|
+
def __delitem__(self, key: str) -> None:
|
|
118
|
+
del self.additional_properties[key]
|
|
119
|
+
|
|
120
|
+
def __contains__(self, key: str) -> bool:
|
|
121
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import Any, TypeVar, Union
|
|
3
|
+
|
|
4
|
+
from attrs import define as _attrs_define
|
|
5
|
+
from attrs import field as _attrs_field
|
|
6
|
+
|
|
7
|
+
from ..models.step_type_enum import StepTypeEnum
|
|
8
|
+
from ..types import UNSET, Unset
|
|
9
|
+
|
|
10
|
+
T = TypeVar("T", bound="TraceRequest")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@_attrs_define
|
|
14
|
+
class TraceRequest:
|
|
15
|
+
"""Serializer for the Trace model.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
sequence (int):
|
|
19
|
+
step_type (Union[Unset, StepTypeEnum]): * `TOOL_CALL` - Tool Call
|
|
20
|
+
* `TOOL_RESPONSE` - Tool Response
|
|
21
|
+
* `AGENT_THOUGHT` - Agent Thought/Reasoning
|
|
22
|
+
* `AGENT_RESPONSE_CHUNK` - Agent Response Chunk
|
|
23
|
+
* `OTHER` - Other
|
|
24
|
+
* `MCP_STEP` - Multi-Context Prompting Step
|
|
25
|
+
* `A2A_COMM` - Agent-to-Agent Communication
|
|
26
|
+
content (Union[Unset, Any]):
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
sequence: int
|
|
30
|
+
step_type: Union[Unset, StepTypeEnum] = UNSET
|
|
31
|
+
content: Union[Unset, Any] = UNSET
|
|
32
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
33
|
+
|
|
34
|
+
def to_dict(self) -> dict[str, Any]:
|
|
35
|
+
sequence = self.sequence
|
|
36
|
+
|
|
37
|
+
step_type: Union[Unset, str] = UNSET
|
|
38
|
+
if not isinstance(self.step_type, Unset):
|
|
39
|
+
step_type = self.step_type.value
|
|
40
|
+
|
|
41
|
+
content = self.content
|
|
42
|
+
|
|
43
|
+
field_dict: dict[str, Any] = {}
|
|
44
|
+
field_dict.update(self.additional_properties)
|
|
45
|
+
field_dict.update(
|
|
46
|
+
{
|
|
47
|
+
"sequence": sequence,
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
if step_type is not UNSET:
|
|
51
|
+
field_dict["step_type"] = step_type
|
|
52
|
+
if content is not UNSET:
|
|
53
|
+
field_dict["content"] = content
|
|
54
|
+
|
|
55
|
+
return field_dict
|
|
56
|
+
|
|
57
|
+
@classmethod
|
|
58
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
59
|
+
d = dict(src_dict)
|
|
60
|
+
sequence = d.pop("sequence")
|
|
61
|
+
|
|
62
|
+
_step_type = d.pop("step_type", UNSET)
|
|
63
|
+
step_type: Union[Unset, StepTypeEnum]
|
|
64
|
+
if isinstance(_step_type, Unset):
|
|
65
|
+
step_type = UNSET
|
|
66
|
+
else:
|
|
67
|
+
step_type = StepTypeEnum(_step_type)
|
|
68
|
+
|
|
69
|
+
content = d.pop("content", UNSET)
|
|
70
|
+
|
|
71
|
+
trace_request = cls(
|
|
72
|
+
sequence=sequence,
|
|
73
|
+
step_type=step_type,
|
|
74
|
+
content=content,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
trace_request.additional_properties = d
|
|
78
|
+
return trace_request
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
def additional_keys(self) -> list[str]:
|
|
82
|
+
return list(self.additional_properties.keys())
|
|
83
|
+
|
|
84
|
+
def __getitem__(self, key: str) -> Any:
|
|
85
|
+
return self.additional_properties[key]
|
|
86
|
+
|
|
87
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
88
|
+
self.additional_properties[key] = value
|
|
89
|
+
|
|
90
|
+
def __delitem__(self, key: str) -> None:
|
|
91
|
+
del self.additional_properties[key]
|
|
92
|
+
|
|
93
|
+
def __contains__(self, key: str) -> bool:
|
|
94
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import Any, TypeVar
|
|
3
|
+
|
|
4
|
+
from attrs import define as _attrs_define
|
|
5
|
+
from attrs import field as _attrs_field
|
|
6
|
+
|
|
7
|
+
T = TypeVar("T", bound="Usage")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@_attrs_define
|
|
11
|
+
class Usage:
|
|
12
|
+
"""
|
|
13
|
+
Attributes:
|
|
14
|
+
prompt_tokens (int): Number of tokens in the prompt
|
|
15
|
+
completion_tokens (int): Number of tokens in the completion
|
|
16
|
+
total_tokens (int): Total tokens used
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
prompt_tokens: int
|
|
20
|
+
completion_tokens: int
|
|
21
|
+
total_tokens: int
|
|
22
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
23
|
+
|
|
24
|
+
def to_dict(self) -> dict[str, Any]:
|
|
25
|
+
prompt_tokens = self.prompt_tokens
|
|
26
|
+
|
|
27
|
+
completion_tokens = self.completion_tokens
|
|
28
|
+
|
|
29
|
+
total_tokens = self.total_tokens
|
|
30
|
+
|
|
31
|
+
field_dict: dict[str, Any] = {}
|
|
32
|
+
field_dict.update(self.additional_properties)
|
|
33
|
+
field_dict.update(
|
|
34
|
+
{
|
|
35
|
+
"prompt_tokens": prompt_tokens,
|
|
36
|
+
"completion_tokens": completion_tokens,
|
|
37
|
+
"total_tokens": total_tokens,
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return field_dict
|
|
42
|
+
|
|
43
|
+
@classmethod
|
|
44
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
45
|
+
d = dict(src_dict)
|
|
46
|
+
prompt_tokens = d.pop("prompt_tokens")
|
|
47
|
+
|
|
48
|
+
completion_tokens = d.pop("completion_tokens")
|
|
49
|
+
|
|
50
|
+
total_tokens = d.pop("total_tokens")
|
|
51
|
+
|
|
52
|
+
usage = cls(
|
|
53
|
+
prompt_tokens=prompt_tokens,
|
|
54
|
+
completion_tokens=completion_tokens,
|
|
55
|
+
total_tokens=total_tokens,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
usage.additional_properties = d
|
|
59
|
+
return usage
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def additional_keys(self) -> list[str]:
|
|
63
|
+
return list(self.additional_properties.keys())
|
|
64
|
+
|
|
65
|
+
def __getitem__(self, key: str) -> Any:
|
|
66
|
+
return self.additional_properties[key]
|
|
67
|
+
|
|
68
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
69
|
+
self.additional_properties[key] = value
|
|
70
|
+
|
|
71
|
+
def __delitem__(self, key: str) -> None:
|
|
72
|
+
del self.additional_properties[key]
|
|
73
|
+
|
|
74
|
+
def __contains__(self, key: str) -> bool:
|
|
75
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from collections.abc import Mapping
|
|
3
|
+
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
|
|
4
|
+
from uuid import UUID
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
from dateutil.parser import isoparse
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from ..models.organization_minimal import OrganizationMinimal
|
|
12
|
+
from ..models.user_profile_minimal import UserProfileMinimal
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
T = TypeVar("T", bound="UserAPIKey")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@_attrs_define
|
|
19
|
+
class UserAPIKey:
|
|
20
|
+
"""Serializer for User API Keys.
|
|
21
|
+
Exposes read-only information about the key, including its prefix.
|
|
22
|
+
The full key is only shown once upon creation by the ViewSet.
|
|
23
|
+
|
|
24
|
+
Attributes:
|
|
25
|
+
id (str):
|
|
26
|
+
name (str): A human-readable name for the API key.
|
|
27
|
+
prefix (str):
|
|
28
|
+
created (datetime.datetime):
|
|
29
|
+
revoked (bool): If the API key is revoked, clients cannot use it anymore. (This cannot be undone.)
|
|
30
|
+
expiry_date (Union[None, datetime.datetime]): Once API key expires, clients cannot use it anymore.
|
|
31
|
+
user (int):
|
|
32
|
+
user_detail (Union['UserProfileMinimal', None]):
|
|
33
|
+
organization (UUID):
|
|
34
|
+
organization_detail (Union['OrganizationMinimal', None]):
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
id: str
|
|
38
|
+
name: str
|
|
39
|
+
prefix: str
|
|
40
|
+
created: datetime.datetime
|
|
41
|
+
revoked: bool
|
|
42
|
+
expiry_date: Union[None, datetime.datetime]
|
|
43
|
+
user: int
|
|
44
|
+
user_detail: Union["UserProfileMinimal", None]
|
|
45
|
+
organization: UUID
|
|
46
|
+
organization_detail: Union["OrganizationMinimal", None]
|
|
47
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
48
|
+
|
|
49
|
+
def to_dict(self) -> dict[str, Any]:
|
|
50
|
+
from ..models.organization_minimal import OrganizationMinimal
|
|
51
|
+
from ..models.user_profile_minimal import UserProfileMinimal
|
|
52
|
+
|
|
53
|
+
id = self.id
|
|
54
|
+
|
|
55
|
+
name = self.name
|
|
56
|
+
|
|
57
|
+
prefix = self.prefix
|
|
58
|
+
|
|
59
|
+
created = self.created.isoformat()
|
|
60
|
+
|
|
61
|
+
revoked = self.revoked
|
|
62
|
+
|
|
63
|
+
expiry_date: Union[None, str]
|
|
64
|
+
if isinstance(self.expiry_date, datetime.datetime):
|
|
65
|
+
expiry_date = self.expiry_date.isoformat()
|
|
66
|
+
else:
|
|
67
|
+
expiry_date = self.expiry_date
|
|
68
|
+
|
|
69
|
+
user = self.user
|
|
70
|
+
|
|
71
|
+
user_detail: Union[None, dict[str, Any]]
|
|
72
|
+
if isinstance(self.user_detail, UserProfileMinimal):
|
|
73
|
+
user_detail = self.user_detail.to_dict()
|
|
74
|
+
else:
|
|
75
|
+
user_detail = self.user_detail
|
|
76
|
+
|
|
77
|
+
organization = str(self.organization)
|
|
78
|
+
|
|
79
|
+
organization_detail: Union[None, dict[str, Any]]
|
|
80
|
+
if isinstance(self.organization_detail, OrganizationMinimal):
|
|
81
|
+
organization_detail = self.organization_detail.to_dict()
|
|
82
|
+
else:
|
|
83
|
+
organization_detail = self.organization_detail
|
|
84
|
+
|
|
85
|
+
field_dict: dict[str, Any] = {}
|
|
86
|
+
field_dict.update(self.additional_properties)
|
|
87
|
+
field_dict.update(
|
|
88
|
+
{
|
|
89
|
+
"id": id,
|
|
90
|
+
"name": name,
|
|
91
|
+
"prefix": prefix,
|
|
92
|
+
"created": created,
|
|
93
|
+
"revoked": revoked,
|
|
94
|
+
"expiry_date": expiry_date,
|
|
95
|
+
"user": user,
|
|
96
|
+
"user_detail": user_detail,
|
|
97
|
+
"organization": organization,
|
|
98
|
+
"organization_detail": organization_detail,
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
return field_dict
|
|
103
|
+
|
|
104
|
+
@classmethod
|
|
105
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
106
|
+
from ..models.organization_minimal import OrganizationMinimal
|
|
107
|
+
from ..models.user_profile_minimal import UserProfileMinimal
|
|
108
|
+
|
|
109
|
+
d = dict(src_dict)
|
|
110
|
+
id = d.pop("id")
|
|
111
|
+
|
|
112
|
+
name = d.pop("name")
|
|
113
|
+
|
|
114
|
+
prefix = d.pop("prefix")
|
|
115
|
+
|
|
116
|
+
created = isoparse(d.pop("created"))
|
|
117
|
+
|
|
118
|
+
revoked = d.pop("revoked")
|
|
119
|
+
|
|
120
|
+
def _parse_expiry_date(data: object) -> Union[None, datetime.datetime]:
|
|
121
|
+
if data is None:
|
|
122
|
+
return data
|
|
123
|
+
try:
|
|
124
|
+
if not isinstance(data, str):
|
|
125
|
+
raise TypeError()
|
|
126
|
+
expiry_date_type_0 = isoparse(data)
|
|
127
|
+
|
|
128
|
+
return expiry_date_type_0
|
|
129
|
+
except: # noqa: E722
|
|
130
|
+
pass
|
|
131
|
+
return cast(Union[None, datetime.datetime], data)
|
|
132
|
+
|
|
133
|
+
expiry_date = _parse_expiry_date(d.pop("expiry_date"))
|
|
134
|
+
|
|
135
|
+
user = d.pop("user")
|
|
136
|
+
|
|
137
|
+
def _parse_user_detail(data: object) -> Union["UserProfileMinimal", None]:
|
|
138
|
+
if data is None:
|
|
139
|
+
return data
|
|
140
|
+
try:
|
|
141
|
+
if not isinstance(data, dict):
|
|
142
|
+
raise TypeError()
|
|
143
|
+
user_detail_type_1 = UserProfileMinimal.from_dict(data)
|
|
144
|
+
|
|
145
|
+
return user_detail_type_1
|
|
146
|
+
except: # noqa: E722
|
|
147
|
+
pass
|
|
148
|
+
return cast(Union["UserProfileMinimal", None], data)
|
|
149
|
+
|
|
150
|
+
user_detail = _parse_user_detail(d.pop("user_detail"))
|
|
151
|
+
|
|
152
|
+
organization = UUID(d.pop("organization"))
|
|
153
|
+
|
|
154
|
+
def _parse_organization_detail(
|
|
155
|
+
data: object,
|
|
156
|
+
) -> Union["OrganizationMinimal", None]:
|
|
157
|
+
if data is None:
|
|
158
|
+
return data
|
|
159
|
+
try:
|
|
160
|
+
if not isinstance(data, dict):
|
|
161
|
+
raise TypeError()
|
|
162
|
+
organization_detail_type_1 = OrganizationMinimal.from_dict(data)
|
|
163
|
+
|
|
164
|
+
return organization_detail_type_1
|
|
165
|
+
except: # noqa: E722
|
|
166
|
+
pass
|
|
167
|
+
return cast(Union["OrganizationMinimal", None], data)
|
|
168
|
+
|
|
169
|
+
organization_detail = _parse_organization_detail(d.pop("organization_detail"))
|
|
170
|
+
|
|
171
|
+
user_api_key = cls(
|
|
172
|
+
id=id,
|
|
173
|
+
name=name,
|
|
174
|
+
prefix=prefix,
|
|
175
|
+
created=created,
|
|
176
|
+
revoked=revoked,
|
|
177
|
+
expiry_date=expiry_date,
|
|
178
|
+
user=user,
|
|
179
|
+
user_detail=user_detail,
|
|
180
|
+
organization=organization,
|
|
181
|
+
organization_detail=organization_detail,
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
user_api_key.additional_properties = d
|
|
185
|
+
return user_api_key
|
|
186
|
+
|
|
187
|
+
@property
|
|
188
|
+
def additional_keys(self) -> list[str]:
|
|
189
|
+
return list(self.additional_properties.keys())
|
|
190
|
+
|
|
191
|
+
def __getitem__(self, key: str) -> Any:
|
|
192
|
+
return self.additional_properties[key]
|
|
193
|
+
|
|
194
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
195
|
+
self.additional_properties[key] = value
|
|
196
|
+
|
|
197
|
+
def __delitem__(self, key: str) -> None:
|
|
198
|
+
del self.additional_properties[key]
|
|
199
|
+
|
|
200
|
+
def __contains__(self, key: str) -> bool:
|
|
201
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import Any, TypeVar, Union
|
|
3
|
+
|
|
4
|
+
from attrs import define as _attrs_define
|
|
5
|
+
from attrs import field as _attrs_field
|
|
6
|
+
|
|
7
|
+
from ..types import UNSET, Unset
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound="UserAPIKeyRequest")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class UserAPIKeyRequest:
|
|
14
|
+
"""Serializer for User API Keys.
|
|
15
|
+
Exposes read-only information about the key, including its prefix.
|
|
16
|
+
The full key is only shown once upon creation by the ViewSet.
|
|
17
|
+
|
|
18
|
+
Attributes:
|
|
19
|
+
name (str): A human-readable name for the API key.
|
|
20
|
+
key (Union[Unset, str]):
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
name: str
|
|
24
|
+
key: Union[Unset, str] = UNSET
|
|
25
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
26
|
+
|
|
27
|
+
def to_dict(self) -> dict[str, Any]:
|
|
28
|
+
name = self.name
|
|
29
|
+
|
|
30
|
+
key = self.key
|
|
31
|
+
|
|
32
|
+
field_dict: dict[str, Any] = {}
|
|
33
|
+
field_dict.update(self.additional_properties)
|
|
34
|
+
field_dict.update(
|
|
35
|
+
{
|
|
36
|
+
"name": name,
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
if key is not UNSET:
|
|
40
|
+
field_dict["key"] = key
|
|
41
|
+
|
|
42
|
+
return field_dict
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
46
|
+
d = dict(src_dict)
|
|
47
|
+
name = d.pop("name")
|
|
48
|
+
|
|
49
|
+
key = d.pop("key", UNSET)
|
|
50
|
+
|
|
51
|
+
user_api_key_request = cls(
|
|
52
|
+
name=name,
|
|
53
|
+
key=key,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
user_api_key_request.additional_properties = d
|
|
57
|
+
return user_api_key_request
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def additional_keys(self) -> list[str]:
|
|
61
|
+
return list(self.additional_properties.keys())
|
|
62
|
+
|
|
63
|
+
def __getitem__(self, key: str) -> Any:
|
|
64
|
+
return self.additional_properties[key]
|
|
65
|
+
|
|
66
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
67
|
+
self.additional_properties[key] = value
|
|
68
|
+
|
|
69
|
+
def __delitem__(self, key: str) -> None:
|
|
70
|
+
del self.additional_properties[key]
|
|
71
|
+
|
|
72
|
+
def __contains__(self, key: str) -> bool:
|
|
73
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import Any, TypeVar, Union, cast
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
|
|
5
|
+
from attrs import define as _attrs_define
|
|
6
|
+
from attrs import field as _attrs_field
|
|
7
|
+
|
|
8
|
+
from ..types import UNSET, Unset
|
|
9
|
+
|
|
10
|
+
T = TypeVar("T", bound="UserProfile")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@_attrs_define
|
|
14
|
+
class UserProfile:
|
|
15
|
+
"""
|
|
16
|
+
Attributes:
|
|
17
|
+
id (UUID):
|
|
18
|
+
user (int):
|
|
19
|
+
username (str):
|
|
20
|
+
organization (UUID):
|
|
21
|
+
organization_name (str):
|
|
22
|
+
auth0_user_id (Union[None, str]): The unique user identifier (sub claim) provided by Auth0.
|
|
23
|
+
email (Union[Unset, str]):
|
|
24
|
+
first_name (Union[Unset, str]):
|
|
25
|
+
last_name (Union[Unset, str]):
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
id: UUID
|
|
29
|
+
user: int
|
|
30
|
+
username: str
|
|
31
|
+
organization: UUID
|
|
32
|
+
organization_name: str
|
|
33
|
+
auth0_user_id: Union[None, str]
|
|
34
|
+
email: Union[Unset, str] = UNSET
|
|
35
|
+
first_name: Union[Unset, str] = UNSET
|
|
36
|
+
last_name: Union[Unset, str] = UNSET
|
|
37
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
38
|
+
|
|
39
|
+
def to_dict(self) -> dict[str, Any]:
|
|
40
|
+
id = str(self.id)
|
|
41
|
+
|
|
42
|
+
user = self.user
|
|
43
|
+
|
|
44
|
+
username = self.username
|
|
45
|
+
|
|
46
|
+
organization = str(self.organization)
|
|
47
|
+
|
|
48
|
+
organization_name = self.organization_name
|
|
49
|
+
|
|
50
|
+
auth0_user_id: Union[None, str]
|
|
51
|
+
auth0_user_id = self.auth0_user_id
|
|
52
|
+
|
|
53
|
+
email = self.email
|
|
54
|
+
|
|
55
|
+
first_name = self.first_name
|
|
56
|
+
|
|
57
|
+
last_name = self.last_name
|
|
58
|
+
|
|
59
|
+
field_dict: dict[str, Any] = {}
|
|
60
|
+
field_dict.update(self.additional_properties)
|
|
61
|
+
field_dict.update(
|
|
62
|
+
{
|
|
63
|
+
"id": id,
|
|
64
|
+
"user": user,
|
|
65
|
+
"username": username,
|
|
66
|
+
"organization": organization,
|
|
67
|
+
"organization_name": organization_name,
|
|
68
|
+
"auth0_user_id": auth0_user_id,
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
if email is not UNSET:
|
|
72
|
+
field_dict["email"] = email
|
|
73
|
+
if first_name is not UNSET:
|
|
74
|
+
field_dict["first_name"] = first_name
|
|
75
|
+
if last_name is not UNSET:
|
|
76
|
+
field_dict["last_name"] = last_name
|
|
77
|
+
|
|
78
|
+
return field_dict
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
82
|
+
d = dict(src_dict)
|
|
83
|
+
id = UUID(d.pop("id"))
|
|
84
|
+
|
|
85
|
+
user = d.pop("user")
|
|
86
|
+
|
|
87
|
+
username = d.pop("username")
|
|
88
|
+
|
|
89
|
+
organization = UUID(d.pop("organization"))
|
|
90
|
+
|
|
91
|
+
organization_name = d.pop("organization_name")
|
|
92
|
+
|
|
93
|
+
def _parse_auth0_user_id(data: object) -> Union[None, str]:
|
|
94
|
+
if data is None:
|
|
95
|
+
return data
|
|
96
|
+
return cast(Union[None, str], data)
|
|
97
|
+
|
|
98
|
+
auth0_user_id = _parse_auth0_user_id(d.pop("auth0_user_id"))
|
|
99
|
+
|
|
100
|
+
email = d.pop("email", UNSET)
|
|
101
|
+
|
|
102
|
+
first_name = d.pop("first_name", UNSET)
|
|
103
|
+
|
|
104
|
+
last_name = d.pop("last_name", UNSET)
|
|
105
|
+
|
|
106
|
+
user_profile = cls(
|
|
107
|
+
id=id,
|
|
108
|
+
user=user,
|
|
109
|
+
username=username,
|
|
110
|
+
organization=organization,
|
|
111
|
+
organization_name=organization_name,
|
|
112
|
+
auth0_user_id=auth0_user_id,
|
|
113
|
+
email=email,
|
|
114
|
+
first_name=first_name,
|
|
115
|
+
last_name=last_name,
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
user_profile.additional_properties = d
|
|
119
|
+
return user_profile
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
def additional_keys(self) -> list[str]:
|
|
123
|
+
return list(self.additional_properties.keys())
|
|
124
|
+
|
|
125
|
+
def __getitem__(self, key: str) -> Any:
|
|
126
|
+
return self.additional_properties[key]
|
|
127
|
+
|
|
128
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
129
|
+
self.additional_properties[key] = value
|
|
130
|
+
|
|
131
|
+
def __delitem__(self, key: str) -> None:
|
|
132
|
+
del self.additional_properties[key]
|
|
133
|
+
|
|
134
|
+
def __contains__(self, key: str) -> bool:
|
|
135
|
+
return key in self.additional_properties
|