binalyze-air-sdk 1.0.1__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.1.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.1.dist-info/METADATA +0 -635
  141. binalyze_air_sdk-1.0.1.dist-info/RECORD +0 -82
  142. {binalyze_air_sdk-1.0.1.dist-info → binalyze_air_sdk-1.0.3.dist-info}/top_level.txt +0 -0
@@ -1,126 +1,351 @@
1
- """
2
- User Management-related commands for the Binalyze AIR SDK.
3
- """
4
-
5
- from typing import Dict, Any, Union
6
-
7
- from ..base import Command
8
- from ..models.user_management import (
9
- UserManagementUser, CreateUserRequest, UpdateUserRequest,
10
- AIUser, CreateAIUserRequest, APIUser, CreateAPIUserRequest
11
- )
12
- from ..http_client import HTTPClient
13
-
14
-
15
- class CreateUserCommand(Command[UserManagementUser]):
16
- """Command to create user."""
17
-
18
- def __init__(self, http_client: HTTPClient, request: Union[CreateUserRequest, Dict[str, Any]]):
19
- self.http_client = http_client
20
- self.request = request
21
-
22
- def execute(self) -> UserManagementUser:
23
- """Execute the create user command."""
24
- # Handle both dict and model objects
25
- if isinstance(self.request, dict):
26
- payload = self.request
27
- else:
28
- payload = self.request.model_dump(exclude_none=True)
29
-
30
- response = self.http_client.post("user-management/users", json_data=payload)
31
-
32
- if response.get("success"):
33
- user_data = response.get("result", {})
34
- return UserManagementUser(**user_data)
35
-
36
- raise Exception(f"Failed to create user: {response.get('error', 'Unknown error')}")
37
-
38
-
39
- class UpdateUserCommand(Command[UserManagementUser]):
40
- """Command to update user."""
41
-
42
- def __init__(self, http_client: HTTPClient, user_id: str, request: Union[UpdateUserRequest, Dict[str, Any]]):
43
- self.http_client = http_client
44
- self.user_id = user_id
45
- self.request = request
46
-
47
- def execute(self) -> UserManagementUser:
48
- """Execute the update user command."""
49
- # Handle both dict and model objects
50
- if isinstance(self.request, dict):
51
- payload = self.request
52
- else:
53
- payload = self.request.model_dump(exclude_none=True)
54
-
55
- response = self.http_client.put(f"user-management/users/{self.user_id}", json_data=payload)
56
-
57
- if response.get("success"):
58
- user_data = response.get("result", {})
59
- return UserManagementUser(**user_data)
60
-
61
- raise Exception(f"Failed to update user: {response.get('error', 'Unknown error')}")
62
-
63
-
64
- class DeleteUserCommand(Command[Dict[str, Any]]):
65
- """Command to delete user."""
66
-
67
- def __init__(self, http_client: HTTPClient, user_id: str):
68
- self.http_client = http_client
69
- self.user_id = user_id
70
-
71
- def execute(self) -> Dict[str, Any]:
72
- """Execute the delete user command."""
73
- response = self.http_client.delete(f"user-management/users/{self.user_id}")
74
-
75
- if response.get("success"):
76
- return response
77
-
78
- raise Exception(f"Failed to delete user: {response.get('error', 'Unknown error')}")
79
-
80
-
81
- class CreateAIUserCommand(Command[AIUser]):
82
- """Command to create AI user."""
83
-
84
- def __init__(self, http_client: HTTPClient, request: Union[CreateAIUserRequest, Dict[str, Any]]):
85
- self.http_client = http_client
86
- self.request = request
87
-
88
- def execute(self) -> AIUser:
89
- """Execute the create AI user command."""
90
- # Handle both dict and model objects
91
- if isinstance(self.request, dict):
92
- payload = self.request
93
- else:
94
- payload = self.request.model_dump(exclude_none=True)
95
-
96
- response = self.http_client.post("user-management/users/ai-user", json_data=payload)
97
-
98
- if response.get("success"):
99
- ai_user_data = response.get("result", {})
100
- return AIUser(**ai_user_data)
101
-
102
- raise Exception(f"Failed to create AI user: {response.get('error', 'Unknown error')}")
103
-
104
-
105
- class CreateAPIUserCommand(Command[APIUser]):
106
- """Command to create API user."""
107
-
108
- def __init__(self, http_client: HTTPClient, request: Union[CreateAPIUserRequest, Dict[str, Any]]):
109
- self.http_client = http_client
110
- self.request = request
111
-
112
- def execute(self) -> APIUser:
113
- """Execute the create API user command."""
114
- # Handle both dict and model objects
115
- if isinstance(self.request, dict):
116
- payload = self.request
117
- else:
118
- payload = self.request.model_dump(exclude_none=True)
119
-
120
- response = self.http_client.post("user-management/users/api-user", json_data=payload)
121
-
122
- if response.get("success"):
123
- api_user_data = response.get("result", {})
124
- return APIUser(**api_user_data)
125
-
126
- raise Exception(f"Failed to create API user: {response.get('error', 'Unknown error')}")
1
+ """
2
+ User Management-related commands for the Binalyze AIR SDK.
3
+ """
4
+
5
+ from typing import Dict, Any, Union
6
+
7
+ from ..base import Command
8
+ from ..models.user_management import (
9
+ UserManagementUser, CreateUserRequest, UpdateUserRequest,
10
+ AIUser, CreateAIUserRequest, APIUser, CreateAPIUserRequest,
11
+ ChangePasswordRequest, SetAPIUserPasswordRequest, ResetPasswordRequest,
12
+ Role, CreateRoleRequest, UpdateRoleRequest,
13
+ UserGroup, CreateUserGroupRequest, UpdateUserGroupRequest
14
+ )
15
+ from ..http_client import HTTPClient
16
+
17
+
18
+ class CreateUserCommand(Command[UserManagementUser]):
19
+ """Command to create user."""
20
+
21
+ def __init__(self, http_client: HTTPClient, request: Union[CreateUserRequest, Dict[str, Any]]):
22
+ self.http_client = http_client
23
+ self.request = request
24
+
25
+ def execute(self) -> UserManagementUser:
26
+ """Execute the create user command."""
27
+ # Handle both dict and model objects
28
+ if isinstance(self.request, dict):
29
+ payload = self.request
30
+ else:
31
+ payload = self.request.model_dump(exclude_none=True)
32
+
33
+ response = self.http_client.post("user-management/users", json_data=payload)
34
+
35
+ if response.get("success"):
36
+ user_data = response.get("result", {})
37
+ return UserManagementUser(**user_data)
38
+
39
+ raise Exception(f"Failed to create user: {response.get('error', 'Unknown error')}")
40
+
41
+
42
+ class UpdateUserCommand(Command[UserManagementUser]):
43
+ """Command to update user."""
44
+
45
+ def __init__(self, http_client: HTTPClient, user_id: str, request: Union[UpdateUserRequest, Dict[str, Any]]):
46
+ self.http_client = http_client
47
+ self.user_id = user_id
48
+ self.request = request
49
+
50
+ def execute(self) -> UserManagementUser:
51
+ """Execute the update user command."""
52
+ # Handle both dict and model objects
53
+ if isinstance(self.request, dict):
54
+ payload = self.request
55
+ else:
56
+ payload = self.request.model_dump(exclude_none=True)
57
+
58
+ response = self.http_client.put(f"user-management/users/{self.user_id}", json_data=payload)
59
+
60
+ if response.get("success"):
61
+ user_data = response.get("result", {})
62
+ return UserManagementUser(**user_data)
63
+
64
+ raise Exception(f"Failed to update user: {response.get('error', 'Unknown error')}")
65
+
66
+
67
+ class DeleteUserCommand(Command[Dict[str, Any]]):
68
+ """Command to delete user."""
69
+
70
+ def __init__(self, http_client: HTTPClient, user_id: str):
71
+ self.http_client = http_client
72
+ self.user_id = user_id
73
+
74
+ def execute(self) -> Dict[str, Any]:
75
+ """Execute the delete user command."""
76
+ response = self.http_client.delete(f"user-management/users/{self.user_id}")
77
+
78
+ if response.get("success"):
79
+ return response
80
+
81
+ raise Exception(f"Failed to delete user: {response.get('error', 'Unknown error')}")
82
+
83
+
84
+ class CreateAIUserCommand(Command[AIUser]):
85
+ """Command to create AI user."""
86
+
87
+ def __init__(self, http_client: HTTPClient, request: Union[CreateAIUserRequest, Dict[str, Any]]):
88
+ self.http_client = http_client
89
+ self.request = request
90
+
91
+ def execute(self) -> AIUser:
92
+ """Execute the create AI user command."""
93
+ # Handle both dict and model objects
94
+ if isinstance(self.request, dict):
95
+ payload = self.request
96
+ else:
97
+ payload = self.request.model_dump(exclude_none=True)
98
+
99
+ response = self.http_client.post("user-management/users/ai-user", json_data=payload)
100
+
101
+ if response.get("success"):
102
+ ai_user_data = response.get("result", {})
103
+ return AIUser(**ai_user_data)
104
+
105
+ raise Exception(f"Failed to create AI user: {response.get('error', 'Unknown error')}")
106
+
107
+
108
+ class CreateAPIUserCommand(Command[APIUser]):
109
+ """Command to create API user."""
110
+
111
+ def __init__(self, http_client: HTTPClient, request: Union[CreateAPIUserRequest, Dict[str, Any]]):
112
+ self.http_client = http_client
113
+ self.request = request
114
+
115
+ def execute(self) -> APIUser:
116
+ """Execute the create API user command."""
117
+ # Handle both dict and model objects
118
+ if isinstance(self.request, dict):
119
+ payload = self.request
120
+ else:
121
+ payload = self.request.model_dump(exclude_none=True)
122
+
123
+ response = self.http_client.post("user-management/users/api-user", json_data=payload)
124
+
125
+ if response.get("success"):
126
+ api_user_data = response.get("result", {})
127
+ return APIUser(**api_user_data)
128
+
129
+ raise Exception(f"Failed to create API user: {response.get('error', 'Unknown error')}")
130
+
131
+
132
+ # Password Management Commands
133
+ class ChangeCurrentUserPasswordCommand(Command[Dict[str, Any]]):
134
+ """Command to change current user password."""
135
+
136
+ def __init__(self, http_client: HTTPClient, request: Union[ChangePasswordRequest, Dict[str, Any]]):
137
+ self.http_client = http_client
138
+ self.request = request
139
+
140
+ def execute(self) -> Dict[str, Any]:
141
+ """Execute the change current user password command."""
142
+ # Handle both dict and model objects
143
+ if isinstance(self.request, dict):
144
+ payload = self.request
145
+ else:
146
+ payload = self.request.model_dump(exclude_none=True)
147
+
148
+ response = self.http_client.put("user-management/users/change-password", json_data=payload)
149
+
150
+ if response.get("success"):
151
+ return response
152
+
153
+ raise Exception(f"Failed to change password: {response.get('error', 'Unknown error')}")
154
+
155
+
156
+ class SetAPIUserPasswordCommand(Command[Dict[str, Any]]):
157
+ """Command to set API user password."""
158
+
159
+ def __init__(self, http_client: HTTPClient, request: Union[SetAPIUserPasswordRequest, Dict[str, Any]]):
160
+ self.http_client = http_client
161
+ self.request = request
162
+
163
+ def execute(self) -> Dict[str, Any]:
164
+ """Execute the set API user password command."""
165
+ # Handle both dict and model objects
166
+ if isinstance(self.request, dict):
167
+ payload = self.request
168
+ else:
169
+ payload = self.request.model_dump(exclude_none=True)
170
+
171
+ response = self.http_client.put("user-management/users/set-api-user-password", json_data=payload)
172
+
173
+ if response.get("success"):
174
+ return response
175
+
176
+ raise Exception(f"Failed to set API user password: {response.get('error', 'Unknown error')}")
177
+
178
+
179
+ class ResetPasswordCommand(Command[Dict[str, Any]]):
180
+ """Command to reset user password."""
181
+
182
+ def __init__(self, http_client: HTTPClient, user_id: str, request: Union[ResetPasswordRequest, Dict[str, Any]]):
183
+ self.http_client = http_client
184
+ self.user_id = user_id
185
+ self.request = request
186
+
187
+ def execute(self) -> Dict[str, Any]:
188
+ """Execute the reset password command."""
189
+ # Handle both dict and model objects
190
+ if isinstance(self.request, dict):
191
+ payload = self.request
192
+ else:
193
+ payload = self.request.model_dump(exclude_none=True)
194
+
195
+ response = self.http_client.post(f"user-management/users/{self.user_id}/reset-password", json_data=payload)
196
+
197
+ if response.get("success"):
198
+ return response
199
+
200
+ raise Exception(f"Failed to reset password: {response.get('error', 'Unknown error')}")
201
+
202
+
203
+ class ResetTFACommand(Command[Dict[str, Any]]):
204
+ """Command to reset TFA for user."""
205
+
206
+ def __init__(self, http_client: HTTPClient, user_id: str):
207
+ self.http_client = http_client
208
+ self.user_id = user_id
209
+
210
+ def execute(self) -> Dict[str, Any]:
211
+ """Execute the reset TFA command."""
212
+ response = self.http_client.post(f"user-management/users/{self.user_id}/reset-tfa")
213
+
214
+ if response.get("success"):
215
+ return response
216
+
217
+ raise Exception(f"Failed to reset TFA: {response.get('error', 'Unknown error')}")
218
+
219
+
220
+ # Role Management Commands
221
+ class CreateRoleCommand(Command[Role]):
222
+ """Command to create role."""
223
+
224
+ def __init__(self, http_client: HTTPClient, request: Union[CreateRoleRequest, Dict[str, Any]]):
225
+ self.http_client = http_client
226
+ self.request = request
227
+
228
+ def execute(self) -> Role:
229
+ """Execute the create role command."""
230
+ # Handle both dict and model objects
231
+ if isinstance(self.request, dict):
232
+ payload = self.request
233
+ else:
234
+ payload = self.request.model_dump(exclude_none=True)
235
+
236
+ response = self.http_client.post("user-management/roles", json_data=payload)
237
+
238
+ if response.get("success"):
239
+ role_data = response.get("result", {})
240
+ return Role(**role_data)
241
+
242
+ raise Exception(f"Failed to create role: {response.get('error', 'Unknown error')}")
243
+
244
+
245
+ class UpdateRoleCommand(Command[Role]):
246
+ """Command to update role."""
247
+
248
+ def __init__(self, http_client: HTTPClient, role_id: str, request: Union[UpdateRoleRequest, Dict[str, Any]]):
249
+ self.http_client = http_client
250
+ self.role_id = role_id
251
+ self.request = request
252
+
253
+ def execute(self) -> Role:
254
+ """Execute the update role command."""
255
+ # Handle both dict and model objects
256
+ if isinstance(self.request, dict):
257
+ payload = self.request
258
+ else:
259
+ payload = self.request.model_dump(exclude_none=True)
260
+
261
+ response = self.http_client.put(f"user-management/roles/{self.role_id}", json_data=payload)
262
+
263
+ if response.get("success"):
264
+ role_data = response.get("result", {})
265
+ return Role(**role_data)
266
+
267
+ raise Exception(f"Failed to update role: {response.get('error', 'Unknown error')}")
268
+
269
+
270
+ class DeleteRoleCommand(Command[Dict[str, Any]]):
271
+ """Command to delete role."""
272
+
273
+ def __init__(self, http_client: HTTPClient, role_id: str):
274
+ self.http_client = http_client
275
+ self.role_id = role_id
276
+
277
+ def execute(self) -> Dict[str, Any]:
278
+ """Execute the delete role command."""
279
+ response = self.http_client.delete(f"user-management/roles/{self.role_id}")
280
+
281
+ if response.get("success"):
282
+ return response
283
+
284
+ raise Exception(f"Failed to delete role: {response.get('error', 'Unknown error')}")
285
+
286
+
287
+ # User Group Management Commands
288
+ class CreateUserGroupCommand(Command[UserGroup]):
289
+ """Command to create user group."""
290
+
291
+ def __init__(self, http_client: HTTPClient, request: Union[CreateUserGroupRequest, Dict[str, Any]]):
292
+ self.http_client = http_client
293
+ self.request = request
294
+
295
+ def execute(self) -> UserGroup:
296
+ """Execute the create user group command."""
297
+ # Handle both dict and model objects
298
+ if isinstance(self.request, dict):
299
+ payload = self.request
300
+ else:
301
+ payload = self.request.model_dump(exclude_none=True)
302
+
303
+ response = self.http_client.post("user-management/user-groups", json_data=payload)
304
+
305
+ if response.get("success"):
306
+ group_data = response.get("result", {})
307
+ return UserGroup(**group_data)
308
+
309
+ raise Exception(f"Failed to create user group: {response.get('error', 'Unknown error')}")
310
+
311
+
312
+ class UpdateUserGroupCommand(Command[UserGroup]):
313
+ """Command to update user group."""
314
+
315
+ def __init__(self, http_client: HTTPClient, group_id: str, request: Union[UpdateUserGroupRequest, Dict[str, Any]]):
316
+ self.http_client = http_client
317
+ self.group_id = group_id
318
+ self.request = request
319
+
320
+ def execute(self) -> UserGroup:
321
+ """Execute the update user group command."""
322
+ # Handle both dict and model objects
323
+ if isinstance(self.request, dict):
324
+ payload = self.request
325
+ else:
326
+ payload = self.request.model_dump(exclude_none=True)
327
+
328
+ response = self.http_client.put(f"user-management/user-groups/{self.group_id}", json_data=payload)
329
+
330
+ if response.get("success"):
331
+ group_data = response.get("result", {})
332
+ return UserGroup(**group_data)
333
+
334
+ raise Exception(f"Failed to update user group: {response.get('error', 'Unknown error')}")
335
+
336
+
337
+ class DeleteUserGroupCommand(Command[Dict[str, Any]]):
338
+ """Command to delete user group."""
339
+
340
+ def __init__(self, http_client: HTTPClient, group_id: str):
341
+ self.http_client = http_client
342
+ self.group_id = group_id
343
+
344
+ def execute(self) -> Dict[str, Any]:
345
+ """Execute the delete user group command."""
346
+ response = self.http_client.delete(f"user-management/user-groups/{self.group_id}")
347
+
348
+ if response.get("success"):
349
+ return response
350
+
351
+ raise Exception(f"Failed to delete user group: {response.get('error', 'Unknown error')}")
@@ -0,0 +1,77 @@
1
+ """
2
+ Webhook Executions commands for the Binalyze AIR SDK.
3
+ """
4
+
5
+ from ..base import Command
6
+ from ..models.webhook_executions import WebhookExecutionResponse, WebhookPostRequest
7
+ from ..http_client import HTTPClient
8
+ from typing import Dict, Any
9
+
10
+
11
+ class ExecuteWebhookGetCommand(Command[WebhookExecutionResponse]):
12
+ """Command to execute webhook via GET request."""
13
+
14
+ def __init__(self, http_client: HTTPClient, slug: str, data: str, token: str):
15
+ self.http_client = http_client
16
+ self.slug = slug
17
+ self.data = data
18
+ self.token = token
19
+
20
+ def execute(self) -> WebhookExecutionResponse:
21
+ """Execute the webhook GET command."""
22
+ params = {'token': self.token}
23
+
24
+ response = self.http_client.get(f'/api/webhook/{self.slug}/{self.data}', params=params)
25
+
26
+ # Parse the response into our model
27
+ return WebhookExecutionResponse(
28
+ task_details_view_url=response.get('taskDetailsViewUrl', ''),
29
+ task_details_data_url=response.get('taskDetailsDataUrl', ''),
30
+ task_id=response.get('taskId', ''),
31
+ status_code=response.get('statusCode', 200)
32
+ )
33
+
34
+
35
+ class ExecuteWebhookPostCommand(Command[WebhookExecutionResponse]):
36
+ """Command to execute webhook via POST request."""
37
+
38
+ def __init__(self, http_client: HTTPClient, slug: str, token: str, request_data: WebhookPostRequest):
39
+ self.http_client = http_client
40
+ self.slug = slug
41
+ self.token = token
42
+ self.request_data = request_data
43
+
44
+ def execute(self) -> WebhookExecutionResponse:
45
+ """Execute the webhook POST command."""
46
+ params = {'token': self.token}
47
+
48
+ response = self.http_client.post(
49
+ f'/api/webhook/{self.slug}',
50
+ params=params,
51
+ json_data=self.request_data.model_dump(exclude_none=True)
52
+ )
53
+
54
+ # Parse the response into our model
55
+ return WebhookExecutionResponse(
56
+ task_details_view_url=response.get('taskDetailsViewUrl', ''),
57
+ task_details_data_url=response.get('taskDetailsDataUrl', ''),
58
+ task_id=response.get('taskId', ''),
59
+ status_code=response.get('statusCode', 200)
60
+ )
61
+
62
+
63
+ # ---------------------------------------------------------------------------
64
+ # Retry Webhook Execution Command
65
+ # ---------------------------------------------------------------------------
66
+
67
+
68
+ class RetryWebhookExecutionCommand(Command[Dict[str, Any]]):
69
+ """Command to retry a failed webhook execution."""
70
+
71
+ def __init__(self, http_client: HTTPClient, execution_id: str):
72
+ self.http_client = http_client
73
+ self.execution_id = execution_id
74
+
75
+ def execute(self) -> Dict[str, Any]:
76
+ """Retry the webhook execution via POST."""
77
+ return self.http_client.post(f"webhook-executions/{self.execution_id}/retry", json_data={})