diff --git a/scaleway-async/scaleway_async/cockpit/v1/__init__.py b/scaleway-async/scaleway_async/cockpit/v1/__init__.py index 833733ae8..a648fc794 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/__init__.py +++ b/scaleway-async/scaleway_async/cockpit/v1/__init__.py @@ -62,6 +62,7 @@ from .types import RegionalApiListManagedAlertsRequest from .types import RegionalApiListTokensRequest from .types import RegionalApiTriggerTestAlertRequest +from .types import RegionalApiUpdateContactPointRequest from .types import RegionalApiUpdateDataSourceRequest from .types import UsageOverview from .api import CockpitV1GlobalAPI @@ -130,6 +131,7 @@ "RegionalApiListManagedAlertsRequest", "RegionalApiListTokensRequest", "RegionalApiTriggerTestAlertRequest", + "RegionalApiUpdateContactPointRequest", "RegionalApiUpdateDataSourceRequest", "UsageOverview", "CockpitV1GlobalAPI", diff --git a/scaleway-async/scaleway_async/cockpit/v1/api.py b/scaleway-async/scaleway_async/cockpit/v1/api.py index 77957d558..6833fdbf3 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/api.py +++ b/scaleway-async/scaleway_async/cockpit/v1/api.py @@ -52,6 +52,7 @@ RegionalApiEnableAlertManagerRequest, RegionalApiEnableManagedAlertsRequest, RegionalApiTriggerTestAlertRequest, + RegionalApiUpdateContactPointRequest, RegionalApiUpdateDataSourceRequest, Token, UsageOverview, @@ -87,6 +88,7 @@ marshal_RegionalApiEnableAlertManagerRequest, marshal_RegionalApiEnableManagedAlertsRequest, marshal_RegionalApiTriggerTestAlertRequest, + marshal_RegionalApiUpdateContactPointRequest, marshal_RegionalApiUpdateDataSourceRequest, ) @@ -1230,6 +1232,7 @@ async def create_contact_point( region: Optional[ScwRegion] = None, project_id: Optional[str] = None, email: Optional[ContactPointEmail] = None, + receive_resolved_notifications: Optional[bool] = None, ) -> ContactPoint: """ Create a contact point. @@ -1240,6 +1243,7 @@ async def create_contact_point( :param project_id: ID of the Project to create the contact point in. :param email: Email address of the contact point to create. One-Of ('configuration'): at most one of 'email' could be set. + :param receive_resolved_notifications: Send an email notification when an alert is marked as resolved. :return: :class:`ContactPoint ` Usage: @@ -1259,6 +1263,7 @@ async def create_contact_point( RegionalApiCreateContactPointRequest( region=region, project_id=project_id, + receive_resolved_notifications=receive_resolved_notifications, email=email, ), self.client, @@ -1343,6 +1348,49 @@ async def list_contact_points_all( }, ) + async def update_contact_point( + self, + *, + region: Optional[ScwRegion] = None, + project_id: Optional[str] = None, + email: Optional[ContactPointEmail] = None, + receive_resolved_notifications: Optional[bool] = None, + ) -> ContactPoint: + """ + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: ID of the Project containing the contact point to update. + :param email: Email address of the contact point to update. + One-Of ('configuration'): at most one of 'email' could be set. + :param receive_resolved_notifications: Enable or disable notifications when alert is resolved. + :return: :class:`ContactPoint ` + + Usage: + :: + + result = await api.update_contact_point() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "PATCH", + f"/cockpit/v1/regions/{param_region}/alert-manager/contact-points", + body=marshal_RegionalApiUpdateContactPointRequest( + RegionalApiUpdateContactPointRequest( + region=region, + project_id=project_id, + receive_resolved_notifications=receive_resolved_notifications, + email=email, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_ContactPoint(res.json()) + async def delete_contact_point( self, *, diff --git a/scaleway-async/scaleway_async/cockpit/v1/marshalling.py b/scaleway-async/scaleway_async/cockpit/v1/marshalling.py index ab3d480cf..6739977d0 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/marshalling.py +++ b/scaleway-async/scaleway_async/cockpit/v1/marshalling.py @@ -45,6 +45,7 @@ RegionalApiEnableAlertManagerRequest, RegionalApiEnableManagedAlertsRequest, RegionalApiTriggerTestAlertRequest, + RegionalApiUpdateContactPointRequest, RegionalApiUpdateDataSourceRequest, ) @@ -76,6 +77,10 @@ def unmarshal_ContactPoint(data: Any) -> ContactPoint: if field is not None: args["region"] = field + field = data.get("receive_resolved_notifications", None) + if field is not None: + args["receive_resolved_notifications"] = field + field = data.get("email", None) if field is not None: args["email"] = unmarshal_ContactPointEmail(field) @@ -773,6 +778,11 @@ def marshal_RegionalApiCreateContactPointRequest( if request.project_id is not None: output["project_id"] = request.project_id or defaults.default_project_id + if request.receive_resolved_notifications is not None: + output["receive_resolved_notifications"] = ( + request.receive_resolved_notifications + ) + return output @@ -894,6 +904,30 @@ def marshal_RegionalApiTriggerTestAlertRequest( return output +def marshal_RegionalApiUpdateContactPointRequest( + request: RegionalApiUpdateContactPointRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("email", request.email), + ] + ), + ) + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.receive_resolved_notifications is not None: + output["receive_resolved_notifications"] = ( + request.receive_resolved_notifications + ) + + return output + + def marshal_RegionalApiUpdateDataSourceRequest( request: RegionalApiUpdateDataSourceRequest, defaults: ProfileDefaults, diff --git a/scaleway-async/scaleway_async/cockpit/v1/types.py b/scaleway-async/scaleway_async/cockpit/v1/types.py index c49ae6ddf..d7363a866 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/types.py +++ b/scaleway-async/scaleway_async/cockpit/v1/types.py @@ -151,7 +151,12 @@ class ContactPoint: region: ScwRegion """ - Region to target. If none is passed will use default region from the config. + Region. + """ + + receive_resolved_notifications: bool + """ + Send an email notification when an alert is marked as resolved. """ email: Optional[ContactPointEmail] @@ -847,6 +852,11 @@ class RegionalApiCreateContactPointRequest: ID of the Project to create the contact point in. """ + receive_resolved_notifications: Optional[bool] + """ + Send an email notification when an alert is marked as resolved. + """ + email: Optional[ContactPointEmail] @@ -1260,6 +1270,30 @@ class RegionalApiTriggerTestAlertRequest: """ +@dataclass +class RegionalApiUpdateContactPointRequest: + """ + Update a contact point. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + ID of the Project containing the contact point to update. + """ + + receive_resolved_notifications: Optional[bool] + """ + Enable or disable notifications when alert is resolved. + """ + + email: Optional[ContactPointEmail] + + @dataclass class RegionalApiUpdateDataSourceRequest: """ diff --git a/scaleway/scaleway/cockpit/v1/__init__.py b/scaleway/scaleway/cockpit/v1/__init__.py index 833733ae8..a648fc794 100644 --- a/scaleway/scaleway/cockpit/v1/__init__.py +++ b/scaleway/scaleway/cockpit/v1/__init__.py @@ -62,6 +62,7 @@ from .types import RegionalApiListManagedAlertsRequest from .types import RegionalApiListTokensRequest from .types import RegionalApiTriggerTestAlertRequest +from .types import RegionalApiUpdateContactPointRequest from .types import RegionalApiUpdateDataSourceRequest from .types import UsageOverview from .api import CockpitV1GlobalAPI @@ -130,6 +131,7 @@ "RegionalApiListManagedAlertsRequest", "RegionalApiListTokensRequest", "RegionalApiTriggerTestAlertRequest", + "RegionalApiUpdateContactPointRequest", "RegionalApiUpdateDataSourceRequest", "UsageOverview", "CockpitV1GlobalAPI", diff --git a/scaleway/scaleway/cockpit/v1/api.py b/scaleway/scaleway/cockpit/v1/api.py index b9a60a816..0be7b2ca2 100644 --- a/scaleway/scaleway/cockpit/v1/api.py +++ b/scaleway/scaleway/cockpit/v1/api.py @@ -52,6 +52,7 @@ RegionalApiEnableAlertManagerRequest, RegionalApiEnableManagedAlertsRequest, RegionalApiTriggerTestAlertRequest, + RegionalApiUpdateContactPointRequest, RegionalApiUpdateDataSourceRequest, Token, UsageOverview, @@ -87,6 +88,7 @@ marshal_RegionalApiEnableAlertManagerRequest, marshal_RegionalApiEnableManagedAlertsRequest, marshal_RegionalApiTriggerTestAlertRequest, + marshal_RegionalApiUpdateContactPointRequest, marshal_RegionalApiUpdateDataSourceRequest, ) @@ -1230,6 +1232,7 @@ def create_contact_point( region: Optional[ScwRegion] = None, project_id: Optional[str] = None, email: Optional[ContactPointEmail] = None, + receive_resolved_notifications: Optional[bool] = None, ) -> ContactPoint: """ Create a contact point. @@ -1240,6 +1243,7 @@ def create_contact_point( :param project_id: ID of the Project to create the contact point in. :param email: Email address of the contact point to create. One-Of ('configuration'): at most one of 'email' could be set. + :param receive_resolved_notifications: Send an email notification when an alert is marked as resolved. :return: :class:`ContactPoint ` Usage: @@ -1259,6 +1263,7 @@ def create_contact_point( RegionalApiCreateContactPointRequest( region=region, project_id=project_id, + receive_resolved_notifications=receive_resolved_notifications, email=email, ), self.client, @@ -1343,6 +1348,49 @@ def list_contact_points_all( }, ) + def update_contact_point( + self, + *, + region: Optional[ScwRegion] = None, + project_id: Optional[str] = None, + email: Optional[ContactPointEmail] = None, + receive_resolved_notifications: Optional[bool] = None, + ) -> ContactPoint: + """ + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: ID of the Project containing the contact point to update. + :param email: Email address of the contact point to update. + One-Of ('configuration'): at most one of 'email' could be set. + :param receive_resolved_notifications: Enable or disable notifications when alert is resolved. + :return: :class:`ContactPoint ` + + Usage: + :: + + result = api.update_contact_point() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "PATCH", + f"/cockpit/v1/regions/{param_region}/alert-manager/contact-points", + body=marshal_RegionalApiUpdateContactPointRequest( + RegionalApiUpdateContactPointRequest( + region=region, + project_id=project_id, + receive_resolved_notifications=receive_resolved_notifications, + email=email, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_ContactPoint(res.json()) + def delete_contact_point( self, *, diff --git a/scaleway/scaleway/cockpit/v1/marshalling.py b/scaleway/scaleway/cockpit/v1/marshalling.py index ab3d480cf..6739977d0 100644 --- a/scaleway/scaleway/cockpit/v1/marshalling.py +++ b/scaleway/scaleway/cockpit/v1/marshalling.py @@ -45,6 +45,7 @@ RegionalApiEnableAlertManagerRequest, RegionalApiEnableManagedAlertsRequest, RegionalApiTriggerTestAlertRequest, + RegionalApiUpdateContactPointRequest, RegionalApiUpdateDataSourceRequest, ) @@ -76,6 +77,10 @@ def unmarshal_ContactPoint(data: Any) -> ContactPoint: if field is not None: args["region"] = field + field = data.get("receive_resolved_notifications", None) + if field is not None: + args["receive_resolved_notifications"] = field + field = data.get("email", None) if field is not None: args["email"] = unmarshal_ContactPointEmail(field) @@ -773,6 +778,11 @@ def marshal_RegionalApiCreateContactPointRequest( if request.project_id is not None: output["project_id"] = request.project_id or defaults.default_project_id + if request.receive_resolved_notifications is not None: + output["receive_resolved_notifications"] = ( + request.receive_resolved_notifications + ) + return output @@ -894,6 +904,30 @@ def marshal_RegionalApiTriggerTestAlertRequest( return output +def marshal_RegionalApiUpdateContactPointRequest( + request: RegionalApiUpdateContactPointRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("email", request.email), + ] + ), + ) + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.receive_resolved_notifications is not None: + output["receive_resolved_notifications"] = ( + request.receive_resolved_notifications + ) + + return output + + def marshal_RegionalApiUpdateDataSourceRequest( request: RegionalApiUpdateDataSourceRequest, defaults: ProfileDefaults, diff --git a/scaleway/scaleway/cockpit/v1/types.py b/scaleway/scaleway/cockpit/v1/types.py index c49ae6ddf..d7363a866 100644 --- a/scaleway/scaleway/cockpit/v1/types.py +++ b/scaleway/scaleway/cockpit/v1/types.py @@ -151,7 +151,12 @@ class ContactPoint: region: ScwRegion """ - Region to target. If none is passed will use default region from the config. + Region. + """ + + receive_resolved_notifications: bool + """ + Send an email notification when an alert is marked as resolved. """ email: Optional[ContactPointEmail] @@ -847,6 +852,11 @@ class RegionalApiCreateContactPointRequest: ID of the Project to create the contact point in. """ + receive_resolved_notifications: Optional[bool] + """ + Send an email notification when an alert is marked as resolved. + """ + email: Optional[ContactPointEmail] @@ -1260,6 +1270,30 @@ class RegionalApiTriggerTestAlertRequest: """ +@dataclass +class RegionalApiUpdateContactPointRequest: + """ + Update a contact point. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + ID of the Project containing the contact point to update. + """ + + receive_resolved_notifications: Optional[bool] + """ + Enable or disable notifications when alert is resolved. + """ + + email: Optional[ContactPointEmail] + + @dataclass class RegionalApiUpdateDataSourceRequest: """