Skip to content

Commit a3c3a3d

Browse files
committed
feat: update generated APIs
1 parent 5215582 commit a3c3a3d

File tree

4 files changed

+98
-33
lines changed

4 files changed

+98
-33
lines changed

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
urlParams,
77
validatePathParam,
88
} from '../../../bridge'
9-
import type { Region } from '../../../bridge'
9+
import type { Region as ScwRegion } from '../../../bridge'
1010
import {
1111
marshalGlobalApiCreateGrafanaUserRequest,
1212
marshalGlobalApiResetGrafanaUserPasswordRequest,
@@ -21,6 +21,7 @@ import {
2121
marshalRegionalApiEnableAlertManagerRequest,
2222
marshalRegionalApiEnableManagedAlertsRequest,
2323
marshalRegionalApiTriggerTestAlertRequest,
24+
marshalRegionalApiUpdateContactPointRequest,
2425
marshalRegionalApiUpdateDataSourceRequest,
2526
unmarshalAlertManager,
2627
unmarshalContactPoint,
@@ -87,6 +88,7 @@ import type {
8788
RegionalApiListManagedAlertsRequest,
8889
RegionalApiListTokensRequest,
8990
RegionalApiTriggerTestAlertRequest,
91+
RegionalApiUpdateContactPointRequest,
9092
RegionalApiUpdateDataSourceRequest,
9193
Token,
9294
UsageOverview,
@@ -402,7 +404,11 @@ export class GlobalAPI extends ParentAPI {
402404
*/
403405
export class RegionalAPI extends ParentAPI {
404406
/** Lists the available regions of the API. */
405-
public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw']
407+
public static readonly LOCALITIES: ScwRegion[] = [
408+
'fr-par',
409+
'nl-ams',
410+
'pl-waw',
411+
]
406412

407413
/**
408414
* Get the Cockpit configuration.
@@ -790,6 +796,24 @@ export class RegionalAPI extends ParentAPI {
790796
) =>
791797
enrichForPagination('contactPoints', this.pageOfListContactPoints, request)
792798

799+
updateContactPoint = (
800+
request: Readonly<RegionalApiUpdateContactPointRequest> = {},
801+
) =>
802+
this.client.fetch<ContactPoint>(
803+
{
804+
body: JSON.stringify(
805+
marshalRegionalApiUpdateContactPointRequest(
806+
request,
807+
this.client.settings,
808+
),
809+
),
810+
headers: jsonContentHeaders,
811+
method: 'PATCH',
812+
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/contact-points`,
813+
},
814+
unmarshalContactPoint,
815+
)
816+
793817
/**
794818
* Delete a contact point. Delete a contact point associated with the default
795819
* receiver.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export type {
6060
RegionalApiListManagedAlertsRequest,
6161
RegionalApiListTokensRequest,
6262
RegionalApiTriggerTestAlertRequest,
63+
RegionalApiUpdateContactPointRequest,
6364
RegionalApiUpdateDataSourceRequest,
6465
Token,
6566
TokenScope,

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import type {
3939
RegionalApiEnableAlertManagerRequest,
4040
RegionalApiEnableManagedAlertsRequest,
4141
RegionalApiTriggerTestAlertRequest,
42+
RegionalApiUpdateContactPointRequest,
4243
RegionalApiUpdateDataSourceRequest,
4344
Token,
4445
Usage,
@@ -66,6 +67,7 @@ export const unmarshalContactPoint = (data: unknown): ContactPoint => {
6667

6768
return {
6869
email: data.email ? unmarshalContactPointEmail(data.email) : undefined,
70+
receiveResolvedNotifications: data.receive_resolved_notifications,
6971
region: data.region,
7072
} as ContactPoint
7173
}
@@ -454,6 +456,7 @@ export const marshalRegionalApiCreateContactPointRequest = (
454456
defaults: DefaultValues,
455457
): Record<string, unknown> => ({
456458
project_id: request.projectId ?? defaults.defaultProjectId,
459+
receive_resolved_notifications: request.receiveResolvedNotifications,
457460
...resolveOneOf([
458461
{
459462
param: 'email',
@@ -536,6 +539,23 @@ export const marshalRegionalApiTriggerTestAlertRequest = (
536539
project_id: request.projectId ?? defaults.defaultProjectId,
537540
})
538541

542+
export const marshalRegionalApiUpdateContactPointRequest = (
543+
request: RegionalApiUpdateContactPointRequest,
544+
defaults: DefaultValues,
545+
): Record<string, unknown> => ({
546+
project_id: request.projectId ?? defaults.defaultProjectId,
547+
receive_resolved_notifications: request.receiveResolvedNotifications,
548+
...resolveOneOf([
549+
{
550+
param: 'email',
551+
value:
552+
request.email !== undefined
553+
? marshalContactPointEmail(request.email, defaults)
554+
: undefined,
555+
},
556+
]),
557+
})
558+
539559
export const marshalRegionalApiUpdateDataSourceRequest = (
540560
request: RegionalApiUpdateDataSourceRequest,
541561
defaults: DefaultValues,

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

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file was automatically generated. DO NOT EDIT.
22
// If you have any remark or suggestion do not hesitate to open an issue.
3-
import type { Region } from '../../../bridge'
3+
import type { Region as ScwRegion } from '../../../bridge'
44

55
export type DataSourceOrigin =
66
| 'unknown_origin'
@@ -72,11 +72,10 @@ export interface ContactPoint {
7272
* One-of ('configuration'): at most one of 'email' could be set.
7373
*/
7474
email?: ContactPointEmail
75-
/**
76-
* Region to target. If none is passed will use default region from the
77-
* config.
78-
*/
79-
region: Region
75+
/** Region. */
76+
region: ScwRegion
77+
/** Send an email notification when an alert is marked as resolved. */
78+
receiveResolvedNotifications: boolean
8079
}
8180

8281
/** Data source. */
@@ -102,7 +101,7 @@ export interface DataSource {
102101
/** BETA - Duration for which the data will be retained in the data source. */
103102
retentionDays: number
104103
/** Region of the data source. */
105-
region: Region
104+
region: ScwRegion
106105
}
107106

108107
/** Grafana dashboard. */
@@ -176,7 +175,7 @@ export interface Token {
176175
/** Token secret key. */
177176
secretKey?: string
178177
/** Regions where the token is located. */
179-
region: Region
178+
region: ScwRegion
180179
}
181180

182181
/** Data source usage. */
@@ -196,7 +195,7 @@ export interface Usage {
196195
/** Data source usage for the given interval. */
197196
quantityOverInterval: number
198197
/** Region of the data source usage. */
199-
region: Region
198+
region: ScwRegion
200199
}
201200

202201
/** Alert manager information. */
@@ -208,7 +207,7 @@ export interface AlertManager {
208207
/** Managed alerts are enabled. */
209208
managedAlertsEnabled: boolean
210209
/** Regions where the Alert manager is enabled. */
211-
region: Region
210+
region: ScwRegion
212211
}
213212

214213
/** Cockpit configuration. */
@@ -402,7 +401,7 @@ export type RegionalApiCreateContactPointRequest = {
402401
* Region to target. If none is passed will use default region from the
403402
* config.
404403
*/
405-
region?: Region
404+
region?: ScwRegion
406405
/** ID of the Project to create the contact point in. */
407406
projectId?: string
408407
/**
@@ -411,6 +410,8 @@ export type RegionalApiCreateContactPointRequest = {
411410
* One-of ('configuration'): at most one of 'email' could be set.
412411
*/
413412
email?: ContactPointEmail
413+
/** Send an email notification when an alert is marked as resolved. */
414+
receiveResolvedNotifications?: boolean
414415
}
415416

416417
/** Create a data source. */
@@ -419,7 +420,7 @@ export type RegionalApiCreateDataSourceRequest = {
419420
* Region to target. If none is passed will use default region from the
420421
* config.
421422
*/
422-
region?: Region
423+
region?: ScwRegion
423424
/** ID of the Project the data source belongs to. */
424425
projectId?: string
425426
/** Data source name. */
@@ -436,7 +437,7 @@ export type RegionalApiCreateTokenRequest = {
436437
* Region to target. If none is passed will use default region from the
437438
* config.
438439
*/
439-
region?: Region
440+
region?: ScwRegion
440441
/** ID of the Project the token belongs to. */
441442
projectId?: string
442443
/** Name of the token. */
@@ -451,7 +452,7 @@ export type RegionalApiDeleteContactPointRequest = {
451452
* Region to target. If none is passed will use default region from the
452453
* config.
453454
*/
454-
region?: Region
455+
region?: ScwRegion
455456
/** ID of the Project containing the contact point to delete. */
456457
projectId?: string
457458
/**
@@ -468,7 +469,7 @@ export type RegionalApiDeleteDataSourceRequest = {
468469
* Region to target. If none is passed will use default region from the
469470
* config.
470471
*/
471-
region?: Region
472+
region?: ScwRegion
472473
/** ID of the data source to delete. */
473474
dataSourceId: string
474475
}
@@ -479,7 +480,7 @@ export type RegionalApiDeleteTokenRequest = {
479480
* Region to target. If none is passed will use default region from the
480481
* config.
481482
*/
482-
region?: Region
483+
region?: ScwRegion
483484
/** ID of the token to delete. */
484485
tokenId: string
485486
}
@@ -490,7 +491,7 @@ export type RegionalApiDisableAlertManagerRequest = {
490491
* Region to target. If none is passed will use default region from the
491492
* config.
492493
*/
493-
region?: Region
494+
region?: ScwRegion
494495
/** ID of the Project to disable the Alert manager in. */
495496
projectId?: string
496497
}
@@ -501,7 +502,7 @@ export type RegionalApiDisableManagedAlertsRequest = {
501502
* Region to target. If none is passed will use default region from the
502503
* config.
503504
*/
504-
region?: Region
505+
region?: ScwRegion
505506
/** ID of the Project. */
506507
projectId?: string
507508
}
@@ -512,7 +513,7 @@ export type RegionalApiEnableAlertManagerRequest = {
512513
* Region to target. If none is passed will use default region from the
513514
* config.
514515
*/
515-
region?: Region
516+
region?: ScwRegion
516517
/** ID of the Project to enable the Alert manager in. */
517518
projectId?: string
518519
}
@@ -523,7 +524,7 @@ export type RegionalApiEnableManagedAlertsRequest = {
523524
* Region to target. If none is passed will use default region from the
524525
* config.
525526
*/
526-
region?: Region
527+
region?: ScwRegion
527528
/** ID of the Project. */
528529
projectId?: string
529530
}
@@ -534,7 +535,7 @@ export type RegionalApiGetAlertManagerRequest = {
534535
* Region to target. If none is passed will use default region from the
535536
* config.
536537
*/
537-
region?: Region
538+
region?: ScwRegion
538539
/** Project ID of the requested Alert manager. */
539540
projectId?: string
540541
}
@@ -545,7 +546,7 @@ export type RegionalApiGetConfigRequest = {
545546
* Region to target. If none is passed will use default region from the
546547
* config.
547548
*/
548-
region?: Region
549+
region?: ScwRegion
549550
}
550551

551552
/** Retrieve a data source. */
@@ -554,7 +555,7 @@ export type RegionalApiGetDataSourceRequest = {
554555
* Region to target. If none is passed will use default region from the
555556
* config.
556557
*/
557-
region?: Region
558+
region?: ScwRegion
558559
/** ID of the relevant data source. */
559560
dataSourceId: string
560561
}
@@ -565,7 +566,7 @@ export type RegionalApiGetTokenRequest = {
565566
* Region to target. If none is passed will use default region from the
566567
* config.
567568
*/
568-
region?: Region
569+
region?: ScwRegion
569570
/** Token ID. */
570571
tokenId: string
571572
}
@@ -575,7 +576,7 @@ export type RegionalApiGetUsageOverviewRequest = {
575576
* Region to target. If none is passed will use default region from the
576577
* config.
577578
*/
578-
region?: Region
579+
region?: ScwRegion
579580
projectId?: string
580581
interval?: string
581582
}
@@ -586,7 +587,7 @@ export type RegionalApiListContactPointsRequest = {
586587
* Region to target. If none is passed will use default region from the
587588
* config.
588589
*/
589-
region?: Region
590+
region?: ScwRegion
590591
/** Page number to return, from the paginated results. */
591592
page?: number
592593
/** Total count of contact points to return per page. */
@@ -601,7 +602,7 @@ export type RegionalApiListDataSourcesRequest = {
601602
* Region to target. If none is passed will use default region from the
602603
* config.
603604
*/
604-
region?: Region
605+
region?: ScwRegion
605606
/** Page number to return, from the paginated results. */
606607
page?: number
607608
/** Number of data sources to return per page. */
@@ -631,7 +632,7 @@ export type RegionalApiListManagedAlertsRequest = {
631632
* Region to target. If none is passed will use default region from the
632633
* config.
633634
*/
634-
region?: Region
635+
region?: ScwRegion
635636
/** Page number to return, from the paginated results. */
636637
page?: number
637638
/** Number of data sources to return per page. */
@@ -651,7 +652,7 @@ export type RegionalApiListTokensRequest = {
651652
* Region to target. If none is passed will use default region from the
652653
* config.
653654
*/
654-
region?: Region
655+
region?: ScwRegion
655656
/** Page number to return, from the paginated results. */
656657
page?: number
657658
/** Number of tokens to return per page. */
@@ -670,18 +671,37 @@ export type RegionalApiTriggerTestAlertRequest = {
670671
* Region to target. If none is passed will use default region from the
671672
* config.
672673
*/
673-
region?: Region
674+
region?: ScwRegion
674675
/** ID of the Project. */
675676
projectId?: string
676677
}
677678

679+
/** Update a contact point. */
680+
export type RegionalApiUpdateContactPointRequest = {
681+
/**
682+
* Region to target. If none is passed will use default region from the
683+
* config.
684+
*/
685+
region?: ScwRegion
686+
/** ID of the Project containing the contact point to update. */
687+
projectId?: string
688+
/**
689+
* Email address of the contact point to update.
690+
*
691+
* One-of ('configuration'): at most one of 'email' could be set.
692+
*/
693+
email?: ContactPointEmail
694+
/** Enable or disable notifications when alert is resolved. */
695+
receiveResolvedNotifications?: boolean
696+
}
697+
678698
/** Update a data source name. */
679699
export type RegionalApiUpdateDataSourceRequest = {
680700
/**
681701
* Region to target. If none is passed will use default region from the
682702
* config.
683703
*/
684-
region?: Region
704+
region?: ScwRegion
685705
/** ID of the data source to update. */
686706
dataSourceId: string
687707
/** Updated name of the data source. */

0 commit comments

Comments
 (0)