Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crowdsec_service_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Server(Enum):
'BlocklistSources',
'BlocklistStats',
'BlocklistSubscriberEntity',
'BlocklistSubscribersResponse',
'BlocklistSubscribersCount',
'BlocklistSubscription',
'BlocklistSubscriptionRequest',
'BlocklistSubscriptionResponse',
Expand Down Expand Up @@ -80,6 +80,7 @@ class Server(Enum):
'PageAllowlistGetItemsResponse',
'PageAllowlistGetResponse',
'PageAllowlistSubscriberEntity',
'PageBlocklistSubscriberEntity',
'PageIntegrationGetResponse',
'PagePublicBlocklistResponse',
'Permission',
Expand Down
Binary file modified crowdsec_service_api/__pycache__/base_model.cpython-311.pyc
Binary file not shown.
Binary file modified crowdsec_service_api/__pycache__/http_client.cpython-311.pyc
Binary file not shown.
32 changes: 25 additions & 7 deletions crowdsec_service_api/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: <stdin>
# timestamp: 2025-04-01T14:11:38+00:00
# timestamp: 2025-04-16T07:12:57+00:00

from __future__ import annotations

Expand Down Expand Up @@ -724,7 +724,7 @@ class BlocklistsUploadBlocklistContentQueryParameters(BaseModelSdk):
Optional[datetime],
Field(
description='Blocklist expiration',
examples='2025-04-01T14:11:16.563106+00:00',
examples='2025-04-16T07:12:36.323875+00:00',
title='Expiration',
),
] = None
Expand Down Expand Up @@ -783,6 +783,15 @@ class BlocklistsSubscribeBlocklistPathParameters(BaseModelSdk):
]


class BlocklistsGetBlocklistSubscribersQueryParameters(BaseModelSdk):
page: Annotated[
Optional[int], Field(description='Page number', ge=1, title='Page')
] = 1
size: Annotated[
Optional[int], Field(description='Page size', ge=1, le=100, title='Size')
] = 50


class BlocklistsGetBlocklistSubscribersPathParameters(BaseModelSdk):
blocklist_id: Annotated[
str, Field(examples=['5f9d88b9e5c4f5b9a3d3e8b1'], title='Blocklist Id')
Expand Down Expand Up @@ -1185,11 +1194,11 @@ class BlocklistSubscriberEntity(BaseModelSdk):
remediation: Annotated[str, Field(description='Remediation', title='Remediation')]


class BlocklistSubscribersResponse(BaseModelSdk):
subscribers: Annotated[
List[BlocklistSubscriberEntity],
Field(description='List of subscribers', title='Subscribers'),
class BlocklistSubscribersCount(BaseModelSdk):
entity_type: Annotated[
SubscriberEntityType, Field(description='Subscriber entity type')
]
count: Annotated[int, Field(description='Subscriber entity count', title='Count')]


class BlocklistSubscriptionRequest(BaseModelSdk):
Expand Down Expand Up @@ -1463,6 +1472,15 @@ class PageAllowlistSubscriberEntity(BaseModelSdk):
links: Links


class PageBlocklistSubscriberEntity(BaseModelSdk):
items: Annotated[List[BlocklistSubscriberEntity], Field(title='Items')]
total: Annotated[Optional[Total], Field(title='Total')] = None
page: Annotated[Optional[Page], Field(title='Page')] = None
size: Annotated[Optional[Size], Field(title='Size')] = None
pages: Annotated[Optional[Pages], Field(title='Pages')] = None
links: Links


class PageIntegrationGetResponse(BaseModelSdk):
items: Annotated[List[IntegrationGetResponse], Field(title='Items')]
total: Annotated[Optional[Total], Field(title='Total')] = None
Expand Down Expand Up @@ -1536,7 +1554,7 @@ class PublicBlocklistResponse(BaseModelSdk):
),
] = None
subscribers: Annotated[
Optional[List[BlocklistSubscriberEntity]],
Optional[List[BlocklistSubscribersCount]],
Field(
description='List of subscribers to the blocklist. Only subscribers belonging to your organization are returned',
title='Subscribers',
Expand Down
Binary file not shown.
12 changes: 9 additions & 3 deletions crowdsec_service_api/services/blocklists.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,17 @@ def download_blocklist_content(
def get_blocklist_subscribers(
self,
blocklist_id: str,
)-> BlocklistSubscribersResponse:
page: int = 1,
size: int = 50,
)-> Page[BlocklistSubscriberEntity]:
endpoint_url = "/blocklists/{blocklist_id}/subscribers"
loc = locals()
headers = {}
params = {}
params = json.loads(
BlocklistsGetBlocklistSubscribersQueryParameters(**loc).model_dump_json(
exclude_none=True
)
)
path_params = json.loads(
BlocklistsGetBlocklistSubscribersPathParameters(**loc).model_dump_json(
exclude_none=True
Expand All @@ -245,7 +251,7 @@ def get_blocklist_subscribers(
url=endpoint_url, path_params=path_params, params=params, headers=headers
)

return BlocklistSubscribersResponse(**response.json())
return Page[BlocklistSubscriberEntity](_client=self, **response.json())

def subscribe_blocklist(
self,
Expand Down
6 changes: 5 additions & 1 deletion doc/Blocklists.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,10 @@ print(response)
| Parameter | Type | Description | Required | Default |
| --------- | ---- | ----------- | -------- | ------- |
| blocklist_id | str | | True | |
| page | int | Page number | False | 1 |
| size | int | Page size | False | 50 |
### Returns:
[BlocklistSubscribersResponse](./Models.md#blocklistsubscribersresponse)
[Page[BlocklistSubscriberEntity]](./Models.md#page[blocklistsubscriberentity])
### Errors:
| Code | Description |
| ---- | ----------- |
Expand All @@ -404,6 +406,8 @@ auth = ApiKeyAuth(api_key='your_api_key')
client = Blocklists(base_url=Server.production_server.value, auth=auth)
response = client.get_blocklist_subscribers(
blocklist_id='sample-blocklist-id',
page=1,
size=50,
)
print(response)
```
Expand Down
22 changes: 18 additions & 4 deletions doc/Models.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,14 @@ id, entity_type, remediation
| entity_type | str | None ||
| remediation | str | Remediation ||

# **BlocklistSubscribersResponse**
# **BlocklistSubscribersCount**
## Required:
subscribers
entity_type, count
## Properties
| Property | Type | Description | Example |
|----------|------|-------------|---------|
| subscribers | list[BlocklistSubscriberEntity] | List of subscribers ||
| entity_type | str | None ||
| count | int | Subscriber entity count ||

# **BlocklistSubscription**
## Required:
Expand Down Expand Up @@ -644,6 +645,19 @@ items, total, page, size, links
| pages | Optional[int] | None ||
| links | Links | None ||

# **Page_BlocklistSubscriberEntity_**
## Required:
items, total, page, size, links
## Properties
| Property | Type | Description | Example |
|----------|------|-------------|---------|
| items | list[BlocklistSubscriberEntity] | None ||
| total | Optional[int] | None ||
| page | Optional[int] | None ||
| size | Optional[int] | None ||
| pages | Optional[int] | None ||
| links | Links | None ||

# **Page_IntegrationGetResponse_**
## Required:
items, total, page, size, links
Expand Down Expand Up @@ -700,7 +714,7 @@ id, created_at, updated_at, name, description, is_private, pricing_tier, source,
| since | Optional[str] | Since duration for the CTI query (eg. 5m, 2h, 7d). Max is 30 days ||
| shared_with | list[Share] | List of organizations shared with ||
| organization_id | Optional[str] | Blocklists owner's organization id ||
| subscribers | list[BlocklistSubscriberEntity] | List of subscribers to the blocklist. Only subscribers belonging to your organization are returned ||
| subscribers | list[BlocklistSubscribersCount] | List of subscribers to the blocklist. Only subscribers belonging to your organization are returned ||
| categories | list[BlocklistCategory] | List of categories for the blocklist ||

# **PublicPaginatedBlocklistResponse**
Expand Down
4 changes: 3 additions & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ You can find a Quickstart about this SDK, following this [documentation](https:/

[BlocklistSubscriberEntity](./Models.md#blocklistsubscriberentity)

[BlocklistSubscribersResponse](./Models.md#blocklistsubscribersresponse)
[BlocklistSubscribersCount](./Models.md#blocklistsubscriberscount)

[BlocklistSubscription](./Models.md#blocklistsubscription)

Expand Down Expand Up @@ -147,6 +147,8 @@ You can find a Quickstart about this SDK, following this [documentation](https:/

[PageAllowlistSubscriberEntity](./Models.md#pageallowlistsubscriberentity)

[PageBlocklistSubscriberEntity](./Models.md#pageblocklistsubscriberentity)

[PageIntegrationGetResponse](./Models.md#pageintegrationgetresponse)

[PagePublicBlocklistResponse](./Models.md#pagepublicblocklistresponse)
Expand Down
2 changes: 1 addition & 1 deletion openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "crowdsec_service_api"
version = "1.62.0"
version = "1.63.0"
license = { text = "MIT" }
authors = [
{ name="crowdsec", email="info@crowdsec.net" }
Expand Down