Skip to content

Commit

Permalink
Merge branch 'main' into v1.6113.0
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone authored Feb 18, 2025
2 parents a708a92 + bb46893 commit c7193ca
Show file tree
Hide file tree
Showing 7 changed files with 5,534 additions and 1,963 deletions.
13 changes: 13 additions & 0 deletions packages/clients/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.66.0](https://github.com/scaleway/scaleway-sdk-js/compare/@scaleway/[email protected]...@scaleway/[email protected]) (2025-02-17)

### Features

- **apple_silicon:** introduce monthly commitment handling ([#1803](https://github.com/scaleway/scaleway-sdk-js/issues/1803)) ([0972b37](https://github.com/scaleway/scaleway-sdk-js/commit/0972b37b4592b0112e6f800426b8129a85192d76))
- **audit_trail:** add key manager to resource api ([#1786](https://github.com/scaleway/scaleway-sdk-js/issues/1786)) ([b985b98](https://github.com/scaleway/scaleway-sdk-js/commit/b985b981e60650c72ed4b8faf2422e3cf4063f08))
- **edge_services:** add WAF billing ([#1800](https://github.com/scaleway/scaleway-sdk-js/issues/1800)) ([84a9ec5](https://github.com/scaleway/scaleway-sdk-js/commit/84a9ec517b24259cf6beef3277790a4764750bbb))

### Bug Fixes

- add prefix to Zone and Region import ([#1802](https://github.com/scaleway/scaleway-sdk-js/issues/1802)) ([ce59650](https://github.com/scaleway/scaleway-sdk-js/commit/ce596501b569b3387a76e12e7d00a90d94ca803e))
- **types:** unknown property accessKey in createClient ([#1781](https://github.com/scaleway/scaleway-sdk-js/issues/1781)) ([865b8c7](https://github.com/scaleway/scaleway-sdk-js/commit/865b8c7b6854314ebc209b5bba6ea836cb792b73))

## [2.65.0](https://github.com/scaleway/scaleway-sdk-js/compare/@scaleway/[email protected]...@scaleway/[email protected]) (2025-02-10)

### Features
Expand Down
2 changes: 1 addition & 1 deletion packages/clients/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scaleway/sdk",
"version": "2.65.0",
"version": "2.66.0",
"license": "Apache-2.0",
"description": "Scaleway SDK.",
"keywords": [
Expand Down
28 changes: 28 additions & 0 deletions packages/clients/src/api/cockpit/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
unmarshalGrafana,
unmarshalGrafanaProductDashboard,
unmarshalGrafanaUser,
unmarshalListAlertsResponse,
unmarshalListContactPointsResponse,
unmarshalListDataSourcesResponse,
unmarshalListGrafanaProductDashboardsResponse,
Expand Down Expand Up @@ -60,6 +61,7 @@ import type {
Grafana,
GrafanaProductDashboard,
GrafanaUser,
ListAlertsResponse,
ListContactPointsResponse,
ListDataSourcesResponse,
ListGrafanaProductDashboardsResponse,
Expand All @@ -83,6 +85,7 @@ import type {
RegionalApiGetDataSourceRequest,
RegionalApiGetTokenRequest,
RegionalApiGetUsageOverviewRequest,
RegionalApiListAlertsRequest,
RegionalApiListContactPointsRequest,
RegionalApiListDataSourcesRequest,
RegionalApiListManagedAlertsRequest,
Expand Down Expand Up @@ -868,6 +871,31 @@ export class RegionalAPI extends ParentAPI {
request: Readonly<RegionalApiListManagedAlertsRequest> = {},
) => enrichForPagination('alerts', this.pageOfListManagedAlerts, request)

/**
* List alerts. List preconfigured and/or custom alerts for the specified
* Project.
*
* @param request - The request {@link RegionalApiListAlertsRequest}
* @returns A Promise of ListAlertsResponse
*/
listAlerts = (request: Readonly<RegionalApiListAlertsRequest> = {}) =>
this.client.fetch<ListAlertsResponse>(
{
method: 'GET',
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alerts`,
urlParams: urlParams(
['is_enabled', request.isEnabled],
['is_preconfigured', request.isPreconfigured],
[
'project_id',
request.projectId ?? this.client.settings.defaultProjectId,
],
['state', request.state],
),
},
unmarshalListAlertsResponse,
)

/**
* Enable managed alerts. Enable the sending of managed alerts for the
* specified Project. Managed alerts are predefined alerts that apply to
Expand Down
35 changes: 35 additions & 0 deletions packages/clients/src/api/cockpit/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { DefaultValues } from '../../../bridge'
import type {
Alert,
AlertManager,
AnyAlert,
ContactPoint,
ContactPointEmail,
DataSource,
Expand All @@ -22,6 +23,7 @@ import type {
Grafana,
GrafanaProductDashboard,
GrafanaUser,
ListAlertsResponse,
ListContactPointsResponse,
ListDataSourcesResponse,
ListGrafanaProductDashboardsResponse,
Expand Down Expand Up @@ -236,6 +238,39 @@ export const unmarshalGrafana = (data: unknown): Grafana => {
} as Grafana
}

const unmarshalAnyAlert = (data: unknown): AnyAlert => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'AnyAlert' failed as data isn't a dictionary.`,
)
}

return {
annotations: data.annotations,
duration: data.duration,
name: data.name,
preconfigured: data.preconfigured,
region: data.region,
rule: data.rule,
state: data.state,
} as AnyAlert
}

export const unmarshalListAlertsResponse = (
data: unknown,
): ListAlertsResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ListAlertsResponse' failed as data isn't a dictionary.`,
)
}

return {
alerts: unmarshalArrayOfObject(data.alerts, unmarshalAnyAlert),
totalCount: data.total_count,
} as ListAlertsResponse
}

export const unmarshalListContactPointsResponse = (
data: unknown,
): ListContactPointsResponse => {
Expand Down
57 changes: 57 additions & 0 deletions packages/clients/src/api/cockpit/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// 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 DataSourceOrigin =
| 'unknown_origin'
| 'scaleway'
Expand Down Expand Up @@ -64,6 +71,20 @@ export interface GetConfigResponseRetention {
defaultDays: number
}

export interface AnyAlert {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region: ScwRegion
preconfigured: boolean
name: string
rule: string
duration: string
state: AnyAlertState
annotations: Record<string, string>
}

/** Contact point. */
export interface ContactPoint {
/**
Expand Down Expand Up @@ -329,6 +350,14 @@ export interface Grafana {
grafanaUrl: string
}

/** Retrieve a list of alerts matching the request. */
export interface ListAlertsResponse {
/** Total count of alerts matching the request. */
totalCount: number
/** List of alerts matching the applied filters. */
alerts: AnyAlert[]
}

/** Response returned when listing contact points. */
export interface ListContactPointsResponse {
/** Total count of contact points associated with the default receiver. */
Expand Down Expand Up @@ -581,6 +610,34 @@ export type RegionalApiGetUsageOverviewRequest = {
interval?: string
}

/** Retrieve a list of alerts. */
export type RegionalApiListAlertsRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: ScwRegion
/** Project ID to filter for, only alerts from this Project will be returned. */
projectId?: string
/**
* True returns only enabled alerts. False returns only disabled alerts. If
* omitted, no alert filtering is applied. Other filters may still apply.
*/
isEnabled?: boolean
/**
* True returns only preconfigured alerts. False returns only custom alerts.
* If omitted, no filtering is applied on alert types. Other filters may still
* apply.
*/
isPreconfigured?: boolean
/**
* Valid values to filter on are `disabled`, `enabled`, `pending` and
* `firing`. If omitted, no filtering is applied on alert states. Other
* filters may still apply.
*/
state?: AnyAlertState
}

/** List contact points. */
export type RegionalApiListContactPointsRequest = {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/clients/src/scw/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const version = 'v2.65.0'
export const version = 'v2.66.0'

export const userAgent = `scaleway-sdk-js/${version}`
Loading

0 comments on commit c7193ca

Please sign in to comment.