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
14 changes: 10 additions & 4 deletions scaleway-async/scaleway_async/audit_trail/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .types import ListAuthenticationEventsRequestOrderBy
from .types import ListCombinedEventsRequestOrderBy
from .types import ListEventsRequestOrderBy
from .types import ListExportJobsRequestOrderBy
from .types import ResourceType
from .types import SystemEventKind
from .types import AccountOrganizationInfo
Expand Down Expand Up @@ -37,19 +38,21 @@
from .types import AuthenticationEvent
from .types import Event
from .types import SystemEvent
from .types import ProductService
from .types import ExportJobS3
from .types import ProductService
from .types import ListCombinedEventsResponseCombinedEvent
from .types import ExportJob
from .types import Product
from .types import CreateExportJobRequest
from .types import DeleteExportJobRequest
from .types import ExportJob
from .types import ListAuthenticationEventsRequest
from .types import ListAuthenticationEventsResponse
from .types import ListCombinedEventsRequest
from .types import ListCombinedEventsResponse
from .types import ListEventsRequest
from .types import ListEventsResponse
from .types import ListExportJobsRequest
from .types import ListExportJobsResponse
from .types import ListProductsRequest
from .types import ListProductsResponse
from .api import AuditTrailV1Alpha1API
Expand All @@ -63,6 +66,7 @@
"ListAuthenticationEventsRequestOrderBy",
"ListCombinedEventsRequestOrderBy",
"ListEventsRequestOrderBy",
"ListExportJobsRequestOrderBy",
"ResourceType",
"SystemEventKind",
"AccountOrganizationInfo",
Expand Down Expand Up @@ -92,19 +96,21 @@
"AuthenticationEvent",
"Event",
"SystemEvent",
"ProductService",
"ExportJobS3",
"ProductService",
"ListCombinedEventsResponseCombinedEvent",
"ExportJob",
"Product",
"CreateExportJobRequest",
"DeleteExportJobRequest",
"ExportJob",
"ListAuthenticationEventsRequest",
"ListAuthenticationEventsResponse",
"ListCombinedEventsRequest",
"ListCombinedEventsResponse",
"ListEventsRequest",
"ListEventsResponse",
"ListExportJobsRequest",
"ListExportJobsResponse",
"ListProductsRequest",
"ListProductsResponse",
"AuditTrailV1Alpha1API",
Expand Down
94 changes: 94 additions & 0 deletions scaleway-async/scaleway_async/audit_trail/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,29 @@
)
from scaleway_core.utils import (
validate_path_param,
fetch_all_pages_async,
)
from .types import (
ListAuthenticationEventsRequestOrderBy,
ListCombinedEventsRequestOrderBy,
ListEventsRequestOrderBy,
ListExportJobsRequestOrderBy,
ResourceType,
CreateExportJobRequest,
ExportJob,
ExportJobS3,
ListAuthenticationEventsResponse,
ListCombinedEventsResponse,
ListEventsResponse,
ListExportJobsResponse,
ListProductsResponse,
)
from .marshalling import (
unmarshal_ExportJob,
unmarshal_ListAuthenticationEventsResponse,
unmarshal_ListCombinedEventsResponse,
unmarshal_ListEventsResponse,
unmarshal_ListExportJobsResponse,
unmarshal_ListProductsResponse,
marshal_CreateExportJobRequest,
)
Expand Down Expand Up @@ -335,3 +339,93 @@ async def delete_export_job(
)

self._throw_on_error(res)

async def list_export_jobs(
self,
*,
region: Optional[ScwRegion] = None,
organization_id: Optional[str] = None,
name: Optional[str] = None,
tags: Optional[dict[str, str]] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
order_by: Optional[ListExportJobsRequestOrderBy] = None,
) -> ListExportJobsResponse:
"""
:param region: Region to target. If none is passed will use default region from the config.
:param organization_id: Filter by Organization ID.
:param name: (Optional) Filter by export name.
:param tags: (Optional) List of tags to filter on.
:param page:
:param page_size:
:param order_by:
:return: :class:`ListExportJobsResponse <ListExportJobsResponse>`

Usage:
::

result = await api.list_export_jobs()
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)

res = self._request(
"GET",
f"/audit-trail/v1alpha1/regions/{param_region}/export-jobs",
params={
"name": name,
"order_by": order_by,
"organization_id": organization_id
or self.client.default_organization_id,
"page": page,
"page_size": page_size or self.client.default_page_size,
"tags": tags,
},
)

self._throw_on_error(res)
return unmarshal_ListExportJobsResponse(res.json())

async def list_export_jobs_all(
self,
*,
region: Optional[ScwRegion] = None,
organization_id: Optional[str] = None,
name: Optional[str] = None,
tags: Optional[dict[str, str]] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
order_by: Optional[ListExportJobsRequestOrderBy] = None,
) -> list[ExportJob]:
"""
:param region: Region to target. If none is passed will use default region from the config.
:param organization_id: Filter by Organization ID.
:param name: (Optional) Filter by export name.
:param tags: (Optional) List of tags to filter on.
:param page:
:param page_size:
:param order_by:
:return: :class:`list[ExportJob] <list[ExportJob]>`

Usage:
::

result = await api.list_export_jobs_all()
"""

return await fetch_all_pages_async(
type=ListExportJobsResponse,
key="export_jobs",
fetcher=self.list_export_jobs,
args={
"region": region,
"organization_id": organization_id,
"name": name,
"tags": tags,
"page": page,
"page_size": page_size,
"order_by": order_by,
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
ListCombinedEventsResponseCombinedEvent,
ListCombinedEventsResponse,
ListEventsResponse,
ListExportJobsResponse,
ProductService,
Product,
ListProductsResponse,
Expand Down Expand Up @@ -1165,6 +1166,31 @@ def unmarshal_ListEventsResponse(data: Any) -> ListEventsResponse:
return ListEventsResponse(**args)


def unmarshal_ListExportJobsResponse(data: Any) -> ListExportJobsResponse:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'ListExportJobsResponse' failed as data isn't a dictionary."
)

args: dict[str, Any] = {}

field = data.get("export_jobs", None)
if field is not None:
args["export_jobs"] = (
[unmarshal_ExportJob(v) for v in field] if field is not None else None
)
else:
args["export_jobs"] = []

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

return ListExportJobsResponse(**args)


def unmarshal_ProductService(data: Any) -> ProductService:
if not isinstance(data, dict):
raise TypeError(
Expand Down
Loading