@@ -32,6 +32,14 @@ def _make_post_request(self, uri, json={}):
3232 else :
3333 raise WarrantException (msg = resp .text , status_code = resp .status_code )
3434
35+ def _make_get_request (self , uri , params = {}):
36+ headers = { "Authorization" : "ApiKey " + self ._apiKey }
37+ resp = requests .get (url = API_ENDPOINT + API_VERSION + uri , headers = headers , params = params )
38+ if resp .status_code == 200 :
39+ return resp .json ()
40+ else :
41+ raise WarrantException (msg = resp .text , status_code = resp .status_code )
42+
3543 def create_user (self , user_id = "" ):
3644 if user_id == "" :
3745 payload = {}
@@ -71,6 +79,16 @@ def create_warrant(self, object_type, object_id, relation, user):
7179 resp = self ._make_post_request (uri = "/warrants" , json = payload )
7280 return resp ['id' ]
7381
82+ def list_warrants (self , object_type = "" , object_id = "" , relation = "" , user_id = "" ):
83+ filters = {
84+ "objectType" : object_type ,
85+ "objectId" : object_id ,
86+ "relation" : relation ,
87+ "userId" : user_id ,
88+ }
89+ resp = self ._make_get_request (uri = "/warrants" , params = filters )
90+ return resp
91+
7492 def is_authorized (self , object_type , object_id , relation , user_to_check ):
7593 if object_type == "" or object_id == "" or relation == "" :
7694 raise WarrantException (msg = "Invalid object_type, object_id and/or relation" )
0 commit comments