Skip to content

Commit 5178106

Browse files
authored
Merge pull request #13 from crowdsecurity/$main-6c91baa
Update python SDK version: 1.69.0
2 parents 6c91baa + 30e03ac commit 5178106

File tree

13 files changed

+128
-37
lines changed

13 files changed

+128
-37
lines changed

crowdsec_service_api/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ class Server(Enum):
7777
'MetricUnits',
7878
'OriginMetrics',
7979
'OutputFormat',
80-
'PageAllowlistGetItemsResponse',
81-
'PageAllowlistGetResponse',
82-
'PageAllowlistSubscriberEntity',
83-
'PageBlocklistSubscriberEntity',
84-
'PageIntegrationGetResponse',
85-
'PagePublicBlocklistResponse',
80+
'PageTAnyCustomizedAllowlistGetItemsResponse',
81+
'PageTAnyCustomizedAllowlistGetResponse',
82+
'PageTAnyCustomizedAllowlistSubscriberEntity',
83+
'PageTAnyCustomizedBlocklistSubscriberEntity',
84+
'PageTAnyCustomizedIntegrationGetResponse',
85+
'PageTAnyCustomizedPublicBlocklistResponse',
8686
'Permission',
8787
'PricingTiers',
8888
'PublicBlocklistResponse',
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

crowdsec_service_api/models.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: <stdin>
3-
# timestamp: 2025-04-16T07:12:57+00:00
3+
# timestamp: 2025-05-02T13:09:22+00:00
44

55
from __future__ import annotations
66

@@ -180,7 +180,12 @@ class BlocklistAddIPsRequest(BaseModelSdk):
180180
)
181181
ips: Annotated[List[str], Field(description='List of IPs or networks', title='Ips')]
182182
expiration: Annotated[
183-
Optional[datetime], Field(description='Expiration date', title='Expiration')
183+
Optional[datetime],
184+
Field(
185+
description='Expiration date',
186+
examples=['2030-01-01T00:00:00.000Z'],
187+
title='Expiration',
188+
),
184189
] = None
185190

186191

@@ -724,7 +729,7 @@ class BlocklistsUploadBlocklistContentQueryParameters(BaseModelSdk):
724729
Optional[datetime],
725730
Field(
726731
description='Blocklist expiration',
727-
examples='2025-04-16T07:12:36.323875+00:00',
732+
examples='2025-05-02T13:08:57.499429+00:00',
728733
title='Expiration',
729734
),
730735
] = None
@@ -746,6 +751,12 @@ class BlocklistsAddIpsToBlocklistPathParameters(BaseModelSdk):
746751
]
747752

748753

754+
class BlocklistsOverwriteIpsPathParameters(BaseModelSdk):
755+
blocklist_id: Annotated[
756+
str, Field(examples=['5f9d88b9e5c4f5b9a3d3e8b1'], title='Blocklist Id')
757+
]
758+
759+
749760
class BlocklistsDeleteIpsFromBlocklistPathParameters(BaseModelSdk):
750761
blocklist_id: Annotated[
751762
str, Field(examples=['5f9d88b9e5c4f5b9a3d3e8b1'], title='Blocklist Id')
@@ -1463,7 +1474,7 @@ class OriginMetrics(BaseModelSdk):
14631474
]
14641475

14651476

1466-
class PageAllowlistSubscriberEntity(BaseModelSdk):
1477+
class PageTAnyCustomizedAllowlistSubscriberEntity(BaseModelSdk):
14671478
items: Annotated[List[AllowlistSubscriberEntity], Field(title='Items')]
14681479
total: Annotated[Optional[Total], Field(title='Total')] = None
14691480
page: Annotated[Optional[Page], Field(title='Page')] = None
@@ -1472,7 +1483,7 @@ class PageAllowlistSubscriberEntity(BaseModelSdk):
14721483
links: Links
14731484

14741485

1475-
class PageBlocklistSubscriberEntity(BaseModelSdk):
1486+
class PageTAnyCustomizedBlocklistSubscriberEntity(BaseModelSdk):
14761487
items: Annotated[List[BlocklistSubscriberEntity], Field(title='Items')]
14771488
total: Annotated[Optional[Total], Field(title='Total')] = None
14781489
page: Annotated[Optional[Page], Field(title='Page')] = None
@@ -1481,7 +1492,7 @@ class PageBlocklistSubscriberEntity(BaseModelSdk):
14811492
links: Links
14821493

14831494

1484-
class PageIntegrationGetResponse(BaseModelSdk):
1495+
class PageTAnyCustomizedIntegrationGetResponse(BaseModelSdk):
14851496
items: Annotated[List[IntegrationGetResponse], Field(title='Items')]
14861497
total: Annotated[Optional[Total], Field(title='Total')] = None
14871498
page: Annotated[Optional[Page], Field(title='Page')] = None
@@ -2364,7 +2375,7 @@ class ComputedSavedMetrics(BaseModelSdk):
23642375
] = []
23652376

23662377

2367-
class PageAllowlistGetItemsResponse(BaseModelSdk):
2378+
class PageTAnyCustomizedAllowlistGetItemsResponse(BaseModelSdk):
23682379
items: Annotated[List[AllowlistGetItemsResponse], Field(title='Items')]
23692380
total: Annotated[Optional[Total], Field(title='Total')] = None
23702381
page: Annotated[Optional[Page], Field(title='Page')] = None
@@ -2373,7 +2384,7 @@ class PageAllowlistGetItemsResponse(BaseModelSdk):
23732384
links: Links
23742385

23752386

2376-
class PageAllowlistGetResponse(BaseModelSdk):
2387+
class PageTAnyCustomizedAllowlistGetResponse(BaseModelSdk):
23772388
items: Annotated[List[AllowlistGetResponse], Field(title='Items')]
23782389
total: Annotated[Optional[Total], Field(title='Total')] = None
23792390
page: Annotated[Optional[Page], Field(title='Page')] = None
@@ -2382,7 +2393,7 @@ class PageAllowlistGetResponse(BaseModelSdk):
23822393
links: Links
23832394

23842395

2385-
class PagePublicBlocklistResponse(BaseModelSdk):
2396+
class PageTAnyCustomizedPublicBlocklistResponse(BaseModelSdk):
23862397
items: Annotated[List[PublicBlocklistResponse], Field(title='Items')]
23872398
total: Annotated[Optional[Total], Field(title='Total')] = None
23882399
page: Annotated[Optional[Page], Field(title='Page')] = None
Binary file not shown.

crowdsec_service_api/services/blocklists.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,32 @@ def add_ips_to_blocklist(
175175

176176
return None
177177

178+
def overwrite_ips(
179+
self,
180+
request: BlocklistAddIPsRequest,
181+
blocklist_id: str,
182+
):
183+
endpoint_url = "/blocklists/{blocklist_id}/ips/bulk_overwrite"
184+
loc = locals()
185+
headers = {}
186+
params = {}
187+
path_params = json.loads(
188+
BlocklistsOverwriteIpsPathParameters(**loc).model_dump_json(
189+
exclude_none=True
190+
)
191+
)
192+
193+
payload = json.loads(
194+
request.model_dump_json(
195+
exclude_none=True
196+
)
197+
) if "request" in loc else None
198+
response = self.http_client.post(
199+
url=endpoint_url, path_params=path_params, params=params, headers=headers, json=payload
200+
)
201+
202+
return None
203+
178204
def delete_ips_from_blocklist(
179205
self,
180206
request: BlocklistDeleteIPsRequest,

doc/Allowlists.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ from crowdsec_service_api import (
7373
Allowlists,
7474
Server,
7575
ApiKeyAuth,
76+
AllowlistCreateRequest,
7677
)
7778
auth = ApiKeyAuth(api_key='your_api_key')
7879
client = Allowlists(base_url=Server.production_server.value, auth=auth)
@@ -177,6 +178,7 @@ from crowdsec_service_api import (
177178
Allowlists,
178179
Server,
179180
ApiKeyAuth,
181+
AllowlistUpdateRequest,
180182
)
181183
auth = ApiKeyAuth(api_key='your_api_key')
182184
client = Allowlists(base_url=Server.production_server.value, auth=auth)
@@ -251,6 +253,7 @@ from crowdsec_service_api import (
251253
Allowlists,
252254
Server,
253255
ApiKeyAuth,
256+
AllowlistItemsCreateRequest,
254257
)
255258
auth = ApiKeyAuth(api_key='your_api_key')
256259
client = Allowlists(base_url=Server.production_server.value, auth=auth)
@@ -360,6 +363,7 @@ from crowdsec_service_api import (
360363
Allowlists,
361364
Server,
362365
ApiKeyAuth,
366+
AllowlistItemUpdateRequest,
363367
)
364368
auth = ApiKeyAuth(api_key='your_api_key')
365369
client = Allowlists(base_url=Server.production_server.value, auth=auth)
@@ -437,6 +441,7 @@ from crowdsec_service_api import (
437441
Allowlists,
438442
Server,
439443
ApiKeyAuth,
444+
AllowlistSubscriptionRequest,
440445
)
441446
auth = ApiKeyAuth(api_key='your_api_key')
442447
client = Allowlists(base_url=Server.production_server.value, auth=auth)

doc/Blocklists.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
| [delete_blocklist](#delete_blocklist) | Delete a blocklist by ID. If the blocklist is shared with other organizations or it has subscriptions, the operation will fail. If you want to force delete the blocklist, you can use the force query parameter, so the blocklists will be unshared / unsubscribed. |
1111
| [update_blocklist](#update_blocklist) | Update a blocklist's details by ID. It is not possible to update the blocklist content using this operation. |
1212
| [add_ips_to_blocklist](#add_ips_to_blocklist) | Add IPs to a blocklist. If an IP is already in the blocklist, its expiration will be updated with the new expiration. |
13+
| [overwrite_ips](#overwrite_ips) | Overwrite blocklist content |
1314
| [delete_ips_from_blocklist](#delete_ips_from_blocklist) | Delete IPs from a blocklist |
1415
| [download_blocklist_content](#download_blocklist_content) | Download blocklist content as a list of ips as plain text separated by new lines. The response will include the ETag header for cache control. If_Modified_Since and If_None_Match cache control headers are supported for conditional requests. |
1516
| [get_blocklist_subscribers](#get_blocklist_subscribers) | Get blocklist subscribers within your organization. |
@@ -85,6 +86,7 @@ from crowdsec_service_api import (
8586
Blocklists,
8687
Server,
8788
ApiKeyAuth,
89+
BlocklistCreateRequest,
8890
)
8991
auth = ApiKeyAuth(api_key='your_api_key')
9092
client = Blocklists(base_url=Server.production_server.value, auth=auth)
@@ -124,6 +126,7 @@ from crowdsec_service_api import (
124126
Blocklists,
125127
Server,
126128
ApiKeyAuth,
129+
BlocklistSearchRequest,
127130
)
128131
auth = ApiKeyAuth(api_key='your_api_key')
129132
client = Blocklists(base_url=Server.production_server.value, auth=auth)
@@ -240,6 +243,7 @@ from crowdsec_service_api import (
240243
Blocklists,
241244
Server,
242245
ApiKeyAuth,
246+
BlocklistUpdateRequest,
243247
)
244248
auth = ApiKeyAuth(api_key='your_api_key')
245249
client = Blocklists(base_url=Server.production_server.value, auth=auth)
@@ -284,6 +288,7 @@ from crowdsec_service_api import (
284288
Blocklists,
285289
Server,
286290
ApiKeyAuth,
291+
BlocklistAddIPsRequest,
287292
)
288293
auth = ApiKeyAuth(api_key='your_api_key')
289294
client = Blocklists(base_url=Server.production_server.value, auth=auth)
@@ -299,6 +304,47 @@ print(response)
299304
```
300305

301306

307+
## **overwrite_ips**
308+
### Overwrite blocklist content
309+
- Endpoint: `/blocklists/{blocklist_id}/ips/bulk_overwrite`
310+
- Method: `POST`
311+
312+
### Parameters:
313+
| Parameter | Type | Description | Required | Default |
314+
| --------- | ---- | ----------- | -------- | ------- |
315+
| request | [BlocklistAddIPsRequest](./Models.md#blocklistaddipsrequest) | Request body | Yes | - |
316+
| blocklist_id | str | | True | |
317+
### Errors:
318+
| Code | Description |
319+
| ---- | ----------- |
320+
| 403 | Blocklist is read-only |
321+
| 404 | Blocklist not found |
322+
| 412 | Payload too large for one operation, limit is 20000 IPs per request |
323+
| 500 | Internal server error |
324+
| 422 | Validation Error |
325+
### Usage
326+
327+
```python
328+
from crowdsec_service_api import (
329+
Blocklists,
330+
Server,
331+
ApiKeyAuth,
332+
BlocklistAddIPsRequest,
333+
)
334+
auth = ApiKeyAuth(api_key='your_api_key')
335+
client = Blocklists(base_url=Server.production_server.value, auth=auth)
336+
request = BlocklistAddIPsRequest(
337+
ips=None,
338+
expiration=None,
339+
)
340+
response = client.overwrite_ips(
341+
request=request,
342+
blocklist_id='sample-blocklist-id',
343+
)
344+
print(response)
345+
```
346+
347+
302348
## **delete_ips_from_blocklist**
303349
### Delete IPs from a blocklist
304350
- Endpoint: `/blocklists/{blocklist_id}/ips/delete`
@@ -323,6 +369,7 @@ from crowdsec_service_api import (
323369
Blocklists,
324370
Server,
325371
ApiKeyAuth,
372+
BlocklistDeleteIPsRequest,
326373
)
327374
auth = ApiKeyAuth(api_key='your_api_key')
328375
client = Blocklists(base_url=Server.production_server.value, auth=auth)
@@ -437,6 +484,7 @@ from crowdsec_service_api import (
437484
Blocklists,
438485
Server,
439486
ApiKeyAuth,
487+
BlocklistSubscriptionRequest,
440488
)
441489
auth = ApiKeyAuth(api_key='your_api_key')
442490
client = Blocklists(base_url=Server.production_server.value, auth=auth)
@@ -509,6 +557,7 @@ from crowdsec_service_api import (
509557
Blocklists,
510558
Server,
511559
ApiKeyAuth,
560+
BlocklistShareRequest,
512561
)
513562
auth = ApiKeyAuth(api_key='your_api_key')
514563
client = Blocklists(base_url=Server.production_server.value, auth=auth)

doc/Integrations.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ from crowdsec_service_api import (
7070
Integrations,
7171
Server,
7272
ApiKeyAuth,
73+
IntegrationCreateRequest,
7374
)
7475
auth = ApiKeyAuth(api_key='your_api_key')
7576
client = Integrations(base_url=Server.production_server.value, auth=auth)
@@ -171,6 +172,7 @@ from crowdsec_service_api import (
171172
Integrations,
172173
Server,
173174
ApiKeyAuth,
175+
IntegrationUpdateRequest,
174176
)
175177
auth = ApiKeyAuth(api_key='your_api_key')
176178
client = Integrations(base_url=Server.production_server.value, auth=auth)

doc/Models.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,6 @@ id, name, organization_id, created_at, updated_at, entity_type, output_format, b
578578
| credentials | Optional[ApiKeyCredentials, BasicAuthCredentials] | Credentials for the integration ||
579579

580580
# **Links**
581-
## Required:
582-
first, last, self, next, prev
583581
## Properties
584582
| Property | Type | Description | Example |
585583
|----------|------|-------------|---------|
@@ -606,9 +604,9 @@ origin, data
606604
## Enum:
607605
PLAIN_TEXT, F5, REMEDIATION_COMPONENT, FORTIGATE, PALOALTO, CHECKPOINT, CISCO, JUNIPER, MIKROTIK, PFSENSE, OPNSENSE, SOPHOS
608606

609-
# **Page_AllowlistGetItemsResponse_**
607+
# **Page__TAny_Customized_AllowlistGetItemsResponse_**
610608
## Required:
611-
items, total, page, size, links
609+
items, page, size, links
612610
## Properties
613611
| Property | Type | Description | Example |
614612
|----------|------|-------------|---------|
@@ -619,9 +617,9 @@ items, total, page, size, links
619617
| pages | Optional[int] | None ||
620618
| links | Links | None ||
621619

622-
# **Page_AllowlistGetResponse_**
620+
# **Page__TAny_Customized_AllowlistGetResponse_**
623621
## Required:
624-
items, total, page, size, links
622+
items, page, size, links
625623
## Properties
626624
| Property | Type | Description | Example |
627625
|----------|------|-------------|---------|
@@ -632,9 +630,9 @@ items, total, page, size, links
632630
| pages | Optional[int] | None ||
633631
| links | Links | None ||
634632

635-
# **Page_AllowlistSubscriberEntity_**
633+
# **Page__TAny_Customized_AllowlistSubscriberEntity_**
636634
## Required:
637-
items, total, page, size, links
635+
items, page, size, links
638636
## Properties
639637
| Property | Type | Description | Example |
640638
|----------|------|-------------|---------|
@@ -645,9 +643,9 @@ items, total, page, size, links
645643
| pages | Optional[int] | None ||
646644
| links | Links | None ||
647645

648-
# **Page_BlocklistSubscriberEntity_**
646+
# **Page__TAny_Customized_BlocklistSubscriberEntity_**
649647
## Required:
650-
items, total, page, size, links
648+
items, page, size, links
651649
## Properties
652650
| Property | Type | Description | Example |
653651
|----------|------|-------------|---------|
@@ -658,9 +656,9 @@ items, total, page, size, links
658656
| pages | Optional[int] | None ||
659657
| links | Links | None ||
660658

661-
# **Page_IntegrationGetResponse_**
659+
# **Page__TAny_Customized_IntegrationGetResponse_**
662660
## Required:
663-
items, total, page, size, links
661+
items, page, size, links
664662
## Properties
665663
| Property | Type | Description | Example |
666664
|----------|------|-------------|---------|
@@ -671,9 +669,9 @@ items, total, page, size, links
671669
| pages | Optional[int] | None ||
672670
| links | Links | None ||
673671

674-
# **Page_PublicBlocklistResponse_**
672+
# **Page__TAny_Customized_PublicBlocklistResponse_**
675673
## Required:
676-
items, total, page, size, links
674+
items, page, size, links
677675
## Properties
678676
| Property | Type | Description | Example |
679677
|----------|------|-------------|---------|

0 commit comments

Comments
 (0)