Skip to content

Commit cefd4ab

Browse files
authored
Add IAM list roles, resource roles, and groups methods for users (#99)
Signed-off-by: rsuplina <[email protected]>
1 parent ee610b9 commit cefd4ab

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/cdpy/iam.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,33 @@ def get_account(self):
174174
warning='CDP Account could not be retrieved')
175175
]
176176
)
177+
178+
def list_groups_for_user(self, user_id=None):
179+
return self.sdk.call(
180+
svc='iam', func='list_groups_for_user', ret_field='groupCrns',
181+
squelch=[
182+
Squelch(field='error_code', value='NOT_FOUND', default=list(),
183+
warning='No users, %s' % str(user_id))
184+
],
185+
userId=user_id
186+
)
187+
188+
def list_user_assigned_roles(self, user=None):
189+
return self.sdk.call(
190+
svc='iam', func='list_user_assigned_roles', ret_field='roleCrns',
191+
squelch=[
192+
Squelch(field='error_code', value='NOT_FOUND', default=list(),
193+
warning='No users, %s' % str(user))
194+
],
195+
user=user
196+
)
197+
198+
def list_user_assigned_resource_roles(self, user=None):
199+
return self.sdk.call(
200+
svc='iam', func='list_user_assigned_resource_roles', ret_field='resourceAssignments',
201+
squelch=[
202+
Squelch(field='error_code', value='NOT_FOUND', default=list(),
203+
warning='No users, %s' % str(user))
204+
],
205+
user=user
206+
)

0 commit comments

Comments
 (0)