diff --git a/packages/clients/src/api/cockpit/v1/api.gen.ts b/packages/clients/src/api/cockpit/v1/api.gen.ts index e04a5b3db..fb34cab0f 100644 --- a/packages/clients/src/api/cockpit/v1/api.gen.ts +++ b/packages/clients/src/api/cockpit/v1/api.gen.ts @@ -6,7 +6,7 @@ import { urlParams, validatePathParam, } from '../../../bridge' -import type { Region } from '../../../bridge' +import type { Region as ScwRegion } from '../../../bridge' import { marshalGlobalApiCreateGrafanaUserRequest, marshalGlobalApiResetGrafanaUserPasswordRequest, @@ -21,6 +21,7 @@ import { marshalRegionalApiEnableAlertManagerRequest, marshalRegionalApiEnableManagedAlertsRequest, marshalRegionalApiTriggerTestAlertRequest, + marshalRegionalApiUpdateContactPointRequest, marshalRegionalApiUpdateDataSourceRequest, unmarshalAlertManager, unmarshalContactPoint, @@ -87,6 +88,7 @@ import type { RegionalApiListManagedAlertsRequest, RegionalApiListTokensRequest, RegionalApiTriggerTestAlertRequest, + RegionalApiUpdateContactPointRequest, RegionalApiUpdateDataSourceRequest, Token, UsageOverview, @@ -402,7 +404,11 @@ export class GlobalAPI extends ParentAPI { */ export class RegionalAPI extends ParentAPI { /** Lists the available regions of the API. */ - public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw'] + public static readonly LOCALITIES: ScwRegion[] = [ + 'fr-par', + 'nl-ams', + 'pl-waw', + ] /** * Get the Cockpit configuration. @@ -790,6 +796,24 @@ export class RegionalAPI extends ParentAPI { ) => enrichForPagination('contactPoints', this.pageOfListContactPoints, request) + updateContactPoint = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalRegionalApiUpdateContactPointRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/contact-points`, + }, + unmarshalContactPoint, + ) + /** * Delete a contact point. Delete a contact point associated with the default * receiver. diff --git a/packages/clients/src/api/cockpit/v1/index.gen.ts b/packages/clients/src/api/cockpit/v1/index.gen.ts index 421639703..cb93899f4 100644 --- a/packages/clients/src/api/cockpit/v1/index.gen.ts +++ b/packages/clients/src/api/cockpit/v1/index.gen.ts @@ -60,6 +60,7 @@ export type { RegionalApiListManagedAlertsRequest, RegionalApiListTokensRequest, RegionalApiTriggerTestAlertRequest, + RegionalApiUpdateContactPointRequest, RegionalApiUpdateDataSourceRequest, Token, TokenScope, diff --git a/packages/clients/src/api/cockpit/v1/marshalling.gen.ts b/packages/clients/src/api/cockpit/v1/marshalling.gen.ts index 30b8ad846..2f7bc9d41 100644 --- a/packages/clients/src/api/cockpit/v1/marshalling.gen.ts +++ b/packages/clients/src/api/cockpit/v1/marshalling.gen.ts @@ -39,6 +39,7 @@ import type { RegionalApiEnableAlertManagerRequest, RegionalApiEnableManagedAlertsRequest, RegionalApiTriggerTestAlertRequest, + RegionalApiUpdateContactPointRequest, RegionalApiUpdateDataSourceRequest, Token, Usage, @@ -66,6 +67,7 @@ export const unmarshalContactPoint = (data: unknown): ContactPoint => { return { email: data.email ? unmarshalContactPointEmail(data.email) : undefined, + receiveResolvedNotifications: data.receive_resolved_notifications, region: data.region, } as ContactPoint } @@ -454,6 +456,7 @@ export const marshalRegionalApiCreateContactPointRequest = ( defaults: DefaultValues, ): Record => ({ project_id: request.projectId ?? defaults.defaultProjectId, + receive_resolved_notifications: request.receiveResolvedNotifications, ...resolveOneOf([ { param: 'email', @@ -536,6 +539,23 @@ export const marshalRegionalApiTriggerTestAlertRequest = ( project_id: request.projectId ?? defaults.defaultProjectId, }) +export const marshalRegionalApiUpdateContactPointRequest = ( + request: RegionalApiUpdateContactPointRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, + receive_resolved_notifications: request.receiveResolvedNotifications, + ...resolveOneOf([ + { + param: 'email', + value: + request.email !== undefined + ? marshalContactPointEmail(request.email, defaults) + : undefined, + }, + ]), +}) + export const marshalRegionalApiUpdateDataSourceRequest = ( request: RegionalApiUpdateDataSourceRequest, defaults: DefaultValues, diff --git a/packages/clients/src/api/cockpit/v1/types.gen.ts b/packages/clients/src/api/cockpit/v1/types.gen.ts index 6b4ee76c5..2d14380c2 100644 --- a/packages/clients/src/api/cockpit/v1/types.gen.ts +++ b/packages/clients/src/api/cockpit/v1/types.gen.ts @@ -1,6 +1,6 @@ // This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. -import type { Region } from '../../../bridge' +import type { Region as ScwRegion } from '../../../bridge' export type DataSourceOrigin = | 'unknown_origin' @@ -72,11 +72,10 @@ export interface ContactPoint { * One-of ('configuration'): at most one of 'email' could be set. */ email?: ContactPointEmail - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region: Region + /** Region. */ + region: ScwRegion + /** Send an email notification when an alert is marked as resolved. */ + receiveResolvedNotifications: boolean } /** Data source. */ @@ -102,7 +101,7 @@ export interface DataSource { /** BETA - Duration for which the data will be retained in the data source. */ retentionDays: number /** Region of the data source. */ - region: Region + region: ScwRegion } /** Grafana dashboard. */ @@ -176,7 +175,7 @@ export interface Token { /** Token secret key. */ secretKey?: string /** Regions where the token is located. */ - region: Region + region: ScwRegion } /** Data source usage. */ @@ -196,7 +195,7 @@ export interface Usage { /** Data source usage for the given interval. */ quantityOverInterval: number /** Region of the data source usage. */ - region: Region + region: ScwRegion } /** Alert manager information. */ @@ -208,7 +207,7 @@ export interface AlertManager { /** Managed alerts are enabled. */ managedAlertsEnabled: boolean /** Regions where the Alert manager is enabled. */ - region: Region + region: ScwRegion } /** Cockpit configuration. */ @@ -402,7 +401,7 @@ export type RegionalApiCreateContactPointRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the Project to create the contact point in. */ projectId?: string /** @@ -411,6 +410,8 @@ export type RegionalApiCreateContactPointRequest = { * One-of ('configuration'): at most one of 'email' could be set. */ email?: ContactPointEmail + /** Send an email notification when an alert is marked as resolved. */ + receiveResolvedNotifications?: boolean } /** Create a data source. */ @@ -419,7 +420,7 @@ export type RegionalApiCreateDataSourceRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the Project the data source belongs to. */ projectId?: string /** Data source name. */ @@ -436,7 +437,7 @@ export type RegionalApiCreateTokenRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the Project the token belongs to. */ projectId?: string /** Name of the token. */ @@ -451,7 +452,7 @@ export type RegionalApiDeleteContactPointRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the Project containing the contact point to delete. */ projectId?: string /** @@ -468,7 +469,7 @@ export type RegionalApiDeleteDataSourceRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the data source to delete. */ dataSourceId: string } @@ -479,7 +480,7 @@ export type RegionalApiDeleteTokenRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the token to delete. */ tokenId: string } @@ -490,7 +491,7 @@ export type RegionalApiDisableAlertManagerRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the Project to disable the Alert manager in. */ projectId?: string } @@ -501,7 +502,7 @@ export type RegionalApiDisableManagedAlertsRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the Project. */ projectId?: string } @@ -512,7 +513,7 @@ export type RegionalApiEnableAlertManagerRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the Project to enable the Alert manager in. */ projectId?: string } @@ -523,7 +524,7 @@ export type RegionalApiEnableManagedAlertsRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the Project. */ projectId?: string } @@ -534,7 +535,7 @@ export type RegionalApiGetAlertManagerRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** Project ID of the requested Alert manager. */ projectId?: string } @@ -545,7 +546,7 @@ export type RegionalApiGetConfigRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion } /** Retrieve a data source. */ @@ -554,7 +555,7 @@ export type RegionalApiGetDataSourceRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the relevant data source. */ dataSourceId: string } @@ -565,7 +566,7 @@ export type RegionalApiGetTokenRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** Token ID. */ tokenId: string } @@ -575,7 +576,7 @@ export type RegionalApiGetUsageOverviewRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion projectId?: string interval?: string } @@ -586,7 +587,7 @@ export type RegionalApiListContactPointsRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** Page number to return, from the paginated results. */ page?: number /** Total count of contact points to return per page. */ @@ -601,7 +602,7 @@ export type RegionalApiListDataSourcesRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** Page number to return, from the paginated results. */ page?: number /** Number of data sources to return per page. */ @@ -631,7 +632,7 @@ export type RegionalApiListManagedAlertsRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** Page number to return, from the paginated results. */ page?: number /** Number of data sources to return per page. */ @@ -651,7 +652,7 @@ export type RegionalApiListTokensRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** Page number to return, from the paginated results. */ page?: number /** Number of tokens to return per page. */ @@ -670,18 +671,37 @@ export type RegionalApiTriggerTestAlertRequest = { * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the Project. */ projectId?: string } +/** Update a contact point. */ +export type RegionalApiUpdateContactPointRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: ScwRegion + /** ID of the Project containing the contact point to update. */ + projectId?: string + /** + * Email address of the contact point to update. + * + * One-of ('configuration'): at most one of 'email' could be set. + */ + email?: ContactPointEmail + /** Enable or disable notifications when alert is resolved. */ + receiveResolvedNotifications?: boolean +} + /** Update a data source name. */ export type RegionalApiUpdateDataSourceRequest = { /** * Region to target. If none is passed will use default region from the * config. */ - region?: Region + region?: ScwRegion /** ID of the data source to update. */ dataSourceId: string /** Updated name of the data source. */