binalyze-air-sdk 1.0.2__py3-none-any.whl → 1.0.3__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 (142) hide show
  1. binalyze_air/__init__.py +77 -77
  2. binalyze_air/apis/__init__.py +67 -27
  3. binalyze_air/apis/acquisitions.py +107 -0
  4. binalyze_air/apis/api_tokens.py +49 -0
  5. binalyze_air/apis/assets.py +161 -0
  6. binalyze_air/apis/audit_logs.py +26 -0
  7. binalyze_air/apis/{authentication.py → auth.py} +29 -27
  8. binalyze_air/apis/auto_asset_tags.py +79 -75
  9. binalyze_air/apis/backup.py +177 -0
  10. binalyze_air/apis/baseline.py +46 -0
  11. binalyze_air/apis/cases.py +225 -0
  12. binalyze_air/apis/cloud_forensics.py +116 -0
  13. binalyze_air/apis/event_subscription.py +96 -96
  14. binalyze_air/apis/evidence.py +249 -53
  15. binalyze_air/apis/interact.py +153 -36
  16. binalyze_air/apis/investigation_hub.py +234 -0
  17. binalyze_air/apis/license.py +104 -0
  18. binalyze_air/apis/logger.py +83 -0
  19. binalyze_air/apis/multipart_upload.py +201 -0
  20. binalyze_air/apis/notifications.py +115 -0
  21. binalyze_air/apis/organizations.py +267 -0
  22. binalyze_air/apis/params.py +44 -39
  23. binalyze_air/apis/policies.py +186 -0
  24. binalyze_air/apis/preset_filters.py +79 -0
  25. binalyze_air/apis/recent_activities.py +71 -0
  26. binalyze_air/apis/relay_server.py +104 -0
  27. binalyze_air/apis/settings.py +395 -27
  28. binalyze_air/apis/tasks.py +80 -0
  29. binalyze_air/apis/triage.py +197 -0
  30. binalyze_air/apis/user_management.py +183 -74
  31. binalyze_air/apis/webhook_executions.py +50 -0
  32. binalyze_air/apis/webhooks.py +322 -230
  33. binalyze_air/base.py +207 -133
  34. binalyze_air/client.py +217 -1337
  35. binalyze_air/commands/__init__.py +175 -145
  36. binalyze_air/commands/acquisitions.py +661 -387
  37. binalyze_air/commands/api_tokens.py +55 -0
  38. binalyze_air/commands/assets.py +324 -362
  39. binalyze_air/commands/{authentication.py → auth.py} +36 -36
  40. binalyze_air/commands/auto_asset_tags.py +230 -230
  41. binalyze_air/commands/backup.py +47 -0
  42. binalyze_air/commands/baseline.py +32 -396
  43. binalyze_air/commands/cases.py +609 -602
  44. binalyze_air/commands/cloud_forensics.py +88 -0
  45. binalyze_air/commands/event_subscription.py +101 -101
  46. binalyze_air/commands/evidences.py +918 -988
  47. binalyze_air/commands/interact.py +172 -58
  48. binalyze_air/commands/investigation_hub.py +315 -0
  49. binalyze_air/commands/license.py +183 -0
  50. binalyze_air/commands/logger.py +126 -0
  51. binalyze_air/commands/multipart_upload.py +363 -0
  52. binalyze_air/commands/notifications.py +45 -0
  53. binalyze_air/commands/organizations.py +200 -221
  54. binalyze_air/commands/policies.py +175 -203
  55. binalyze_air/commands/preset_filters.py +55 -0
  56. binalyze_air/commands/recent_activities.py +32 -0
  57. binalyze_air/commands/relay_server.py +144 -0
  58. binalyze_air/commands/settings.py +431 -29
  59. binalyze_air/commands/tasks.py +95 -56
  60. binalyze_air/commands/triage.py +224 -360
  61. binalyze_air/commands/user_management.py +351 -126
  62. binalyze_air/commands/webhook_executions.py +77 -0
  63. binalyze_air/config.py +244 -244
  64. binalyze_air/exceptions.py +49 -49
  65. binalyze_air/http_client.py +426 -305
  66. binalyze_air/models/__init__.py +287 -285
  67. binalyze_air/models/acquisitions.py +365 -250
  68. binalyze_air/models/api_tokens.py +73 -0
  69. binalyze_air/models/assets.py +438 -438
  70. binalyze_air/models/audit.py +247 -272
  71. binalyze_air/models/audit_logs.py +14 -0
  72. binalyze_air/models/{authentication.py → auth.py} +69 -69
  73. binalyze_air/models/auto_asset_tags.py +227 -116
  74. binalyze_air/models/backup.py +138 -0
  75. binalyze_air/models/baseline.py +231 -231
  76. binalyze_air/models/cases.py +275 -275
  77. binalyze_air/models/cloud_forensics.py +145 -0
  78. binalyze_air/models/event_subscription.py +170 -171
  79. binalyze_air/models/evidence.py +65 -65
  80. binalyze_air/models/evidences.py +367 -348
  81. binalyze_air/models/interact.py +266 -135
  82. binalyze_air/models/investigation_hub.py +265 -0
  83. binalyze_air/models/license.py +150 -0
  84. binalyze_air/models/logger.py +83 -0
  85. binalyze_air/models/multipart_upload.py +352 -0
  86. binalyze_air/models/notifications.py +138 -0
  87. binalyze_air/models/organizations.py +293 -293
  88. binalyze_air/models/params.py +153 -127
  89. binalyze_air/models/policies.py +260 -249
  90. binalyze_air/models/preset_filters.py +79 -0
  91. binalyze_air/models/recent_activities.py +70 -0
  92. binalyze_air/models/relay_server.py +121 -0
  93. binalyze_air/models/settings.py +538 -84
  94. binalyze_air/models/tasks.py +215 -149
  95. binalyze_air/models/triage.py +141 -142
  96. binalyze_air/models/user_management.py +200 -97
  97. binalyze_air/models/webhook_executions.py +33 -0
  98. binalyze_air/queries/__init__.py +121 -133
  99. binalyze_air/queries/acquisitions.py +155 -155
  100. binalyze_air/queries/api_tokens.py +46 -0
  101. binalyze_air/queries/assets.py +186 -105
  102. binalyze_air/queries/audit.py +400 -416
  103. binalyze_air/queries/{authentication.py → auth.py} +55 -55
  104. binalyze_air/queries/auto_asset_tags.py +59 -59
  105. binalyze_air/queries/backup.py +66 -0
  106. binalyze_air/queries/baseline.py +21 -185
  107. binalyze_air/queries/cases.py +292 -292
  108. binalyze_air/queries/cloud_forensics.py +137 -0
  109. binalyze_air/queries/event_subscription.py +54 -54
  110. binalyze_air/queries/evidence.py +139 -139
  111. binalyze_air/queries/evidences.py +279 -279
  112. binalyze_air/queries/interact.py +140 -28
  113. binalyze_air/queries/investigation_hub.py +329 -0
  114. binalyze_air/queries/license.py +85 -0
  115. binalyze_air/queries/logger.py +58 -0
  116. binalyze_air/queries/multipart_upload.py +180 -0
  117. binalyze_air/queries/notifications.py +71 -0
  118. binalyze_air/queries/organizations.py +222 -222
  119. binalyze_air/queries/params.py +154 -115
  120. binalyze_air/queries/policies.py +149 -149
  121. binalyze_air/queries/preset_filters.py +60 -0
  122. binalyze_air/queries/recent_activities.py +44 -0
  123. binalyze_air/queries/relay_server.py +42 -0
  124. binalyze_air/queries/settings.py +533 -20
  125. binalyze_air/queries/tasks.py +125 -81
  126. binalyze_air/queries/triage.py +230 -230
  127. binalyze_air/queries/user_management.py +193 -83
  128. binalyze_air/queries/webhook_executions.py +39 -0
  129. binalyze_air_sdk-1.0.3.dist-info/METADATA +752 -0
  130. binalyze_air_sdk-1.0.3.dist-info/RECORD +132 -0
  131. {binalyze_air_sdk-1.0.2.dist-info → binalyze_air_sdk-1.0.3.dist-info}/WHEEL +1 -1
  132. binalyze_air/apis/endpoints.py +0 -22
  133. binalyze_air/apis/evidences.py +0 -216
  134. binalyze_air/apis/users.py +0 -68
  135. binalyze_air/commands/users.py +0 -101
  136. binalyze_air/models/endpoints.py +0 -76
  137. binalyze_air/models/users.py +0 -82
  138. binalyze_air/queries/endpoints.py +0 -25
  139. binalyze_air/queries/users.py +0 -69
  140. binalyze_air_sdk-1.0.2.dist-info/METADATA +0 -706
  141. binalyze_air_sdk-1.0.2.dist-info/RECORD +0 -82
  142. {binalyze_air_sdk-1.0.2.dist-info → binalyze_air_sdk-1.0.3.dist-info}/top_level.txt +0 -0
@@ -1,203 +1,175 @@
1
- """
2
- Policy-related commands for the Binalyze AIR SDK.
3
- """
4
-
5
- from typing import Dict, Any, List, Optional, Union
6
-
7
- from ..base import Command
8
- from ..models.policies import (
9
- CreatePolicyRequest, UpdatePolicyRequest, UpdatePoliciesPrioritiesRequest,
10
- Policy, PolicyPriority, AssignPolicyRequest
11
- )
12
- from ..http_client import HTTPClient
13
-
14
-
15
- class CreatePolicyCommand(Command[Policy]):
16
- """Command to create a new policy."""
17
-
18
- def __init__(self, http_client: HTTPClient, policy_data: Union[CreatePolicyRequest, Dict[str, Any]]):
19
- self.http_client = http_client
20
- self.policy_data = policy_data
21
-
22
- def execute(self) -> Policy:
23
- """Execute the create policy command."""
24
- # Handle both dict and model objects
25
- if isinstance(self.policy_data, dict):
26
- payload = self.policy_data.copy()
27
- else:
28
- # Convert model to dict using model_dump with aliases
29
- payload = self.policy_data.model_dump(by_alias=True, exclude_none=True)
30
-
31
- response = self.http_client.post("policies", json_data=payload)
32
-
33
- # Parse using Pydantic models with automatic field mapping
34
- return Policy.model_validate(response.get("result", {}))
35
-
36
-
37
- class UpdatePolicyCommand(Command[Policy]):
38
- """Command to update an existing policy."""
39
-
40
- def __init__(self, http_client: HTTPClient, policy_id: str, update_data: Union[UpdatePolicyRequest, Dict[str, Any]]):
41
- self.http_client = http_client
42
- self.policy_id = policy_id
43
- self.update_data = update_data
44
-
45
- def execute(self) -> Policy:
46
- """Execute the update policy command."""
47
- # Handle both dict and model objects
48
- if isinstance(self.update_data, dict):
49
- payload = self.update_data.copy()
50
- else:
51
- # Convert model to dict using model_dump with aliases
52
- payload = self.update_data.model_dump(by_alias=True, exclude_none=True)
53
-
54
- response = self.http_client.put(f"policies/{self.policy_id}", json_data=payload)
55
-
56
- # Parse using Pydantic models with automatic field mapping
57
- return Policy.model_validate(response.get("result", {}))
58
-
59
-
60
- class UpdatePoliciesPrioritiesCommand(Command[Dict[str, Any]]):
61
- """Command to update policy priorities."""
62
-
63
- def __init__(self, http_client: HTTPClient, priorities_data: Union[UpdatePoliciesPrioritiesRequest, Dict[str, Any]]):
64
- self.http_client = http_client
65
- self.priorities_data = priorities_data
66
-
67
- def execute(self) -> Dict[str, Any]:
68
- """Execute the update policy priorities command."""
69
- # Handle both dict and model objects
70
- if isinstance(self.priorities_data, dict):
71
- payload = self.priorities_data.copy()
72
- else:
73
- # Convert model to dict using model_dump with aliases
74
- payload = self.priorities_data.model_dump(by_alias=True, exclude_none=True)
75
-
76
- return self.http_client.put("policies/priorities", json_data=payload)
77
-
78
-
79
- class DeletePolicyCommand(Command[Dict[str, Any]]):
80
- """Command to delete a policy."""
81
-
82
- def __init__(self, http_client: HTTPClient, policy_id: str):
83
- self.http_client = http_client
84
- self.policy_id = policy_id
85
-
86
- def execute(self) -> Dict[str, Any]:
87
- """Execute the delete policy command."""
88
- return self.http_client.delete(f"policies/{self.policy_id}")
89
-
90
-
91
- class AssignPolicyCommand(Command[Dict[str, Any]]):
92
- """Command to assign policy to endpoints."""
93
-
94
- def __init__(self, http_client: HTTPClient, assignment_data: Union[AssignPolicyRequest, Dict[str, Any]]):
95
- self.http_client = http_client
96
- self.assignment_data = assignment_data
97
-
98
- def execute(self) -> Dict[str, Any]:
99
- """Execute the assign policy command."""
100
- # Handle both dict and model objects
101
- if isinstance(self.assignment_data, dict):
102
- payload = self.assignment_data.copy()
103
- else:
104
- payload = {
105
- "policyId": self.assignment_data.policy_id,
106
- "endpointIds": self.assignment_data.endpoint_ids,
107
- "organizationIds": self.assignment_data.organization_ids,
108
- }
109
-
110
- if self.assignment_data.filter_params:
111
- payload["filter"] = self.assignment_data.filter_params
112
-
113
- return self.http_client.post("policies/assign", json_data=payload)
114
-
115
-
116
- class UnassignPolicyCommand(Command[Dict[str, Any]]):
117
- """Command to unassign policy from endpoints."""
118
-
119
- def __init__(self, http_client: HTTPClient, policy_id: str, endpoint_ids: List[str]):
120
- self.http_client = http_client
121
- self.policy_id = policy_id
122
- self.endpoint_ids = endpoint_ids
123
-
124
- def execute(self) -> Dict[str, Any]:
125
- """Execute the unassign policy command."""
126
- payload = {
127
- "policyId": self.policy_id,
128
- "endpointIds": self.endpoint_ids,
129
- }
130
-
131
- return self.http_client.post("policies/unassign", json_data=payload)
132
-
133
-
134
- class ExecutePolicyCommand(Command[Dict[str, Any]]):
135
- """Command to execute a policy on assigned endpoints."""
136
-
137
- def __init__(self, http_client: HTTPClient, policy_id: str, endpoint_ids: Optional[List[str]] = None):
138
- self.http_client = http_client
139
- self.policy_id = policy_id
140
- self.endpoint_ids = endpoint_ids
141
-
142
- def execute(self) -> Dict[str, Any]:
143
- """Execute the policy execution command."""
144
- payload = {"policyId": self.policy_id}
145
-
146
- if self.endpoint_ids:
147
- payload["endpointIds"] = self.endpoint_ids
148
-
149
- return self.http_client.post("policies/execute", json_data=payload)
150
-
151
-
152
- class ActivatePolicyCommand(Command[Policy]):
153
- """Command to activate a policy."""
154
-
155
- def __init__(self, http_client: HTTPClient, policy_id: str):
156
- self.http_client = http_client
157
- self.policy_id = policy_id
158
-
159
- def execute(self) -> Policy:
160
- """Execute the activate policy command."""
161
- payload = {"status": "active"}
162
- response = self.http_client.put(f"policies/{self.policy_id}", json_data=payload)
163
-
164
- entity_data = response.get("result", {})
165
- return Policy(
166
- id=entity_data.get("_id", self.policy_id),
167
- name=entity_data.get("name", ""),
168
- description=entity_data.get("description"),
169
- type=entity_data.get("type", "custom"),
170
- status=entity_data.get("status", "active"),
171
- organization_ids=entity_data.get("organizationIds", [0]),
172
- created_by=entity_data.get("createdBy", ""),
173
- created_at=entity_data.get("createdAt"),
174
- rules=entity_data.get("rules", []),
175
- tags=entity_data.get("tags", [])
176
- )
177
-
178
-
179
- class DeactivatePolicyCommand(Command[Policy]):
180
- """Command to deactivate a policy."""
181
-
182
- def __init__(self, http_client: HTTPClient, policy_id: str):
183
- self.http_client = http_client
184
- self.policy_id = policy_id
185
-
186
- def execute(self) -> Policy:
187
- """Execute the deactivate policy command."""
188
- payload = {"status": "inactive"}
189
- response = self.http_client.put(f"policies/{self.policy_id}", json_data=payload)
190
-
191
- entity_data = response.get("result", {})
192
- return Policy(
193
- id=entity_data.get("_id", self.policy_id),
194
- name=entity_data.get("name", ""),
195
- description=entity_data.get("description"),
196
- type=entity_data.get("type", "custom"),
197
- status=entity_data.get("status", "inactive"),
198
- organization_ids=entity_data.get("organizationIds", [0]),
199
- created_by=entity_data.get("createdBy", ""),
200
- created_at=entity_data.get("createdAt"),
201
- rules=entity_data.get("rules", []),
202
- tags=entity_data.get("tags", [])
203
- )
1
+ """
2
+ Policy-related commands for the Binalyze AIR SDK.
3
+ """
4
+
5
+ from typing import Dict, Any, List, Optional, Union, cast
6
+
7
+ from ..base import Command
8
+ from ..models.policies import (
9
+ CreatePolicyRequest, UpdatePolicyRequest, UpdatePoliciesPrioritiesRequest,
10
+ Policy, PolicyPriority, AssignPolicyRequest
11
+ )
12
+ from ..http_client import HTTPClient
13
+
14
+
15
+ class CreatePolicyCommand(Command[Policy]):
16
+ """Command to create a new policy."""
17
+
18
+ def __init__(self, http_client: HTTPClient, policy_data: Union[CreatePolicyRequest, Dict[str, Any]]):
19
+ self.http_client = http_client
20
+ self.policy_data = policy_data
21
+
22
+ def execute(self) -> Policy:
23
+ """Execute the create policy command."""
24
+ # Handle both dict and model objects
25
+ if isinstance(self.policy_data, dict):
26
+ payload = self.policy_data.copy()
27
+ else:
28
+ # Convert model to dict using model_dump with aliases
29
+ payload = self.policy_data.model_dump(by_alias=True, exclude_none=True)
30
+
31
+ response = self.http_client.post("policies", json_data=payload)
32
+
33
+ # Parse using Pydantic models with automatic field mapping
34
+ return Policy.model_validate(response.get("result", {}))
35
+
36
+
37
+ class UpdatePolicyCommand(Command[Policy]):
38
+ """Command to update an existing policy."""
39
+
40
+ def __init__(self, http_client: HTTPClient, policy_id: str, update_data: Union[UpdatePolicyRequest, Dict[str, Any]]):
41
+ self.http_client = http_client
42
+ self.policy_id = policy_id
43
+ self.update_data = update_data
44
+
45
+ def execute(self) -> Policy:
46
+ """Execute the update policy command."""
47
+ # Handle both dict and model objects
48
+ if isinstance(self.update_data, dict):
49
+ payload = self.update_data.copy()
50
+ else:
51
+ # Convert model to dict using model_dump with aliases
52
+ payload = self.update_data.model_dump(by_alias=True, exclude_none=True)
53
+
54
+ response = self.http_client.put(f"policies/{self.policy_id}", json_data=payload)
55
+
56
+ # Parse using Pydantic models with automatic field mapping
57
+ return Policy.model_validate(response.get("result", {}))
58
+
59
+
60
+ class UpdatePoliciesPrioritiesCommand(Command[Dict[str, Any]]):
61
+ """Command to update policy priorities."""
62
+
63
+ def __init__(self, http_client: HTTPClient, priorities_data: Union[UpdatePoliciesPrioritiesRequest, Dict[str, Any]]):
64
+ self.http_client = http_client
65
+ self.priorities_data = priorities_data
66
+
67
+ def execute(self) -> Dict[str, Any]:
68
+ """Execute the update policy priorities command."""
69
+ # Handle both dict and model objects
70
+ if isinstance(self.priorities_data, dict):
71
+ payload = self.priorities_data.copy()
72
+ else:
73
+ # Convert model to dict using model_dump with aliases
74
+ payload = self.priorities_data.model_dump(by_alias=True, exclude_none=True)
75
+
76
+ return self.http_client.put("policies/priorities", json_data=payload)
77
+
78
+
79
+ class DeletePolicyCommand(Command[Dict[str, Any]]):
80
+ """Command to delete a policy."""
81
+
82
+ def __init__(self, http_client: HTTPClient, policy_id: str):
83
+ self.http_client = http_client
84
+ self.policy_id = policy_id
85
+
86
+ def execute(self) -> Dict[str, Any]:
87
+ """Execute the delete policy command."""
88
+ return self.http_client.delete(f"policies/{self.policy_id}")
89
+
90
+
91
+ class AssignPolicyCommand(Command[Dict[str, Any]]):
92
+ """Command to assign policy to endpoints."""
93
+
94
+ def __init__(self, http_client: HTTPClient, assignment_data: Union[AssignPolicyRequest, Dict[str, Any]]):
95
+ self.http_client = http_client
96
+ self.assignment_data = assignment_data
97
+
98
+ def execute(self) -> Dict[str, Any]:
99
+ """Execute the assign policy command."""
100
+ # Handle both dict and model objects
101
+ if isinstance(self.assignment_data, dict):
102
+ payload = self.assignment_data.copy()
103
+ else:
104
+ # Use model_dump method to properly serialize the request object
105
+ payload = self.assignment_data.model_dump(by_alias=True, exclude_none=True)
106
+
107
+ return self.http_client.post("policies/assign", json_data=payload)
108
+
109
+
110
+ class UnassignPolicyCommand(Command[Dict[str, Any]]):
111
+ """Command to unassign policy from endpoints."""
112
+
113
+ def __init__(self, http_client: HTTPClient, policy_id: str, endpoint_ids: List[str]):
114
+ self.http_client = http_client
115
+ self.policy_id = policy_id
116
+ self.endpoint_ids = endpoint_ids
117
+
118
+ def execute(self) -> Dict[str, Any]:
119
+ """Execute the unassign policy command."""
120
+ payload: Dict[str, Any] = {}
121
+ payload["policyId"] = self.policy_id
122
+ payload["endpointIds"] = self.endpoint_ids
123
+
124
+ return self.http_client.post("policies/unassign", json_data=payload)
125
+
126
+
127
+ class ExecutePolicyCommand(Command[Dict[str, Any]]):
128
+ """Command to execute a policy on assigned endpoints."""
129
+
130
+ def __init__(self, http_client: HTTPClient, policy_id: str, endpoint_ids: Optional[List[str]] = None):
131
+ self.http_client = http_client
132
+ self.policy_id = policy_id
133
+ self.endpoint_ids = endpoint_ids
134
+
135
+ def execute(self) -> Dict[str, Any]:
136
+ """Execute the policy execution command."""
137
+ payload: Dict[str, Any] = {}
138
+ payload["policyId"] = self.policy_id
139
+
140
+ if self.endpoint_ids:
141
+ payload["endpointIds"] = self.endpoint_ids
142
+
143
+ return self.http_client.post("policies/execute", json_data=payload)
144
+
145
+
146
+ class ActivatePolicyCommand(Command[Policy]):
147
+ """Command to activate a policy."""
148
+
149
+ def __init__(self, http_client: HTTPClient, policy_id: str):
150
+ self.http_client = http_client
151
+ self.policy_id = policy_id
152
+
153
+ def execute(self) -> Policy:
154
+ """Execute the activate policy command."""
155
+ payload = {"status": "active"}
156
+ response = self.http_client.put(f"policies/{self.policy_id}", json_data=payload)
157
+
158
+ entity_data = response.get("result", {})
159
+ return Policy.model_validate(entity_data)
160
+
161
+
162
+ class DeactivatePolicyCommand(Command[Policy]):
163
+ """Command to deactivate a policy."""
164
+
165
+ def __init__(self, http_client: HTTPClient, policy_id: str):
166
+ self.http_client = http_client
167
+ self.policy_id = policy_id
168
+
169
+ def execute(self) -> Policy:
170
+ """Execute the deactivate policy command."""
171
+ payload = {"status": "inactive"}
172
+ response = self.http_client.put(f"policies/{self.policy_id}", json_data=payload)
173
+
174
+ entity_data = response.get("result", {})
175
+ return Policy.model_validate(entity_data)
@@ -0,0 +1,55 @@
1
+ """
2
+ Preset Filters commands for the Binalyze AIR SDK.
3
+ """
4
+
5
+ from typing import Dict, Any
6
+
7
+ from ..base import Command
8
+ from ..models.preset_filters import PresetFilter, CreatePresetFilterRequest, UpdatePresetFilterRequest
9
+ from ..http_client import HTTPClient
10
+
11
+
12
+ class CreatePresetFilterCommand(Command[PresetFilter]):
13
+ """Command to create a preset filter."""
14
+
15
+ def __init__(self, http_client: HTTPClient, preset_filter_data: CreatePresetFilterRequest):
16
+ self.http_client = http_client
17
+ self.preset_filter_data = preset_filter_data
18
+
19
+ def execute(self) -> PresetFilter:
20
+ """Execute the command to create a preset filter."""
21
+ response = self.http_client.post(
22
+ '/preset-filters',
23
+ json_data=self.preset_filter_data.to_dict()
24
+ )
25
+ return PresetFilter(**response['result'])
26
+
27
+
28
+ class UpdatePresetFilterCommand(Command[PresetFilter]):
29
+ """Command to update a preset filter."""
30
+
31
+ def __init__(self, http_client: HTTPClient, filter_id: str, preset_filter_data: UpdatePresetFilterRequest):
32
+ self.http_client = http_client
33
+ self.filter_id = filter_id
34
+ self.preset_filter_data = preset_filter_data
35
+
36
+ def execute(self) -> PresetFilter:
37
+ """Execute the command to update a preset filter."""
38
+ response = self.http_client.put(
39
+ f'/preset-filters/{self.filter_id}',
40
+ json_data=self.preset_filter_data.to_dict()
41
+ )
42
+ return PresetFilter(**response['result'])
43
+
44
+
45
+ class DeletePresetFilterCommand(Command[Dict[str, Any]]):
46
+ """Command to delete a preset filter."""
47
+
48
+ def __init__(self, http_client: HTTPClient, filter_id: str):
49
+ self.http_client = http_client
50
+ self.filter_id = filter_id
51
+
52
+ def execute(self) -> Dict[str, Any]:
53
+ """Execute the command to delete a preset filter."""
54
+ response = self.http_client.delete(f'/preset-filters/{self.filter_id}')
55
+ return response
@@ -0,0 +1,32 @@
1
+ """
2
+ Recent Activities commands for the Binalyze AIR SDK.
3
+ """
4
+
5
+ from typing import Dict, Any
6
+
7
+ from ..base import Command
8
+ from ..models.recent_activities import CreateRecentActivityRequest
9
+ from ..http_client import HTTPClient
10
+
11
+
12
+ class CreateRecentActivityCommand(Command[Dict[str, Any]]):
13
+ """Command to create a recent activity."""
14
+
15
+ def __init__(self, http_client: HTTPClient, activity_data: CreateRecentActivityRequest):
16
+ self.http_client = http_client
17
+ self.activity_data = activity_data
18
+
19
+ def execute(self) -> Dict[str, Any]:
20
+ """Execute the command to create a recent activity."""
21
+ # API only requires 'type' and 'entityId' fields
22
+ # Other fields like username, organizationId are filled automatically by server
23
+ minimal_data = {
24
+ 'type': self.activity_data.type,
25
+ 'entityId': self.activity_data.entity_id
26
+ }
27
+
28
+ response = self.http_client.post(
29
+ '/recent-activities',
30
+ json_data=minimal_data
31
+ )
32
+ return response
@@ -0,0 +1,144 @@
1
+ """
2
+ Relay Server commands for the Binalyze AIR SDK.
3
+ """
4
+
5
+ from typing import Dict, Any
6
+
7
+ from ..base import Command
8
+ from ..models.relay_server import (
9
+ RebootTaskRequest, ShutdownTaskRequest, LogRetrievalTaskRequest, VersionUpdateTaskRequest,
10
+ UpdateTagsRequest, UpdateLabelRequest, UpdateAddressRequest
11
+ )
12
+ from ..http_client import HTTPClient
13
+
14
+
15
+ class AssignRebootTaskCommand(Command[Dict[str, Any]]):
16
+ """Command to assign reboot task to relay server."""
17
+
18
+ def __init__(self, http_client: HTTPClient, relay_server_id: str, task_request: RebootTaskRequest):
19
+ self.http_client = http_client
20
+ self.relay_server_id = relay_server_id
21
+ self.task_request = task_request
22
+
23
+ def execute(self) -> Dict[str, Any]:
24
+ """Execute the command to assign reboot task."""
25
+ response = self.http_client.post(
26
+ f'/relay-servers/{self.relay_server_id}/tasks/reboot',
27
+ json_data=self.task_request.model_dump(exclude_none=True)
28
+ )
29
+ return response
30
+
31
+
32
+ class AssignShutdownTaskCommand(Command[Dict[str, Any]]):
33
+ """Command to assign shutdown task to relay server."""
34
+
35
+ def __init__(self, http_client: HTTPClient, relay_server_id: str, task_request: ShutdownTaskRequest):
36
+ self.http_client = http_client
37
+ self.relay_server_id = relay_server_id
38
+ self.task_request = task_request
39
+
40
+ def execute(self) -> Dict[str, Any]:
41
+ """Execute the command to assign shutdown task."""
42
+ response = self.http_client.post(
43
+ f'/relay-servers/{self.relay_server_id}/tasks/shutdown',
44
+ json_data=self.task_request.model_dump(exclude_none=True)
45
+ )
46
+ return response
47
+
48
+
49
+ class AssignLogRetrievalTaskCommand(Command[Dict[str, Any]]):
50
+ """Command to assign log retrieval task to relay server."""
51
+
52
+ def __init__(self, http_client: HTTPClient, relay_server_id: str, task_request: LogRetrievalTaskRequest):
53
+ self.http_client = http_client
54
+ self.relay_server_id = relay_server_id
55
+ self.task_request = task_request
56
+
57
+ def execute(self) -> Dict[str, Any]:
58
+ """Execute the command to assign log retrieval task."""
59
+ response = self.http_client.post(
60
+ f'/relay-servers/{self.relay_server_id}/tasks/log-retrieval',
61
+ json_data=self.task_request.model_dump(exclude_none=True)
62
+ )
63
+ return response
64
+
65
+
66
+ class AssignVersionUpdateTaskCommand(Command[Dict[str, Any]]):
67
+ """Command to assign version update task to relay server."""
68
+
69
+ def __init__(self, http_client: HTTPClient, relay_server_id: str, task_request: VersionUpdateTaskRequest):
70
+ self.http_client = http_client
71
+ self.relay_server_id = relay_server_id
72
+ self.task_request = task_request
73
+
74
+ def execute(self) -> Dict[str, Any]:
75
+ """Execute the command to assign version update task."""
76
+ response = self.http_client.post(
77
+ f'/relay-servers/{self.relay_server_id}/tasks/version-update',
78
+ json_data=self.task_request.model_dump(exclude_none=True)
79
+ )
80
+ return response
81
+
82
+
83
+ class DeleteRelayServerCommand(Command[Dict[str, Any]]):
84
+ """Command to delete a relay server."""
85
+
86
+ def __init__(self, http_client: HTTPClient, server_id: str):
87
+ self.http_client = http_client
88
+ self.server_id = server_id
89
+
90
+ def execute(self) -> Dict[str, Any]:
91
+ """Execute the command to delete a relay server."""
92
+ response = self.http_client.delete(f'/relay-servers/remove', params={'id': self.server_id})
93
+ return response
94
+
95
+
96
+ class UpdateTagsCommand(Command[Dict[str, Any]]):
97
+ """Command to update tags for a relay server."""
98
+
99
+ def __init__(self, http_client: HTTPClient, relay_server_id: str, tags_request: UpdateTagsRequest):
100
+ self.http_client = http_client
101
+ self.relay_server_id = relay_server_id
102
+ self.tags_request = tags_request
103
+
104
+ def execute(self) -> Dict[str, Any]:
105
+ """Execute the command to update tags."""
106
+ response = self.http_client.patch(
107
+ f'/relay-servers/{self.relay_server_id}/tag',
108
+ json_data=self.tags_request.model_dump(exclude_none=True)
109
+ )
110
+ return response
111
+
112
+
113
+ class UpdateLabelCommand(Command[Dict[str, Any]]):
114
+ """Command to update label for a relay server."""
115
+
116
+ def __init__(self, http_client: HTTPClient, relay_server_id: str, label_request: UpdateLabelRequest):
117
+ self.http_client = http_client
118
+ self.relay_server_id = relay_server_id
119
+ self.label_request = label_request
120
+
121
+ def execute(self) -> Dict[str, Any]:
122
+ """Execute the command to update label."""
123
+ response = self.http_client.patch(
124
+ f'/relay-servers/{self.relay_server_id}/label',
125
+ json_data=self.label_request.model_dump(exclude_none=True)
126
+ )
127
+ return response
128
+
129
+
130
+ class UpdateAddressCommand(Command[Dict[str, Any]]):
131
+ """Command to update address for a relay server."""
132
+
133
+ def __init__(self, http_client: HTTPClient, relay_server_id: str, address_request: UpdateAddressRequest):
134
+ self.http_client = http_client
135
+ self.relay_server_id = relay_server_id
136
+ self.address_request = address_request
137
+
138
+ def execute(self) -> Dict[str, Any]:
139
+ """Execute the command to update address."""
140
+ response = self.http_client.patch(
141
+ f'/relay-servers/{self.relay_server_id}/address',
142
+ json_data=self.address_request.model_dump(exclude_none=True)
143
+ )
144
+ return response