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
36 changes: 0 additions & 36 deletions packages/clients/src/api/cockpit/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
unmarshalListDataSourcesResponse,
unmarshalListGrafanaProductDashboardsResponse,
unmarshalListGrafanaUsersResponse,
unmarshalListManagedAlertsResponse,
unmarshalListPlansResponse,
unmarshalListTokensResponse,
unmarshalPlan,
Expand Down Expand Up @@ -66,7 +65,6 @@ import type {
ListDataSourcesResponse,
ListGrafanaProductDashboardsResponse,
ListGrafanaUsersResponse,
ListManagedAlertsResponse,
ListPlansResponse,
ListTokensResponse,
Plan,
Expand All @@ -88,7 +86,6 @@ import type {
RegionalApiListAlertsRequest,
RegionalApiListContactPointsRequest,
RegionalApiListDataSourcesRequest,
RegionalApiListManagedAlertsRequest,
RegionalApiListTokensRequest,
RegionalApiTriggerTestAlertRequest,
RegionalApiUpdateContactPointRequest,
Expand Down Expand Up @@ -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<RegionalApiListManagedAlertsRequest> = {},
) =>
this.client.fetch<ListManagedAlertsResponse>(
{
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<RegionalApiListManagedAlertsRequest> = {},
) => enrichForPagination('alerts', this.pageOfListManagedAlerts, request)

/**
* List alerts. List preconfigured and/or custom alerts for the specified
* Project.
Expand Down
6 changes: 1 addition & 5 deletions packages/clients/src/api/cockpit/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ export { GlobalAPI, RegionalAPI } from './api.gen'
export type {
Alert,
AlertManager,
AnyAlert,
AnyAlertState,
AlertState,
ContactPoint,
ContactPointEmail,
DataSource,
Expand Down Expand Up @@ -35,8 +34,6 @@ export type {
ListGrafanaProductDashboardsResponse,
ListGrafanaUsersRequestOrderBy,
ListGrafanaUsersResponse,
ListManagedAlertsRequestOrderBy,
ListManagedAlertsResponse,
ListPlansRequestOrderBy,
ListPlansResponse,
ListTokensRequestOrderBy,
Expand All @@ -61,7 +58,6 @@ export type {
RegionalApiListAlertsRequest,
RegionalApiListContactPointsRequest,
RegionalApiListDataSourcesRequest,
RegionalApiListManagedAlertsRequest,
RegionalApiListTokensRequest,
RegionalApiTriggerTestAlertRequest,
RegionalApiUpdateContactPointRequest,
Expand Down
44 changes: 6 additions & 38 deletions packages/clients/src/api/cockpit/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type { DefaultValues } from '../../../bridge'
import type {
Alert,
AlertManager,
AnyAlert,
ContactPoint,
ContactPointEmail,
DataSource,
Expand All @@ -28,7 +27,6 @@ import type {
ListDataSourcesResponse,
ListGrafanaProductDashboardsResponse,
ListGrafanaUsersResponse,
ListManagedAlertsResponse,
ListPlansResponse,
ListTokensResponse,
Plan,
Expand Down Expand Up @@ -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 = (
Expand All @@ -266,7 +265,7 @@ export const unmarshalListAlertsResponse = (
}

return {
alerts: unmarshalArrayOfObject(data.alerts, unmarshalAnyAlert),
alerts: unmarshalArrayOfObject(data.alerts, unmarshalAlert),
totalCount: data.total_count,
} as ListAlertsResponse
}
Expand Down Expand Up @@ -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 => {
Expand Down
60 changes: 6 additions & 54 deletions packages/clients/src/api/cockpit/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 =
Expand Down Expand Up @@ -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.
Expand All @@ -81,7 +68,8 @@ export interface AnyAlert {
name: string
rule: string
duration: string
state: AnyAlertState
enabled: boolean
state?: AlertState
annotations: Record<string, string>
}

Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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 = {
/**
Expand Down
10 changes: 0 additions & 10 deletions packages/clients/src/api/cockpit/v1/validation-rules.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ export const RegionalApiListDataSourcesRequest = {
},
}

export const RegionalApiListManagedAlertsRequest = {
page: {
greaterThanOrEqual: 1,
},
pageSize: {
greaterThanOrEqual: 1,
lessThanOrEqual: 1000,
},
}

export const RegionalApiListTokensRequest = {
page: {
greaterThanOrEqual: 1,
Expand Down
Loading