@@ -22,14 +22,11 @@ def __init__(self, domain, token, telemetry=True, timeout=5.0):
2222 self .domain = domain
2323 self .client = RestClient (jwt = token , telemetry = telemetry , timeout = timeout )
2424
25- def _url (self , id = None , path = None , secondary_id = None ):
25+ def _url (self , * args ):
2626 url = 'https://{}/api/v2/organizations' .format (self .domain )
27- if id is not None :
28- url = '{}/{}' .format (url , id )
29- if path is not None :
30- url = '{}/{}' .format (url , path )
31- if secondary_id is not None :
32- url = '{}/{}' .format (url , secondary_id )
27+ for p in args :
28+ if p is not None :
29+ url = '{}/{}' .format (url , p )
3330 return url
3431
3532 # Organizations
@@ -221,4 +218,57 @@ def delete_organization_members(self, id, body):
221218 See: https://auth0.com/docs/api/management/v2#!/Clients/delete_clients_by_id
222219 """
223220
224- return self .client .delete (self ._url (id , 'members' ), data = body )
221+ return self .client .delete (self ._url (id , 'members' ), data = body )
222+
223+ # Organization Member Roles
224+ def all_organization_member_roles (self , id , user_id , page = None , per_page = None ):
225+ """Retrieves a list of all the roles from the given organization member.
226+
227+ Args:
228+ id (str): the ID of the organization.
229+
230+ user_id (str): the ID of the user member of the organization.
231+
232+ page (int): The result's page number (zero based). When not set,
233+ the default value is up to the server.
234+
235+ per_page (int, optional): The amount of entries per page. When not set,
236+ the default value is up to the server.
237+
238+ See: https://auth0.com/docs/api/management/v2#!/Clients/get_clients
239+ """
240+ params = {}
241+ params ['page' ] = page
242+ params ['per_page' ] = per_page
243+
244+ return self .client .get (self ._url (id , 'members' , user_id , 'roles' ), params = params )
245+
246+ def create_organization_member_roles (self , id , user_id , body ):
247+ """Adds roles to a member of an organization.
248+
249+ Args:
250+ id (str): the ID of the organization.
251+
252+ user_id (str): the ID of the user member of the organization.
253+
254+ body (dict): Attributes from the members to add.
255+
256+ See: https://auth0.com/docs/api/v2#!/Clients/post_clients
257+ """
258+
259+ return self .client .post (self ._url (id , 'members' , user_id , 'roles' ), data = body )
260+
261+ def delete_organization_member_roles (self , id , user_id , body ):
262+ """Deletes roles from a member of an organization.
263+
264+ Args:
265+ id (str): Id of organization.
266+
267+ user_id (str): the ID of the user member of the organization.
268+
269+ body (dict): Attributes from the members to delete
270+
271+ See: https://auth0.com/docs/api/management/v2#!/Clients/delete_clients_by_id
272+ """
273+
274+ return self .client .delete (self ._url (id , 'members' , user_id , 'roles' ), data = body )
0 commit comments