Skip to content

Commit 5eec75d

Browse files
fix(cockpit): add return object for enable/disable alert endpoints (#2045)
Co-authored-by: devtools-ci-cd <[email protected]>
1 parent b072c2f commit 5eec75d

File tree

5 files changed

+73
-24
lines changed

5 files changed

+73
-24
lines changed

packages_generated/cockpit/src/v1/api.gen.ts

+32-20
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import {
2828
unmarshalAlertManager,
2929
unmarshalContactPoint,
3030
unmarshalDataSource,
31+
unmarshalDisableAlertRulesResponse,
32+
unmarshalEnableAlertRulesResponse,
3133
unmarshalGetConfigResponse,
3234
unmarshalGrafana,
3335
unmarshalGrafanaProductDashboard,
@@ -47,6 +49,8 @@ import type {
4749
AlertManager,
4850
ContactPoint,
4951
DataSource,
52+
DisableAlertRulesResponse,
53+
EnableAlertRulesResponse,
5054
GetConfigResponse,
5155
GlobalApiCreateGrafanaUserRequest,
5256
GlobalApiDeleteGrafanaUserRequest,
@@ -861,41 +865,49 @@ If you need to receive alerts for other receivers, you can create additional con
861865
* Enable preconfigured alert rules. Enable alert rules from the list of available preconfigured rules.. Enable preconfigured alert rules. Enable alert rules from the list of available preconfigured rules.
862866
*
863867
* @param request - The request {@link RegionalApiEnableAlertRulesRequest}
868+
* @returns A Promise of EnableAlertRulesResponse
864869
*/
865870
enableAlertRules = (
866871
request: Readonly<RegionalApiEnableAlertRulesRequest> = {},
867872
) =>
868-
this.client.fetch<void>({
869-
body: JSON.stringify(
870-
marshalRegionalApiEnableAlertRulesRequest(
871-
request,
872-
this.client.settings,
873+
this.client.fetch<EnableAlertRulesResponse>(
874+
{
875+
body: JSON.stringify(
876+
marshalRegionalApiEnableAlertRulesRequest(
877+
request,
878+
this.client.settings,
879+
),
873880
),
874-
),
875-
headers: jsonContentHeaders,
876-
method: 'POST',
877-
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/enable-alert-rules`,
878-
})
881+
headers: jsonContentHeaders,
882+
method: 'POST',
883+
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/enable-alert-rules`,
884+
},
885+
unmarshalEnableAlertRulesResponse,
886+
)
879887

880888
/**
881889
* Disable preconfigured alert rules. Disable alert rules from the list of available preconfigured rules.. Disable preconfigured alert rules. Disable alert rules from the list of available preconfigured rules.
882890
*
883891
* @param request - The request {@link RegionalApiDisableAlertRulesRequest}
892+
* @returns A Promise of DisableAlertRulesResponse
884893
*/
885894
disableAlertRules = (
886895
request: Readonly<RegionalApiDisableAlertRulesRequest> = {},
887896
) =>
888-
this.client.fetch<void>({
889-
body: JSON.stringify(
890-
marshalRegionalApiDisableAlertRulesRequest(
891-
request,
892-
this.client.settings,
897+
this.client.fetch<DisableAlertRulesResponse>(
898+
{
899+
body: JSON.stringify(
900+
marshalRegionalApiDisableAlertRulesRequest(
901+
request,
902+
this.client.settings,
903+
),
893904
),
894-
),
895-
headers: jsonContentHeaders,
896-
method: 'POST',
897-
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/disable-alert-rules`,
898-
})
905+
headers: jsonContentHeaders,
906+
method: 'POST',
907+
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/disable-alert-rules`,
908+
},
909+
unmarshalDisableAlertRulesResponse,
910+
)
899911

900912
/**
901913
* Trigger a test alert. Send a test alert to the Alert manager to make sure your contact points get notified.

packages_generated/cockpit/src/v1/index.gen.ts

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export type {
1414
DataSource,
1515
DataSourceOrigin,
1616
DataSourceType,
17+
DisableAlertRulesResponse,
18+
EnableAlertRulesResponse,
1719
GetConfigResponse,
1820
GetConfigResponseRetention,
1921
GlobalApiCreateGrafanaUserRequest,

packages_generated/cockpit/src/v1/marshalling.gen.ts

+30
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import type {
1313
ContactPoint,
1414
ContactPointEmail,
1515
DataSource,
16+
DisableAlertRulesResponse,
17+
EnableAlertRulesResponse,
1618
GetConfigResponse,
1719
GetConfigResponseRetention,
1820
GlobalApiCreateGrafanaUserRequest,
@@ -183,6 +185,34 @@ export const unmarshalAlertManager = (data: unknown): AlertManager => {
183185
} as AlertManager
184186
}
185187

188+
export const unmarshalDisableAlertRulesResponse = (
189+
data: unknown,
190+
): DisableAlertRulesResponse => {
191+
if (!isJSONObject(data)) {
192+
throw new TypeError(
193+
`Unmarshalling the type 'DisableAlertRulesResponse' failed as data isn't a dictionary.`,
194+
)
195+
}
196+
197+
return {
198+
disabledRuleIds: data.disabled_rule_ids,
199+
} as DisableAlertRulesResponse
200+
}
201+
202+
export const unmarshalEnableAlertRulesResponse = (
203+
data: unknown,
204+
): EnableAlertRulesResponse => {
205+
if (!isJSONObject(data)) {
206+
throw new TypeError(
207+
`Unmarshalling the type 'EnableAlertRulesResponse' failed as data isn't a dictionary.`,
208+
)
209+
}
210+
211+
return {
212+
enabledRuleIds: data.enabled_rule_ids,
213+
} as EnableAlertRulesResponse
214+
}
215+
186216
const unmarshalGetConfigResponseRetention = (
187217
data: unknown,
188218
): GetConfigResponseRetention => {

packages_generated/cockpit/src/v1/types.gen.ts

+8
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,14 @@ export interface AlertManager {
372372
region: ScwRegion
373373
}
374374

375+
export interface DisableAlertRulesResponse {
376+
disabledRuleIds: string[]
377+
}
378+
379+
export interface EnableAlertRulesResponse {
380+
enabledRuleIds: string[]
381+
}
382+
375383
/**
376384
* Cockpit configuration.
377385
*/
+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
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-
export type {
4-
CountryCode,
5-
LanguageCode,
6-
} from './types.gen'
3+
export type { LanguageCode } from './types.gen'

0 commit comments

Comments
 (0)