Skip to content

fix(cockpit): add return object for enable/disable alert endpoints #2045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2025
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
52 changes: 32 additions & 20 deletions packages_generated/cockpit/src/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {
unmarshalAlertManager,
unmarshalContactPoint,
unmarshalDataSource,
unmarshalDisableAlertRulesResponse,
unmarshalEnableAlertRulesResponse,
unmarshalGetConfigResponse,
unmarshalGrafana,
unmarshalGrafanaProductDashboard,
Expand All @@ -47,6 +49,8 @@ import type {
AlertManager,
ContactPoint,
DataSource,
DisableAlertRulesResponse,
EnableAlertRulesResponse,
GetConfigResponse,
GlobalApiCreateGrafanaUserRequest,
GlobalApiDeleteGrafanaUserRequest,
Expand Down Expand Up @@ -861,41 +865,49 @@ If you need to receive alerts for other receivers, you can create additional con
* 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.
*
* @param request - The request {@link RegionalApiEnableAlertRulesRequest}
* @returns A Promise of EnableAlertRulesResponse
*/
enableAlertRules = (
request: Readonly<RegionalApiEnableAlertRulesRequest> = {},
) =>
this.client.fetch<void>({
body: JSON.stringify(
marshalRegionalApiEnableAlertRulesRequest(
request,
this.client.settings,
this.client.fetch<EnableAlertRulesResponse>(
{
body: JSON.stringify(
marshalRegionalApiEnableAlertRulesRequest(
request,
this.client.settings,
),
),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/enable-alert-rules`,
})
headers: jsonContentHeaders,
method: 'POST',
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/enable-alert-rules`,
},
unmarshalEnableAlertRulesResponse,
)

/**
* 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.
*
* @param request - The request {@link RegionalApiDisableAlertRulesRequest}
* @returns A Promise of DisableAlertRulesResponse
*/
disableAlertRules = (
request: Readonly<RegionalApiDisableAlertRulesRequest> = {},
) =>
this.client.fetch<void>({
body: JSON.stringify(
marshalRegionalApiDisableAlertRulesRequest(
request,
this.client.settings,
this.client.fetch<DisableAlertRulesResponse>(
{
body: JSON.stringify(
marshalRegionalApiDisableAlertRulesRequest(
request,
this.client.settings,
),
),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/disable-alert-rules`,
})
headers: jsonContentHeaders,
method: 'POST',
path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/disable-alert-rules`,
},
unmarshalDisableAlertRulesResponse,
)

/**
* Trigger a test alert. Send a test alert to the Alert manager to make sure your contact points get notified.
Expand Down
2 changes: 2 additions & 0 deletions packages_generated/cockpit/src/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export type {
DataSource,
DataSourceOrigin,
DataSourceType,
DisableAlertRulesResponse,
EnableAlertRulesResponse,
GetConfigResponse,
GetConfigResponseRetention,
GlobalApiCreateGrafanaUserRequest,
Expand Down
30 changes: 30 additions & 0 deletions packages_generated/cockpit/src/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import type {
ContactPoint,
ContactPointEmail,
DataSource,
DisableAlertRulesResponse,
EnableAlertRulesResponse,
GetConfigResponse,
GetConfigResponseRetention,
GlobalApiCreateGrafanaUserRequest,
Expand Down Expand Up @@ -183,6 +185,34 @@ export const unmarshalAlertManager = (data: unknown): AlertManager => {
} as AlertManager
}

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

return {
disabledRuleIds: data.disabled_rule_ids,
} as DisableAlertRulesResponse
}

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

return {
enabledRuleIds: data.enabled_rule_ids,
} as EnableAlertRulesResponse
}

const unmarshalGetConfigResponseRetention = (
data: unknown,
): GetConfigResponseRetention => {
Expand Down
8 changes: 8 additions & 0 deletions packages_generated/cockpit/src/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,14 @@ export interface AlertManager {
region: ScwRegion
}

export interface DisableAlertRulesResponse {
disabledRuleIds: string[]
}

export interface EnableAlertRulesResponse {
enabledRuleIds: string[]
}

/**
* Cockpit configuration.
*/
Expand Down
5 changes: 1 addition & 4 deletions packages_generated/std/src/index.gen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
export type {
CountryCode,
LanguageCode,
} from './types.gen'
export type { LanguageCode } from './types.gen'
Loading