Skip to content

Commit 073b924

Browse files
committed
udpate API
1 parent be710a9 commit 073b924

1 file changed

Lines changed: 74 additions & 5 deletions

File tree

databunkerpro/api.py

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,22 @@ class PolicyOptions(TypedDict, total=False):
153153
policy: Any
154154

155155

156+
class PolicyUpdateOptions(TypedDict, total=False):
157+
"""Options for policy update operations."""
158+
159+
policyname: Optional[str]
160+
policydesc: Optional[str]
161+
policy: Any
162+
163+
164+
class PatchOperation(TypedDict, total=False):
165+
"""Represents a patch operation for user data."""
166+
167+
op: str # Operation type (e.g., 'add', 'replace', 'remove')
168+
path: str # JSON path to the field to modify
169+
value: Optional[Any] # New value for the field
170+
171+
156172
class DatabunkerproAPI:
157173
"""Main client class for interacting with the DatabunkerPro API."""
158174

@@ -264,7 +280,33 @@ def create_users_bulk(
264280
options: Optional[BasicOptions] = None,
265281
request_metadata: Optional[Dict[str, Any]] = None,
266282
) -> Dict[str, Any]:
267-
"""Create multiple users in bulk."""
283+
"""
284+
Creates multiple users in bulk with their profiles and group information.
285+
286+
Args:
287+
records: Array of user records to create
288+
options: Global options for all users
289+
request_metadata: Additional metadata to include with the request
290+
291+
Returns:
292+
The created users information
293+
294+
Example:
295+
# Create multiple users with global time settings
296+
users = api.create_users_bulk([
297+
{
298+
"profile": {"email": "user1@example.com", "name": "User One"},
299+
"groupname": "premium"
300+
},
301+
{
302+
"profile": {"email": "user2@example.com", "name": "User Two"},
303+
"groupid": 123
304+
}
305+
], {
306+
"finaltime": "100d",
307+
"slidingtime": "30d"
308+
})
309+
"""
268310
data: Dict[str, Any] = {
269311
"records": [
270312
{
@@ -351,7 +393,7 @@ def patch_user(
351393
self,
352394
mode: str,
353395
identity: str,
354-
patch: Dict[str, Any],
396+
patch: List[PatchOperation],
355397
request_metadata: Optional[Dict[str, Any]] = None,
356398
) -> Dict[str, Any]:
357399
"""Patch a user record with specific changes."""
@@ -366,7 +408,7 @@ def request_user_patch(
366408
self,
367409
mode: str,
368410
identity: str,
369-
patch: Dict[str, Any],
411+
patch: List[PatchOperation],
370412
request_metadata: Optional[Dict[str, Any]] = None,
371413
) -> Dict[str, Any]:
372414
"""Request a user patch operation."""
@@ -504,7 +546,7 @@ def cancel_user_request(
504546
options: Optional[Dict[str, Any]] = None,
505547
request_metadata: Optional[Dict[str, Any]] = None,
506548
) -> Dict[str, Any]:
507-
"""Cancel a user request."""
549+
"""Cancels a user request."""
508550
data = {"requestuuid": request_uuid}
509551
if options and "reason" in options:
510552
data["reason"] = options["reason"]
@@ -1264,7 +1306,7 @@ def create_policy(
12641306
def update_policy(
12651307
self,
12661308
policy_id: Union[str, int],
1267-
options: PolicyOptions,
1309+
options: PolicyUpdateOptions,
12681310
request_metadata: Optional[Dict[str, Any]] = None,
12691311
) -> Dict[str, Any]:
12701312
"""Update policy information."""
@@ -1458,6 +1500,33 @@ def parse_prometheus_metrics(self, metrics_text: str) -> Dict[str, Any]:
14581500
metrics[metric_key] = float(value)
14591501
return metrics
14601502

1503+
def generate_wrapping_key(
1504+
self,
1505+
key1: str,
1506+
key2: str,
1507+
key3: str,
1508+
request_metadata: Optional[Dict[str, Any]] = None,
1509+
) -> Dict[str, Any]:
1510+
"""
1511+
Generates a wrapping key from three Shamir's Secret Sharing keys.
1512+
1513+
Args:
1514+
key1: First Shamir secret sharing key
1515+
key2: Second Shamir secret sharing key
1516+
key3: Third Shamir secret sharing key
1517+
request_metadata: Optional request metadata
1518+
1519+
Returns:
1520+
Dict containing the generated wrapping key
1521+
1522+
Example:
1523+
>>> result = api.generate_wrapping_key("key1", "key2", "key3")
1524+
>>> print(result)
1525+
{'status': 'ok', 'wrappingkey': 'generated-wrapping-key-value'}
1526+
"""
1527+
data = {"key1": key1, "key2": key2, "key3": key3}
1528+
return self._make_request("SystemGenerateWrappingKey", data, request_metadata)
1529+
14611530
# Session Management
14621531
def upsert_session(
14631532
self,

0 commit comments

Comments
 (0)