binalyze-air-sdk 1.0.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.
- binalyze_air/__init__.py +77 -0
- binalyze_air/apis/__init__.py +27 -0
- binalyze_air/apis/authentication.py +27 -0
- binalyze_air/apis/auto_asset_tags.py +75 -0
- binalyze_air/apis/endpoints.py +22 -0
- binalyze_air/apis/event_subscription.py +97 -0
- binalyze_air/apis/evidence.py +53 -0
- binalyze_air/apis/evidences.py +216 -0
- binalyze_air/apis/interact.py +36 -0
- binalyze_air/apis/params.py +40 -0
- binalyze_air/apis/settings.py +27 -0
- binalyze_air/apis/user_management.py +74 -0
- binalyze_air/apis/users.py +68 -0
- binalyze_air/apis/webhooks.py +231 -0
- binalyze_air/base.py +133 -0
- binalyze_air/client.py +1338 -0
- binalyze_air/commands/__init__.py +146 -0
- binalyze_air/commands/acquisitions.py +387 -0
- binalyze_air/commands/assets.py +363 -0
- binalyze_air/commands/authentication.py +37 -0
- binalyze_air/commands/auto_asset_tags.py +231 -0
- binalyze_air/commands/baseline.py +396 -0
- binalyze_air/commands/cases.py +603 -0
- binalyze_air/commands/event_subscription.py +102 -0
- binalyze_air/commands/evidences.py +988 -0
- binalyze_air/commands/interact.py +58 -0
- binalyze_air/commands/organizations.py +221 -0
- binalyze_air/commands/policies.py +203 -0
- binalyze_air/commands/settings.py +29 -0
- binalyze_air/commands/tasks.py +56 -0
- binalyze_air/commands/triage.py +360 -0
- binalyze_air/commands/user_management.py +126 -0
- binalyze_air/commands/users.py +101 -0
- binalyze_air/config.py +245 -0
- binalyze_air/exceptions.py +50 -0
- binalyze_air/http_client.py +306 -0
- binalyze_air/models/__init__.py +285 -0
- binalyze_air/models/acquisitions.py +251 -0
- binalyze_air/models/assets.py +439 -0
- binalyze_air/models/audit.py +273 -0
- binalyze_air/models/authentication.py +70 -0
- binalyze_air/models/auto_asset_tags.py +117 -0
- binalyze_air/models/baseline.py +232 -0
- binalyze_air/models/cases.py +276 -0
- binalyze_air/models/endpoints.py +76 -0
- binalyze_air/models/event_subscription.py +172 -0
- binalyze_air/models/evidence.py +66 -0
- binalyze_air/models/evidences.py +349 -0
- binalyze_air/models/interact.py +136 -0
- binalyze_air/models/organizations.py +294 -0
- binalyze_air/models/params.py +128 -0
- binalyze_air/models/policies.py +250 -0
- binalyze_air/models/settings.py +84 -0
- binalyze_air/models/tasks.py +149 -0
- binalyze_air/models/triage.py +143 -0
- binalyze_air/models/user_management.py +97 -0
- binalyze_air/models/users.py +82 -0
- binalyze_air/queries/__init__.py +134 -0
- binalyze_air/queries/acquisitions.py +156 -0
- binalyze_air/queries/assets.py +105 -0
- binalyze_air/queries/audit.py +417 -0
- binalyze_air/queries/authentication.py +56 -0
- binalyze_air/queries/auto_asset_tags.py +60 -0
- binalyze_air/queries/baseline.py +185 -0
- binalyze_air/queries/cases.py +293 -0
- binalyze_air/queries/endpoints.py +25 -0
- binalyze_air/queries/event_subscription.py +55 -0
- binalyze_air/queries/evidence.py +140 -0
- binalyze_air/queries/evidences.py +280 -0
- binalyze_air/queries/interact.py +28 -0
- binalyze_air/queries/organizations.py +223 -0
- binalyze_air/queries/params.py +115 -0
- binalyze_air/queries/policies.py +150 -0
- binalyze_air/queries/settings.py +20 -0
- binalyze_air/queries/tasks.py +82 -0
- binalyze_air/queries/triage.py +231 -0
- binalyze_air/queries/user_management.py +83 -0
- binalyze_air/queries/users.py +69 -0
- binalyze_air_sdk-1.0.1.dist-info/METADATA +635 -0
- binalyze_air_sdk-1.0.1.dist-info/RECORD +82 -0
- binalyze_air_sdk-1.0.1.dist-info/WHEEL +5 -0
- binalyze_air_sdk-1.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
"""
|
2
|
+
Event Subscription commands for the Binalyze AIR SDK.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from typing import Dict, Any, Union
|
6
|
+
|
7
|
+
from ..base import Command
|
8
|
+
from ..models.event_subscription import EventSubscription, CreateEventSubscriptionRequest, UpdateEventSubscriptionRequest
|
9
|
+
from ..http_client import HTTPClient
|
10
|
+
|
11
|
+
|
12
|
+
class CreateEventSubscriptionCommand(Command[EventSubscription]):
|
13
|
+
"""Command to create an event subscription."""
|
14
|
+
|
15
|
+
def __init__(self, http_client: HTTPClient, request: Union[CreateEventSubscriptionRequest, Dict[str, Any]]):
|
16
|
+
self.http_client = http_client
|
17
|
+
self.request = request
|
18
|
+
|
19
|
+
def execute(self) -> EventSubscription:
|
20
|
+
"""Execute the command to create an event subscription."""
|
21
|
+
# Handle both dict and model objects
|
22
|
+
if isinstance(self.request, dict):
|
23
|
+
data = self.request
|
24
|
+
else:
|
25
|
+
data = self.request.model_dump(exclude_none=True)
|
26
|
+
|
27
|
+
response = self.http_client.post("event-subscription", json_data=data)
|
28
|
+
|
29
|
+
# Handle null result from API
|
30
|
+
result = response.get("result")
|
31
|
+
if result is None:
|
32
|
+
# If result is null but status is success, create a basic EventSubscription
|
33
|
+
if response.get("success"):
|
34
|
+
# Use Pydantic parsing with proper field aliasing
|
35
|
+
basic_data = {
|
36
|
+
"id": data.get("name", "unknown"), # Use name as fallback ID
|
37
|
+
"name": data.get("name", ""),
|
38
|
+
"url": data.get("url", ""),
|
39
|
+
"active": data.get("active", True),
|
40
|
+
"events": data.get("events", []),
|
41
|
+
"organizationId": data.get("organizationId", 0)
|
42
|
+
}
|
43
|
+
return EventSubscription.model_validate(basic_data)
|
44
|
+
else:
|
45
|
+
# Create empty EventSubscription for failed requests
|
46
|
+
basic_data = {
|
47
|
+
"id": "failed",
|
48
|
+
"name": "Failed Creation"
|
49
|
+
}
|
50
|
+
return EventSubscription.model_validate(basic_data)
|
51
|
+
|
52
|
+
# Convert id to string as Pydantic expects
|
53
|
+
if "id" in result:
|
54
|
+
result["id"] = str(result["id"])
|
55
|
+
|
56
|
+
# Use Pydantic parsing with proper field aliasing
|
57
|
+
return EventSubscription.model_validate(result)
|
58
|
+
|
59
|
+
|
60
|
+
class UpdateEventSubscriptionCommand(Command[EventSubscription]):
|
61
|
+
"""Command to update an event subscription."""
|
62
|
+
|
63
|
+
def __init__(self, http_client: HTTPClient, subscription_id: str, request: Union[UpdateEventSubscriptionRequest, Dict[str, Any]]):
|
64
|
+
self.http_client = http_client
|
65
|
+
self.subscription_id = subscription_id
|
66
|
+
self.request = request
|
67
|
+
|
68
|
+
def execute(self) -> EventSubscription:
|
69
|
+
"""Execute the command to update an event subscription."""
|
70
|
+
# Handle both dict and model objects
|
71
|
+
if isinstance(self.request, dict):
|
72
|
+
data = self.request
|
73
|
+
else:
|
74
|
+
data = self.request.model_dump(exclude_none=True)
|
75
|
+
|
76
|
+
response = self.http_client.put(
|
77
|
+
f"event-subscription/{self.subscription_id}",
|
78
|
+
json_data=data
|
79
|
+
)
|
80
|
+
|
81
|
+
result = response.get("result", {})
|
82
|
+
|
83
|
+
# Convert id to string as Pydantic expects
|
84
|
+
if "id" in result:
|
85
|
+
result["id"] = str(result["id"])
|
86
|
+
|
87
|
+
# Use Pydantic parsing with proper field aliasing
|
88
|
+
return EventSubscription.model_validate(result)
|
89
|
+
|
90
|
+
|
91
|
+
class DeleteEventSubscriptionCommand(Command[Dict[str, Any]]):
|
92
|
+
"""Command to delete an event subscription."""
|
93
|
+
|
94
|
+
def __init__(self, http_client: HTTPClient, subscription_id: str):
|
95
|
+
self.http_client = http_client
|
96
|
+
self.subscription_id = subscription_id
|
97
|
+
|
98
|
+
def execute(self) -> Dict[str, Any]:
|
99
|
+
"""Execute the command to delete an event subscription."""
|
100
|
+
response = self.http_client.delete(f"event-subscription/{self.subscription_id}")
|
101
|
+
|
102
|
+
return response
|