Skip to content

Commit 13c256a

Browse files
authored
Merge pull request #5 from crowdsecurity/$main-543f11a
Update python SDK version: 1.94.2
2 parents 543f11a + 6599d6a commit 13c256a

File tree

13 files changed

+44
-42
lines changed

13 files changed

+44
-42
lines changed
50 Bytes
Binary file not shown.
113 Bytes
Binary file not shown.

crowdsec_tracker_api/base_model.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ class Page(BaseModelSdk, Generic[T]):
3737

3838

3939
class Service:
40-
def __init__(self, base_url: str, auth: Auth) -> None:
41-
self.http_client = HttpClient(base_url=base_url, auth=auth)
40+
def __init__(self, base_url: str, auth: Auth, user_agent: str = None) -> None:
41+
self.http_client = HttpClient(
42+
base_url=base_url, auth=auth, user_agent=user_agent
43+
)
4244

4345
def next_page(self, page: BaseModelSdk) -> Optional[BaseModelSdk]:
4446
if not hasattr(page, "links") or not page.links:

crowdsec_tracker_api/http_client.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,20 @@ def auth_flow(self, request):
4545

4646

4747
class HttpClient:
48-
def __init__(self, base_url: str, auth: httpx.Auth, aws_region="eu-west-1") -> None:
48+
def __init__(
49+
self,
50+
base_url: str,
51+
auth: httpx.Auth,
52+
user_agent: str = None,
53+
aws_region="eu-west-1",
54+
) -> None:
4955
self.aws_region = aws_region
5056
self.base_url = base_url
5157
self.auth = auth
52-
self.client = httpx.Client(headers={"Accept-Encoding": "gzip"})
58+
headers = {"Accept-Encoding": "gzip"}
59+
if user_agent:
60+
headers["User-Agent"] = user_agent
61+
self.client = httpx.Client(headers=headers)
5362
self.timeout = 30
5463

5564
def _replace_path_params(self, url: str, path_params: dict):

crowdsec_tracker_api/models.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: <stdin>
3-
# timestamp: 2025-12-17T10:47:38+00:00
3+
# timestamp: 2025-12-29T14:24:53+00:00
44

55
from __future__ import annotations
66

@@ -546,7 +546,7 @@ class CvesGetCveIpsDetailsQueryParameters(BaseModelSdk):
546546
description='Filter IPs seen since this date, format duration (e.g., 7d, 24h), default to 14d',
547547
title='Since',
548548
),
549-
] = Since('14d')
549+
] = '14d'
550550
page: Annotated[
551551
Optional[int], Field(description='Page number', ge=1, title='Page')
552552
] = 1
@@ -662,13 +662,9 @@ class IntegrationCreateResponse(BaseModelSdk):
662662
title='Endpoint',
663663
),
664664
]
665-
stats: Annotated[
666-
Optional[Stats],
667-
Field(
668-
default_factory=lambda: Stats.model_validate({'count': 0}),
669-
description='Stats of the integration',
670-
),
671-
]
665+
stats: Annotated[Optional[Stats], Field(description='Stats of the integration')] = {
666+
'count': 0
667+
}
672668
tags: Annotated[
673669
Optional[List[str]],
674670
Field(description='Tags associated with the integration', title='Tags'),
@@ -736,13 +732,9 @@ class IntegrationGetResponse(BaseModelSdk):
736732
title='Endpoint',
737733
),
738734
]
739-
stats: Annotated[
740-
Optional[Stats],
741-
Field(
742-
default_factory=lambda: Stats.model_validate({'count': 0}),
743-
description='Stats of the integration',
744-
),
745-
]
735+
stats: Annotated[Optional[Stats], Field(description='Stats of the integration')] = {
736+
'count': 0
737+
}
746738
tags: Annotated[
747739
Optional[List[str]],
748740
Field(description='Tags associated with the integration', title='Tags'),
@@ -835,13 +827,9 @@ class IntegrationUpdateResponse(BaseModelSdk):
835827
title='Endpoint',
836828
),
837829
]
838-
stats: Annotated[
839-
Optional[Stats],
840-
Field(
841-
default_factory=lambda: Stats.model_validate({'count': 0}),
842-
description='Stats of the integration',
843-
),
844-
]
830+
stats: Annotated[Optional[Stats], Field(description='Stats of the integration')] = {
831+
'count': 0
832+
}
845833
tags: Annotated[
846834
Optional[List[str]],
847835
Field(description='Tags associated with the integration', title='Tags'),
Binary file not shown.

crowdsec_tracker_api/services/cves.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

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

1616
def get_cves(
1717
self,
@@ -21,7 +21,7 @@ def get_cves(
2121
page: int = 1,
2222
size: int = 50,
2323
)-> GetCVEsResponsePage:
24-
endpoint_url = "/cves/"
24+
endpoint_url = "/cves"
2525
loc = locals()
2626
headers = {}
2727
params = json.loads(

crowdsec_tracker_api/services/integrations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

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

1616
def get_integrations(
1717
self,
@@ -124,7 +124,7 @@ def get_integration_content(
124124
integration_id: str,
125125
page: int = 1,
126126
page_size: Optional[int] = None,
127-
):
127+
)-> str:
128128
endpoint_url = "/integrations/{integration_id}/content"
129129
loc = locals()
130130
headers = {}
@@ -143,7 +143,7 @@ def get_integration_content(
143143
url=endpoint_url, path_params=path_params, params=params, headers=headers
144144
)
145145

146-
return None
146+
return response.text
147147

148148
def get_integration_content_stream(
149149
self,

doc/Cves.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
## **get_cves**
1515
### Get a paginated list of CVEs that CrowdSec is tracking
16-
- Endpoint: `/cves/`
16+
- Endpoint: `/cves`
1717
- Method: `GET`
1818

1919
### Parameters:

doc/Integrations.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,13 @@ except HTTPStatusError as e:
212212
| integration_id | str | | True | |
213213
| page | int | Page number to return | False | 1 |
214214
| page_size | Optional[int] | Maximum number of items to return, 0 means no limit (default), should be greater than 10000 | False | None |
215+
### Returns:
216+
[str](./Models.md#str)
215217
### Errors:
216218
| Code | Description |
217219
| ---- | ----------- |
218220
| 404 | Integration not found |
221+
| 204 | Integration has no subscribed blocklists or no content available |
219222
| 422 | Validation Error |
220223
### Usage
221224

0 commit comments

Comments
 (0)