-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathexample_async_client.py
More file actions
36 lines (24 loc) · 1.02 KB
/
example_async_client.py
File metadata and controls
36 lines (24 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Example usage of the async LeakIX client."""
import asyncio
import decouple
from leakix import AsyncClient, Scope
API_KEY = decouple.config("API_KEY")
async def example_search_services():
"""Search for services using a raw query string."""
async with AsyncClient(api_key=API_KEY) as client:
response = await client.search("+country:FR +port:22", scope=Scope.SERVICE)
assert response.status_code() == 200
for event in response.json():
print(f"{event.ip}:{event.port} - {event.summary}")
async def example_search_leaks():
"""Search for leaks using a raw query string."""
async with AsyncClient(api_key=API_KEY) as client:
response = await client.search("+plugin:GitConfigHttpPlugin", scope=Scope.LEAK)
assert response.status_code() == 200
for event in response.json():
print(f"{event.host} - {event.summary}")
async def main():
await example_search_services()
await example_search_leaks()
if __name__ == "__main__":
asyncio.run(main())