Skip to content

Commit f1af60a

Browse files
nitescucgithub-actions[bot]
authored andcommitted
Update python SDK 1.42.0
1 parent 495d80c commit f1af60a

File tree

15 files changed

+903
-80
lines changed

15 files changed

+903
-80
lines changed

crowdsec_service_api/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from enum import Enum
2-
from .base_model import Page
32
from .models import *
3+
from .base_model import Page
44
from .services.blocklists import Blocklists
55
from .services.integrations import Integrations
66
from .services.info import Info
@@ -18,6 +18,7 @@ class Server(Enum):
1818
'ApiKeyCredentials',
1919
'BasicAuthCredentials',
2020
'BlocklistAddIPsRequest',
21+
'BlocklistCategory',
2122
'BlocklistContentStats',
2223
'BlocklistCreateRequest',
2324
'BlocklistCreateResponse',
@@ -43,7 +44,6 @@ class Server(Enum):
4344
'CtiCountry',
4445
'CtiIp',
4546
'CtiScenario',
46-
'EntityType',
4747
'HTTPValidationError',
4848
'InfoResponse',
4949
'IntegrationCreateRequest',
@@ -61,10 +61,17 @@ class Server(Enum):
6161
'PricingTiers',
6262
'Share',
6363
'Stats',
64+
'SubscriberEntityType',
6465
'ValidationError',
65-
'HubItem',
66-
'HubType',
66+
'AppsecConfigIndex',
67+
'AppsecRuleIndex',
68+
'CollectionIndex',
69+
'ContextIndex',
6770
'Index',
71+
'ParserIndex',
72+
'PostoverflowIndex',
73+
'ScenarioIndex',
74+
'VersionDetail',
6875
'ApiKeyAuth',
6976
'Server',
7077
'Page'
Binary file not shown.
Binary file not shown.

crowdsec_service_api/base_model.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@ class BaseModelSdk(BaseModel):
1515

1616

1717
class Page(BaseModelSdk, Generic[T]):
18+
_client: "Service"
1819
items: Sequence[T]
1920
total: Optional[int]
2021
page: Optional[int]
2122
size: Optional[int]
2223
pages: Optional[int] = None
2324
links: Optional[dict] = None
2425

25-
def next(self, client: "Service") -> "Page[T]":
26-
return client.next_page(self)
26+
def __init__(self, _client: "Service", **data):
27+
super().__init__(**data)
28+
self._client = _client
29+
30+
def next(self, client: "Service" = None) -> "Page[T]":
31+
return (client if client is not None else self._client).next_page(self)
2732

2833

2934
class Service:
@@ -41,5 +46,5 @@ def next_page(self, page: Page[T]) -> Page[T]:
4146
response = self.http_client.get(
4247
f"{parsed_url.scheme}://{parsed_url.netloc}{page.links['next']}"
4348
)
44-
return Page[T](**response.json())
49+
return page.__class__(_client=self, **response.json())
4550
return None

0 commit comments

Comments
 (0)