Skip to content

Commit

Permalink
Update python SDK 1.42.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nitescuc authored and github-actions[bot] committed Nov 15, 2024
1 parent 495d80c commit f1af60a
Show file tree
Hide file tree
Showing 15 changed files with 903 additions and 80 deletions.
15 changes: 11 additions & 4 deletions crowdsec_service_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from enum import Enum
from .base_model import Page
from .models import *
from .base_model import Page
from .services.blocklists import Blocklists
from .services.integrations import Integrations
from .services.info import Info
Expand All @@ -18,6 +18,7 @@ class Server(Enum):
'ApiKeyCredentials',
'BasicAuthCredentials',
'BlocklistAddIPsRequest',
'BlocklistCategory',
'BlocklistContentStats',
'BlocklistCreateRequest',
'BlocklistCreateResponse',
Expand All @@ -43,7 +44,6 @@ class Server(Enum):
'CtiCountry',
'CtiIp',
'CtiScenario',
'EntityType',
'HTTPValidationError',
'InfoResponse',
'IntegrationCreateRequest',
Expand All @@ -61,10 +61,17 @@ class Server(Enum):
'PricingTiers',
'Share',
'Stats',
'SubscriberEntityType',
'ValidationError',
'HubItem',
'HubType',
'AppsecConfigIndex',
'AppsecRuleIndex',
'CollectionIndex',
'ContextIndex',
'Index',
'ParserIndex',
'PostoverflowIndex',
'ScenarioIndex',
'VersionDetail',
'ApiKeyAuth',
'Server',
'Page'
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.
11 changes: 8 additions & 3 deletions crowdsec_service_api/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ class BaseModelSdk(BaseModel):


class Page(BaseModelSdk, Generic[T]):
_client: "Service"
items: Sequence[T]
total: Optional[int]
page: Optional[int]
size: Optional[int]
pages: Optional[int] = None
links: Optional[dict] = None

def next(self, client: "Service") -> "Page[T]":
return client.next_page(self)
def __init__(self, _client: "Service", **data):
super().__init__(**data)
self._client = _client

def next(self, client: "Service" = None) -> "Page[T]":
return (client if client is not None else self._client).next_page(self)


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

0 comments on commit f1af60a

Please sign in to comment.