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
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/search/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .types import ObsDatasourceInfoDataType
from .types import ObsExporterInfoDestinationType
from .types import ResourceType
from .types import SearchResourcesRequestOrderBy
from .types import BrmServerInfo
from .types import ObsDatasourceInfo
from .types import ObsExporterInfo
Expand All @@ -21,6 +22,7 @@
"ObsDatasourceInfoDataType",
"ObsExporterInfoDestinationType",
"ResourceType",
"SearchResourcesRequestOrderBy",
"BrmServerInfo",
"ObsDatasourceInfo",
"ObsExporterInfo",
Expand Down
10 changes: 10 additions & 0 deletions scaleway-async/scaleway_async/search/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .types import (
Locality,
ResourceType,
SearchResourcesRequestOrderBy,
SearchResourcesResponse,
)
from .marshalling import (
Expand All @@ -30,6 +31,9 @@ async def search_resources(
created_before: Optional[datetime] = None,
modified_after: Optional[datetime] = None,
modified_before: Optional[datetime] = None,
page_token: Optional[str] = None,
page_size: Optional[int] = None,
order_by: Optional[SearchResourcesRequestOrderBy] = None,
) -> SearchResourcesResponse:
"""
Search API.
Expand All @@ -42,6 +46,9 @@ async def search_resources(
:param created_before: Filter resources created before this timestamp.
:param modified_after: Filter resources modified after this timestamp.
:param modified_before: Filter resources modified before this timestamp.
:param page_token: Leave empty or omit to fetch the first page.
:param page_size: Number of resources to retrieve per page.
:param order_by: Sort order in the response.
:return: :class:`SearchResourcesResponse <SearchResourcesResponse>`

Usage:
Expand All @@ -61,8 +68,11 @@ async def search_resources(
"localities": localities,
"modified_after": modified_after,
"modified_before": modified_before,
"order_by": order_by,
"organization_id": organization_id
or self.client.default_organization_id,
"page_size": page_size or self.client.default_page_size,
"page_token": page_token,
"project_ids": project_ids,
"query": query,
"types": types,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,10 @@ def unmarshal_SearchResourcesResponse(data: Any) -> SearchResourcesResponse:
else:
args["resources"] = []

field = data.get("next_page_token", None)
if field is not None:
args["next_page_token"] = field
else:
args["next_page_token"] = None

return SearchResourcesResponse(**args)
36 changes: 36 additions & 0 deletions scaleway-async/scaleway_async/search/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ def __str__(self) -> str:
return str(self.value)


class SearchResourcesRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
CREATED_AT_ASC = "created_at_asc"
CREATED_AT_DESC = "created_at_desc"
MODIFIED_AT_ASC = "modified_at_asc"
MODIFIED_AT_DESC = "modified_at_desc"
NAME_ASC = "name_asc"
NAME_DESC = "name_desc"
TYPE_ASC = "type_asc"
TYPE_DESC = "type_desc"

def __str__(self) -> str:
return str(self.value)


@dataclass
class BrmServerInfo:
ip: str
Expand Down Expand Up @@ -269,10 +283,32 @@ class SearchResourcesRequest:
Filter resources modified before this timestamp.
"""

page_token: Optional[str] = None
"""
Leave empty or omit to fetch the first page.
"""

page_size: Optional[int] = 0
"""
Number of resources to retrieve per page.
"""

order_by: Optional[SearchResourcesRequestOrderBy] = (
SearchResourcesRequestOrderBy.CREATED_AT_ASC
)
"""
Sort order in the response.
"""


@dataclass
class SearchResourcesResponse:
resources: list[Resource]
"""
Top resources found.
"""

next_page_token: str
"""
If this string is empty, it means there are no more pages available.
"""
2 changes: 2 additions & 0 deletions scaleway/scaleway/search/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .types import ObsDatasourceInfoDataType
from .types import ObsExporterInfoDestinationType
from .types import ResourceType
from .types import SearchResourcesRequestOrderBy
from .types import BrmServerInfo
from .types import ObsDatasourceInfo
from .types import ObsExporterInfo
Expand All @@ -21,6 +22,7 @@
"ObsDatasourceInfoDataType",
"ObsExporterInfoDestinationType",
"ResourceType",
"SearchResourcesRequestOrderBy",
"BrmServerInfo",
"ObsDatasourceInfo",
"ObsExporterInfo",
Expand Down
10 changes: 10 additions & 0 deletions scaleway/scaleway/search/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .types import (
Locality,
ResourceType,
SearchResourcesRequestOrderBy,
SearchResourcesResponse,
)
from .marshalling import (
Expand All @@ -30,6 +31,9 @@ def search_resources(
created_before: Optional[datetime] = None,
modified_after: Optional[datetime] = None,
modified_before: Optional[datetime] = None,
page_token: Optional[str] = None,
page_size: Optional[int] = None,
order_by: Optional[SearchResourcesRequestOrderBy] = None,
) -> SearchResourcesResponse:
"""
Search API.
Expand All @@ -42,6 +46,9 @@ def search_resources(
:param created_before: Filter resources created before this timestamp.
:param modified_after: Filter resources modified after this timestamp.
:param modified_before: Filter resources modified before this timestamp.
:param page_token: Leave empty or omit to fetch the first page.
:param page_size: Number of resources to retrieve per page.
:param order_by: Sort order in the response.
:return: :class:`SearchResourcesResponse <SearchResourcesResponse>`

Usage:
Expand All @@ -61,8 +68,11 @@ def search_resources(
"localities": localities,
"modified_after": modified_after,
"modified_before": modified_before,
"order_by": order_by,
"organization_id": organization_id
or self.client.default_organization_id,
"page_size": page_size or self.client.default_page_size,
"page_token": page_token,
"project_ids": project_ids,
"query": query,
"types": types,
Expand Down
6 changes: 6 additions & 0 deletions scaleway/scaleway/search/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,10 @@ def unmarshal_SearchResourcesResponse(data: Any) -> SearchResourcesResponse:
else:
args["resources"] = []

field = data.get("next_page_token", None)
if field is not None:
args["next_page_token"] = field
else:
args["next_page_token"] = None

return SearchResourcesResponse(**args)
36 changes: 36 additions & 0 deletions scaleway/scaleway/search/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ def __str__(self) -> str:
return str(self.value)


class SearchResourcesRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
CREATED_AT_ASC = "created_at_asc"
CREATED_AT_DESC = "created_at_desc"
MODIFIED_AT_ASC = "modified_at_asc"
MODIFIED_AT_DESC = "modified_at_desc"
NAME_ASC = "name_asc"
NAME_DESC = "name_desc"
TYPE_ASC = "type_asc"
TYPE_DESC = "type_desc"

def __str__(self) -> str:
return str(self.value)


@dataclass
class BrmServerInfo:
ip: str
Expand Down Expand Up @@ -269,10 +283,32 @@ class SearchResourcesRequest:
Filter resources modified before this timestamp.
"""

page_token: Optional[str] = None
"""
Leave empty or omit to fetch the first page.
"""

page_size: Optional[int] = 0
"""
Number of resources to retrieve per page.
"""

order_by: Optional[SearchResourcesRequestOrderBy] = (
SearchResourcesRequestOrderBy.CREATED_AT_ASC
)
"""
Sort order in the response.
"""


@dataclass
class SearchResourcesResponse:
resources: list[Resource]
"""
Top resources found.
"""

next_page_token: str
"""
If this string is empty, it means there are no more pages available.
"""
Loading