diff --git a/packages/clients/src/api/cockpit/v1/api.gen.ts b/packages/clients/src/api/cockpit/v1/api.gen.ts index d567f8049..e8c784cee 100644 --- a/packages/clients/src/api/cockpit/v1/api.gen.ts +++ b/packages/clients/src/api/cockpit/v1/api.gen.ts @@ -35,7 +35,6 @@ import { unmarshalListDataSourcesResponse, unmarshalListGrafanaProductDashboardsResponse, unmarshalListGrafanaUsersResponse, - unmarshalListManagedAlertsResponse, unmarshalListPlansResponse, unmarshalListTokensResponse, unmarshalPlan, @@ -66,7 +65,6 @@ import type { ListDataSourcesResponse, ListGrafanaProductDashboardsResponse, ListGrafanaUsersResponse, - ListManagedAlertsResponse, ListPlansResponse, ListTokensResponse, Plan, @@ -88,7 +86,6 @@ import type { RegionalApiListAlertsRequest, RegionalApiListContactPointsRequest, RegionalApiListDataSourcesRequest, - RegionalApiListManagedAlertsRequest, RegionalApiListTokensRequest, RegionalApiTriggerTestAlertRequest, RegionalApiUpdateContactPointRequest, @@ -838,39 +835,6 @@ export class RegionalAPI extends ParentAPI { path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/contact-points/delete`, }) - protected pageOfListManagedAlerts = ( - request: Readonly = {}, - ) => - this.client.fetch( - { - method: 'GET', - path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/managed-alerts`, - urlParams: urlParams( - ['order_by', request.orderBy], - ['page', request.page], - [ - 'page_size', - request.pageSize ?? this.client.settings.defaultPageSize, - ], - [ - 'project_id', - request.projectId ?? this.client.settings.defaultProjectId, - ], - ), - }, - unmarshalListManagedAlertsResponse, - ) - - /** - * List managed alerts. List all managed alerts for the specified Project. - * - * @param request - The request {@link RegionalApiListManagedAlertsRequest} - * @returns A Promise of ListManagedAlertsResponse - */ - listManagedAlerts = ( - request: Readonly = {}, - ) => enrichForPagination('alerts', this.pageOfListManagedAlerts, request) - /** * List alerts. List preconfigured and/or custom alerts for the specified * Project. diff --git a/packages/clients/src/api/cockpit/v1/index.gen.ts b/packages/clients/src/api/cockpit/v1/index.gen.ts index 38b032127..36ef92f90 100644 --- a/packages/clients/src/api/cockpit/v1/index.gen.ts +++ b/packages/clients/src/api/cockpit/v1/index.gen.ts @@ -4,8 +4,7 @@ export { GlobalAPI, RegionalAPI } from './api.gen' export type { Alert, AlertManager, - AnyAlert, - AnyAlertState, + AlertState, ContactPoint, ContactPointEmail, DataSource, @@ -35,8 +34,6 @@ export type { ListGrafanaProductDashboardsResponse, ListGrafanaUsersRequestOrderBy, ListGrafanaUsersResponse, - ListManagedAlertsRequestOrderBy, - ListManagedAlertsResponse, ListPlansRequestOrderBy, ListPlansResponse, ListTokensRequestOrderBy, @@ -61,7 +58,6 @@ export type { RegionalApiListAlertsRequest, RegionalApiListContactPointsRequest, RegionalApiListDataSourcesRequest, - RegionalApiListManagedAlertsRequest, RegionalApiListTokensRequest, RegionalApiTriggerTestAlertRequest, RegionalApiUpdateContactPointRequest, diff --git a/packages/clients/src/api/cockpit/v1/marshalling.gen.ts b/packages/clients/src/api/cockpit/v1/marshalling.gen.ts index 6693e1636..ae9ec94d7 100644 --- a/packages/clients/src/api/cockpit/v1/marshalling.gen.ts +++ b/packages/clients/src/api/cockpit/v1/marshalling.gen.ts @@ -10,7 +10,6 @@ import type { DefaultValues } from '../../../bridge' import type { Alert, AlertManager, - AnyAlert, ContactPoint, ContactPointEmail, DataSource, @@ -28,7 +27,6 @@ import type { ListDataSourcesResponse, ListGrafanaProductDashboardsResponse, ListGrafanaUsersResponse, - ListManagedAlertsResponse, ListPlansResponse, ListTokensResponse, Plan, @@ -238,22 +236,23 @@ export const unmarshalGrafana = (data: unknown): Grafana => { } as Grafana } -const unmarshalAnyAlert = (data: unknown): AnyAlert => { +const unmarshalAlert = (data: unknown): Alert => { if (!isJSONObject(data)) { throw new TypeError( - `Unmarshalling the type 'AnyAlert' failed as data isn't a dictionary.`, + `Unmarshalling the type 'Alert' failed as data isn't a dictionary.`, ) } return { annotations: data.annotations, duration: data.duration, + enabled: data.enabled, name: data.name, preconfigured: data.preconfigured, region: data.region, rule: data.rule, - state: data.state, - } as AnyAlert + state: data.state ? data.state : undefined, + } as Alert } export const unmarshalListAlertsResponse = ( @@ -266,7 +265,7 @@ export const unmarshalListAlertsResponse = ( } return { - alerts: unmarshalArrayOfObject(data.alerts, unmarshalAnyAlert), + alerts: unmarshalArrayOfObject(data.alerts, unmarshalAlert), totalCount: data.total_count, } as ListAlertsResponse } @@ -342,37 +341,6 @@ export const unmarshalListGrafanaUsersResponse = ( } as ListGrafanaUsersResponse } -const unmarshalAlert = (data: unknown): Alert => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'Alert' failed as data isn't a dictionary.`, - ) - } - - return { - description: data.description, - name: data.name, - product: data.product, - productFamily: data.product_family, - rule: data.rule, - } as Alert -} - -export const unmarshalListManagedAlertsResponse = ( - data: unknown, -): ListManagedAlertsResponse => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ListManagedAlertsResponse' failed as data isn't a dictionary.`, - ) - } - - return { - alerts: unmarshalArrayOfObject(data.alerts, unmarshalAlert), - totalCount: data.total_count, - } as ListManagedAlertsResponse -} - export const unmarshalListPlansResponse = ( data: unknown, ): ListPlansResponse => { diff --git a/packages/clients/src/api/cockpit/v1/types.gen.ts b/packages/clients/src/api/cockpit/v1/types.gen.ts index 6f609f35f..b499c9ec1 100644 --- a/packages/clients/src/api/cockpit/v1/types.gen.ts +++ b/packages/clients/src/api/cockpit/v1/types.gen.ts @@ -2,12 +2,7 @@ // If you have any remark or suggestion do not hesitate to open an issue. import type { Region as ScwRegion } from '../../../bridge' -export type AnyAlertState = - | 'unknown_state' - | 'disabled' - | 'enabled' - | 'pending' - | 'firing' +export type AlertState = 'unknown_state' | 'inactive' | 'pending' | 'firing' export type DataSourceOrigin = | 'unknown_origin' @@ -29,14 +24,6 @@ export type ListDataSourcesRequestOrderBy = export type ListGrafanaUsersRequestOrderBy = 'login_asc' | 'login_desc' -export type ListManagedAlertsRequestOrderBy = - | 'created_at_asc' - | 'created_at_desc' - | 'name_asc' - | 'name_desc' - | 'type_asc' - | 'type_desc' - export type ListPlansRequestOrderBy = 'name_asc' | 'name_desc' export type ListTokensRequestOrderBy = @@ -71,7 +58,7 @@ export interface GetConfigResponseRetention { defaultDays: number } -export interface AnyAlert { +export interface Alert { /** * Region to target. If none is passed will use default region from the * config. @@ -81,7 +68,8 @@ export interface AnyAlert { name: string rule: string duration: string - state: AnyAlertState + enabled: boolean + state?: AlertState annotations: Record } @@ -151,14 +139,6 @@ export interface GrafanaUser { password?: string } -export interface Alert { - productFamily: string - product: string - name: string - rule: string - description: string -} - /** Type of pricing plan. */ export interface Plan { /** Name of a given pricing plan. */ @@ -355,7 +335,7 @@ export interface ListAlertsResponse { /** Total count of alerts matching the request. */ totalCount: number /** List of alerts matching the applied filters. */ - alerts: AnyAlert[] + alerts: Alert[] } /** Response returned when listing contact points. */ @@ -400,14 +380,6 @@ export interface ListGrafanaUsersResponse { grafanaUsers: GrafanaUser[] } -/** Response returned when listing data sources. */ -export interface ListManagedAlertsResponse { - /** Total count of data sources matching the request. */ - totalCount: number - /** Alerts matching the request within the pagination. */ - alerts: Alert[] -} - /** Output returned when listing pricing plans. */ export interface ListPlansResponse { /** Total count of available pricing plans. */ @@ -635,7 +607,7 @@ export type RegionalApiListAlertsRequest = { * `firing`. If omitted, no filtering is applied on alert states. Other * filters may still apply. */ - state?: AnyAlertState + state?: AlertState } /** List contact points. */ @@ -683,26 +655,6 @@ export type RegionalApiListDataSourcesRequest = { types?: DataSourceType[] } -/** Enable the sending of managed alerts. */ -export type RegionalApiListManagedAlertsRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: ScwRegion - /** Page number to return, from the paginated results. */ - page?: number - /** Number of data sources to return per page. */ - pageSize?: number - /** Sort order for data sources in the response. */ - orderBy?: ListManagedAlertsRequestOrderBy - /** - * Project ID to filter for, only data sources from this Project will be - * returned. - */ - projectId?: string -} - /** List tokens. */ export type RegionalApiListTokensRequest = { /** diff --git a/packages/clients/src/api/cockpit/v1/validation-rules.gen.ts b/packages/clients/src/api/cockpit/v1/validation-rules.gen.ts index 9ca6d2b4f..68cda3196 100644 --- a/packages/clients/src/api/cockpit/v1/validation-rules.gen.ts +++ b/packages/clients/src/api/cockpit/v1/validation-rules.gen.ts @@ -42,16 +42,6 @@ export const RegionalApiListDataSourcesRequest = { }, } -export const RegionalApiListManagedAlertsRequest = { - page: { - greaterThanOrEqual: 1, - }, - pageSize: { - greaterThanOrEqual: 1, - lessThanOrEqual: 1000, - }, -} - export const RegionalApiListTokensRequest = { page: { greaterThanOrEqual: 1,