|
| 1 | +# This file was automatically generated. DO NOT EDIT. |
| 2 | +# If you have any remark or suggestion do not hesitate to open an issue. |
| 3 | + |
| 4 | +from datetime import datetime |
| 5 | +from typing import Optional |
| 6 | + |
| 7 | +from scaleway_core.api import API |
| 8 | +from scaleway_core.bridge import ( |
| 9 | + Region, |
| 10 | +) |
| 11 | +from scaleway_core.utils import ( |
| 12 | + validate_path_param, |
| 13 | +) |
| 14 | +from .types import ( |
| 15 | + ListEventsRequestOrderBy, |
| 16 | + ResourceType, |
| 17 | + ListEventsResponse, |
| 18 | + ListProductsResponse, |
| 19 | +) |
| 20 | +from .marshalling import ( |
| 21 | + unmarshal_ListEventsResponse, |
| 22 | + unmarshal_ListProductsResponse, |
| 23 | +) |
| 24 | + |
| 25 | + |
| 26 | +class AuditTrailV1Alpha1API(API): |
| 27 | + """ |
| 28 | + This API allows you to ensure accountability and security by recording events and changes performed within your Scaleway Organization. |
| 29 | + """ |
| 30 | + |
| 31 | + async def list_events( |
| 32 | + self, |
| 33 | + *, |
| 34 | + region: Optional[Region] = None, |
| 35 | + project_id: Optional[str] = None, |
| 36 | + organization_id: Optional[str] = None, |
| 37 | + resource_type: Optional[ResourceType] = None, |
| 38 | + method_name: Optional[str] = None, |
| 39 | + status: Optional[int] = None, |
| 40 | + recorded_after: Optional[datetime] = None, |
| 41 | + recorded_before: Optional[datetime] = None, |
| 42 | + order_by: Optional[ListEventsRequestOrderBy] = None, |
| 43 | + page_size: Optional[int] = None, |
| 44 | + page_token: Optional[str] = None, |
| 45 | + product_name: Optional[str] = None, |
| 46 | + ) -> ListEventsResponse: |
| 47 | + """ |
| 48 | + List events. |
| 49 | + Retrieve the list of Audit Trail events for a Scaleway Organization and/or Project. You must specify the `organization_id` and optionally, the `project_id`. |
| 50 | + :param region: Region to target. If none is passed will use default region from the config. |
| 51 | + :param project_id: (Optional) ID of the Project containing the Audit Trail events. |
| 52 | + :param organization_id: ID of the Organization containing the Audit Trail events. |
| 53 | + :param resource_type: (Optional) Returns a paginated list of Scaleway resources' features. |
| 54 | + :param method_name: (Optional) Name of the method or the API call performed. |
| 55 | + :param status: (Optional) HTTP status code of the request. Returns either `200` if the request was successful or `403` if the permission was denied. |
| 56 | + :param recorded_after: (Optional) The `recorded_after` parameter defines the earliest timestamp from which Audit Trail events are retrieved. Returns `one hour ago` by default. |
| 57 | + :param recorded_before: (Optional) The `recorded_before` parameter defines the latest timestamp up to which Audit Trail events are retrieved. Returns `now` by default. |
| 58 | + :param order_by: |
| 59 | + :param page_size: |
| 60 | + :param page_token: |
| 61 | + :param product_name: (Optional) Name of the Scaleway resource in a hyphenated format. |
| 62 | + :return: :class:`ListEventsResponse <ListEventsResponse>` |
| 63 | +
|
| 64 | + Usage: |
| 65 | + :: |
| 66 | +
|
| 67 | + result = await api.list_events() |
| 68 | + """ |
| 69 | + |
| 70 | + param_region = validate_path_param( |
| 71 | + "region", region or self.client.default_region |
| 72 | + ) |
| 73 | + |
| 74 | + res = self._request( |
| 75 | + "GET", |
| 76 | + f"/audit-trail/v1alpha1/regions/{param_region}/events", |
| 77 | + params={ |
| 78 | + "method_name": method_name, |
| 79 | + "order_by": order_by, |
| 80 | + "organization_id": organization_id |
| 81 | + or self.client.default_organization_id, |
| 82 | + "page_size": page_size or self.client.default_page_size, |
| 83 | + "page_token": page_token, |
| 84 | + "product_name": product_name, |
| 85 | + "project_id": project_id or self.client.default_project_id, |
| 86 | + "recorded_after": recorded_after, |
| 87 | + "recorded_before": recorded_before, |
| 88 | + "resource_type": resource_type, |
| 89 | + "status": status, |
| 90 | + }, |
| 91 | + ) |
| 92 | + |
| 93 | + self._throw_on_error(res) |
| 94 | + return unmarshal_ListEventsResponse(res.json()) |
| 95 | + |
| 96 | + async def list_products( |
| 97 | + self, |
| 98 | + *, |
| 99 | + region: Optional[Region] = None, |
| 100 | + ) -> ListProductsResponse: |
| 101 | + """ |
| 102 | + Retrieve the list of Scaleway resources for which you have Audit Trail events. |
| 103 | + :param region: Region to target. If none is passed will use default region from the config. |
| 104 | + :return: :class:`ListProductsResponse <ListProductsResponse>` |
| 105 | +
|
| 106 | + Usage: |
| 107 | + :: |
| 108 | +
|
| 109 | + result = await api.list_products() |
| 110 | + """ |
| 111 | + |
| 112 | + param_region = validate_path_param( |
| 113 | + "region", region or self.client.default_region |
| 114 | + ) |
| 115 | + |
| 116 | + res = self._request( |
| 117 | + "GET", |
| 118 | + f"/audit-trail/v1alpha1/regions/{param_region}/products", |
| 119 | + ) |
| 120 | + |
| 121 | + self._throw_on_error(res) |
| 122 | + return unmarshal_ListProductsResponse(res.json()) |
0 commit comments