@@ -32,6 +32,14 @@ def _make_post_request(self, uri, json={}):
32
32
else :
33
33
raise WarrantException (msg = resp .text , status_code = resp .status_code )
34
34
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
+
35
43
def create_user (self , user_id = "" ):
36
44
if user_id == "" :
37
45
payload = {}
@@ -71,6 +79,16 @@ def create_warrant(self, object_type, object_id, relation, user):
71
79
resp = self ._make_post_request (uri = "/warrants" , json = payload )
72
80
return resp ['id' ]
73
81
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
+
74
92
def is_authorized (self , object_type , object_id , relation , user_to_check ):
75
93
if object_type == "" or object_id == "" or relation == "" :
76
94
raise WarrantException (msg = "Invalid object_type, object_id and/or relation" )
0 commit comments