From 300f4fe571f5af0fed08a413ff143d8cfd3b57d1 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Mon, 4 Nov 2024 17:26:09 +0000 Subject: [PATCH] feat: update generated APIs --- .../scaleway_async/cockpit/v1/__init__.py | 6 ++ .../scaleway_async/cockpit/v1/api.py | 44 +++++++++++++ .../scaleway_async/cockpit/v1/marshalling.py | 64 +++++++++++++++++++ .../scaleway_async/cockpit/v1/types.py | 59 ++++++++++++++++- scaleway/scaleway/cockpit/v1/__init__.py | 6 ++ scaleway/scaleway/cockpit/v1/api.py | 44 +++++++++++++ scaleway/scaleway/cockpit/v1/marshalling.py | 64 +++++++++++++++++++ scaleway/scaleway/cockpit/v1/types.py | 59 ++++++++++++++++- 8 files changed, 344 insertions(+), 2 deletions(-) diff --git a/scaleway-async/scaleway_async/cockpit/v1/__init__.py b/scaleway-async/scaleway_async/cockpit/v1/__init__.py index b0f14ef96..833733ae8 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/__init__.py +++ b/scaleway-async/scaleway_async/cockpit/v1/__init__.py @@ -12,6 +12,7 @@ from .types import TokenScope from .types import UsageUnit from .types import ContactPointEmail +from .types import GetConfigResponseRetention from .types import ContactPoint from .types import DataSource from .types import GrafanaProductDashboard @@ -21,6 +22,7 @@ from .types import Token from .types import Usage from .types import AlertManager +from .types import GetConfigResponse from .types import GlobalApiCreateGrafanaUserRequest from .types import GlobalApiDeleteGrafanaUserRequest from .types import GlobalApiGetCurrentPlanRequest @@ -51,6 +53,7 @@ from .types import RegionalApiEnableAlertManagerRequest from .types import RegionalApiEnableManagedAlertsRequest from .types import RegionalApiGetAlertManagerRequest +from .types import RegionalApiGetConfigRequest from .types import RegionalApiGetDataSourceRequest from .types import RegionalApiGetTokenRequest from .types import RegionalApiGetUsageOverviewRequest @@ -77,6 +80,7 @@ "TokenScope", "UsageUnit", "ContactPointEmail", + "GetConfigResponseRetention", "ContactPoint", "DataSource", "GrafanaProductDashboard", @@ -86,6 +90,7 @@ "Token", "Usage", "AlertManager", + "GetConfigResponse", "GlobalApiCreateGrafanaUserRequest", "GlobalApiDeleteGrafanaUserRequest", "GlobalApiGetCurrentPlanRequest", @@ -116,6 +121,7 @@ "RegionalApiEnableAlertManagerRequest", "RegionalApiEnableManagedAlertsRequest", "RegionalApiGetAlertManagerRequest", + "RegionalApiGetConfigRequest", "RegionalApiGetDataSourceRequest", "RegionalApiGetTokenRequest", "RegionalApiGetUsageOverviewRequest", diff --git a/scaleway-async/scaleway_async/cockpit/v1/api.py b/scaleway-async/scaleway_async/cockpit/v1/api.py index c3db4eec8..183601987 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/api.py +++ b/scaleway-async/scaleway_async/cockpit/v1/api.py @@ -27,6 +27,7 @@ ContactPoint, ContactPointEmail, DataSource, + GetConfigResponse, GlobalApiCreateGrafanaUserRequest, GlobalApiResetGrafanaUserPasswordRequest, GlobalApiSelectPlanRequest, @@ -63,6 +64,7 @@ unmarshal_Plan, unmarshal_Token, unmarshal_AlertManager, + unmarshal_GetConfigResponse, unmarshal_Grafana, unmarshal_ListContactPointsResponse, unmarshal_ListDataSourcesResponse, @@ -451,10 +453,12 @@ async def list_plans( """ List plan types. Retrieve a list of available pricing plan types. + Deprecated, retention is now managed at the data source level. :param page: Page number. :param page_size: Page size. :param order_by: :return: :class:`ListPlansResponse ` + :deprecated Usage: :: @@ -485,10 +489,12 @@ async def list_plans_all( """ List plan types. Retrieve a list of available pricing plan types. + Deprecated, retention is now managed at the data source level. :param page: Page number. :param page_size: Page size. :param order_by: :return: :class:`List[Plan] ` + :deprecated Usage: :: @@ -516,9 +522,11 @@ async def select_plan( """ Apply a pricing plan. Apply a pricing plan on a given Project. You must specify the ID of the pricing plan type. Note that you will be billed for the plan you apply. + Deprecated, retention is now managed at the data source level. :param project_id: ID of the Project. :param plan_name: Name of the pricing plan. :return: :class:`Plan ` + :deprecated Usage: :: @@ -549,8 +557,10 @@ async def get_current_plan( """ Get current plan. Retrieve a pricing plan for the given Project, specified by the ID of the Project. + Deprecated, retention is now managed at the data source level. :param project_id: ID of the Project. :return: :class:`Plan ` + :deprecated Usage: :: @@ -575,6 +585,34 @@ class CockpitV1RegionalAPI(API): The Cockpit Regional API allows you to create data sources and tokens to store and query data types such as metrics, logs, and traces. You can also push your data into Cockpit, and send alerts to your contact points when your resources may require your attention, using the regional Alert manager. """ + async def get_config( + self, + *, + region: Optional[Region] = None, + ) -> GetConfigResponse: + """ + Get the Cockpit configuration. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`GetConfigResponse ` + + Usage: + :: + + result = await api.get_config() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/cockpit/v1/regions/{param_region}/config", + ) + + self._throw_on_error(res) + return unmarshal_GetConfigResponse(res.json()) + async def create_data_source( self, *, @@ -582,6 +620,7 @@ async def create_data_source( region: Optional[Region] = None, project_id: Optional[str] = None, type_: Optional[DataSourceType] = None, + retention_days: Optional[int] = None, ) -> DataSource: """ Create a data source. @@ -594,6 +633,7 @@ async def create_data_source( :param region: Region to target. If none is passed will use default region from the config. :param project_id: ID of the Project the data source belongs to. :param type_: Data source type. + :param retention_days: Default values are 30 days for metrics, 7 days for logs and traces. :return: :class:`DataSource ` Usage: @@ -617,6 +657,7 @@ async def create_data_source( region=region, project_id=project_id, type_=type_, + retention_days=retention_days, ), self.client, ), @@ -792,6 +833,7 @@ async def update_data_source( data_source_id: str, region: Optional[Region] = None, name: Optional[str] = None, + retention_days: Optional[int] = None, ) -> DataSource: """ Update a data source. @@ -799,6 +841,7 @@ async def update_data_source( :param data_source_id: ID of the data source to update. :param region: Region to target. If none is passed will use default region from the config. :param name: Updated name of the data source. + :param retention_days: BETA - Duration for which the data will be retained in the data source. :return: :class:`DataSource ` Usage: @@ -822,6 +865,7 @@ async def update_data_source( data_source_id=data_source_id, region=region, name=name, + retention_days=retention_days, ), self.client, ), diff --git a/scaleway-async/scaleway_async/cockpit/v1/marshalling.py b/scaleway-async/scaleway_async/cockpit/v1/marshalling.py index 44b08a97c..a21ce6e66 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/marshalling.py +++ b/scaleway-async/scaleway_async/cockpit/v1/marshalling.py @@ -19,6 +19,8 @@ Plan, Token, AlertManager, + GetConfigResponseRetention, + GetConfigResponse, Grafana, ListContactPointsResponse, ListDataSourcesResponse, @@ -119,6 +121,10 @@ def unmarshal_DataSource(data: Any) -> DataSource: if field is not None: args["synchronized_with_grafana"] = field + field = data.get("retention_days", None) + if field is not None: + args["retention_days"] = field + field = data.get("region", None) if field is not None: args["region"] = field @@ -325,6 +331,58 @@ def unmarshal_AlertManager(data: Any) -> AlertManager: return AlertManager(**args) +def unmarshal_GetConfigResponseRetention(data: Any) -> GetConfigResponseRetention: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetConfigResponseRetention' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("min_days", None) + if field is not None: + args["min_days"] = field + + field = data.get("max_days", None) + if field is not None: + args["max_days"] = field + + field = data.get("default_days", None) + if field is not None: + args["default_days"] = field + + return GetConfigResponseRetention(**args) + + +def unmarshal_GetConfigResponse(data: Any) -> GetConfigResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetConfigResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("metrics_retention", None) + if field is not None: + args["metrics_retention"] = unmarshal_GetConfigResponseRetention(field) + else: + args["metrics_retention"] = None + + field = data.get("logs_retention", None) + if field is not None: + args["logs_retention"] = unmarshal_GetConfigResponseRetention(field) + else: + args["logs_retention"] = None + + field = data.get("traces_retention", None) + if field is not None: + args["traces_retention"] = unmarshal_GetConfigResponseRetention(field) + else: + args["traces_retention"] = None + + return GetConfigResponse(**args) + + def unmarshal_Grafana(data: Any) -> Grafana: if not isinstance(data, dict): raise TypeError( @@ -721,6 +779,9 @@ def marshal_RegionalApiCreateDataSourceRequest( if request.type_ is not None: output["type"] = str(request.type_) + if request.retention_days is not None: + output["retention_days"] = request.retention_days + return output @@ -830,4 +891,7 @@ def marshal_RegionalApiUpdateDataSourceRequest( if request.name is not None: output["name"] = request.name + if request.retention_days is not None: + output["retention_days"] = request.retention_days + return output diff --git a/scaleway-async/scaleway_async/cockpit/v1/types.py b/scaleway-async/scaleway_async/cockpit/v1/types.py index afa90b87e..6dff66189 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/types.py +++ b/scaleway-async/scaleway_async/cockpit/v1/types.py @@ -29,7 +29,6 @@ class DataSourceType(str, Enum, metaclass=StrEnumMeta): METRICS = "metrics" LOGS = "logs" TRACES = "traces" - ALERTS = "alerts" def __str__(self) -> str: return str(self.value) @@ -134,6 +133,15 @@ class ContactPointEmail: to: str +@dataclass +class GetConfigResponseRetention: + min_days: int + + max_days: int + + default_days: int + + @dataclass class ContactPoint: """ @@ -189,6 +197,11 @@ class DataSource: Indicates whether the data source is synchronized with Grafana. """ + retention_days: int + """ + BETA - Duration for which the data will be retained in the data source. + """ + region: Region """ Region of the data source. @@ -445,6 +458,28 @@ class AlertManager: """ +@dataclass +class GetConfigResponse: + """ + Cockpit configuration. + """ + + metrics_retention: Optional[GetConfigResponseRetention] + """ + Metrics retention configuration. + """ + + logs_retention: Optional[GetConfigResponseRetention] + """ + Logs retention configuration. + """ + + traces_retention: Optional[GetConfigResponseRetention] + """ + Traces retention configuration. + """ + + @dataclass class GlobalApiCreateGrafanaUserRequest: """ @@ -830,6 +865,11 @@ class RegionalApiCreateDataSourceRequest: Data source type. """ + retention_days: Optional[int] + """ + Default values are 30 days for metrics, 7 days for logs and traces. + """ + @dataclass class RegionalApiCreateTokenRequest: @@ -996,6 +1036,18 @@ class RegionalApiGetAlertManagerRequest: """ +@dataclass +class RegionalApiGetConfigRequest: + """ + Get Cockpit configuration. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class RegionalApiGetDataSourceRequest: """ @@ -1218,6 +1270,11 @@ class RegionalApiUpdateDataSourceRequest: Updated name of the data source. """ + retention_days: Optional[int] + """ + BETA - Duration for which the data will be retained in the data source. + """ + @dataclass class UsageOverview: diff --git a/scaleway/scaleway/cockpit/v1/__init__.py b/scaleway/scaleway/cockpit/v1/__init__.py index b0f14ef96..833733ae8 100644 --- a/scaleway/scaleway/cockpit/v1/__init__.py +++ b/scaleway/scaleway/cockpit/v1/__init__.py @@ -12,6 +12,7 @@ from .types import TokenScope from .types import UsageUnit from .types import ContactPointEmail +from .types import GetConfigResponseRetention from .types import ContactPoint from .types import DataSource from .types import GrafanaProductDashboard @@ -21,6 +22,7 @@ from .types import Token from .types import Usage from .types import AlertManager +from .types import GetConfigResponse from .types import GlobalApiCreateGrafanaUserRequest from .types import GlobalApiDeleteGrafanaUserRequest from .types import GlobalApiGetCurrentPlanRequest @@ -51,6 +53,7 @@ from .types import RegionalApiEnableAlertManagerRequest from .types import RegionalApiEnableManagedAlertsRequest from .types import RegionalApiGetAlertManagerRequest +from .types import RegionalApiGetConfigRequest from .types import RegionalApiGetDataSourceRequest from .types import RegionalApiGetTokenRequest from .types import RegionalApiGetUsageOverviewRequest @@ -77,6 +80,7 @@ "TokenScope", "UsageUnit", "ContactPointEmail", + "GetConfigResponseRetention", "ContactPoint", "DataSource", "GrafanaProductDashboard", @@ -86,6 +90,7 @@ "Token", "Usage", "AlertManager", + "GetConfigResponse", "GlobalApiCreateGrafanaUserRequest", "GlobalApiDeleteGrafanaUserRequest", "GlobalApiGetCurrentPlanRequest", @@ -116,6 +121,7 @@ "RegionalApiEnableAlertManagerRequest", "RegionalApiEnableManagedAlertsRequest", "RegionalApiGetAlertManagerRequest", + "RegionalApiGetConfigRequest", "RegionalApiGetDataSourceRequest", "RegionalApiGetTokenRequest", "RegionalApiGetUsageOverviewRequest", diff --git a/scaleway/scaleway/cockpit/v1/api.py b/scaleway/scaleway/cockpit/v1/api.py index c866e22f3..af201fc28 100644 --- a/scaleway/scaleway/cockpit/v1/api.py +++ b/scaleway/scaleway/cockpit/v1/api.py @@ -27,6 +27,7 @@ ContactPoint, ContactPointEmail, DataSource, + GetConfigResponse, GlobalApiCreateGrafanaUserRequest, GlobalApiResetGrafanaUserPasswordRequest, GlobalApiSelectPlanRequest, @@ -63,6 +64,7 @@ unmarshal_Plan, unmarshal_Token, unmarshal_AlertManager, + unmarshal_GetConfigResponse, unmarshal_Grafana, unmarshal_ListContactPointsResponse, unmarshal_ListDataSourcesResponse, @@ -451,10 +453,12 @@ def list_plans( """ List plan types. Retrieve a list of available pricing plan types. + Deprecated, retention is now managed at the data source level. :param page: Page number. :param page_size: Page size. :param order_by: :return: :class:`ListPlansResponse ` + :deprecated Usage: :: @@ -485,10 +489,12 @@ def list_plans_all( """ List plan types. Retrieve a list of available pricing plan types. + Deprecated, retention is now managed at the data source level. :param page: Page number. :param page_size: Page size. :param order_by: :return: :class:`List[Plan] ` + :deprecated Usage: :: @@ -516,9 +522,11 @@ def select_plan( """ Apply a pricing plan. Apply a pricing plan on a given Project. You must specify the ID of the pricing plan type. Note that you will be billed for the plan you apply. + Deprecated, retention is now managed at the data source level. :param project_id: ID of the Project. :param plan_name: Name of the pricing plan. :return: :class:`Plan ` + :deprecated Usage: :: @@ -549,8 +557,10 @@ def get_current_plan( """ Get current plan. Retrieve a pricing plan for the given Project, specified by the ID of the Project. + Deprecated, retention is now managed at the data source level. :param project_id: ID of the Project. :return: :class:`Plan ` + :deprecated Usage: :: @@ -575,6 +585,34 @@ class CockpitV1RegionalAPI(API): The Cockpit Regional API allows you to create data sources and tokens to store and query data types such as metrics, logs, and traces. You can also push your data into Cockpit, and send alerts to your contact points when your resources may require your attention, using the regional Alert manager. """ + def get_config( + self, + *, + region: Optional[Region] = None, + ) -> GetConfigResponse: + """ + Get the Cockpit configuration. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`GetConfigResponse ` + + Usage: + :: + + result = api.get_config() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/cockpit/v1/regions/{param_region}/config", + ) + + self._throw_on_error(res) + return unmarshal_GetConfigResponse(res.json()) + def create_data_source( self, *, @@ -582,6 +620,7 @@ def create_data_source( region: Optional[Region] = None, project_id: Optional[str] = None, type_: Optional[DataSourceType] = None, + retention_days: Optional[int] = None, ) -> DataSource: """ Create a data source. @@ -594,6 +633,7 @@ def create_data_source( :param region: Region to target. If none is passed will use default region from the config. :param project_id: ID of the Project the data source belongs to. :param type_: Data source type. + :param retention_days: Default values are 30 days for metrics, 7 days for logs and traces. :return: :class:`DataSource ` Usage: @@ -617,6 +657,7 @@ def create_data_source( region=region, project_id=project_id, type_=type_, + retention_days=retention_days, ), self.client, ), @@ -792,6 +833,7 @@ def update_data_source( data_source_id: str, region: Optional[Region] = None, name: Optional[str] = None, + retention_days: Optional[int] = None, ) -> DataSource: """ Update a data source. @@ -799,6 +841,7 @@ def update_data_source( :param data_source_id: ID of the data source to update. :param region: Region to target. If none is passed will use default region from the config. :param name: Updated name of the data source. + :param retention_days: BETA - Duration for which the data will be retained in the data source. :return: :class:`DataSource ` Usage: @@ -822,6 +865,7 @@ def update_data_source( data_source_id=data_source_id, region=region, name=name, + retention_days=retention_days, ), self.client, ), diff --git a/scaleway/scaleway/cockpit/v1/marshalling.py b/scaleway/scaleway/cockpit/v1/marshalling.py index 44b08a97c..a21ce6e66 100644 --- a/scaleway/scaleway/cockpit/v1/marshalling.py +++ b/scaleway/scaleway/cockpit/v1/marshalling.py @@ -19,6 +19,8 @@ Plan, Token, AlertManager, + GetConfigResponseRetention, + GetConfigResponse, Grafana, ListContactPointsResponse, ListDataSourcesResponse, @@ -119,6 +121,10 @@ def unmarshal_DataSource(data: Any) -> DataSource: if field is not None: args["synchronized_with_grafana"] = field + field = data.get("retention_days", None) + if field is not None: + args["retention_days"] = field + field = data.get("region", None) if field is not None: args["region"] = field @@ -325,6 +331,58 @@ def unmarshal_AlertManager(data: Any) -> AlertManager: return AlertManager(**args) +def unmarshal_GetConfigResponseRetention(data: Any) -> GetConfigResponseRetention: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetConfigResponseRetention' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("min_days", None) + if field is not None: + args["min_days"] = field + + field = data.get("max_days", None) + if field is not None: + args["max_days"] = field + + field = data.get("default_days", None) + if field is not None: + args["default_days"] = field + + return GetConfigResponseRetention(**args) + + +def unmarshal_GetConfigResponse(data: Any) -> GetConfigResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetConfigResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("metrics_retention", None) + if field is not None: + args["metrics_retention"] = unmarshal_GetConfigResponseRetention(field) + else: + args["metrics_retention"] = None + + field = data.get("logs_retention", None) + if field is not None: + args["logs_retention"] = unmarshal_GetConfigResponseRetention(field) + else: + args["logs_retention"] = None + + field = data.get("traces_retention", None) + if field is not None: + args["traces_retention"] = unmarshal_GetConfigResponseRetention(field) + else: + args["traces_retention"] = None + + return GetConfigResponse(**args) + + def unmarshal_Grafana(data: Any) -> Grafana: if not isinstance(data, dict): raise TypeError( @@ -721,6 +779,9 @@ def marshal_RegionalApiCreateDataSourceRequest( if request.type_ is not None: output["type"] = str(request.type_) + if request.retention_days is not None: + output["retention_days"] = request.retention_days + return output @@ -830,4 +891,7 @@ def marshal_RegionalApiUpdateDataSourceRequest( if request.name is not None: output["name"] = request.name + if request.retention_days is not None: + output["retention_days"] = request.retention_days + return output diff --git a/scaleway/scaleway/cockpit/v1/types.py b/scaleway/scaleway/cockpit/v1/types.py index afa90b87e..6dff66189 100644 --- a/scaleway/scaleway/cockpit/v1/types.py +++ b/scaleway/scaleway/cockpit/v1/types.py @@ -29,7 +29,6 @@ class DataSourceType(str, Enum, metaclass=StrEnumMeta): METRICS = "metrics" LOGS = "logs" TRACES = "traces" - ALERTS = "alerts" def __str__(self) -> str: return str(self.value) @@ -134,6 +133,15 @@ class ContactPointEmail: to: str +@dataclass +class GetConfigResponseRetention: + min_days: int + + max_days: int + + default_days: int + + @dataclass class ContactPoint: """ @@ -189,6 +197,11 @@ class DataSource: Indicates whether the data source is synchronized with Grafana. """ + retention_days: int + """ + BETA - Duration for which the data will be retained in the data source. + """ + region: Region """ Region of the data source. @@ -445,6 +458,28 @@ class AlertManager: """ +@dataclass +class GetConfigResponse: + """ + Cockpit configuration. + """ + + metrics_retention: Optional[GetConfigResponseRetention] + """ + Metrics retention configuration. + """ + + logs_retention: Optional[GetConfigResponseRetention] + """ + Logs retention configuration. + """ + + traces_retention: Optional[GetConfigResponseRetention] + """ + Traces retention configuration. + """ + + @dataclass class GlobalApiCreateGrafanaUserRequest: """ @@ -830,6 +865,11 @@ class RegionalApiCreateDataSourceRequest: Data source type. """ + retention_days: Optional[int] + """ + Default values are 30 days for metrics, 7 days for logs and traces. + """ + @dataclass class RegionalApiCreateTokenRequest: @@ -996,6 +1036,18 @@ class RegionalApiGetAlertManagerRequest: """ +@dataclass +class RegionalApiGetConfigRequest: + """ + Get Cockpit configuration. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class RegionalApiGetDataSourceRequest: """ @@ -1218,6 +1270,11 @@ class RegionalApiUpdateDataSourceRequest: Updated name of the data source. """ + retention_days: Optional[int] + """ + BETA - Duration for which the data will be retained in the data source. + """ + @dataclass class UsageOverview: