From d94a2d0556f8d3e322253dc163337c37d79d64aa Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Wed, 17 Apr 2024 09:17:05 +0000 Subject: [PATCH 1/2] feat: update generated APIs --- .../clients/src/api/cockpit/v1/api.gen.ts | 833 ++++++++++++++++++ .../clients/src/api/cockpit/v1/index.gen.ts | 62 ++ .../src/api/cockpit/v1/marshalling.gen.ts | 455 ++++++++++ .../clients/src/api/cockpit/v1/types.gen.ts | 603 +++++++++++++ .../api/cockpit/v1/validation-rules.gen.ts | 48 + 5 files changed, 2001 insertions(+) create mode 100644 packages/clients/src/api/cockpit/v1/api.gen.ts create mode 100644 packages/clients/src/api/cockpit/v1/index.gen.ts create mode 100644 packages/clients/src/api/cockpit/v1/marshalling.gen.ts create mode 100644 packages/clients/src/api/cockpit/v1/types.gen.ts create mode 100644 packages/clients/src/api/cockpit/v1/validation-rules.gen.ts diff --git a/packages/clients/src/api/cockpit/v1/api.gen.ts b/packages/clients/src/api/cockpit/v1/api.gen.ts new file mode 100644 index 000000000..e0a22cb34 --- /dev/null +++ b/packages/clients/src/api/cockpit/v1/api.gen.ts @@ -0,0 +1,833 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import { + API as ParentAPI, + enrichForPagination, + urlParams, + validatePathParam, +} from '../../../bridge' +import type { Region } from '../../../bridge' +import { + marshalGlobalApiCreateGrafanaUserRequest, + marshalGlobalApiResetGrafanaUserPasswordRequest, + marshalGlobalApiSelectPlanRequest, + marshalGlobalApiSyncGrafanaDataSourcesRequest, + marshalRegionalApiCreateContactPointRequest, + marshalRegionalApiCreateDataSourceRequest, + marshalRegionalApiCreateTokenRequest, + marshalRegionalApiDeleteContactPointRequest, + marshalRegionalApiDisableAlertManagerRequest, + marshalRegionalApiDisableManagedAlertsRequest, + marshalRegionalApiEnableAlertManagerRequest, + marshalRegionalApiEnableManagedAlertsRequest, + marshalRegionalApiTriggerTestAlertRequest, + unmarshalAlertManager, + unmarshalContactPoint, + unmarshalDataSource, + unmarshalGrafana, + unmarshalGrafanaProductDashboard, + unmarshalGrafanaUser, + unmarshalListContactPointsResponse, + unmarshalListDataSourcesResponse, + unmarshalListGrafanaProductDashboardsResponse, + unmarshalListGrafanaUsersResponse, + unmarshalListPlansResponse, + unmarshalListTokensResponse, + unmarshalPlan, + unmarshalToken, + unmarshalUsageOverview, +} from './marshalling.gen' +import type { + AlertManager, + ContactPoint, + DataSource, + GlobalApiCreateGrafanaUserRequest, + GlobalApiDeleteGrafanaUserRequest, + GlobalApiGetCurrentPlanRequest, + GlobalApiGetGrafanaProductDashboardRequest, + GlobalApiGetGrafanaRequest, + GlobalApiListGrafanaProductDashboardsRequest, + GlobalApiListGrafanaUsersRequest, + GlobalApiListPlansRequest, + GlobalApiResetGrafanaUserPasswordRequest, + GlobalApiSelectPlanRequest, + GlobalApiSyncGrafanaDataSourcesRequest, + Grafana, + GrafanaProductDashboard, + GrafanaUser, + ListContactPointsResponse, + ListDataSourcesResponse, + ListGrafanaProductDashboardsResponse, + ListGrafanaUsersResponse, + ListPlansResponse, + ListTokensResponse, + Plan, + RegionalApiCreateContactPointRequest, + RegionalApiCreateDataSourceRequest, + RegionalApiCreateTokenRequest, + RegionalApiDeleteContactPointRequest, + RegionalApiDeleteDataSourceRequest, + RegionalApiDeleteTokenRequest, + RegionalApiDisableAlertManagerRequest, + RegionalApiDisableManagedAlertsRequest, + RegionalApiEnableAlertManagerRequest, + RegionalApiEnableManagedAlertsRequest, + RegionalApiGetAlertManagerRequest, + RegionalApiGetDataSourceRequest, + RegionalApiGetTokenRequest, + RegionalApiGetUsageOverviewRequest, + RegionalApiListContactPointsRequest, + RegionalApiListDataSourcesRequest, + RegionalApiListTokensRequest, + RegionalApiTriggerTestAlertRequest, + Token, + UsageOverview, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** + * Cockpit Global API. + * + * The Cockpit Global API allows you to manage your Cockpit's Grafana and plans. + */ +export class GlobalAPI extends ParentAPI { + /** + * Get your Cockpit's Grafana. Retrieve information on your Cockpit's Grafana, + * specified by the ID of the Project the Cockpit belongs to. The output + * returned displays the URL to access your Cockpit's Grafana. + * + * @param request - The request {@link GlobalApiGetGrafanaRequest} + * @returns A Promise of Grafana + */ + getGrafana = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/grafana`, + urlParams: urlParams([ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ]), + }, + unmarshalGrafana, + ) + + /** + * Synchronize Grafana data sources. Trigger the synchronization of all your + * data sources and the alert manager in the relevant regions. The alert + * manager will only be synchronized if you have enabled it. + * + * @param request - The request {@link GlobalApiSyncGrafanaDataSourcesRequest} + */ + syncGrafanaDataSources = ( + request: Readonly = {}, + ) => + this.client.fetch({ + body: JSON.stringify( + marshalGlobalApiSyncGrafanaDataSourcesRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1/grafana/sync-data-sources`, + }) + + /** + * Create a Grafana user. Create a Grafana user to connect to your Cockpit's + * Grafana. Upon creation, your user password displays only once, so make sure + * that you save it. Each Grafana user is associated with a role: viewer or + * editor. A viewer can only view dashboards, whereas an editor can create and + * edit dashboards. Note that the `admin` username is not available for + * creation. + * + * @param request - The request {@link GlobalApiCreateGrafanaUserRequest} + * @returns A Promise of GrafanaUser + */ + createGrafanaUser = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalGlobalApiCreateGrafanaUserRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1/grafana/users`, + }, + unmarshalGrafanaUser, + ) + + protected pageOfListGrafanaUsers = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/grafana/users`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ), + }, + unmarshalListGrafanaUsersResponse, + ) + + /** + * List Grafana users. List all Grafana users created in your Cockpit's + * Grafana. By default, the Grafana users returned in the list are ordered in + * ascending order. + * + * @param request - The request {@link GlobalApiListGrafanaUsersRequest} + * @returns A Promise of ListGrafanaUsersResponse + */ + listGrafanaUsers = ( + request: Readonly = {}, + ) => enrichForPagination('grafanaUsers', this.pageOfListGrafanaUsers, request) + + /** + * Delete a Grafana user. Delete a Grafana user from your Cockpit's Grafana, + * specified by the ID of the Project the Cockpit belongs to, and the ID of + * the Grafana user. + * + * @param request - The request {@link GlobalApiDeleteGrafanaUserRequest} + */ + deleteGrafanaUser = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/cockpit/v1/grafana/users/${validatePathParam('grafanaUserId', request.grafanaUserId)}`, + urlParams: urlParams([ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ]), + }) + + /** + * Reset a Grafana user password. Reset the password of a Grafana user, + * specified by the ID of the Project the Cockpit belongs to, and the ID of + * the Grafana user. A new password regenerates and only displays once. Make + * sure that you save it. + * + * @param request - The request + * {@link GlobalApiResetGrafanaUserPasswordRequest} + * @returns A Promise of GrafanaUser + */ + resetGrafanaUserPassword = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalGlobalApiResetGrafanaUserPasswordRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1/grafana/users/${validatePathParam('grafanaUserId', request.grafanaUserId)}/reset-password`, + }, + unmarshalGrafanaUser, + ) + + protected pageOfListGrafanaProductDashboards = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/grafana/product-dashboards`, + urlParams: urlParams( + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ['tags', request.tags], + ), + }, + unmarshalListGrafanaProductDashboardsResponse, + ) + + /** + * List Scaleway resources dashboards. Retrieve a list of available dashboards + * in Grafana, for all Scaleway resources which are integrated with Cockpit. + * + * @param request - The request + * {@link GlobalApiListGrafanaProductDashboardsRequest} + * @returns A Promise of ListGrafanaProductDashboardsResponse + */ + listGrafanaProductDashboards = ( + request: Readonly = {}, + ) => + enrichForPagination( + 'dashboards', + this.pageOfListGrafanaProductDashboards, + request, + ) + + /** + * Get Scaleway resource dashboard. Retrieve information about the dashboard + * of a Scaleway resource in Grafana, specified by the ID of the Project the + * Cockpit belongs to, and the name of the dashboard. + * + * @param request - The request + * {@link GlobalApiGetGrafanaProductDashboardRequest} + * @returns A Promise of GrafanaProductDashboard + */ + getGrafanaProductDashboard = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/grafana/product-dashboards/${validatePathParam('dashboardName', request.dashboardName)}`, + urlParams: urlParams([ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ]), + }, + unmarshalGrafanaProductDashboard, + ) + + protected pageOfListPlans = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/plans`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListPlansResponse, + ) + + /** + * List plan types. Retrieve a list of available pricing plan types. + * + * @param request - The request {@link GlobalApiListPlansRequest} + * @returns A Promise of ListPlansResponse + */ + listPlans = (request: Readonly = {}) => + enrichForPagination('plans', this.pageOfListPlans, request) + + /** + * Apply a pricing plan. Apply a pricing plan on a given Project. You must + * specify the ID of the pricing plan type. Note that you will be billed for + * the plan you apply. + * + * @param request - The request {@link GlobalApiSelectPlanRequest} + * @returns A Promise of Plan + */ + selectPlan = (request: Readonly = {}) => + this.client.fetch( + { + body: JSON.stringify( + marshalGlobalApiSelectPlanRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/cockpit/v1/plans`, + }, + unmarshalPlan, + ) + + /** + * Get current plan. Retrieve a pricing plan for the given Project, specified + * by the ID of the Project. + * + * @param request - The request {@link GlobalApiGetCurrentPlanRequest} + * @returns A Promise of Plan + */ + getCurrentPlan = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/current-plan`, + urlParams: urlParams([ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ]), + }, + unmarshalPlan, + ) +} + +/** + * Cockpit Regional API. + * + * The Cockpit Regional API allows you to create data sources and tokens to + * store and query data types such as metrics, logs, and traces. You can also + * push your data into Cockpit, and send alerts to your contact points when your + * resources may require your attention, using the regional Alert manager. + */ +export class RegionalAPI extends ParentAPI { + /** Lists the available regions of the API. */ + public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw'] + + /** + * Create a data source. You must specify the data source type upon creation. + * Available data source types include: + * + * - Metrics + * - Logs + * - Traces The name of the data source will then be used as reference to name + * the associated Grafana data source. + * + * @param request - The request {@link RegionalApiCreateDataSourceRequest} + * @returns A Promise of DataSource + */ + createDataSource = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalRegionalApiCreateDataSourceRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/data-sources`, + }, + unmarshalDataSource, + ) + + /** + * Get a data source. Retrieve information about a given data source, + * specified by the data source ID. The data source's information such as its + * name, type, URL, origin, and retention period, is returned. + * + * @param request - The request {@link RegionalApiGetDataSourceRequest} + * @returns A Promise of DataSource + */ + getDataSource = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/data-sources/${validatePathParam('dataSourceId', request.dataSourceId)}`, + }, + unmarshalDataSource, + ) + + /** + * Delete a data source. Delete a given data source, specified by the data + * source ID. Note that deleting a data source is irreversible, and cannot be + * undone. + * + * @param request - The request {@link RegionalApiDeleteDataSourceRequest} + */ + deleteDataSource = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/data-sources/${validatePathParam('dataSourceId', request.dataSourceId)}`, + }) + + protected pageOfListDataSources = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/data-sources`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['origin', request.origin], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ['types', request.types], + ), + }, + unmarshalListDataSourcesResponse, + ) + + /** + * List data sources. Retrieve the list of data sources available in the + * specified region. By default, the data sources returned in the list are + * ordered by creation date, in ascending order. You can list data sources by + * Project, type and origin. + * + * @param request - The request {@link RegionalApiListDataSourcesRequest} + * @returns A Promise of ListDataSourcesResponse + */ + listDataSources = ( + request: Readonly = {}, + ) => enrichForPagination('dataSources', this.pageOfListDataSources, request) + + /** + * Get data source usage overview. Retrieve the data source usage overview per + * type for the specified Project. + * + * @param request - The request {@link RegionalApiGetUsageOverviewRequest} + * @returns A Promise of UsageOverview + */ + getUsageOverview = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/usage-overview`, + urlParams: urlParams( + ['interval', request.interval], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ), + }, + unmarshalUsageOverview, + ) + + /** + * Create a token. Give your token the relevant scopes to ensure it has the + * right permissions to interact with your data sources and the Alert manager. + * Make sure that you create your token in the same regions as the data + * sources you want to use it for. Upon creation, your token's secret key + * display only once. Make sure that you save it. + * + * @param request - The request {@link RegionalApiCreateTokenRequest} + * @returns A Promise of Token + */ + createToken = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalRegionalApiCreateTokenRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/tokens`, + }, + unmarshalToken, + ) + + protected pageOfListTokens = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/tokens`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ['token_scopes', request.tokenScopes], + ), + }, + unmarshalListTokensResponse, + ) + + /** + * List tokens. Retrieve a list of all tokens in the specified region. By + * default, tokens returned in the list are ordered by creation date, in + * ascending order. You can filter tokens by Project ID and token scopes. + * + * @param request - The request {@link RegionalApiListTokensRequest} + * @returns A Promise of ListTokensResponse + */ + listTokens = (request: Readonly = {}) => + enrichForPagination('tokens', this.pageOfListTokens, request) + + /** + * Get a token. Retrieve information about a given token, specified by the + * token ID. The token's information such as its scopes, is returned. + * + * @param request - The request {@link RegionalApiGetTokenRequest} + * @returns A Promise of Token + */ + getToken = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/tokens/${validatePathParam('tokenId', request.tokenId)}`, + }, + unmarshalToken, + ) + + /** + * Delete a token. Delete a given token, specified by the token ID. Deleting a + * token is irreversible and cannot be undone. + * + * @param request - The request {@link RegionalApiDeleteTokenRequest} + */ + deleteToken = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/tokens/${validatePathParam('tokenId', request.tokenId)}`, + }) + + /** + * Get the Alert manager. Retrieve information about the Alert manager which + * is unique per Project and region. By default the Alert manager is disabled. + * The output returned displays a URL to access the Alert manager, and whether + * the Alert manager and managed alerts are enabled. + * + * @param request - The request {@link RegionalApiGetAlertManagerRequest} + * @returns A Promise of AlertManager + */ + getAlertManager = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager`, + urlParams: urlParams([ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ]), + }, + unmarshalAlertManager, + ) + + /** + * Enable the Alert manager. Enabling the Alert manager allows you to enable + * managed alerts and create contact points in the specified Project and + * region, to be notified when your Scaleway resources may require your + * attention. + * + * @param request - The request {@link RegionalApiEnableAlertManagerRequest} + * @returns A Promise of AlertManager + */ + enableAlertManager = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalRegionalApiEnableAlertManagerRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/enable`, + }, + unmarshalAlertManager, + ) + + /** + * Disable the Alert manager. Disabling the Alert manager deletes the contact + * points you have created and disables managed alerts in the specified + * Project and region. + * + * @param request - The request {@link RegionalApiDisableAlertManagerRequest} + * @returns A Promise of AlertManager + */ + disableAlertManager = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalRegionalApiDisableAlertManagerRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/disable`, + }, + unmarshalAlertManager, + ) + + /** + * Create a contact point. Contact points are email addresses associated with + * the default receiver, that the Alert manager sends alerts to. The source of + * the alerts are data sources within the same Project and region as the Alert + * manager. If you need to receive alerts for other receivers, you can create + * additional contact points and receivers in Grafana. Make sure that you + * select the Scaleway Alert manager. + * + * @param request - The request {@link RegionalApiCreateContactPointRequest} + * @returns A Promise of ContactPoint + */ + createContactPoint = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalRegionalApiCreateContactPointRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/contact-points`, + }, + unmarshalContactPoint, + ) + + protected pageOfListContactPoints = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/contact-points`, + urlParams: urlParams( + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ), + }, + unmarshalListContactPointsResponse, + ) + + /** + * List contact points. Retrieve a list of contact points for the specified + * Project. The response lists all contact points and receivers created in + * Grafana or via the API. + * + * @param request - The request {@link RegionalApiListContactPointsRequest} + * @returns A Promise of ListContactPointsResponse + */ + listContactPoints = ( + request: Readonly = {}, + ) => + enrichForPagination('contactPoints', this.pageOfListContactPoints, request) + + /** + * Delete a contact point. Delete a contact point associated with the default + * receiver. + * + * @param request - The request {@link RegionalApiDeleteContactPointRequest} + */ + deleteContactPoint = ( + request: Readonly = {}, + ) => + this.client.fetch({ + body: JSON.stringify( + marshalRegionalApiDeleteContactPointRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/contact-points/delete`, + }) + + /** + * Enable managed alerts. Enable the sending of managed alerts for the + * specified Project. Managed alerts are predefined alerts that apply to + * Scaleway recources integrated with Cockpit by default. + * + * @param request - The request {@link RegionalApiEnableManagedAlertsRequest} + * @returns A Promise of AlertManager + */ + enableManagedAlerts = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalRegionalApiEnableManagedAlertsRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/managed-alerts/enable`, + }, + unmarshalAlertManager, + ) + + /** + * Disable managed alerts. Disable the sending of managed alerts for the + * specified Project. + * + * @param request - The request {@link RegionalApiDisableManagedAlertsRequest} + * @returns A Promise of AlertManager + */ + disableManagedAlerts = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalRegionalApiDisableManagedAlertsRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/managed-alerts/disable`, + }, + unmarshalAlertManager, + ) + + /** + * Trigger a test alert. Send a test alert to the Alert manager to make sure + * your contact points get notified. + * + * @param request - The request {@link RegionalApiTriggerTestAlertRequest} + */ + triggerTestAlert = ( + request: Readonly = {}, + ) => + this.client.fetch({ + body: JSON.stringify( + marshalRegionalApiTriggerTestAlertRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/alert-manager/trigger-test-alert`, + }) +} diff --git a/packages/clients/src/api/cockpit/v1/index.gen.ts b/packages/clients/src/api/cockpit/v1/index.gen.ts new file mode 100644 index 000000000..40c7c709c --- /dev/null +++ b/packages/clients/src/api/cockpit/v1/index.gen.ts @@ -0,0 +1,62 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +export { GlobalAPI, RegionalAPI } from './api.gen' +export type { + AlertManager, + ContactPoint, + ContactPointEmail, + DataSource, + DataSourceOrigin, + DataSourceType, + GlobalApiCreateGrafanaUserRequest, + GlobalApiDeleteGrafanaUserRequest, + GlobalApiGetCurrentPlanRequest, + GlobalApiGetGrafanaProductDashboardRequest, + GlobalApiGetGrafanaRequest, + GlobalApiListGrafanaProductDashboardsRequest, + GlobalApiListGrafanaUsersRequest, + GlobalApiListPlansRequest, + GlobalApiResetGrafanaUserPasswordRequest, + GlobalApiSelectPlanRequest, + GlobalApiSyncGrafanaDataSourcesRequest, + Grafana, + GrafanaProductDashboard, + GrafanaUser, + GrafanaUserRole, + ListContactPointsResponse, + ListDataSourcesRequestOrderBy, + ListDataSourcesResponse, + ListGrafanaProductDashboardsResponse, + ListGrafanaUsersRequestOrderBy, + ListGrafanaUsersResponse, + ListPlansRequestOrderBy, + ListPlansResponse, + ListTokensRequestOrderBy, + ListTokensResponse, + Plan, + PlanName, + RegionalApiCreateContactPointRequest, + RegionalApiCreateDataSourceRequest, + RegionalApiCreateTokenRequest, + RegionalApiDeleteContactPointRequest, + RegionalApiDeleteDataSourceRequest, + RegionalApiDeleteTokenRequest, + RegionalApiDisableAlertManagerRequest, + RegionalApiDisableManagedAlertsRequest, + RegionalApiEnableAlertManagerRequest, + RegionalApiEnableManagedAlertsRequest, + RegionalApiGetAlertManagerRequest, + RegionalApiGetDataSourceRequest, + RegionalApiGetTokenRequest, + RegionalApiGetUsageOverviewRequest, + RegionalApiListContactPointsRequest, + RegionalApiListDataSourcesRequest, + RegionalApiListTokensRequest, + RegionalApiTriggerTestAlertRequest, + Token, + TokenScope, + Usage, + UsageOverview, + UsageUnit, +} from './types.gen' +export * as ValidationRules from './validation-rules.gen' diff --git a/packages/clients/src/api/cockpit/v1/marshalling.gen.ts b/packages/clients/src/api/cockpit/v1/marshalling.gen.ts new file mode 100644 index 000000000..22b20825e --- /dev/null +++ b/packages/clients/src/api/cockpit/v1/marshalling.gen.ts @@ -0,0 +1,455 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import { + isJSONObject, + resolveOneOf, + unmarshalArrayOfObject, + unmarshalDate, +} from '../../../bridge' +import type { DefaultValues } from '../../../bridge' +import type { + AlertManager, + ContactPoint, + ContactPointEmail, + DataSource, + GlobalApiCreateGrafanaUserRequest, + GlobalApiResetGrafanaUserPasswordRequest, + GlobalApiSelectPlanRequest, + GlobalApiSyncGrafanaDataSourcesRequest, + Grafana, + GrafanaProductDashboard, + GrafanaUser, + ListContactPointsResponse, + ListDataSourcesResponse, + ListGrafanaProductDashboardsResponse, + ListGrafanaUsersResponse, + ListPlansResponse, + ListTokensResponse, + Plan, + RegionalApiCreateContactPointRequest, + RegionalApiCreateDataSourceRequest, + RegionalApiCreateTokenRequest, + RegionalApiDeleteContactPointRequest, + RegionalApiDisableAlertManagerRequest, + RegionalApiDisableManagedAlertsRequest, + RegionalApiEnableAlertManagerRequest, + RegionalApiEnableManagedAlertsRequest, + RegionalApiTriggerTestAlertRequest, + Token, + Usage, + UsageOverview, +} from './types.gen' + +const unmarshalContactPointEmail = (data: unknown): ContactPointEmail => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ContactPointEmail' failed as data isn't a dictionary.`, + ) + } + + return { + to: data.to, + } as ContactPointEmail +} + +export const unmarshalContactPoint = (data: unknown): ContactPoint => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ContactPoint' failed as data isn't a dictionary.`, + ) + } + + return { + email: data.email ? unmarshalContactPointEmail(data.email) : undefined, + region: data.region, + } as ContactPoint +} + +export const unmarshalDataSource = (data: unknown): DataSource => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'DataSource' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + id: data.id, + name: data.name, + origin: data.origin, + projectId: data.project_id, + region: data.region, + synchronizedWithGrafana: data.synchronized_with_grafana, + type: data.type, + updatedAt: unmarshalDate(data.updated_at), + url: data.url, + } as DataSource +} + +export const unmarshalGrafanaProductDashboard = ( + data: unknown, +): GrafanaProductDashboard => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'GrafanaProductDashboard' failed as data isn't a dictionary.`, + ) + } + + return { + name: data.name, + tags: data.tags, + title: data.title, + url: data.url, + variables: data.variables, + } as GrafanaProductDashboard +} + +export const unmarshalGrafanaUser = (data: unknown): GrafanaUser => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'GrafanaUser' failed as data isn't a dictionary.`, + ) + } + + return { + id: data.id, + login: data.login, + password: data.password, + role: data.role, + } as GrafanaUser +} + +export const unmarshalPlan = (data: unknown): Plan => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Plan' failed as data isn't a dictionary.`, + ) + } + + return { + logsIngestionPrice: data.logs_ingestion_price, + monthlyPrice: data.monthly_price, + name: data.name, + retentionLogsInterval: data.retention_logs_interval, + retentionMetricsInterval: data.retention_metrics_interval, + retentionTracesInterval: data.retention_traces_interval, + sampleIngestionPrice: data.sample_ingestion_price, + tracesIngestionPrice: data.traces_ingestion_price, + } as Plan +} + +export const unmarshalToken = (data: unknown): Token => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Token' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + id: data.id, + name: data.name, + projectId: data.project_id, + region: data.region, + scopes: data.scopes, + secretKey: data.secret_key, + updatedAt: unmarshalDate(data.updated_at), + } as Token +} + +export const unmarshalAlertManager = (data: unknown): AlertManager => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'AlertManager' failed as data isn't a dictionary.`, + ) + } + + return { + alertManagerEnabled: data.alert_manager_enabled, + alertManagerUrl: data.alert_manager_url, + managedAlertsEnabled: data.managed_alerts_enabled, + region: data.region, + } as AlertManager +} + +export const unmarshalGrafana = (data: unknown): Grafana => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Grafana' failed as data isn't a dictionary.`, + ) + } + + return { + grafanaUrl: data.grafana_url, + } as Grafana +} + +export const unmarshalListContactPointsResponse = ( + data: unknown, +): ListContactPointsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListContactPointsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + contactPoints: unmarshalArrayOfObject( + data.contact_points, + unmarshalContactPoint, + ), + hasAdditionalContactPoints: data.has_additional_contact_points, + hasAdditionalReceivers: data.has_additional_receivers, + totalCount: data.total_count, + } as ListContactPointsResponse +} + +export const unmarshalListDataSourcesResponse = ( + data: unknown, +): ListDataSourcesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListDataSourcesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + dataSources: unmarshalArrayOfObject(data.data_sources, unmarshalDataSource), + totalCount: data.total_count, + } as ListDataSourcesResponse +} + +export const unmarshalListGrafanaProductDashboardsResponse = ( + data: unknown, +): ListGrafanaProductDashboardsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListGrafanaProductDashboardsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + dashboards: unmarshalArrayOfObject( + data.dashboards, + unmarshalGrafanaProductDashboard, + ), + totalCount: data.total_count, + } as ListGrafanaProductDashboardsResponse +} + +export const unmarshalListGrafanaUsersResponse = ( + data: unknown, +): ListGrafanaUsersResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListGrafanaUsersResponse' failed as data isn't a dictionary.`, + ) + } + + return { + grafanaUsers: unmarshalArrayOfObject( + data.grafana_users, + unmarshalGrafanaUser, + ), + totalCount: data.total_count, + } as ListGrafanaUsersResponse +} + +export const unmarshalListPlansResponse = ( + data: unknown, +): ListPlansResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListPlansResponse' failed as data isn't a dictionary.`, + ) + } + + return { + plans: unmarshalArrayOfObject(data.plans, unmarshalPlan), + totalCount: data.total_count, + } as ListPlansResponse +} + +export const unmarshalListTokensResponse = ( + data: unknown, +): ListTokensResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListTokensResponse' failed as data isn't a dictionary.`, + ) + } + + return { + tokens: unmarshalArrayOfObject(data.tokens, unmarshalToken), + totalCount: data.total_count, + } as ListTokensResponse +} + +const unmarshalUsage = (data: unknown): Usage => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Usage' failed as data isn't a dictionary.`, + ) + } + + return { + dataSourceId: data.data_source_id, + dataSourceOrigin: data.data_source_origin, + dataSourceType: data.data_source_type, + interval: data.interval, + projectId: data.project_id, + quantityOverInterval: data.quantity_over_interval, + region: data.region, + unit: data.unit, + } as Usage +} + +export const unmarshalUsageOverview = (data: unknown): UsageOverview => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'UsageOverview' failed as data isn't a dictionary.`, + ) + } + + return { + externalLogsUsage: data.external_logs_usage + ? unmarshalUsage(data.external_logs_usage) + : undefined, + externalMetricsUsage: data.external_metrics_usage + ? unmarshalUsage(data.external_metrics_usage) + : undefined, + externalTracesUsage: data.external_traces_usage + ? unmarshalUsage(data.external_traces_usage) + : undefined, + scalewayLogsUsage: data.scaleway_logs_usage + ? unmarshalUsage(data.scaleway_logs_usage) + : undefined, + scalewayMetricsUsage: data.scaleway_metrics_usage + ? unmarshalUsage(data.scaleway_metrics_usage) + : undefined, + } as UsageOverview +} + +export const marshalGlobalApiCreateGrafanaUserRequest = ( + request: GlobalApiCreateGrafanaUserRequest, + defaults: DefaultValues, +): Record => ({ + login: request.login, + project_id: request.projectId ?? defaults.defaultProjectId, + role: request.role, +}) + +export const marshalGlobalApiResetGrafanaUserPasswordRequest = ( + request: GlobalApiResetGrafanaUserPasswordRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalGlobalApiSelectPlanRequest = ( + request: GlobalApiSelectPlanRequest, + defaults: DefaultValues, +): Record => ({ + plan_name: request.planName, + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalGlobalApiSyncGrafanaDataSourcesRequest = ( + request: GlobalApiSyncGrafanaDataSourcesRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +const marshalContactPointEmail = ( + request: ContactPointEmail, + defaults: DefaultValues, +): Record => ({ + to: request.to, +}) + +export const marshalRegionalApiCreateContactPointRequest = ( + request: RegionalApiCreateContactPointRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, + ...resolveOneOf([ + { + param: 'email', + value: + request.email !== undefined + ? marshalContactPointEmail(request.email, defaults) + : undefined, + }, + ]), +}) + +export const marshalRegionalApiCreateDataSourceRequest = ( + request: RegionalApiCreateDataSourceRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + project_id: request.projectId ?? defaults.defaultProjectId, + type: request.type, +}) + +export const marshalRegionalApiCreateTokenRequest = ( + request: RegionalApiCreateTokenRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + project_id: request.projectId ?? defaults.defaultProjectId, + token_scopes: + request.tokenScopes !== undefined ? request.tokenScopes : undefined, +}) + +export const marshalRegionalApiDeleteContactPointRequest = ( + request: RegionalApiDeleteContactPointRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, + ...resolveOneOf([ + { + param: 'email', + value: + request.email !== undefined + ? marshalContactPointEmail(request.email, defaults) + : undefined, + }, + ]), +}) + +export const marshalRegionalApiDisableAlertManagerRequest = ( + request: RegionalApiDisableAlertManagerRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalRegionalApiDisableManagedAlertsRequest = ( + request: RegionalApiDisableManagedAlertsRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalRegionalApiEnableAlertManagerRequest = ( + request: RegionalApiEnableAlertManagerRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalRegionalApiEnableManagedAlertsRequest = ( + request: RegionalApiEnableManagedAlertsRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalRegionalApiTriggerTestAlertRequest = ( + request: RegionalApiTriggerTestAlertRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) diff --git a/packages/clients/src/api/cockpit/v1/types.gen.ts b/packages/clients/src/api/cockpit/v1/types.gen.ts new file mode 100644 index 000000000..cb06e31d9 --- /dev/null +++ b/packages/clients/src/api/cockpit/v1/types.gen.ts @@ -0,0 +1,603 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { Region } from '../../../bridge' + +export type DataSourceOrigin = 'unknown_origin' | 'scaleway' | 'external' + +export type DataSourceType = 'unknown_type' | 'metrics' | 'logs' | 'traces' + +export type GrafanaUserRole = 'unknown_role' | 'editor' | 'viewer' + +export type ListDataSourcesRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + | 'type_asc' + | 'type_desc' + +export type ListGrafanaUsersRequestOrderBy = 'login_asc' | 'login_desc' + +export type ListPlansRequestOrderBy = 'name_asc' | 'name_desc' + +export type ListTokensRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + +export type PlanName = 'unknown_name' | 'free' | 'premium' | 'custom' + +export type TokenScope = + | 'unknown_scope' + | 'read_only_metrics' + | 'write_only_metrics' + | 'full_access_metrics_rules' + | 'read_only_logs' + | 'write_only_logs' + | 'full_access_logs_rules' + | 'full_access_alert_manager' + | 'read_only_traces' + | 'write_only_traces' + +export type UsageUnit = 'unknown_unit' | 'bytes' | 'samples' + +export interface ContactPointEmail { + to: string +} + +/** Contact point. */ +export interface ContactPoint { + /** + * Email address to send alerts to. + * + * One-of ('configuration'): at most one of 'email' could be set. + */ + email?: ContactPointEmail + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region: Region +} + +/** Data source. */ +export interface DataSource { + /** ID of the data source. */ + id: string + /** ID of the Project the data source belongs to. */ + projectId: string + /** Data source name. */ + name: string + /** Data source URL. */ + url: string + /** Data source type. */ + type: DataSourceType + /** Data source origin. */ + origin: DataSourceOrigin + /** Date the data source was created. */ + createdAt?: Date + /** Date the data source was last updated. */ + updatedAt?: Date + /** Indicates whether the data source is synchronized with Grafana. */ + synchronizedWithGrafana: boolean + /** Region of the data source. */ + region: Region +} + +/** Grafana dashboard. */ +export interface GrafanaProductDashboard { + /** Dashboard name. */ + name: string + /** Dashboard title. */ + title: string + /** Dashboard URL. */ + url: string + /** Dashboard tags. */ + tags: string[] + /** Dashboard variables. */ + variables: string[] +} + +/** Grafana user. */ +export interface GrafanaUser { + /** ID of the Grafana user. */ + id: number + /** Username of the Grafana user. */ + login: string + /** Role assigned to the Grafana user. */ + role: GrafanaUserRole + /** Grafana user's password. */ + password?: string +} + +/** Type of pricing plan. */ +export interface Plan { + /** Name of a given pricing plan. */ + name: PlanName + /** Interval of time during which Scaleway's Cockpit keeps your metrics. */ + retentionMetricsInterval?: string + /** Interval of time during which Scaleway's Cockpit keeps your logs. */ + retentionLogsInterval?: string + /** Interval of time during which Scaleway's Cockpit keeps your traces. */ + retentionTracesInterval?: string + /** Ingestion price in cents for 1 million samples. */ + sampleIngestionPrice: number + /** Ingestion price in cents for 1 GB of logs. */ + logsIngestionPrice: number + /** Ingestion price in cents for 1 GB of traces. */ + tracesIngestionPrice: number + /** Retention price in euros per month. */ + monthlyPrice: number +} + +/** Token. */ +export interface Token { + /** ID of the token. */ + id: string + /** ID of the Project the token belongs to. */ + projectId: string + /** Name of the token. */ + name: string + /** Token creation date. */ + createdAt?: Date + /** Token last modification date. */ + updatedAt?: Date + /** Token permission scopes. */ + scopes: TokenScope[] + /** Token secret key. */ + secretKey?: string + /** Regions where the token is located. */ + region: Region +} + +/** Data source usage. */ +export interface Usage { + /** ID of the data source. */ + dataSourceId?: string + /** ID of the Project the data source belongs to. */ + projectId: string + /** Origin of the data source. */ + dataSourceOrigin: DataSourceOrigin + /** Type of the data source. */ + dataSourceType: DataSourceType + /** Unit of the data source usage. */ + unit: UsageUnit + /** Interval for the data source usage. */ + interval?: string + /** Data source usage for the given interval. */ + quantityOverInterval: number + /** Region of the data source usage. */ + region: Region +} + +/** Alert manager information. */ +export interface AlertManager { + /** Alert manager URL. */ + alertManagerUrl?: string + /** The Alert manager is enabled. */ + alertManagerEnabled: boolean + /** Managed alerts are enabled. */ + managedAlertsEnabled: boolean + /** Regions where the Alert manager is enabled. */ + region: Region +} + +/** Create a Grafana user. */ +export type GlobalApiCreateGrafanaUserRequest = { + /** ID of the Project in which to create the Grafana user. */ + projectId?: string + /** + * Username of the Grafana user. Note that the `admin` username is not + * available for creation. + */ + login: string + /** Role assigned to the Grafana user. */ + role?: GrafanaUserRole +} + +/** Delete a Grafana user. */ +export type GlobalApiDeleteGrafanaUserRequest = { + /** ID of the Grafana user. */ + grafanaUserId: number + /** ID of the Project to target. */ + projectId?: string +} + +/** Retrieve a pricing plan for the given Project. */ +export type GlobalApiGetCurrentPlanRequest = { + /** ID of the Project. */ + projectId?: string +} + +/** Retrieve a specific dashboard. */ +export type GlobalApiGetGrafanaProductDashboardRequest = { + /** Name of the dashboard. */ + dashboardName: string + /** ID of the Project the dashboard belongs to. */ + projectId?: string +} + +/** Request a Grafana. */ +export type GlobalApiGetGrafanaRequest = { + /** ID of the Project. */ + projectId?: string +} + +/** Retrieve a list of available product dashboards. */ +export type GlobalApiListGrafanaProductDashboardsRequest = { + /** ID of the Project to target. */ + projectId?: string + /** Page number. */ + page?: number + /** Page size. */ + pageSize?: number + /** Tags to filter for. */ + tags?: string[] +} + +/** List all Grafana users. */ +export type GlobalApiListGrafanaUsersRequest = { + /** Page number. */ + page?: number + /** Page size. */ + pageSize?: number + /** Order of the Grafana users. */ + orderBy?: ListGrafanaUsersRequestOrderBy + /** ID of the Project to target. */ + projectId?: string +} + +/** Retrieve a list of available pricing plans. */ +export type GlobalApiListPlansRequest = { + /** Page number. */ + page?: number + /** Page size. */ + pageSize?: number + orderBy?: ListPlansRequestOrderBy +} + +/** Reset a Grafana user's password. */ +export type GlobalApiResetGrafanaUserPasswordRequest = { + /** ID of the Grafana user. */ + grafanaUserId: number + /** ID of the Project to target. */ + projectId?: string +} + +/** Select a specific pricing plan. */ +export type GlobalApiSelectPlanRequest = { + /** ID of the Project. */ + projectId?: string + /** Name of the pricing plan. */ + planName?: PlanName +} + +/** + * Trigger the synchronization of all data sources created in the relevant + * regions. + */ +export type GlobalApiSyncGrafanaDataSourcesRequest = { + /** ID of the Project to target. */ + projectId?: string +} + +/** Grafana user. */ +export interface Grafana { + /** URL to access your Cockpit's Grafana. */ + grafanaUrl: string +} + +/** Response returned when listing contact points. */ +export interface ListContactPointsResponse { + /** Total count of contact points associated with the default receiver. */ + totalCount: number + /** List of contact points associated with the default receiver. */ + contactPoints: ContactPoint[] + /** + * Indicates whether the Alert manager has other receivers than the default + * one. + */ + hasAdditionalReceivers: boolean + /** + * Indicates whether there are unmanaged contact points on the default + * receiver. + */ + hasAdditionalContactPoints: boolean +} + +/** Response returned when listing data sources. */ +export interface ListDataSourcesResponse { + /** Total count of data sources matching the request. */ + totalCount: number + /** Data sources matching the request within the pagination. */ + dataSources: DataSource[] +} + +/** Output returned when listing dashboards. */ +export interface ListGrafanaProductDashboardsResponse { + /** Total count of Grafana dashboards. */ + totalCount: number + /** Grafana dashboards information. */ + dashboards: GrafanaProductDashboard[] +} + +/** Ouptut returned when listing Grafana users. */ +export interface ListGrafanaUsersResponse { + /** Total count of Grafana users. */ + totalCount: number + /** Grafana users information. */ + grafanaUsers: GrafanaUser[] +} + +/** Output returned when listing pricing plans. */ +export interface ListPlansResponse { + /** Total count of available pricing plans. */ + totalCount: number + /** Plan types information. */ + plans: Plan[] +} + +/** Response returned when listing tokens. */ +export interface ListTokensResponse { + /** Total count of tokens matching the request. */ + totalCount: number + /** Tokens matching the request within the pagination. */ + tokens: Token[] +} + +/** Create a contact point. */ +export type RegionalApiCreateContactPointRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the Project to create the contact point in. */ + projectId?: string + /** + * Email address of the contact point to create. + * + * One-of ('configuration'): at most one of 'email' could be set. + */ + email?: ContactPointEmail +} + +/** Create a data source. */ +export type RegionalApiCreateDataSourceRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the Project the data source belongs to. */ + projectId?: string + /** Data source name. */ + name: string + /** Data source type. */ + type?: DataSourceType +} + +/** Create a token. */ +export type RegionalApiCreateTokenRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the Project the token belongs to. */ + projectId?: string + /** Name of the token. */ + name: string + /** Token permission scopes. */ + tokenScopes?: TokenScope[] +} + +/** Delete a contact point. */ +export type RegionalApiDeleteContactPointRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the Project containing the contact point to delete. */ + projectId?: string + /** + * Email address of the contact point to delete. + * + * One-of ('configuration'): at most one of 'email' could be set. + */ + email?: ContactPointEmail +} + +/** Delete a data source. */ +export type RegionalApiDeleteDataSourceRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the data source to delete. */ + dataSourceId: string +} + +/** Delete a token. */ +export type RegionalApiDeleteTokenRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the token to delete. */ + tokenId: string +} + +/** Disable the Alert manager. */ +export type RegionalApiDisableAlertManagerRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the Project to disable the Alert manager in. */ + projectId?: string +} + +/** Disable the sending of managed alerts. */ +export type RegionalApiDisableManagedAlertsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the Project. */ + projectId?: string +} + +/** Enable the Alert manager. */ +export type RegionalApiEnableAlertManagerRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the Project to enable the Alert manager in. */ + projectId?: string +} + +/** Enable the sending of managed alerts. */ +export type RegionalApiEnableManagedAlertsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the Project. */ + projectId?: string +} + +/** Get the Alert manager. */ +export type RegionalApiGetAlertManagerRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Project ID of the requested Alert manager. */ + projectId?: string +} + +/** Retrieve a data source. */ +export type RegionalApiGetDataSourceRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the relevant data source. */ + dataSourceId: string +} + +/** Get a token. */ +export type RegionalApiGetTokenRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Token ID. */ + tokenId: string +} + +export type RegionalApiGetUsageOverviewRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + projectId?: string + interval?: string +} + +/** List contact points. */ +export type RegionalApiListContactPointsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Page number to return, from the paginated results. */ + page?: number + /** Total count of contact points to return per page. */ + pageSize?: number + /** ID of the Project containing the contact points to list. */ + projectId?: string +} + +/** List data sources. */ +export type RegionalApiListDataSourcesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Page number to return, from the paginated results. */ + page?: number + /** Number of data sources to return per page. */ + pageSize?: number + /** Sort order for data sources in the response. */ + orderBy?: ListDataSourcesRequestOrderBy + /** + * Project ID to filter for, only data sources from this Project will be + * returned. + */ + projectId?: string + /** + * Origin to filter for, only data sources with matching origin will be + * returned. + */ + origin?: DataSourceOrigin + /** + * Types to filter for, only data sources with matching types will be + * returned. + */ + types?: DataSourceType[] +} + +/** List tokens. */ +export type RegionalApiListTokensRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Page number to return, from the paginated results. */ + page?: number + /** Number of tokens to return per page. */ + pageSize?: number + /** Order in which to return results. */ + orderBy?: ListTokensRequestOrderBy + /** ID of the Project the tokens belong to. */ + projectId?: string + /** Token scopes to filter for. */ + tokenScopes?: TokenScope[] +} + +/** Request to trigger a test alert. */ +export type RegionalApiTriggerTestAlertRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the Project. */ + projectId?: string +} + +export interface UsageOverview { + scalewayMetricsUsage?: Usage + scalewayLogsUsage?: Usage + externalMetricsUsage?: Usage + externalLogsUsage?: Usage + externalTracesUsage?: Usage +} diff --git a/packages/clients/src/api/cockpit/v1/validation-rules.gen.ts b/packages/clients/src/api/cockpit/v1/validation-rules.gen.ts new file mode 100644 index 000000000..5ba618da7 --- /dev/null +++ b/packages/clients/src/api/cockpit/v1/validation-rules.gen.ts @@ -0,0 +1,48 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +export const RegionalApiCreateDataSourceRequest = { + name: { + maxLength: 50, + minLength: 3, + pattern: /^[A-Za-z0-9-_. ]+$/, + }, +} + +export const RegionalApiCreateTokenRequest = { + name: { + maxLength: 50, + minLength: 3, + pattern: /^[A-Za-z0-9-_]+$/, + }, +} + +export const RegionalApiListContactPointsRequest = { + page: { + greaterThanOrEqual: 1, + }, + pageSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 1000, + }, +} + +export const RegionalApiListDataSourcesRequest = { + page: { + greaterThanOrEqual: 1, + }, + pageSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 1000, + }, +} + +export const RegionalApiListTokensRequest = { + page: { + greaterThanOrEqual: 1, + }, + pageSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 1000, + }, +} From 233b4568b1bf1655a3e2f7e76e655f057d0e33e4 Mon Sep 17 00:00:00 2001 From: Yacine FODIL Date: Wed, 17 Apr 2024 11:23:53 +0200 Subject: [PATCH 2/2] update index.ts --- packages/clients/src/api/cockpit/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/clients/src/api/cockpit/index.ts b/packages/clients/src/api/cockpit/index.ts index 1984b471f..95a18d773 100644 --- a/packages/clients/src/api/cockpit/index.ts +++ b/packages/clients/src/api/cockpit/index.ts @@ -1 +1,2 @@ +export * as v1 from './v1/index.gen' export * as v1beta1 from './v1beta1/index.gen'