hackagent 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. hackagent/__init__.py +23 -0
  2. hackagent/agent.py +193 -0
  3. hackagent/api/__init__.py +1 -0
  4. hackagent/api/agent/__init__.py +1 -0
  5. hackagent/api/agent/agent_create.py +340 -0
  6. hackagent/api/agent/agent_destroy.py +136 -0
  7. hackagent/api/agent/agent_list.py +234 -0
  8. hackagent/api/agent/agent_partial_update.py +354 -0
  9. hackagent/api/agent/agent_retrieve.py +227 -0
  10. hackagent/api/agent/agent_update.py +354 -0
  11. hackagent/api/attack/__init__.py +1 -0
  12. hackagent/api/attack/attack_create.py +264 -0
  13. hackagent/api/attack/attack_destroy.py +140 -0
  14. hackagent/api/attack/attack_list.py +242 -0
  15. hackagent/api/attack/attack_partial_update.py +278 -0
  16. hackagent/api/attack/attack_retrieve.py +235 -0
  17. hackagent/api/attack/attack_update.py +278 -0
  18. hackagent/api/key/__init__.py +1 -0
  19. hackagent/api/key/key_create.py +168 -0
  20. hackagent/api/key/key_destroy.py +97 -0
  21. hackagent/api/key/key_list.py +158 -0
  22. hackagent/api/key/key_retrieve.py +150 -0
  23. hackagent/api/prompt/__init__.py +1 -0
  24. hackagent/api/prompt/prompt_create.py +160 -0
  25. hackagent/api/prompt/prompt_destroy.py +98 -0
  26. hackagent/api/prompt/prompt_list.py +173 -0
  27. hackagent/api/prompt/prompt_partial_update.py +174 -0
  28. hackagent/api/prompt/prompt_retrieve.py +151 -0
  29. hackagent/api/prompt/prompt_update.py +174 -0
  30. hackagent/api/result/__init__.py +1 -0
  31. hackagent/api/result/result_create.py +160 -0
  32. hackagent/api/result/result_destroy.py +98 -0
  33. hackagent/api/result/result_list.py +233 -0
  34. hackagent/api/result/result_partial_update.py +178 -0
  35. hackagent/api/result/result_retrieve.py +151 -0
  36. hackagent/api/result/result_trace_create.py +178 -0
  37. hackagent/api/result/result_update.py +174 -0
  38. hackagent/api/run/__init__.py +1 -0
  39. hackagent/api/run/run_create.py +172 -0
  40. hackagent/api/run/run_destroy.py +104 -0
  41. hackagent/api/run/run_list.py +260 -0
  42. hackagent/api/run/run_partial_update.py +186 -0
  43. hackagent/api/run/run_result_create.py +178 -0
  44. hackagent/api/run/run_retrieve.py +163 -0
  45. hackagent/api/run/run_run_tests_create.py +172 -0
  46. hackagent/api/run/run_update.py +186 -0
  47. hackagent/attacks/AdvPrefix/README.md +7 -0
  48. hackagent/attacks/AdvPrefix/__init__.py +0 -0
  49. hackagent/attacks/AdvPrefix/completer.py +438 -0
  50. hackagent/attacks/AdvPrefix/config.py +59 -0
  51. hackagent/attacks/AdvPrefix/preprocessing.py +521 -0
  52. hackagent/attacks/AdvPrefix/scorer.py +259 -0
  53. hackagent/attacks/AdvPrefix/scorer_parser.py +498 -0
  54. hackagent/attacks/AdvPrefix/selector.py +246 -0
  55. hackagent/attacks/AdvPrefix/step1_generate.py +324 -0
  56. hackagent/attacks/AdvPrefix/step4_compute_ce.py +293 -0
  57. hackagent/attacks/AdvPrefix/step6_get_completions.py +387 -0
  58. hackagent/attacks/AdvPrefix/step7_evaluate_responses.py +289 -0
  59. hackagent/attacks/AdvPrefix/step8_aggregate_evaluations.py +177 -0
  60. hackagent/attacks/AdvPrefix/step9_select_prefixes.py +59 -0
  61. hackagent/attacks/AdvPrefix/utils.py +192 -0
  62. hackagent/attacks/__init__.py +6 -0
  63. hackagent/attacks/advprefix.py +1136 -0
  64. hackagent/attacks/base.py +50 -0
  65. hackagent/attacks/strategies.py +539 -0
  66. hackagent/branding.py +143 -0
  67. hackagent/client.py +328 -0
  68. hackagent/errors.py +31 -0
  69. hackagent/logger.py +67 -0
  70. hackagent/models/__init__.py +71 -0
  71. hackagent/models/agent.py +240 -0
  72. hackagent/models/agent_request.py +169 -0
  73. hackagent/models/agent_type_enum.py +12 -0
  74. hackagent/models/attack.py +154 -0
  75. hackagent/models/attack_request.py +82 -0
  76. hackagent/models/evaluation_status_enum.py +14 -0
  77. hackagent/models/organization_minimal.py +68 -0
  78. hackagent/models/paginated_agent_list.py +123 -0
  79. hackagent/models/paginated_attack_list.py +123 -0
  80. hackagent/models/paginated_prompt_list.py +123 -0
  81. hackagent/models/paginated_result_list.py +123 -0
  82. hackagent/models/paginated_run_list.py +123 -0
  83. hackagent/models/paginated_user_api_key_list.py +123 -0
  84. hackagent/models/patched_agent_request.py +176 -0
  85. hackagent/models/patched_attack_request.py +92 -0
  86. hackagent/models/patched_prompt_request.py +162 -0
  87. hackagent/models/patched_result_request.py +237 -0
  88. hackagent/models/patched_run_request.py +138 -0
  89. hackagent/models/prompt.py +226 -0
  90. hackagent/models/prompt_request.py +155 -0
  91. hackagent/models/result.py +294 -0
  92. hackagent/models/result_list_evaluation_status.py +14 -0
  93. hackagent/models/result_request.py +232 -0
  94. hackagent/models/run.py +233 -0
  95. hackagent/models/run_list_status.py +12 -0
  96. hackagent/models/run_request.py +133 -0
  97. hackagent/models/status_enum.py +12 -0
  98. hackagent/models/step_type_enum.py +14 -0
  99. hackagent/models/trace.py +121 -0
  100. hackagent/models/trace_request.py +94 -0
  101. hackagent/models/user_api_key.py +201 -0
  102. hackagent/models/user_api_key_request.py +73 -0
  103. hackagent/models/user_profile_minimal.py +76 -0
  104. hackagent/py.typed +1 -0
  105. hackagent/router/__init__.py +11 -0
  106. hackagent/router/adapters/__init__.py +5 -0
  107. hackagent/router/adapters/google_adk.py +658 -0
  108. hackagent/router/adapters/litellm_adapter.py +290 -0
  109. hackagent/router/base.py +48 -0
  110. hackagent/router/router.py +753 -0
  111. hackagent/types.py +46 -0
  112. hackagent/utils.py +61 -0
  113. hackagent/vulnerabilities/__init__.py +0 -0
  114. hackagent-0.1.0.dist-info/LICENSE +202 -0
  115. hackagent-0.1.0.dist-info/METADATA +173 -0
  116. hackagent-0.1.0.dist-info/RECORD +117 -0
  117. hackagent-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,68 @@
1
+ from collections.abc import Mapping
2
+ from typing import Any, TypeVar
3
+ from uuid import UUID
4
+
5
+ from attrs import define as _attrs_define
6
+ from attrs import field as _attrs_field
7
+
8
+ T = TypeVar("T", bound="OrganizationMinimal")
9
+
10
+
11
+ @_attrs_define
12
+ class OrganizationMinimal:
13
+ """
14
+ Attributes:
15
+ id (UUID):
16
+ name (str):
17
+ """
18
+
19
+ id: UUID
20
+ name: str
21
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
22
+
23
+ def to_dict(self) -> dict[str, Any]:
24
+ id = str(self.id)
25
+
26
+ name = self.name
27
+
28
+ field_dict: dict[str, Any] = {}
29
+ field_dict.update(self.additional_properties)
30
+ field_dict.update(
31
+ {
32
+ "id": id,
33
+ "name": name,
34
+ }
35
+ )
36
+
37
+ return field_dict
38
+
39
+ @classmethod
40
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
41
+ d = dict(src_dict)
42
+ id = UUID(d.pop("id"))
43
+
44
+ name = d.pop("name")
45
+
46
+ organization_minimal = cls(
47
+ id=id,
48
+ name=name,
49
+ )
50
+
51
+ organization_minimal.additional_properties = d
52
+ return organization_minimal
53
+
54
+ @property
55
+ def additional_keys(self) -> list[str]:
56
+ return list(self.additional_properties.keys())
57
+
58
+ def __getitem__(self, key: str) -> Any:
59
+ return self.additional_properties[key]
60
+
61
+ def __setitem__(self, key: str, value: Any) -> None:
62
+ self.additional_properties[key] = value
63
+
64
+ def __delitem__(self, key: str) -> None:
65
+ del self.additional_properties[key]
66
+
67
+ def __contains__(self, key: str) -> bool:
68
+ return key in self.additional_properties
@@ -0,0 +1,123 @@
1
+ from collections.abc import Mapping
2
+ from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
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
+ if TYPE_CHECKING:
10
+ from ..models.agent import Agent
11
+
12
+
13
+ T = TypeVar("T", bound="PaginatedAgentList")
14
+
15
+
16
+ @_attrs_define
17
+ class PaginatedAgentList:
18
+ """
19
+ Attributes:
20
+ count (int): Example: 123.
21
+ results (list['Agent']):
22
+ next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4.
23
+ previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2.
24
+ """
25
+
26
+ count: int
27
+ results: list["Agent"]
28
+ next_: Union[None, Unset, str] = UNSET
29
+ previous: Union[None, Unset, str] = UNSET
30
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
31
+
32
+ def to_dict(self) -> dict[str, Any]:
33
+ count = self.count
34
+
35
+ results = []
36
+ for results_item_data in self.results:
37
+ results_item = results_item_data.to_dict()
38
+ results.append(results_item)
39
+
40
+ next_: Union[None, Unset, str]
41
+ if isinstance(self.next_, Unset):
42
+ next_ = UNSET
43
+ else:
44
+ next_ = self.next_
45
+
46
+ previous: Union[None, Unset, str]
47
+ if isinstance(self.previous, Unset):
48
+ previous = UNSET
49
+ else:
50
+ previous = self.previous
51
+
52
+ field_dict: dict[str, Any] = {}
53
+ field_dict.update(self.additional_properties)
54
+ field_dict.update(
55
+ {
56
+ "count": count,
57
+ "results": results,
58
+ }
59
+ )
60
+ if next_ is not UNSET:
61
+ field_dict["next"] = next_
62
+ if previous is not UNSET:
63
+ field_dict["previous"] = previous
64
+
65
+ return field_dict
66
+
67
+ @classmethod
68
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
69
+ from ..models.agent import Agent
70
+
71
+ d = dict(src_dict)
72
+ count = d.pop("count")
73
+
74
+ results = []
75
+ _results = d.pop("results")
76
+ for results_item_data in _results:
77
+ results_item = Agent.from_dict(results_item_data)
78
+
79
+ results.append(results_item)
80
+
81
+ def _parse_next_(data: object) -> Union[None, Unset, str]:
82
+ if data is None:
83
+ return data
84
+ if isinstance(data, Unset):
85
+ return data
86
+ return cast(Union[None, Unset, str], data)
87
+
88
+ next_ = _parse_next_(d.pop("next", UNSET))
89
+
90
+ def _parse_previous(data: object) -> Union[None, Unset, str]:
91
+ if data is None:
92
+ return data
93
+ if isinstance(data, Unset):
94
+ return data
95
+ return cast(Union[None, Unset, str], data)
96
+
97
+ previous = _parse_previous(d.pop("previous", UNSET))
98
+
99
+ paginated_agent_list = cls(
100
+ count=count,
101
+ results=results,
102
+ next_=next_,
103
+ previous=previous,
104
+ )
105
+
106
+ paginated_agent_list.additional_properties = d
107
+ return paginated_agent_list
108
+
109
+ @property
110
+ def additional_keys(self) -> list[str]:
111
+ return list(self.additional_properties.keys())
112
+
113
+ def __getitem__(self, key: str) -> Any:
114
+ return self.additional_properties[key]
115
+
116
+ def __setitem__(self, key: str, value: Any) -> None:
117
+ self.additional_properties[key] = value
118
+
119
+ def __delitem__(self, key: str) -> None:
120
+ del self.additional_properties[key]
121
+
122
+ def __contains__(self, key: str) -> bool:
123
+ return key in self.additional_properties
@@ -0,0 +1,123 @@
1
+ from collections.abc import Mapping
2
+ from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
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
+ if TYPE_CHECKING:
10
+ from ..models.attack import Attack
11
+
12
+
13
+ T = TypeVar("T", bound="PaginatedAttackList")
14
+
15
+
16
+ @_attrs_define
17
+ class PaginatedAttackList:
18
+ """
19
+ Attributes:
20
+ count (int): Example: 123.
21
+ results (list['Attack']):
22
+ next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4.
23
+ previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2.
24
+ """
25
+
26
+ count: int
27
+ results: list["Attack"]
28
+ next_: Union[None, Unset, str] = UNSET
29
+ previous: Union[None, Unset, str] = UNSET
30
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
31
+
32
+ def to_dict(self) -> dict[str, Any]:
33
+ count = self.count
34
+
35
+ results = []
36
+ for results_item_data in self.results:
37
+ results_item = results_item_data.to_dict()
38
+ results.append(results_item)
39
+
40
+ next_: Union[None, Unset, str]
41
+ if isinstance(self.next_, Unset):
42
+ next_ = UNSET
43
+ else:
44
+ next_ = self.next_
45
+
46
+ previous: Union[None, Unset, str]
47
+ if isinstance(self.previous, Unset):
48
+ previous = UNSET
49
+ else:
50
+ previous = self.previous
51
+
52
+ field_dict: dict[str, Any] = {}
53
+ field_dict.update(self.additional_properties)
54
+ field_dict.update(
55
+ {
56
+ "count": count,
57
+ "results": results,
58
+ }
59
+ )
60
+ if next_ is not UNSET:
61
+ field_dict["next"] = next_
62
+ if previous is not UNSET:
63
+ field_dict["previous"] = previous
64
+
65
+ return field_dict
66
+
67
+ @classmethod
68
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
69
+ from ..models.attack import Attack
70
+
71
+ d = dict(src_dict)
72
+ count = d.pop("count")
73
+
74
+ results = []
75
+ _results = d.pop("results")
76
+ for results_item_data in _results:
77
+ results_item = Attack.from_dict(results_item_data)
78
+
79
+ results.append(results_item)
80
+
81
+ def _parse_next_(data: object) -> Union[None, Unset, str]:
82
+ if data is None:
83
+ return data
84
+ if isinstance(data, Unset):
85
+ return data
86
+ return cast(Union[None, Unset, str], data)
87
+
88
+ next_ = _parse_next_(d.pop("next", UNSET))
89
+
90
+ def _parse_previous(data: object) -> Union[None, Unset, str]:
91
+ if data is None:
92
+ return data
93
+ if isinstance(data, Unset):
94
+ return data
95
+ return cast(Union[None, Unset, str], data)
96
+
97
+ previous = _parse_previous(d.pop("previous", UNSET))
98
+
99
+ paginated_attack_list = cls(
100
+ count=count,
101
+ results=results,
102
+ next_=next_,
103
+ previous=previous,
104
+ )
105
+
106
+ paginated_attack_list.additional_properties = d
107
+ return paginated_attack_list
108
+
109
+ @property
110
+ def additional_keys(self) -> list[str]:
111
+ return list(self.additional_properties.keys())
112
+
113
+ def __getitem__(self, key: str) -> Any:
114
+ return self.additional_properties[key]
115
+
116
+ def __setitem__(self, key: str, value: Any) -> None:
117
+ self.additional_properties[key] = value
118
+
119
+ def __delitem__(self, key: str) -> None:
120
+ del self.additional_properties[key]
121
+
122
+ def __contains__(self, key: str) -> bool:
123
+ return key in self.additional_properties
@@ -0,0 +1,123 @@
1
+ from collections.abc import Mapping
2
+ from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
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
+ if TYPE_CHECKING:
10
+ from ..models.prompt import Prompt
11
+
12
+
13
+ T = TypeVar("T", bound="PaginatedPromptList")
14
+
15
+
16
+ @_attrs_define
17
+ class PaginatedPromptList:
18
+ """
19
+ Attributes:
20
+ count (int): Example: 123.
21
+ results (list['Prompt']):
22
+ next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4.
23
+ previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2.
24
+ """
25
+
26
+ count: int
27
+ results: list["Prompt"]
28
+ next_: Union[None, Unset, str] = UNSET
29
+ previous: Union[None, Unset, str] = UNSET
30
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
31
+
32
+ def to_dict(self) -> dict[str, Any]:
33
+ count = self.count
34
+
35
+ results = []
36
+ for results_item_data in self.results:
37
+ results_item = results_item_data.to_dict()
38
+ results.append(results_item)
39
+
40
+ next_: Union[None, Unset, str]
41
+ if isinstance(self.next_, Unset):
42
+ next_ = UNSET
43
+ else:
44
+ next_ = self.next_
45
+
46
+ previous: Union[None, Unset, str]
47
+ if isinstance(self.previous, Unset):
48
+ previous = UNSET
49
+ else:
50
+ previous = self.previous
51
+
52
+ field_dict: dict[str, Any] = {}
53
+ field_dict.update(self.additional_properties)
54
+ field_dict.update(
55
+ {
56
+ "count": count,
57
+ "results": results,
58
+ }
59
+ )
60
+ if next_ is not UNSET:
61
+ field_dict["next"] = next_
62
+ if previous is not UNSET:
63
+ field_dict["previous"] = previous
64
+
65
+ return field_dict
66
+
67
+ @classmethod
68
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
69
+ from ..models.prompt import Prompt
70
+
71
+ d = dict(src_dict)
72
+ count = d.pop("count")
73
+
74
+ results = []
75
+ _results = d.pop("results")
76
+ for results_item_data in _results:
77
+ results_item = Prompt.from_dict(results_item_data)
78
+
79
+ results.append(results_item)
80
+
81
+ def _parse_next_(data: object) -> Union[None, Unset, str]:
82
+ if data is None:
83
+ return data
84
+ if isinstance(data, Unset):
85
+ return data
86
+ return cast(Union[None, Unset, str], data)
87
+
88
+ next_ = _parse_next_(d.pop("next", UNSET))
89
+
90
+ def _parse_previous(data: object) -> Union[None, Unset, str]:
91
+ if data is None:
92
+ return data
93
+ if isinstance(data, Unset):
94
+ return data
95
+ return cast(Union[None, Unset, str], data)
96
+
97
+ previous = _parse_previous(d.pop("previous", UNSET))
98
+
99
+ paginated_prompt_list = cls(
100
+ count=count,
101
+ results=results,
102
+ next_=next_,
103
+ previous=previous,
104
+ )
105
+
106
+ paginated_prompt_list.additional_properties = d
107
+ return paginated_prompt_list
108
+
109
+ @property
110
+ def additional_keys(self) -> list[str]:
111
+ return list(self.additional_properties.keys())
112
+
113
+ def __getitem__(self, key: str) -> Any:
114
+ return self.additional_properties[key]
115
+
116
+ def __setitem__(self, key: str, value: Any) -> None:
117
+ self.additional_properties[key] = value
118
+
119
+ def __delitem__(self, key: str) -> None:
120
+ del self.additional_properties[key]
121
+
122
+ def __contains__(self, key: str) -> bool:
123
+ return key in self.additional_properties
@@ -0,0 +1,123 @@
1
+ from collections.abc import Mapping
2
+ from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
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
+ if TYPE_CHECKING:
10
+ from ..models.result import Result
11
+
12
+
13
+ T = TypeVar("T", bound="PaginatedResultList")
14
+
15
+
16
+ @_attrs_define
17
+ class PaginatedResultList:
18
+ """
19
+ Attributes:
20
+ count (int): Example: 123.
21
+ results (list['Result']):
22
+ next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4.
23
+ previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2.
24
+ """
25
+
26
+ count: int
27
+ results: list["Result"]
28
+ next_: Union[None, Unset, str] = UNSET
29
+ previous: Union[None, Unset, str] = UNSET
30
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
31
+
32
+ def to_dict(self) -> dict[str, Any]:
33
+ count = self.count
34
+
35
+ results = []
36
+ for results_item_data in self.results:
37
+ results_item = results_item_data.to_dict()
38
+ results.append(results_item)
39
+
40
+ next_: Union[None, Unset, str]
41
+ if isinstance(self.next_, Unset):
42
+ next_ = UNSET
43
+ else:
44
+ next_ = self.next_
45
+
46
+ previous: Union[None, Unset, str]
47
+ if isinstance(self.previous, Unset):
48
+ previous = UNSET
49
+ else:
50
+ previous = self.previous
51
+
52
+ field_dict: dict[str, Any] = {}
53
+ field_dict.update(self.additional_properties)
54
+ field_dict.update(
55
+ {
56
+ "count": count,
57
+ "results": results,
58
+ }
59
+ )
60
+ if next_ is not UNSET:
61
+ field_dict["next"] = next_
62
+ if previous is not UNSET:
63
+ field_dict["previous"] = previous
64
+
65
+ return field_dict
66
+
67
+ @classmethod
68
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
69
+ from ..models.result import Result
70
+
71
+ d = dict(src_dict)
72
+ count = d.pop("count")
73
+
74
+ results = []
75
+ _results = d.pop("results")
76
+ for results_item_data in _results:
77
+ results_item = Result.from_dict(results_item_data)
78
+
79
+ results.append(results_item)
80
+
81
+ def _parse_next_(data: object) -> Union[None, Unset, str]:
82
+ if data is None:
83
+ return data
84
+ if isinstance(data, Unset):
85
+ return data
86
+ return cast(Union[None, Unset, str], data)
87
+
88
+ next_ = _parse_next_(d.pop("next", UNSET))
89
+
90
+ def _parse_previous(data: object) -> Union[None, Unset, str]:
91
+ if data is None:
92
+ return data
93
+ if isinstance(data, Unset):
94
+ return data
95
+ return cast(Union[None, Unset, str], data)
96
+
97
+ previous = _parse_previous(d.pop("previous", UNSET))
98
+
99
+ paginated_result_list = cls(
100
+ count=count,
101
+ results=results,
102
+ next_=next_,
103
+ previous=previous,
104
+ )
105
+
106
+ paginated_result_list.additional_properties = d
107
+ return paginated_result_list
108
+
109
+ @property
110
+ def additional_keys(self) -> list[str]:
111
+ return list(self.additional_properties.keys())
112
+
113
+ def __getitem__(self, key: str) -> Any:
114
+ return self.additional_properties[key]
115
+
116
+ def __setitem__(self, key: str, value: Any) -> None:
117
+ self.additional_properties[key] = value
118
+
119
+ def __delitem__(self, key: str) -> None:
120
+ del self.additional_properties[key]
121
+
122
+ def __contains__(self, key: str) -> bool:
123
+ return key in self.additional_properties
@@ -0,0 +1,123 @@
1
+ from collections.abc import Mapping
2
+ from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
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
+ if TYPE_CHECKING:
10
+ from ..models.run import Run
11
+
12
+
13
+ T = TypeVar("T", bound="PaginatedRunList")
14
+
15
+
16
+ @_attrs_define
17
+ class PaginatedRunList:
18
+ """
19
+ Attributes:
20
+ count (int): Example: 123.
21
+ results (list['Run']):
22
+ next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4.
23
+ previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2.
24
+ """
25
+
26
+ count: int
27
+ results: list["Run"]
28
+ next_: Union[None, Unset, str] = UNSET
29
+ previous: Union[None, Unset, str] = UNSET
30
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
31
+
32
+ def to_dict(self) -> dict[str, Any]:
33
+ count = self.count
34
+
35
+ results = []
36
+ for results_item_data in self.results:
37
+ results_item = results_item_data.to_dict()
38
+ results.append(results_item)
39
+
40
+ next_: Union[None, Unset, str]
41
+ if isinstance(self.next_, Unset):
42
+ next_ = UNSET
43
+ else:
44
+ next_ = self.next_
45
+
46
+ previous: Union[None, Unset, str]
47
+ if isinstance(self.previous, Unset):
48
+ previous = UNSET
49
+ else:
50
+ previous = self.previous
51
+
52
+ field_dict: dict[str, Any] = {}
53
+ field_dict.update(self.additional_properties)
54
+ field_dict.update(
55
+ {
56
+ "count": count,
57
+ "results": results,
58
+ }
59
+ )
60
+ if next_ is not UNSET:
61
+ field_dict["next"] = next_
62
+ if previous is not UNSET:
63
+ field_dict["previous"] = previous
64
+
65
+ return field_dict
66
+
67
+ @classmethod
68
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
69
+ from ..models.run import Run
70
+
71
+ d = dict(src_dict)
72
+ count = d.pop("count")
73
+
74
+ results = []
75
+ _results = d.pop("results")
76
+ for results_item_data in _results:
77
+ results_item = Run.from_dict(results_item_data)
78
+
79
+ results.append(results_item)
80
+
81
+ def _parse_next_(data: object) -> Union[None, Unset, str]:
82
+ if data is None:
83
+ return data
84
+ if isinstance(data, Unset):
85
+ return data
86
+ return cast(Union[None, Unset, str], data)
87
+
88
+ next_ = _parse_next_(d.pop("next", UNSET))
89
+
90
+ def _parse_previous(data: object) -> Union[None, Unset, str]:
91
+ if data is None:
92
+ return data
93
+ if isinstance(data, Unset):
94
+ return data
95
+ return cast(Union[None, Unset, str], data)
96
+
97
+ previous = _parse_previous(d.pop("previous", UNSET))
98
+
99
+ paginated_run_list = cls(
100
+ count=count,
101
+ results=results,
102
+ next_=next_,
103
+ previous=previous,
104
+ )
105
+
106
+ paginated_run_list.additional_properties = d
107
+ return paginated_run_list
108
+
109
+ @property
110
+ def additional_keys(self) -> list[str]:
111
+ return list(self.additional_properties.keys())
112
+
113
+ def __getitem__(self, key: str) -> Any:
114
+ return self.additional_properties[key]
115
+
116
+ def __setitem__(self, key: str, value: Any) -> None:
117
+ self.additional_properties[key] = value
118
+
119
+ def __delitem__(self, key: str) -> None:
120
+ del self.additional_properties[key]
121
+
122
+ def __contains__(self, key: str) -> bool:
123
+ return key in self.additional_properties