Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update python SDK version: 1.43.1 #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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