Skip to content

Commit 675c40a

Browse files
authored
Merge pull request #2 from crowdsecurity/$main-1beaf5b
Update python SDK version: 1.0.1
2 parents 1beaf5b + b01d354 commit 675c40a

File tree

12 files changed

+150
-104
lines changed

12 files changed

+150
-104
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# crowdsec_tracker_api
22

3-
**crowdsec_tracker_api** is a Python SDK for the [CrowdSec Tracker API](https://docs.crowdsec.net/u/service_api/intro/).
3+
**crowdsec_tracker_api** is a Python SDK for the [CrowdSec Tracker API](https://docs.crowdsec.net/u/tracker_api/intro/).
44
This library enables you to manage CrowdSec Live Exploit Tracker resources such as CVEs data, IPs from a specific CVE and manage integrations.
55

66
## Installation
@@ -11,7 +11,7 @@ pip install crowdsec_tracker_api
1111

1212
## Usage
1313

14-
You can follow this [documentation](https://docs.crowdsec.net/u/service_api/quickstart/blocklists) to see the basic usage of the SDK.
14+
You can follow this [documentation](https://docs.crowdsec.net/u/tracker_api/intro/) to see the basic usage of the SDK.
1515

1616
## Documentation
1717
You can access the full usage documentation [here](https://github.com/crowdsecurity/crowdsec-tracker-api-sdk-python/tree/main/doc).
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

crowdsec_tracker_api/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: <stdin>
3-
# timestamp: 2025-12-11T09:50:59+00:00
3+
# timestamp: 2025-12-11T15:02:14+00:00
44

55
from __future__ import annotations
66

Binary file not shown.

crowdsec_tracker_api/services/cves.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from ..http_client import HttpClient
1111

1212
class Cves(Service):
13+
def __init__(self, auth: Auth, base_url: str = "https://admin.api.crowdsec.net/v1") -> None:
14+
super().__init__(base_url=base_url, auth=auth)
1315

1416
def get_cves(
1517
self,

crowdsec_tracker_api/services/integrations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from ..http_client import HttpClient
1111

1212
class Integrations(Service):
13+
def __init__(self, auth: Auth, base_url: str = "https://admin.api.crowdsec.net/v1") -> None:
14+
super().__init__(base_url=base_url, auth=auth)
1315

1416
def get_integrations(
1517
self,

doc/Cves.md

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,20 @@
3232
```python
3333
from crowdsec_tracker_api import (
3434
Cves,
35-
Server,
3635
ApiKeyAuth,
3736
)
37+
from httpx import HTTPStatusError
3838
auth = ApiKeyAuth(api_key='your_api_key')
39-
client = Cves(base_url=Server.production_server.value, auth=auth)
40-
response = client.get_cves(
41-
query=None,
42-
page=1,
43-
size=50,
44-
)
45-
print(response)
39+
client = Cves(auth=auth)
40+
try:
41+
response = client.get_cves(
42+
query=None,
43+
page=1,
44+
size=50,
45+
)
46+
print(response)
47+
except HTTPStatusError as e:
48+
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
4649
```
4750

4851

@@ -67,15 +70,18 @@ print(response)
6770
```python
6871
from crowdsec_tracker_api import (
6972
Cves,
70-
Server,
7173
ApiKeyAuth,
7274
)
75+
from httpx import HTTPStatusError
7376
auth = ApiKeyAuth(api_key='your_api_key')
74-
client = Cves(base_url=Server.production_server.value, auth=auth)
75-
response = client.get_cve(
76-
cve_id='cve_id',
77-
)
78-
print(response)
77+
client = Cves(auth=auth)
78+
try:
79+
response = client.get_cve(
80+
cve_id='cve_id',
81+
)
82+
print(response)
83+
except HTTPStatusError as e:
84+
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
7985
```
8086

8187

@@ -103,18 +109,21 @@ print(response)
103109
```python
104110
from crowdsec_tracker_api import (
105111
Cves,
106-
Server,
107112
ApiKeyAuth,
108113
)
114+
from httpx import HTTPStatusError
109115
auth = ApiKeyAuth(api_key='your_api_key')
110-
client = Cves(base_url=Server.production_server.value, auth=auth)
111-
response = client.get_cve_ips(
112-
cve_id='cve_id',
113-
since=None,
114-
page=1,
115-
size=50,
116-
)
117-
print(response)
116+
client = Cves(auth=auth)
117+
try:
118+
response = client.get_cve_ips(
119+
cve_id='cve_id',
120+
since=None,
121+
page=1,
122+
size=50,
123+
)
124+
print(response)
125+
except HTTPStatusError as e:
126+
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
118127
```
119128

120129

@@ -141,17 +150,20 @@ print(response)
141150
```python
142151
from crowdsec_tracker_api import (
143152
Cves,
144-
Server,
145153
ApiKeyAuth,
146154
)
155+
from httpx import HTTPStatusError
147156
auth = ApiKeyAuth(api_key='your_api_key')
148-
client = Cves(base_url=Server.production_server.value, auth=auth)
149-
response = client.get_cve_subscribed_integrations(
150-
cve_id='cve_id',
151-
page=1,
152-
size=50,
153-
)
154-
print(response)
157+
client = Cves(auth=auth)
158+
try:
159+
response = client.get_cve_subscribed_integrations(
160+
cve_id='cve_id',
161+
page=1,
162+
size=50,
163+
)
164+
print(response)
165+
except HTTPStatusError as e:
166+
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
155167
```
156168

157169

@@ -176,20 +188,23 @@ print(response)
176188
```python
177189
from crowdsec_tracker_api import (
178190
Cves,
179-
Server,
180191
ApiKeyAuth,
181192
SubscribeCVEIntegrationRequest,
182193
)
194+
from httpx import HTTPStatusError
183195
auth = ApiKeyAuth(api_key='your_api_key')
184-
client = Cves(base_url=Server.production_server.value, auth=auth)
196+
client = Cves(auth=auth)
185197
request = SubscribeCVEIntegrationRequest(
186198
name=None,
187199
)
188-
response = client.subscribe_integration_to_cve(
189-
request=request,
190-
cve_id='cve_id',
191-
)
192-
print(response)
200+
try:
201+
response = client.subscribe_integration_to_cve(
202+
request=request,
203+
cve_id='cve_id',
204+
)
205+
print(response)
206+
except HTTPStatusError as e:
207+
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
193208
```
194209

195210

@@ -214,15 +229,18 @@ print(response)
214229
```python
215230
from crowdsec_tracker_api import (
216231
Cves,
217-
Server,
218232
ApiKeyAuth,
219233
)
234+
from httpx import HTTPStatusError
220235
auth = ApiKeyAuth(api_key='your_api_key')
221-
client = Cves(base_url=Server.production_server.value, auth=auth)
222-
response = client.unsubscribe_integration_from_cve(
223-
cve_id='cve_id',
224-
integration_name='integration_name',
225-
)
226-
print(response)
236+
client = Cves(auth=auth)
237+
try:
238+
response = client.unsubscribe_integration_from_cve(
239+
cve_id='cve_id',
240+
integration_name='integration_name',
241+
)
242+
print(response)
243+
except HTTPStatusError as e:
244+
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
227245
```
228246

0 commit comments

Comments
 (0)