88from leakix .response import SuccessResponse , ErrorResponse , RateLimitResponse
99from leakix .query import *
1010from leakix .plugin import *
11+ from leakix .plugin import APIResult
1112from leakix .field import *
1213
1314
@@ -58,6 +59,22 @@ def __get(self, url, params):
5859 return ErrorResponse (response = r , response_json = r .json ())
5960
6061 def get (self , scope : Scope , queries : Optional [List [Query ]] = None , page : int = 0 ):
62+ """
63+ The function takes a scope (either "leaks" or "services"). The value can be constructed using `Scope.SERVICE` or
64+ `Scope.LEAK`.
65+ The second parameter is a list of queries. The default value will be considered as the wildcard `*`, which is
66+ also the default value on the web interface.
67+ Structured queries can be built using the different classes in `query.py` and `field.py`.
68+ If you want to build "raw" queries, like on the search bar on the website, use the class `RawQuery`.
69+
70+ The output will be an abstract response, which can be a successfull HTTP response (represented by the class
71+ `SuccessResponse`) or a failed HTTP response (represented by the class `ErrorResponse`).
72+ Methods `is_success` and `is_error` are provided to the user to verify in their application what the state of
73+ the response is.
74+
75+ The output of a query can be accessed using the method `json`, for instance `response.json()`.
76+ In the case of a successfull response, the output will be a list of L9Event.
77+ """
6178 if page < 0 :
6279 raise ValueError ("Page argument must be a positive integer" )
6380 if queries is None or len (queries ) == 0 :
@@ -73,6 +90,10 @@ def get(self, scope: Scope, queries: Optional[List[Query]] = None, page: int = 0
7390 return r
7491
7592 def get_service (self , queries : Optional [List [Query ]] = None , page : int = 0 ):
93+ """
94+ Shortcut for `get` with the scope `Scope.Service`.
95+
96+ """
7697 r = self .get (Scope .SERVICE , queries = queries , page = page )
7798 if r .is_success ():
7899 r .response_json = [
@@ -81,6 +102,9 @@ def get_service(self, queries: Optional[List[Query]] = None, page: int = 0):
81102 return r
82103
83104 def get_leak (self , queries : Optional [List [Query ]] = None , page : int = 0 ):
105+ """
106+ Shortcut for `get` with the scope `Scope.Leak`.
107+ """
84108 r = self .get (Scope .LEAK , queries = queries , page = page )
85109 if r .is_success ():
86110 r .response_json = [
@@ -89,6 +113,10 @@ def get_leak(self, queries: Optional[List[Query]] = None, page: int = 0):
89113 return r
90114
91115 def get_host (self , ipv4 : str ):
116+ """
117+ Returns the list of services and associated leaks for a given host. Only the ipv4 format is supported at the
118+ moment.
119+ """
92120 url = "%s/host/%s" % (self .base_url , ipv4 )
93121 r = self .__get (url , params = None )
94122 if r .is_success ():
@@ -102,6 +130,15 @@ def get_host(self, ipv4: str):
102130 return r
103131
104132 def get_plugins (self ):
133+ """
134+ Returns the list of plugins the authenticated user with the given API key has access to.
135+
136+ The output is a list of `APIResult` objects. The fields are `name` which is the plugin name, and `description`
137+ which contains a brief description of the plugin.
138+ Paid users have access to a broader list of plugins. The full list you can be found on
139+ https://leakix.net/plugins.
140+ For the paid plans, have a look at https://leakix.net/pricing.
141+ """
105142 url = "%s/api/plugins" % (self .base_url )
106143 r = self .__get (url , params = None )
107144 if r .is_success ():
0 commit comments