Skip to content
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
27 changes: 27 additions & 0 deletions packages/clients/src/api/cockpit/v1beta1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
marshalResetGrafanaUserPasswordRequest,
marshalTriggerTestAlertRequest,
unmarshalCockpit,
unmarshalCockpitMetrics,
unmarshalContactPoint,
unmarshalGrafanaUser,
unmarshalListContactPointsResponse,
Expand All @@ -33,6 +34,7 @@ import {
import type {
ActivateCockpitRequest,
Cockpit,
CockpitMetrics,
ContactPoint,
CreateContactPointRequest,
CreateGrafanaUserRequest,
Expand All @@ -43,6 +45,7 @@ import type {
DeleteTokenRequest,
DisableManagedAlertsRequest,
EnableManagedAlertsRequest,
GetCockpitMetricsRequest,
GetCockpitRequest,
GetTokenRequest,
GrafanaUser,
Expand Down Expand Up @@ -127,6 +130,30 @@ export class API extends ParentAPI {
options,
)

/**
* Get cockpit metrics. Get the cockpit metrics with the given project ID.
*
* @param request - The request {@link GetCockpitMetricsRequest}
* @returns A Promise of CockpitMetrics
*/
getCockpitMetrics = (request: Readonly<GetCockpitMetricsRequest> = {}) =>
this.client.fetch<CockpitMetrics>(
{
method: 'GET',
path: `/cockpit/v1beta1/cockpit/metrics`,
urlParams: urlParams(
['end_date', request.endDate],
['metric_name', request.metricName],
[
'project_id',
request.projectId ?? this.client.settings.defaultProjectId,
],
['start_date', request.startDate],
),
},
unmarshalCockpitMetrics,
)

/**
* Deactivate a cockpit. Deactivate a cockpit associated with the given
* project ID.
Expand Down
2 changes: 2 additions & 0 deletions packages/clients/src/api/cockpit/v1beta1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type {
ActivateCockpitRequest,
Cockpit,
CockpitEndpoints,
CockpitMetrics,
CockpitStatus,
ContactPoint,
ContactPointEmail,
Expand All @@ -18,6 +19,7 @@ export type {
DeleteTokenRequest,
DisableManagedAlertsRequest,
EnableManagedAlertsRequest,
GetCockpitMetricsRequest,
GetCockpitRequest,
GetTokenRequest,
GrafanaUser,
Expand Down
14 changes: 14 additions & 0 deletions packages/clients/src/api/cockpit/v1beta1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import {
resolveOneOf,
unmarshalArrayOfObject,
unmarshalDate,
unmarshalTimeSeries,
} from '../../../bridge'
import type { DefaultValues } from '../../../bridge'
import type {
ActivateCockpitRequest,
Cockpit,
CockpitEndpoints,
CockpitMetrics,
ContactPoint,
ContactPointEmail,
CreateContactPointRequest,
Expand Down Expand Up @@ -140,6 +142,18 @@ export const unmarshalCockpit = (data: unknown) => {
} as Cockpit
}

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

return {
timeseries: unmarshalArrayOfObject(data.timeseries, unmarshalTimeSeries),
} as CockpitMetrics
}

export const unmarshalListContactPointsResponse = (data: unknown) => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down
18 changes: 18 additions & 0 deletions packages/clients/src/api/cockpit/v1beta1/types.gen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
import type { TimeSeries } from '../../../bridge'

export type CockpitStatus =
| 'unknown_status'
Expand Down Expand Up @@ -43,6 +44,12 @@ export interface CockpitEndpoints {
grafanaUrl: string
}

/** Cockpit metrics. */
export interface CockpitMetrics {
/** Timeseries array. */
timeseries: TimeSeries[]
}

/** Alert contact point. Contact point. */
export interface ContactPoint {
/**
Expand Down Expand Up @@ -119,6 +126,17 @@ export type GetCockpitRequest = {
projectId?: string
}

export type GetCockpitMetricsRequest = {
/** Project ID. */
projectId?: string
/** Start date. */
startDate?: Date
/** End date. */
endDate?: Date
/** Metric name. */
metricName?: string
}

export type DeactivateCockpitRequest = {
projectId?: string
}
Expand Down