mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Add (manual) script to generate alerting RTKQ APIs from OpenAPI spec (#89482)
This commit is contained in:
38
scripts/generate-alerting-rtk-apis.ts
Normal file
38
scripts/generate-alerting-rtk-apis.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* To generate alerting k8s APIs, run:
|
||||
* `npx rtk-query-codegen-openapi ./scripts/generate-alerting-rtk-apis.ts`
|
||||
*/
|
||||
|
||||
import { ConfigFile } from '@rtk-query/codegen-openapi';
|
||||
import { accessSync } from 'fs';
|
||||
|
||||
const schemaFile = '../data/alerting/openapi.json';
|
||||
|
||||
try {
|
||||
// Check we have the OpenAPI before generating alerting RTK APIs,
|
||||
// as this is currently a manual process
|
||||
accessSync(schemaFile);
|
||||
} catch (e) {
|
||||
console.error('\nCould not find OpenAPI definition.\n');
|
||||
console.error(
|
||||
'Please visit /openapi/v3/apis/notifications.alerting.grafana.app/v0alpha1 and save the OpenAPI definition to data/alerting/openapi.json\n'
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
|
||||
const config: ConfigFile = {
|
||||
schemaFile,
|
||||
apiFile: '',
|
||||
tag: true,
|
||||
outputFiles: {
|
||||
'../public/app/features/alerting/unified/openapi/timeIntervalsApi.gen.ts': {
|
||||
apiFile: '../public/app/features/alerting/unified/api/alertingApi.ts',
|
||||
apiImport: 'alertingApi',
|
||||
filterEndpoints: ['listTimeIntervalForAllNamespaces'],
|
||||
exportName: 'generatedTimeIntervalsApi',
|
||||
flattenArg: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
Reference in New Issue
Block a user