Skip to content
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
28 changes: 26 additions & 2 deletions packages/clients/src/api/cockpit/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
urlParams,
validatePathParam,
} from '../../../bridge'
import type { Region } from '../../../bridge'
import type { Region as ScwRegion } from '../../../bridge'
import {
marshalGlobalApiCreateGrafanaUserRequest,
marshalGlobalApiResetGrafanaUserPasswordRequest,
Expand All @@ -21,6 +21,7 @@ import {
marshalRegionalApiEnableAlertManagerRequest,
marshalRegionalApiEnableManagedAlertsRequest,
marshalRegionalApiTriggerTestAlertRequest,
marshalRegionalApiUpdateContactPointRequest,
marshalRegionalApiUpdateDataSourceRequest,
unmarshalAlertManager,
unmarshalContactPoint,
Expand Down Expand Up @@ -87,6 +88,7 @@ import type {
RegionalApiListManagedAlertsRequest,
RegionalApiListTokensRequest,
RegionalApiTriggerTestAlertRequest,
RegionalApiUpdateContactPointRequest,
RegionalApiUpdateDataSourceRequest,
Token,
UsageOverview,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -790,6 +796,24 @@ export class RegionalAPI extends ParentAPI {
) =>
enrichForPagination('contactPoints', this.pageOfListContactPoints, request)

updateContactPoint = (
request: Readonly<RegionalApiUpdateContactPointRequest> = {},
) =>
this.client.fetch<ContactPoint>(
{
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.
Expand Down
1 change: 1 addition & 0 deletions packages/clients/src/api/cockpit/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export type {
RegionalApiListManagedAlertsRequest,
RegionalApiListTokensRequest,
RegionalApiTriggerTestAlertRequest,
RegionalApiUpdateContactPointRequest,
RegionalApiUpdateDataSourceRequest,
Token,
TokenScope,
Expand Down
20 changes: 20 additions & 0 deletions packages/clients/src/api/cockpit/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import type {
RegionalApiEnableAlertManagerRequest,
RegionalApiEnableManagedAlertsRequest,
RegionalApiTriggerTestAlertRequest,
RegionalApiUpdateContactPointRequest,
RegionalApiUpdateDataSourceRequest,
Token,
Usage,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -454,6 +456,7 @@ export const marshalRegionalApiCreateContactPointRequest = (
defaults: DefaultValues,
): Record<string, unknown> => ({
project_id: request.projectId ?? defaults.defaultProjectId,
receive_resolved_notifications: request.receiveResolvedNotifications,
...resolveOneOf([
{
param: 'email',
Expand Down Expand Up @@ -536,6 +539,23 @@ export const marshalRegionalApiTriggerTestAlertRequest = (
project_id: request.projectId ?? defaults.defaultProjectId,
})

export const marshalRegionalApiUpdateContactPointRequest = (
request: RegionalApiUpdateContactPointRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
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,
Expand Down
82 changes: 51 additions & 31 deletions packages/clients/src/api/cockpit/v1/types.gen.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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. */
Expand All @@ -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. */
Expand Down Expand Up @@ -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. */
Expand All @@ -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. */
Expand All @@ -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. */
Expand Down Expand Up @@ -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
/**
Expand All @@ -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. */
Expand All @@ -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. */
Expand All @@ -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. */
Expand All @@ -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
/**
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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. */
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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. */
Expand All @@ -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. */
Expand Down Expand Up @@ -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. */
Expand All @@ -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. */
Expand All @@ -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. */
Expand Down
Loading