Skip to content

Commit aadb378

Browse files
authored
Merge branch 'main' into v1.6122.0
2 parents 3fc4216 + 4997495 commit aadb378

File tree

5 files changed

+150
-0
lines changed

5 files changed

+150
-0
lines changed

packages/clients/src/api/cockpit/v1/api.gen.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
unmarshalGrafana,
3131
unmarshalGrafanaProductDashboard,
3232
unmarshalGrafanaUser,
33+
unmarshalListAlertsResponse,
3334
unmarshalListContactPointsResponse,
3435
unmarshalListDataSourcesResponse,
3536
unmarshalListGrafanaProductDashboardsResponse,
@@ -60,6 +61,7 @@ import type {
6061
Grafana,
6162
GrafanaProductDashboard,
6263
GrafanaUser,
64+
ListAlertsResponse,
6365
ListContactPointsResponse,
6466
ListDataSourcesResponse,
6567
ListGrafanaProductDashboardsResponse,
@@ -83,6 +85,7 @@ import type {
8385
RegionalApiGetDataSourceRequest,
8486
RegionalApiGetTokenRequest,
8587
RegionalApiGetUsageOverviewRequest,
88+
RegionalApiListAlertsRequest,
8689
RegionalApiListContactPointsRequest,
8790
RegionalApiListDataSourcesRequest,
8891
RegionalApiListManagedAlertsRequest,
@@ -868,6 +871,31 @@ export class RegionalAPI extends ParentAPI {
868871
request: Readonly<RegionalApiListManagedAlertsRequest> = {},
869872
) => enrichForPagination('alerts', this.pageOfListManagedAlerts, request)
870873

874+
/**
875+
* List alerts. List preconfigured and/or custom alerts for the specified
876+
* Project.
877+
*
878+
* @param request - The request {@link RegionalApiListAlertsRequest}
879+
* @returns A Promise of ListAlertsResponse
880+
*/
881+
listAlerts = (request: Readonly<RegionalApiListAlertsRequest> = {}) =>
882+
this.client.fetch<ListAlertsResponse>(
883+
{
884+
method: 'GET',
885+
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alerts`,
886+
urlParams: urlParams(
887+
['is_enabled', request.isEnabled],
888+
['is_preconfigured', request.isPreconfigured],
889+
[
890+
'project_id',
891+
request.projectId ?? this.client.settings.defaultProjectId,
892+
],
893+
['state', request.state],
894+
),
895+
},
896+
unmarshalListAlertsResponse,
897+
)
898+
871899
/**
872900
* Enable managed alerts. Enable the sending of managed alerts for the
873901
* specified Project. Managed alerts are predefined alerts that apply to

packages/clients/src/api/cockpit/v1/marshalling.gen.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { DefaultValues } from '../../../bridge'
1010
import type {
1111
Alert,
1212
AlertManager,
13+
AnyAlert,
1314
ContactPoint,
1415
ContactPointEmail,
1516
DataSource,
@@ -22,6 +23,7 @@ import type {
2223
Grafana,
2324
GrafanaProductDashboard,
2425
GrafanaUser,
26+
ListAlertsResponse,
2527
ListContactPointsResponse,
2628
ListDataSourcesResponse,
2729
ListGrafanaProductDashboardsResponse,
@@ -236,6 +238,39 @@ export const unmarshalGrafana = (data: unknown): Grafana => {
236238
} as Grafana
237239
}
238240

241+
const unmarshalAnyAlert = (data: unknown): AnyAlert => {
242+
if (!isJSONObject(data)) {
243+
throw new TypeError(
244+
`Unmarshalling the type 'AnyAlert' failed as data isn't a dictionary.`,
245+
)
246+
}
247+
248+
return {
249+
annotations: data.annotations,
250+
duration: data.duration,
251+
name: data.name,
252+
preconfigured: data.preconfigured,
253+
region: data.region,
254+
rule: data.rule,
255+
state: data.state,
256+
} as AnyAlert
257+
}
258+
259+
export const unmarshalListAlertsResponse = (
260+
data: unknown,
261+
): ListAlertsResponse => {
262+
if (!isJSONObject(data)) {
263+
throw new TypeError(
264+
`Unmarshalling the type 'ListAlertsResponse' failed as data isn't a dictionary.`,
265+
)
266+
}
267+
268+
return {
269+
alerts: unmarshalArrayOfObject(data.alerts, unmarshalAnyAlert),
270+
totalCount: data.total_count,
271+
} as ListAlertsResponse
272+
}
273+
239274
export const unmarshalListContactPointsResponse = (
240275
data: unknown,
241276
): ListContactPointsResponse => {

packages/clients/src/api/cockpit/v1/types.gen.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
// If you have any remark or suggestion do not hesitate to open an issue.
33
import type { Region as ScwRegion } from '../../../bridge'
44

5+
export type AnyAlertState =
6+
| 'unknown_state'
7+
| 'disabled'
8+
| 'enabled'
9+
| 'pending'
10+
| 'firing'
11+
512
export type DataSourceOrigin =
613
| 'unknown_origin'
714
| 'scaleway'
@@ -64,6 +71,20 @@ export interface GetConfigResponseRetention {
6471
defaultDays: number
6572
}
6673

74+
export interface AnyAlert {
75+
/**
76+
* Region to target. If none is passed will use default region from the
77+
* config.
78+
*/
79+
region: ScwRegion
80+
preconfigured: boolean
81+
name: string
82+
rule: string
83+
duration: string
84+
state: AnyAlertState
85+
annotations: Record<string, string>
86+
}
87+
6788
/** Contact point. */
6889
export interface ContactPoint {
6990
/**
@@ -329,6 +350,14 @@ export interface Grafana {
329350
grafanaUrl: string
330351
}
331352

353+
/** Retrieve a list of alerts matching the request. */
354+
export interface ListAlertsResponse {
355+
/** Total count of alerts matching the request. */
356+
totalCount: number
357+
/** List of alerts matching the applied filters. */
358+
alerts: AnyAlert[]
359+
}
360+
332361
/** Response returned when listing contact points. */
333362
export interface ListContactPointsResponse {
334363
/** Total count of contact points associated with the default receiver. */
@@ -581,6 +610,34 @@ export type RegionalApiGetUsageOverviewRequest = {
581610
interval?: string
582611
}
583612

613+
/** Retrieve a list of alerts. */
614+
export type RegionalApiListAlertsRequest = {
615+
/**
616+
* Region to target. If none is passed will use default region from the
617+
* config.
618+
*/
619+
region?: ScwRegion
620+
/** Project ID to filter for, only alerts from this Project will be returned. */
621+
projectId?: string
622+
/**
623+
* True returns only enabled alerts. False returns only disabled alerts. If
624+
* omitted, no alert filtering is applied. Other filters may still apply.
625+
*/
626+
isEnabled?: boolean
627+
/**
628+
* True returns only preconfigured alerts. False returns only custom alerts.
629+
* If omitted, no filtering is applied on alert types. Other filters may still
630+
* apply.
631+
*/
632+
isPreconfigured?: boolean
633+
/**
634+
* Valid values to filter on are `disabled`, `enabled`, `pending` and
635+
* `firing`. If omitted, no filtering is applied on alert states. Other
636+
* filters may still apply.
637+
*/
638+
state?: AnyAlertState
639+
}
640+
584641
/** List contact points. */
585642
export type RegionalApiListContactPointsRequest = {
586643
/**

packages/clients/src/api/lb/v1/marshalling.gen.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ export const unmarshalFrontend = (data: unknown): Frontend => {
431431
? unmarshalCertificate(data.certificate)
432432
: undefined,
433433
certificateIds: data.certificate_ids,
434+
connectionRateLimit: data.connection_rate_limit,
434435
createdAt: unmarshalDate(data.created_at),
435436
enableHttp3: data.enable_http3,
436437
id: data.id,
@@ -1126,6 +1127,7 @@ export const marshalCreateFrontendRequest = (
11261127
backend_id: request.backendId,
11271128
certificate_id: request.certificateId,
11281129
certificate_ids: request.certificateIds,
1130+
connection_rate_limit: request.connectionRateLimit,
11291131
enable_http3: request.enableHttp3,
11301132
inbound_port: request.inboundPort,
11311133
name: request.name || randomName('lbf'),
@@ -1332,6 +1334,7 @@ export const marshalUpdateFrontendRequest = (
13321334
backend_id: request.backendId,
13331335
certificate_id: request.certificateId,
13341336
certificate_ids: request.certificateIds,
1337+
connection_rate_limit: request.connectionRateLimit,
13351338
enable_http3: request.enableHttp3,
13361339
inbound_port: request.inboundPort,
13371340
name: request.name,
@@ -1568,6 +1571,7 @@ export const marshalZonedApiCreateFrontendRequest = (
15681571
backend_id: request.backendId,
15691572
certificate_id: request.certificateId,
15701573
certificate_ids: request.certificateIds,
1574+
connection_rate_limit: request.connectionRateLimit,
15711575
enable_http3: request.enableHttp3,
15721576
inbound_port: request.inboundPort,
15731577
name: request.name || randomName('lbf'),
@@ -1771,6 +1775,7 @@ export const marshalZonedApiUpdateFrontendRequest = (
17711775
backend_id: request.backendId,
17721776
certificate_id: request.certificateId,
17731777
certificate_ids: request.certificateIds,
1778+
connection_rate_limit: request.connectionRateLimit,
17741779
enable_http3: request.enableHttp3,
17751780
inbound_port: request.inboundPort,
17761781
name: request.name,

packages/clients/src/api/lb/v1/types.gen.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,11 @@ export interface Frontend {
563563
updatedAt?: Date
564564
/** Defines whether to enable HTTP/3 protocol on the frontend. */
565565
enableHttp3: boolean
566+
/**
567+
* Rate limit for new connections established on this frontend. Use 0 value to
568+
* disable, else value is connections per second.
569+
*/
570+
connectionRateLimit?: number
566571
}
567572

568573
export interface PrivateNetworkDHCPConfig {
@@ -967,6 +972,11 @@ export type CreateFrontendRequest = {
967972
certificateIds?: string[]
968973
/** Defines whether to enable HTTP/3 protocol on the frontend. */
969974
enableHttp3: boolean
975+
/**
976+
* Rate limit for new connections established on this frontend. Use 0 value to
977+
* disable, else value is connections per second.
978+
*/
979+
connectionRateLimit?: number
970980
}
971981

972982
export type CreateIpRequest = {
@@ -1816,6 +1826,11 @@ export type UpdateFrontendRequest = {
18161826
certificateIds?: string[]
18171827
/** Defines whether to enable HTTP/3 protocol on the frontend. */
18181828
enableHttp3: boolean
1829+
/**
1830+
* Rate limit for new connections established on this frontend. Use 0 value to
1831+
* disable, else value is connections per second.
1832+
*/
1833+
connectionRateLimit?: number
18191834
}
18201835

18211836
export type UpdateHealthCheckRequest = {
@@ -2189,6 +2204,11 @@ export type ZonedApiCreateFrontendRequest = {
21892204
certificateIds?: string[]
21902205
/** Defines whether to enable HTTP/3 protocol on the frontend. */
21912206
enableHttp3: boolean
2207+
/**
2208+
* Rate limit for new connections established on this frontend. Use 0 value to
2209+
* disable, else value is connections per second.
2210+
*/
2211+
connectionRateLimit?: number
21922212
}
21932213

21942214
export type ZonedApiCreateIpRequest = {
@@ -2835,6 +2855,11 @@ export type ZonedApiUpdateFrontendRequest = {
28352855
certificateIds?: string[]
28362856
/** Defines whether to enable HTTP/3 protocol on the frontend. */
28372857
enableHttp3: boolean
2858+
/**
2859+
* Rate limit for new connections established on this frontend. Use 0 value to
2860+
* disable, else value is connections per second.
2861+
*/
2862+
connectionRateLimit?: number
28382863
}
28392864

28402865
export type ZonedApiUpdateHealthCheckRequest = {

0 commit comments

Comments
 (0)