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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions packages_generated/account/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/applesilicon/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/audit_trail/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/baremetal/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/billing/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/block/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/cockpit/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
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
4 changes: 2 additions & 2 deletions packages_generated/cockpit/src/v1/validation-rules.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const RegionalApiCreateDataSourceRequest = {
retentionDays: {
greaterThanOrEqual: 1,
ignoreEmpty: true,
lessThanOrEqual: 365,
lessThanOrEqual: 1825,
},
}

Expand Down Expand Up @@ -62,6 +62,6 @@ export const RegionalApiUpdateDataSourceRequest = {
retentionDays: {
greaterThanOrEqual: 1,
ignoreEmpty: true,
lessThanOrEqual: 365,
lessThanOrEqual: 1825,
},
}
6 changes: 6 additions & 0 deletions packages_generated/container/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/dedibox/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/domain/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/edge_services/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/file/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/flexibleip/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/function/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/iam/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
88 changes: 88 additions & 0 deletions packages_generated/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

import * as Account from './account/index.gen'
import * as Applesilicon from './applesilicon/index.gen'
import * as AuditTrail from './audit_trail/index.gen'
import * as Baremetal from './baremetal/index.gen'
import * as Billing from './billing/index.gen'
import * as Block from './block/index.gen'
import * as Cockpit from './cockpit/index.gen'
import * as Container from './container/index.gen'
import * as Dedibox from './dedibox/index.gen'
import * as Domain from './domain/index.gen'
import * as EdgeServices from './edge_services/index.gen'
import * as File from './file/index.gen'
import * as Flexibleip from './flexibleip/index.gen'
import * as Function from './function/index.gen'
import * as Iam from './iam/index.gen'
import * as Inference from './inference/index.gen'
import * as Instance from './instance/index.gen'
import * as Interlink from './interlink/index.gen'
import * as Iot from './iot/index.gen'
import * as Ipam from './ipam/index.gen'
import * as Jobs from './jobs/index.gen'
import * as K8s from './k8s/index.gen'
import * as KeyManager from './key_manager/index.gen'
import * as Lb from './lb/index.gen'
import * as Marketplace from './marketplace/index.gen'
import * as Mnq from './mnq/index.gen'
import * as Mongodb from './mongodb/index.gen'
import * as ProductCatalog from './product_catalog/index.gen'
import * as Qaas from './qaas/index.gen'
import * as Rdb from './rdb/index.gen'
import * as Redis from './redis/index.gen'
import * as Registry from './registry/index.gen'
import * as Secret from './secret/index.gen'
import * as ServerlessSqldb from './serverless_sqldb/index.gen'
import * as Std from './std/index.gen'
import * as Tem from './tem/index.gen'
import * as Test from './test/index.gen'
import * as Vpc from './vpc/index.gen'
import * as Vpcgw from './vpcgw/index.gen'
import * as Webhosting from './webhosting/index.gen'

export {
Account,
Applesilicon,
AuditTrail,
Baremetal,
Billing,
Block,
Cockpit,
Container,
Dedibox,
Domain,
EdgeServices,
File,
Flexibleip,
Function,
Iam,
Inference,
Instance,
Interlink,
Iot,
Ipam,
Jobs,
K8s,
KeyManager,
Lb,
Marketplace,
Mnq,
Mongodb,
ProductCatalog,
Qaas,
Rdb,
Redis,
Registry,
Secret,
ServerlessSqldb,
Std,
Tem,
Test,
Vpc,
Vpcgw,
Webhosting,
}
6 changes: 6 additions & 0 deletions packages_generated/inference/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
6 changes: 6 additions & 0 deletions packages_generated/instance/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This file is automatically generated from /scripts/generate.js
* PLEASE DO NOT EDIT HERE
*/

export * as src from './src/index.gen'
4 changes: 4 additions & 0 deletions packages_generated/instance/src/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export * from './marshalling.gen'
export type {
ApplyBlockMigrationRequest,
Arch,
AttachServerFileSystemRequest,
AttachServerFileSystemResponse,
AttachServerVolumeRequest,
AttachServerVolumeRequestVolumeType,
AttachServerVolumeResponse,
Expand Down Expand Up @@ -41,6 +43,8 @@ export type {
DeleteServerUserDataRequest,
DeleteSnapshotRequest,
DeleteVolumeRequest,
DetachServerFileSystemRequest,
DetachServerFileSystemResponse,
DetachServerVolumeRequest,
DetachServerVolumeResponse,
ExportSnapshotRequest,
Expand Down
Loading
Loading