Skip to content

feat(cockpit): add received_resolved field #850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2025
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/cockpit/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -130,6 +131,7 @@
"RegionalApiListManagedAlertsRequest",
"RegionalApiListTokensRequest",
"RegionalApiTriggerTestAlertRequest",
"RegionalApiUpdateContactPointRequest",
"RegionalApiUpdateDataSourceRequest",
"UsageOverview",
"CockpitV1GlobalAPI",
Expand Down
48 changes: 48 additions & 0 deletions scaleway-async/scaleway_async/cockpit/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
RegionalApiEnableAlertManagerRequest,
RegionalApiEnableManagedAlertsRequest,
RegionalApiTriggerTestAlertRequest,
RegionalApiUpdateContactPointRequest,
RegionalApiUpdateDataSourceRequest,
Token,
UsageOverview,
Expand Down Expand Up @@ -87,6 +88,7 @@
marshal_RegionalApiEnableAlertManagerRequest,
marshal_RegionalApiEnableManagedAlertsRequest,
marshal_RegionalApiTriggerTestAlertRequest,
marshal_RegionalApiUpdateContactPointRequest,
marshal_RegionalApiUpdateDataSourceRequest,
)

Expand Down Expand Up @@ -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.
Expand All @@ -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 <ContactPoint>`

Usage:
Expand All @@ -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,
Expand Down Expand Up @@ -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 <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,
*,
Expand Down
34 changes: 34 additions & 0 deletions scaleway-async/scaleway_async/cockpit/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
RegionalApiEnableAlertManagerRequest,
RegionalApiEnableManagedAlertsRequest,
RegionalApiTriggerTestAlertRequest,
RegionalApiUpdateContactPointRequest,
RegionalApiUpdateDataSourceRequest,
)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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,
Expand Down
36 changes: 35 additions & 1 deletion scaleway-async/scaleway_async/cockpit/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]


Expand Down Expand Up @@ -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:
"""
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/cockpit/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -130,6 +131,7 @@
"RegionalApiListManagedAlertsRequest",
"RegionalApiListTokensRequest",
"RegionalApiTriggerTestAlertRequest",
"RegionalApiUpdateContactPointRequest",
"RegionalApiUpdateDataSourceRequest",
"UsageOverview",
"CockpitV1GlobalAPI",
Expand Down
48 changes: 48 additions & 0 deletions scaleway/scaleway/cockpit/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
RegionalApiEnableAlertManagerRequest,
RegionalApiEnableManagedAlertsRequest,
RegionalApiTriggerTestAlertRequest,
RegionalApiUpdateContactPointRequest,
RegionalApiUpdateDataSourceRequest,
Token,
UsageOverview,
Expand Down Expand Up @@ -87,6 +88,7 @@
marshal_RegionalApiEnableAlertManagerRequest,
marshal_RegionalApiEnableManagedAlertsRequest,
marshal_RegionalApiTriggerTestAlertRequest,
marshal_RegionalApiUpdateContactPointRequest,
marshal_RegionalApiUpdateDataSourceRequest,
)

Expand Down Expand Up @@ -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.
Expand All @@ -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 <ContactPoint>`

Usage:
Expand All @@ -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,
Expand Down Expand Up @@ -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 <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,
*,
Expand Down
34 changes: 34 additions & 0 deletions scaleway/scaleway/cockpit/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
RegionalApiEnableAlertManagerRequest,
RegionalApiEnableManagedAlertsRequest,
RegionalApiTriggerTestAlertRequest,
RegionalApiUpdateContactPointRequest,
RegionalApiUpdateDataSourceRequest,
)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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,
Expand Down
Loading