Skip to content

Commit 1ed78c6

Browse files
committed
Update Audit Logs API responses
1 parent 6e5d8b0 commit 1ed78c6

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

slack_sdk/audit_logs/v1/logs.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
from typing import Optional, List, Union, Any, Dict
23

34

@@ -252,6 +253,21 @@ class Details:
252253
initiated_by: Optional[str]
253254
source_team: Optional[str]
254255
destination_team: Optional[str]
256+
succeeded_users: Optional[List[str]]
257+
failed_users: Optional[List[str]]
258+
enterprise: Optional[str]
259+
subteam: Optional[str]
260+
action: Optional[str]
261+
idp_group_member_count: Optional[int]
262+
workspace_member_count: Optional[int]
263+
added_user_count: Optional[int]
264+
added_user_error_count: Optional[int]
265+
reactivated_user_count: Optional[int]
266+
removed_user_count: Optional[int]
267+
removed_user_error_count: Optional[int]
268+
total_removal_count: Optional[int]
269+
is_flagged: Optional[str]
270+
target_user: Optional[str]
255271

256272
def __init__(
257273
self,
@@ -330,6 +346,21 @@ def __init__(
330346
initiated_by: Optional[str] = None,
331347
source_team: Optional[str] = None,
332348
destination_team: Optional[str] = None,
349+
succeeded_users: Optional[Union[List[str], str]] = None,
350+
failed_users: Optional[Union[List[str], str]] = None,
351+
enterprise: Optional[str] = None,
352+
subteam: Optional[str] = None,
353+
action: Optional[str] = None,
354+
idp_group_member_count: Optional[int] = None,
355+
workspace_member_count: Optional[int] = None,
356+
added_user_count: Optional[int] = None,
357+
added_user_error_count: Optional[int] = None,
358+
reactivated_user_count: Optional[int] = None,
359+
removed_user_count: Optional[int] = None,
360+
removed_user_error_count: Optional[int] = None,
361+
total_removal_count: Optional[int] = None,
362+
is_flagged: Optional[str] = None,
363+
target_user: Optional[str] = None,
333364
**kwargs,
334365
) -> None:
335366
self.name = name
@@ -435,6 +466,25 @@ def __init__(
435466
self.initiated_by = initiated_by
436467
self.source_team = source_team
437468
self.destination_team = destination_team
469+
self.succeeded_users = (
470+
succeeded_users if succeeded_users is None or isinstance(succeeded_users, list) else json.loads(succeeded_users)
471+
)
472+
self.failed_users = (
473+
failed_users if failed_users is None or isinstance(failed_users, list) else json.loads(failed_users)
474+
)
475+
self.enterprise = enterprise
476+
self.subteam = subteam
477+
self.action = action
478+
self.idp_group_member_count = idp_group_member_count
479+
self.workspace_member_count = workspace_member_count
480+
self.added_user_count = added_user_count
481+
self.added_user_error_count = added_user_error_count
482+
self.reactivated_user_count = reactivated_user_count
483+
self.removed_user_count = removed_user_count
484+
self.removed_user_error_count = removed_user_error_count
485+
self.total_removal_count = total_removal_count
486+
self.is_flagged = is_flagged
487+
self.target_user = target_user
438488

439489

440490
class Channel:
@@ -509,6 +559,49 @@ def __init__(
509559
self.unknown_fields = kwargs
510560

511561

562+
class Huddle:
563+
id: Optional[str]
564+
date_start: Optional[int]
565+
date_end: Optional[int]
566+
participants: Optional[List[str]]
567+
unknown_fields: Dict[str, Any]
568+
569+
def __init__(
570+
self,
571+
*,
572+
id: Optional[str] = None,
573+
date_start: Optional[int] = None,
574+
date_end: Optional[int] = None,
575+
participants: Optional[List[str]] = None,
576+
**kwargs,
577+
) -> None:
578+
self.id = id
579+
self.date_start = date_start
580+
self.date_end = date_end
581+
self.participants = participants
582+
self.unknown_fields = kwargs
583+
584+
585+
class Role:
586+
id: Optional[str]
587+
name: Optional[str]
588+
type: Optional[str]
589+
unknown_fields: Dict[str, Any]
590+
591+
def __init__(
592+
self,
593+
*,
594+
id: Optional[str] = None,
595+
name: Optional[str] = None,
596+
type: Optional[str] = None,
597+
**kwargs,
598+
) -> None:
599+
self.id = id
600+
self.name = name
601+
self.type = type
602+
self.unknown_fields = kwargs
603+
604+
512605
class Workflow:
513606
id: Optional[str]
514607
name: Optional[str]
@@ -560,6 +653,8 @@ class Entity:
560653
channel: Optional[Channel]
561654
file: Optional[File]
562655
app: Optional[App]
656+
huddle: Optional[Huddle]
657+
role: Optional[Role]
563658
usergroup: Optional[Usergroup]
564659
workflow: Optional[Workflow]
565660
barrier: Optional[InformationBarrier]
@@ -575,6 +670,8 @@ def __init__(
575670
channel: Optional[Union[Channel, Dict[str, Any]]] = None,
576671
file: Optional[Union[File, Dict[str, Any]]] = None,
577672
app: Optional[Union[App, Dict[str, Any]]] = None,
673+
huddle: Optional[Union[Huddle, Dict[str, Any]]] = None,
674+
role: Optional[Union[Role, Dict[str, Any]]] = None,
578675
usergroup: Optional[Union[Usergroup, Dict[str, Any]]] = None,
579676
workflow: Optional[Union[Workflow, Dict[str, Any]]] = None,
580677
barrier: Optional[Union[InformationBarrier, Dict[str, Any]]] = None,
@@ -587,6 +684,8 @@ def __init__(
587684
self.channel = Channel(**channel) if isinstance(channel, dict) else channel
588685
self.file = File(**file) if isinstance(file, dict) else file
589686
self.app = App(**app) if isinstance(app, dict) else app
687+
self.huddle = Huddle(**huddle) if isinstance(huddle, dict) else huddle
688+
self.role = Role(**role) if isinstance(role, dict) else role
590689
self.usergroup = Usergroup(**usergroup) if isinstance(usergroup, dict) else usergroup
591690
self.workflow = Workflow(**workflow) if isinstance(workflow, dict) else workflow
592691
self.barrier = InformationBarrier(**barrier) if isinstance(barrier, dict) else barrier

tests/slack_sdk/audit_logs/test_response.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ def test_logs_complete(self):
138138
self.assertEqual(entry.details.can_thread.type, ["admin", "org_admin"])
139139
self.assertEqual(entry.details.can_thread.user, ["W222"])
140140
self.assertEqual(entry.details.is_external_limited, True)
141+
# Due to historical reasons, succeeded_users/failed_users can be
142+
# either an array or a single string with encoded JSON data
143+
self.assertEqual(entry.details.succeeded_users, ["W111", "W222"])
144+
self.assertEqual(entry.details.failed_users, ["W333", "W444"])
141145
self.assertEqual(entry.details.exporting_team_id, 1134128598372)
142146

143147

@@ -361,6 +365,8 @@ def test_logs_complete(self):
361365
]
362366
},
363367
"is_external_limited": true,
368+
"succeeded_users": "[\\\"W111\\\", \\\"W222\\\"]",
369+
"failed_users": "[\\\"W333\\\", \\\"W444\\\"]",
364370
"exporting_team_id": 1134128598372
365371
}
366372
}

0 commit comments

Comments
 (0)