mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Cloudwatch: Use generated TS types (#63166)
* Add veneer * Fix queries * Remove redundant type * Fix todos * Sync and fix some todos * Revert unrelated changes * Revert unrelated changes[2] * Revert unrelated changes[3]
This commit is contained in:
@@ -54,7 +54,6 @@ const (
|
||||
// Defines values for CloudWatchMetricsQuerySqlFromPropertyType.
|
||||
const (
|
||||
CloudWatchMetricsQuerySqlFromPropertyTypeString CloudWatchMetricsQuerySqlFromPropertyType = "string"
|
||||
CloudWatchMetricsQuerySqlFromPropertyTypeTest CloudWatchMetricsQuerySqlFromPropertyType = "test"
|
||||
)
|
||||
|
||||
// Defines values for CloudWatchMetricsQuerySqlGroupByType.
|
||||
@@ -114,6 +113,16 @@ const (
|
||||
QueryEditorArrayExpressionTypeOr QueryEditorArrayExpressionType = "or"
|
||||
)
|
||||
|
||||
// Defines values for QueryEditorExpressionParametersType.
|
||||
const (
|
||||
QueryEditorExpressionParametersTypeFunctionParameter QueryEditorExpressionParametersType = "functionParameter"
|
||||
)
|
||||
|
||||
// Defines values for QueryEditorExpressionPropertyType.
|
||||
const (
|
||||
QueryEditorExpressionPropertyTypeString QueryEditorExpressionPropertyType = "string"
|
||||
)
|
||||
|
||||
// Defines values for QueryEditorExpressionType.
|
||||
const (
|
||||
QueryEditorExpressionTypeAnd QueryEditorExpressionType = "and"
|
||||
@@ -143,7 +152,6 @@ const (
|
||||
// Defines values for QueryEditorGroupByExpressionPropertyType.
|
||||
const (
|
||||
QueryEditorGroupByExpressionPropertyTypeString QueryEditorGroupByExpressionPropertyType = "string"
|
||||
QueryEditorGroupByExpressionPropertyTypeTest QueryEditorGroupByExpressionPropertyType = "test"
|
||||
)
|
||||
|
||||
// Defines values for QueryEditorGroupByExpressionType.
|
||||
@@ -154,7 +162,6 @@ const (
|
||||
// Defines values for QueryEditorOperatorExpressionPropertyType.
|
||||
const (
|
||||
QueryEditorOperatorExpressionPropertyTypeString QueryEditorOperatorExpressionPropertyType = "string"
|
||||
QueryEditorOperatorExpressionPropertyTypeTest QueryEditorOperatorExpressionPropertyType = "test"
|
||||
)
|
||||
|
||||
// Defines values for QueryEditorOperatorExpressionType.
|
||||
@@ -165,13 +172,11 @@ const (
|
||||
// Defines values for QueryEditorPropertyType.
|
||||
const (
|
||||
QueryEditorPropertyTypeString QueryEditorPropertyType = "string"
|
||||
QueryEditorPropertyTypeTest QueryEditorPropertyType = "test"
|
||||
)
|
||||
|
||||
// Defines values for QueryEditorPropertyExpressionPropertyType.
|
||||
const (
|
||||
QueryEditorPropertyExpressionPropertyTypeString QueryEditorPropertyExpressionPropertyType = "string"
|
||||
QueryEditorPropertyExpressionPropertyTypeTest QueryEditorPropertyExpressionPropertyType = "test"
|
||||
)
|
||||
|
||||
// Defines values for QueryEditorPropertyExpressionType.
|
||||
@@ -187,7 +192,6 @@ const (
|
||||
// Defines values for SQLExpressionFromPropertyType.
|
||||
const (
|
||||
SQLExpressionFromPropertyTypeString SQLExpressionFromPropertyType = "string"
|
||||
SQLExpressionFromPropertyTypeTest SQLExpressionFromPropertyType = "test"
|
||||
)
|
||||
|
||||
// Defines values for SQLExpressionGroupByType.
|
||||
@@ -224,18 +228,37 @@ const (
|
||||
|
||||
// CloudWatchAnnotationQuery defines model for CloudWatchAnnotationQuery.
|
||||
type CloudWatchAnnotationQuery struct {
|
||||
AccountId *string `json:"accountId,omitempty"`
|
||||
ActionPrefix *string `json:"actionPrefix,omitempty"`
|
||||
AlarmNamePrefix *string `json:"alarmNamePrefix,omitempty"`
|
||||
Dimensions map[string]interface{} `json:"dimensions,omitempty"`
|
||||
MatchExact *bool `json:"matchExact,omitempty"`
|
||||
MetricName *string `json:"metricName,omitempty"`
|
||||
Namespace string `json:"namespace"`
|
||||
Period *string `json:"period,omitempty"`
|
||||
PrefixMatching *bool `json:"prefixMatching,omitempty"`
|
||||
QueryMode CloudWatchAnnotationQueryQueryMode `json:"queryMode"`
|
||||
Region string `json:"region"`
|
||||
Statistic *string `json:"statistic,omitempty"`
|
||||
AccountId *string `json:"accountId,omitempty"`
|
||||
ActionPrefix *string `json:"actionPrefix,omitempty"`
|
||||
AlarmNamePrefix *string `json:"alarmNamePrefix,omitempty"`
|
||||
|
||||
// For mixed data sources the selected datasource is on the query level.
|
||||
// For non mixed scenarios this is undefined.
|
||||
// TODO find a better way to do this ^ that's friendly to schema
|
||||
// TODO this shouldn't be unknown but DataSourceRef | null
|
||||
Datasource *interface{} `json:"datasource,omitempty"`
|
||||
Dimensions map[string]interface{} `json:"dimensions,omitempty"`
|
||||
|
||||
// Hide true if query is disabled (ie should not be returned to the dashboard)
|
||||
Hide *bool `json:"hide,omitempty"`
|
||||
|
||||
// Unique, guid like, string used in explore mode
|
||||
Key *string `json:"key,omitempty"`
|
||||
MatchExact *bool `json:"matchExact,omitempty"`
|
||||
MetricName *string `json:"metricName,omitempty"`
|
||||
Namespace string `json:"namespace"`
|
||||
Period *string `json:"period,omitempty"`
|
||||
PrefixMatching *bool `json:"prefixMatching,omitempty"`
|
||||
QueryMode CloudWatchAnnotationQueryQueryMode `json:"queryMode"`
|
||||
|
||||
// Specify the query flavor
|
||||
// TODO make this required and give it a default
|
||||
QueryType *string `json:"queryType,omitempty"`
|
||||
|
||||
// A - Z
|
||||
RefId string `json:"refId"`
|
||||
Region string `json:"region"`
|
||||
Statistic *string `json:"statistic,omitempty"`
|
||||
|
||||
// @deprecated use statistic
|
||||
Statistics []string `json:"statistics,omitempty"`
|
||||
@@ -288,15 +311,27 @@ type CloudWatchLogsQueryQueryMode string
|
||||
|
||||
// CloudWatchMetricsQuery defines model for CloudWatchMetricsQuery.
|
||||
type CloudWatchMetricsQuery struct {
|
||||
AccountId *string `json:"accountId,omitempty"`
|
||||
Alias *string `json:"alias,omitempty"`
|
||||
AccountId *string `json:"accountId,omitempty"`
|
||||
Alias *string `json:"alias,omitempty"`
|
||||
|
||||
// For mixed data sources the selected datasource is on the query level.
|
||||
// For non mixed scenarios this is undefined.
|
||||
// TODO find a better way to do this ^ that's friendly to schema
|
||||
// TODO this shouldn't be unknown but DataSourceRef | null
|
||||
Datasource *interface{} `json:"datasource,omitempty"`
|
||||
Dimensions map[string]interface{} `json:"dimensions,omitempty"`
|
||||
|
||||
// Math expression query
|
||||
Expression *string `json:"expression,omitempty"`
|
||||
|
||||
// Hide true if query is disabled (ie should not be returned to the dashboard)
|
||||
Hide *bool `json:"hide,omitempty"`
|
||||
|
||||
// Id common props
|
||||
Id string `json:"id"`
|
||||
Id string `json:"id"`
|
||||
|
||||
// Unique, guid like, string used in explore mode
|
||||
Key *string `json:"key,omitempty"`
|
||||
Label *string `json:"label,omitempty"`
|
||||
MatchExact *bool `json:"matchExact,omitempty"`
|
||||
MetricEditorMode *CloudWatchMetricsQueryMetricEditorMode `json:"metricEditorMode,omitempty"`
|
||||
@@ -305,14 +340,21 @@ type CloudWatchMetricsQuery struct {
|
||||
Namespace string `json:"namespace"`
|
||||
Period *string `json:"period,omitempty"`
|
||||
QueryMode *CloudWatchMetricsQueryQueryMode `json:"queryMode,omitempty"`
|
||||
Region string `json:"region"`
|
||||
Sql *struct {
|
||||
|
||||
// Specify the query flavor
|
||||
// TODO make this required and give it a default
|
||||
QueryType *string `json:"queryType,omitempty"`
|
||||
|
||||
// A - Z
|
||||
RefId string `json:"refId"`
|
||||
Region string `json:"region"`
|
||||
Sql *struct {
|
||||
From *CloudWatchMetricsQuerySqlFrom `json:"from,omitempty"`
|
||||
GroupBy *struct {
|
||||
// TODO should be QueryEditorExpression[] | QueryEditorArrayExpression[], extend in veneer
|
||||
// TS type expressions: QueryEditorExpression[] | QueryEditorArrayExpression[], extended in veneer
|
||||
Expressions interface{} `json:"expressions"`
|
||||
|
||||
// TODO this doesn't work
|
||||
// TODO this doesn't work; temporarily extended in veneer
|
||||
Type CloudWatchMetricsQuerySqlGroupByType `json:"type"`
|
||||
} `json:"groupBy,omitempty"`
|
||||
Limit *int64 `json:"limit,omitempty"`
|
||||
@@ -334,10 +376,10 @@ type CloudWatchMetricsQuery struct {
|
||||
Type CloudWatchMetricsQuerySqlSelectType `json:"type"`
|
||||
} `json:"select,omitempty"`
|
||||
Where *struct {
|
||||
// TODO should be QueryEditorExpression[] | QueryEditorArrayExpression[], extend in veneer
|
||||
// TS type expressions: QueryEditorExpression[] | QueryEditorArrayExpression[], extended in veneer
|
||||
Expressions interface{} `json:"expressions"`
|
||||
|
||||
// TODO this doesn't work
|
||||
// TODO this doesn't work; temporarily extended in veneer
|
||||
Type CloudWatchMetricsQuerySqlWhereType `json:"type"`
|
||||
} `json:"where,omitempty"`
|
||||
} `json:"sql,omitempty"`
|
||||
@@ -378,7 +420,7 @@ type CloudWatchMetricsQuerySqlFrom struct {
|
||||
union json.RawMessage
|
||||
}
|
||||
|
||||
// TODO this doesn't work
|
||||
// TODO this doesn't work; temporarily extended in veneer
|
||||
type CloudWatchMetricsQuerySqlGroupByType string
|
||||
|
||||
// CloudWatchMetricsQuerySqlOrderByParametersType defines model for CloudWatchMetricsQuery.Sql.OrderBy.Parameters.Type.
|
||||
@@ -393,7 +435,7 @@ type CloudWatchMetricsQuerySqlSelectParametersType string
|
||||
// CloudWatchMetricsQuerySqlSelectType defines model for CloudWatchMetricsQuery.Sql.Select.Type.
|
||||
type CloudWatchMetricsQuerySqlSelectType string
|
||||
|
||||
// TODO this doesn't work
|
||||
// TODO this doesn't work; temporarily extended in veneer
|
||||
type CloudWatchMetricsQuerySqlWhereType string
|
||||
|
||||
// CloudWatchQueryMode defines model for CloudWatchQueryMode.
|
||||
@@ -433,16 +475,43 @@ type MetricStat struct {
|
||||
|
||||
// QueryEditorArrayExpression defines model for QueryEditorArrayExpression.
|
||||
type QueryEditorArrayExpression struct {
|
||||
// TODO should be QueryEditorExpression[] | QueryEditorArrayExpression[], extend in veneer
|
||||
// TS type expressions: QueryEditorExpression[] | QueryEditorArrayExpression[], extended in veneer
|
||||
Expressions interface{} `json:"expressions"`
|
||||
|
||||
// TODO this doesn't work
|
||||
// TODO this doesn't work; temporarily extended in veneer
|
||||
Type QueryEditorArrayExpressionType `json:"type"`
|
||||
}
|
||||
|
||||
// TODO this doesn't work
|
||||
// TODO this doesn't work; temporarily extended in veneer
|
||||
type QueryEditorArrayExpressionType string
|
||||
|
||||
// QueryEditorArrayExpression is added in veneer
|
||||
type QueryEditorExpression struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
|
||||
// TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer
|
||||
Operator *struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Value *interface{} `json:"value,omitempty"`
|
||||
} `json:"operator,omitempty"`
|
||||
Parameters []struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Type QueryEditorExpressionParametersType `json:"type"`
|
||||
} `json:"parameters,omitempty"`
|
||||
Property *struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Type QueryEditorExpressionPropertyType `json:"type"`
|
||||
} `json:"property,omitempty"`
|
||||
Type *interface{} `json:"type,omitempty"`
|
||||
union json.RawMessage
|
||||
}
|
||||
|
||||
// QueryEditorExpressionParametersType defines model for QueryEditorExpression.Parameters.Type.
|
||||
type QueryEditorExpressionParametersType string
|
||||
|
||||
// QueryEditorExpressionPropertyType defines model for QueryEditorExpression.Property.Type.
|
||||
type QueryEditorExpressionPropertyType string
|
||||
|
||||
// QueryEditorExpressionType defines model for QueryEditorExpressionType.
|
||||
type QueryEditorExpressionType string
|
||||
|
||||
@@ -486,7 +555,7 @@ type QueryEditorGroupByExpressionPropertyType string
|
||||
// QueryEditorGroupByExpressionType defines model for QueryEditorGroupByExpression.Type.
|
||||
type QueryEditorGroupByExpressionType string
|
||||
|
||||
// TODO <T extends QueryEditorOperatorValueType>, extend in veneer
|
||||
// TS type is QueryEditorOperator<T extends QueryEditorOperatorValueType>, extended in veneer
|
||||
type QueryEditorOperator struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Value *interface{} `json:"value,omitempty"`
|
||||
@@ -494,7 +563,7 @@ type QueryEditorOperator struct {
|
||||
|
||||
// QueryEditorOperatorExpression defines model for QueryEditorOperatorExpression.
|
||||
type QueryEditorOperatorExpression struct {
|
||||
// TODO QueryEditorOperator<QueryEditorOperatorValueType>, extend in veneer
|
||||
// TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer
|
||||
Operator struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Value *interface{} `json:"value,omitempty"`
|
||||
@@ -540,10 +609,10 @@ type QueryEditorPropertyExpressionType string
|
||||
type SQLExpression struct {
|
||||
From *SQLExpressionFrom `json:"from,omitempty"`
|
||||
GroupBy *struct {
|
||||
// TODO should be QueryEditorExpression[] | QueryEditorArrayExpression[], extend in veneer
|
||||
// TS type expressions: QueryEditorExpression[] | QueryEditorArrayExpression[], extended in veneer
|
||||
Expressions interface{} `json:"expressions"`
|
||||
|
||||
// TODO this doesn't work
|
||||
// TODO this doesn't work; temporarily extended in veneer
|
||||
Type SQLExpressionGroupByType `json:"type"`
|
||||
} `json:"groupBy,omitempty"`
|
||||
Limit *int64 `json:"limit,omitempty"`
|
||||
@@ -565,10 +634,10 @@ type SQLExpression struct {
|
||||
Type SQLExpressionSelectType `json:"type"`
|
||||
} `json:"select,omitempty"`
|
||||
Where *struct {
|
||||
// TODO should be QueryEditorExpression[] | QueryEditorArrayExpression[], extend in veneer
|
||||
// TS type expressions: QueryEditorExpression[] | QueryEditorArrayExpression[], extended in veneer
|
||||
Expressions interface{} `json:"expressions"`
|
||||
|
||||
// TODO this doesn't work
|
||||
// TODO this doesn't work; temporarily extended in veneer
|
||||
Type SQLExpressionWhereType `json:"type"`
|
||||
} `json:"where,omitempty"`
|
||||
}
|
||||
@@ -594,7 +663,7 @@ type SQLExpressionFrom struct {
|
||||
union json.RawMessage
|
||||
}
|
||||
|
||||
// TODO this doesn't work
|
||||
// TODO this doesn't work; temporarily extended in veneer
|
||||
type SQLExpressionGroupByType string
|
||||
|
||||
// SQLExpressionOrderByParametersType defines model for SQLExpression.OrderBy.Parameters.Type.
|
||||
@@ -609,5 +678,5 @@ type SQLExpressionSelectParametersType string
|
||||
// SQLExpressionSelectType defines model for SQLExpression.Select.Type.
|
||||
type SQLExpressionSelectType string
|
||||
|
||||
// TODO this doesn't work
|
||||
// TODO this doesn't work; temporarily extended in veneer
|
||||
type SQLExpressionWhereType string
|
||||
|
||||
@@ -46,21 +46,17 @@ composableKinds: DataQuery: {
|
||||
#Dimensions: {[string]: string | [...string]} @cuetsy(kind="type")
|
||||
|
||||
#CloudWatchMetricsQuery: {
|
||||
// TODO extend common.DataQuery when the issues with redundant fields is fixed
|
||||
// common.DataQuery
|
||||
common.DataQuery
|
||||
#MetricStat
|
||||
queryMode?: #CloudWatchQueryMode
|
||||
metricQueryType?: #MetricQueryType
|
||||
metricEditorMode?: #MetricEditorMode
|
||||
// common props
|
||||
id: string
|
||||
|
||||
id: string
|
||||
alias?: string
|
||||
label?: string
|
||||
|
||||
// Math expression query
|
||||
expression?: string
|
||||
|
||||
expression?: string
|
||||
sqlExpression?: string
|
||||
sql?: #SQLExpression
|
||||
} @cuetsy(kind="interface")
|
||||
@@ -104,15 +100,15 @@ composableKinds: DataQuery: {
|
||||
#QueryEditorOperatorExpression: {
|
||||
type: #QueryEditorExpressionType & "operator"
|
||||
property: #QueryEditorProperty
|
||||
// TODO QueryEditorOperator<QueryEditorOperatorValueType>, extend in veneer
|
||||
// TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer
|
||||
operator: #QueryEditorOperator
|
||||
} @cuetsy(kind="interface")
|
||||
|
||||
// TODO <T extends QueryEditorOperatorValueType>, extend in veneer
|
||||
// TS type is QueryEditorOperator<T extends QueryEditorOperatorValueType>, extended in veneer
|
||||
#QueryEditorOperator: {
|
||||
name?: string
|
||||
value?: #QueryEditorOperatorType | [...#QueryEditorOperatorType]
|
||||
}
|
||||
} @cuetsy(kind="interface")
|
||||
|
||||
#QueryEditorOperatorValueType: #QueryEditorOperatorType | [...#QueryEditorOperatorType] @cuetsy(kind="type")
|
||||
#QueryEditorOperatorType: string | bool | int64 @cuetsy(kind="type")
|
||||
@@ -122,15 +118,18 @@ composableKinds: DataQuery: {
|
||||
name?: string
|
||||
} @cuetsy(kind="interface")
|
||||
|
||||
#QueryEditorPropertyType: "string" | "test" @cuetsy(kind="enum")
|
||||
#QueryEditorPropertyType: "string" @cuetsy(kind="enum")
|
||||
|
||||
#QueryEditorArrayExpression: {
|
||||
// TODO this doesn't work
|
||||
// TODO this doesn't work; temporarily extended in veneer
|
||||
type: (#QueryEditorExpressionType & "and") | (#QueryEditorExpressionType & "or")
|
||||
// TODO should be QueryEditorExpression[] | QueryEditorArrayExpression[], extend in veneer
|
||||
expressions: _ // TODO modify this in veneer
|
||||
// TS type expressions: QueryEditorExpression[] | QueryEditorArrayExpression[], extended in veneer
|
||||
expressions: _
|
||||
} @cuetsy(kind="interface")
|
||||
|
||||
// QueryEditorArrayExpression is added in veneer
|
||||
#QueryEditorExpression: #QueryEditorPropertyExpression | #QueryEditorGroupByExpression | #QueryEditorFunctionExpression | #QueryEditorFunctionParameterExpression | #QueryEditorOperatorExpression @cuetsy(kind="type")
|
||||
|
||||
#CloudWatchLogsQuery: {
|
||||
common.DataQuery
|
||||
queryMode: #CloudWatchQueryMode
|
||||
@@ -153,8 +152,7 @@ composableKinds: DataQuery: {
|
||||
#CloudWatchQueryMode: "Metrics" | "Logs" | "Annotations" @cuetsy(kind="type")
|
||||
|
||||
#CloudWatchAnnotationQuery: {
|
||||
// TODO extend common.DataQuery when the issues with redundant fields is fixed
|
||||
//common.DataQuery
|
||||
common.DataQuery
|
||||
#MetricStat
|
||||
queryMode: #CloudWatchQueryMode
|
||||
prefixMatching?: bool
|
||||
@@ -162,7 +160,7 @@ composableKinds: DataQuery: {
|
||||
alarmNamePrefix?: string
|
||||
} @cuetsy(kind="interface")
|
||||
|
||||
// TODO this doesn't work. Also the type is CloudWatchDefaultQuery = Omit<CloudWatchLogsQuery, 'queryMode'> & CloudWatchMetricsQuery;
|
||||
// TS type is CloudWatchDefaultQuery = Omit<CloudWatchLogsQuery, 'queryMode'> & CloudWatchMetricsQuery, declared in veneer
|
||||
// #CloudWatchDefaultQuery: #CloudWatchLogsQuery & #CloudWatchMetricsQuery @cuetsy(kind="type")
|
||||
},
|
||||
]
|
||||
|
||||
@@ -33,7 +33,7 @@ export const defaultMetricStat: Partial<MetricStat> = {
|
||||
|
||||
export type Dimensions = Record<string, (string | Array<string>)>;
|
||||
|
||||
export interface CloudWatchMetricsQuery extends MetricStat {
|
||||
export interface CloudWatchMetricsQuery extends common.DataQuery, MetricStat {
|
||||
alias?: string;
|
||||
/**
|
||||
* Math expression query
|
||||
@@ -110,16 +110,21 @@ export interface QueryEditorGroupByExpression {
|
||||
|
||||
export interface QueryEditorOperatorExpression {
|
||||
/**
|
||||
* TODO QueryEditorOperator<QueryEditorOperatorValueType>, extend in veneer
|
||||
* TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer
|
||||
*/
|
||||
operator: {
|
||||
name?: string;
|
||||
value?: (QueryEditorOperatorType | Array<QueryEditorOperatorType>);
|
||||
};
|
||||
operator: QueryEditorOperator;
|
||||
property: QueryEditorProperty;
|
||||
type: QueryEditorExpressionType.Operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* TS type is QueryEditorOperator<T extends QueryEditorOperatorValueType>, extended in veneer
|
||||
*/
|
||||
export interface QueryEditorOperator {
|
||||
name?: string;
|
||||
value?: (QueryEditorOperatorType | Array<QueryEditorOperatorType>);
|
||||
}
|
||||
|
||||
export type QueryEditorOperatorValueType = (QueryEditorOperatorType | Array<QueryEditorOperatorType>);
|
||||
|
||||
export type QueryEditorOperatorType = (string | boolean | number);
|
||||
@@ -131,20 +136,24 @@ export interface QueryEditorProperty {
|
||||
|
||||
export enum QueryEditorPropertyType {
|
||||
String = 'string',
|
||||
Test = 'test',
|
||||
}
|
||||
|
||||
export interface QueryEditorArrayExpression {
|
||||
/**
|
||||
* TODO should be QueryEditorExpression[] | QueryEditorArrayExpression[], extend in veneer
|
||||
* TS type expressions: QueryEditorExpression[] | QueryEditorArrayExpression[], extended in veneer
|
||||
*/
|
||||
expressions: unknown;
|
||||
/**
|
||||
* TODO this doesn't work
|
||||
* TODO this doesn't work; temporarily extended in veneer
|
||||
*/
|
||||
type: QueryEditorExpressionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* QueryEditorArrayExpression is added in veneer
|
||||
*/
|
||||
export type QueryEditorExpression = (QueryEditorPropertyExpression | QueryEditorGroupByExpression | QueryEditorFunctionExpression | QueryEditorFunctionParameterExpression | QueryEditorOperatorExpression);
|
||||
|
||||
export interface CloudWatchLogsQuery extends common.DataQuery {
|
||||
expression?: string;
|
||||
id: string;
|
||||
@@ -171,7 +180,7 @@ export interface LogGroup {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface CloudWatchAnnotationQuery extends MetricStat {
|
||||
export interface CloudWatchAnnotationQuery extends common.DataQuery, MetricStat {
|
||||
actionPrefix?: string;
|
||||
alarmNamePrefix?: string;
|
||||
prefixMatching?: boolean;
|
||||
|
||||
@@ -1,66 +1,33 @@
|
||||
export enum QueryEditorPropertyType {
|
||||
String = 'string',
|
||||
}
|
||||
import {
|
||||
QueryEditorOperatorExpression as QueryEditorOperatorExpressionBase,
|
||||
QueryEditorOperator as QueryEditorOperatorBase,
|
||||
QueryEditorOperatorValueType,
|
||||
QueryEditorExpressionType,
|
||||
QueryEditorArrayExpression as QueryEditorArrayExpressionBase,
|
||||
QueryEditorExpression as QueryEditorExpressionBase,
|
||||
} from './dataquery.gen';
|
||||
export {
|
||||
QueryEditorPropertyType,
|
||||
QueryEditorProperty,
|
||||
QueryEditorPropertyExpression,
|
||||
QueryEditorGroupByExpression,
|
||||
QueryEditorFunctionExpression,
|
||||
QueryEditorFunctionParameterExpression,
|
||||
} from './dataquery.gen';
|
||||
|
||||
export interface QueryEditorProperty {
|
||||
type: QueryEditorPropertyType;
|
||||
name?: string;
|
||||
}
|
||||
export { QueryEditorExpressionType };
|
||||
|
||||
export type QueryEditorOperatorType = string | boolean | number;
|
||||
type QueryEditorOperatorValueType = QueryEditorOperatorType | QueryEditorOperatorType[];
|
||||
|
||||
export interface QueryEditorOperator<T extends QueryEditorOperatorValueType> {
|
||||
name?: string;
|
||||
export interface QueryEditorOperator<T extends QueryEditorOperatorValueType> extends QueryEditorOperatorBase {
|
||||
value?: T;
|
||||
}
|
||||
|
||||
export interface QueryEditorOperatorExpression {
|
||||
type: QueryEditorExpressionType.Operator;
|
||||
property: QueryEditorProperty;
|
||||
export interface QueryEditorOperatorExpression extends QueryEditorOperatorExpressionBase {
|
||||
operator: QueryEditorOperator<QueryEditorOperatorValueType>;
|
||||
}
|
||||
|
||||
export interface QueryEditorArrayExpression {
|
||||
export interface QueryEditorArrayExpression extends QueryEditorArrayExpressionBase {
|
||||
type: QueryEditorExpressionType.And | QueryEditorExpressionType.Or;
|
||||
expressions: QueryEditorExpression[] | QueryEditorArrayExpression[];
|
||||
}
|
||||
|
||||
export interface QueryEditorPropertyExpression {
|
||||
type: QueryEditorExpressionType.Property;
|
||||
property: QueryEditorProperty;
|
||||
}
|
||||
|
||||
export enum QueryEditorExpressionType {
|
||||
Property = 'property',
|
||||
Operator = 'operator',
|
||||
Or = 'or',
|
||||
And = 'and',
|
||||
GroupBy = 'groupBy',
|
||||
Function = 'function',
|
||||
FunctionParameter = 'functionParameter',
|
||||
}
|
||||
|
||||
export type QueryEditorExpression =
|
||||
| QueryEditorArrayExpression
|
||||
| QueryEditorPropertyExpression
|
||||
| QueryEditorGroupByExpression
|
||||
| QueryEditorFunctionExpression
|
||||
| QueryEditorFunctionParameterExpression
|
||||
| QueryEditorOperatorExpression;
|
||||
|
||||
export interface QueryEditorGroupByExpression {
|
||||
type: QueryEditorExpressionType.GroupBy;
|
||||
property: QueryEditorProperty;
|
||||
}
|
||||
|
||||
export interface QueryEditorFunctionExpression {
|
||||
type: QueryEditorExpressionType.Function;
|
||||
name?: string;
|
||||
parameters?: QueryEditorFunctionParameterExpression[];
|
||||
}
|
||||
|
||||
export interface QueryEditorFunctionParameterExpression {
|
||||
type: QueryEditorExpressionType.FunctionParameter;
|
||||
name?: string;
|
||||
}
|
||||
export type QueryEditorExpression = QueryEditorArrayExpression | QueryEditorExpressionBase;
|
||||
|
||||
@@ -1,81 +1,37 @@
|
||||
import { AwsAuthDataSourceJsonData, AwsAuthDataSourceSecureJsonData } from '@grafana/aws-sdk';
|
||||
import { DataFrame, DataQuery, DataSourceRef, SelectableValue } from '@grafana/data';
|
||||
import { DataFrame, DataSourceRef } from '@grafana/data';
|
||||
import { DataQuery } from '@grafana/schema';
|
||||
|
||||
import {
|
||||
QueryEditorArrayExpression,
|
||||
QueryEditorFunctionExpression,
|
||||
QueryEditorPropertyExpression,
|
||||
} from './expressions';
|
||||
import * as raw from './dataquery.gen';
|
||||
import { QueryEditorArrayExpression } from './expressions';
|
||||
|
||||
export interface Dimensions {
|
||||
[key: string]: string | string[];
|
||||
export * from './dataquery.gen';
|
||||
|
||||
// QueryEditorArrayExpression has a recursive property, so cannot be defined in cue
|
||||
export interface SQLExpression extends raw.SQLExpression {
|
||||
where?: QueryEditorArrayExpression;
|
||||
groupBy?: QueryEditorArrayExpression;
|
||||
}
|
||||
|
||||
export type CloudWatchQuery =
|
||||
| CloudWatchMetricsQuery
|
||||
| raw.CloudWatchLogsQuery
|
||||
| raw.CloudWatchAnnotationQuery
|
||||
| CloudWatchDefaultQuery;
|
||||
|
||||
export interface CloudWatchMetricsQuery extends raw.CloudWatchMetricsQuery {
|
||||
sql?: SQLExpression;
|
||||
}
|
||||
|
||||
// We want to allow setting defaults for both Logs and Metrics queries
|
||||
export type CloudWatchDefaultQuery = Omit<raw.CloudWatchLogsQuery, 'queryMode'> & CloudWatchMetricsQuery;
|
||||
|
||||
export interface MultiFilters {
|
||||
[key: string]: string[];
|
||||
}
|
||||
|
||||
export type CloudWatchQueryMode = 'Metrics' | 'Logs' | 'Annotations';
|
||||
|
||||
export enum MetricQueryType {
|
||||
'Search',
|
||||
'Query',
|
||||
}
|
||||
|
||||
export enum MetricEditorMode {
|
||||
'Builder',
|
||||
'Code',
|
||||
}
|
||||
|
||||
export type Direction = 'ASC' | 'DESC';
|
||||
|
||||
export interface SQLExpression {
|
||||
select?: QueryEditorFunctionExpression;
|
||||
from?: QueryEditorPropertyExpression | QueryEditorFunctionExpression;
|
||||
where?: QueryEditorArrayExpression;
|
||||
groupBy?: QueryEditorArrayExpression;
|
||||
orderBy?: QueryEditorFunctionExpression;
|
||||
orderByDirection?: string;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export interface CloudWatchMetricsQuery extends MetricStat, DataQuery {
|
||||
queryMode?: CloudWatchQueryMode;
|
||||
metricQueryType?: MetricQueryType;
|
||||
metricEditorMode?: MetricEditorMode;
|
||||
|
||||
//common props
|
||||
id: string;
|
||||
|
||||
alias?: string;
|
||||
label?: string;
|
||||
|
||||
// Math expression query
|
||||
expression?: string;
|
||||
|
||||
sqlExpression?: string;
|
||||
sql?: SQLExpression;
|
||||
}
|
||||
|
||||
export interface MetricStat {
|
||||
region: string;
|
||||
namespace: string;
|
||||
metricName?: string;
|
||||
dimensions?: Dimensions;
|
||||
matchExact?: boolean;
|
||||
period?: string;
|
||||
accountId?: string;
|
||||
statistic?: string;
|
||||
/**
|
||||
* @deprecated use statistic
|
||||
*/
|
||||
statistics?: string[];
|
||||
}
|
||||
|
||||
export interface CloudWatchMathExpressionQuery extends DataQuery {
|
||||
expression: string;
|
||||
}
|
||||
|
||||
export type LogAction = 'GetQueryResults' | 'GetLogEvents' | 'StartQuery' | 'StopQuery';
|
||||
|
||||
export enum CloudWatchLogsQueryStatus {
|
||||
@@ -87,34 +43,6 @@ export enum CloudWatchLogsQueryStatus {
|
||||
Timeout = 'Timeout',
|
||||
}
|
||||
|
||||
export interface CloudWatchLogsQuery extends DataQuery {
|
||||
queryMode: CloudWatchQueryMode;
|
||||
id: string;
|
||||
region: string;
|
||||
expression?: string;
|
||||
statsGroups?: string[];
|
||||
logGroups?: LogGroup[];
|
||||
/* deprecated, use logGroups instead */
|
||||
logGroupNames?: string[];
|
||||
}
|
||||
// We want to allow setting defaults for both Logs and Metrics queries
|
||||
export type CloudWatchDefaultQuery = Omit<CloudWatchLogsQuery, 'queryMode'> & CloudWatchMetricsQuery;
|
||||
|
||||
export type CloudWatchQuery =
|
||||
| CloudWatchMetricsQuery
|
||||
| CloudWatchLogsQuery
|
||||
| CloudWatchAnnotationQuery
|
||||
| CloudWatchDefaultQuery;
|
||||
|
||||
export interface CloudWatchAnnotationQuery extends MetricStat, DataQuery {
|
||||
queryMode: CloudWatchQueryMode;
|
||||
prefixMatching?: boolean;
|
||||
actionPrefix?: string;
|
||||
alarmNamePrefix?: string;
|
||||
}
|
||||
|
||||
export type SelectableStrings = Array<SelectableValue<string>>;
|
||||
|
||||
export interface CloudWatchJsonData extends AwsAuthDataSourceJsonData {
|
||||
timeField?: string;
|
||||
database?: string;
|
||||
@@ -125,7 +53,7 @@ export interface CloudWatchJsonData extends AwsAuthDataSourceJsonData {
|
||||
// Used to create links if logs contain traceId.
|
||||
tracingDatasourceUid?: string;
|
||||
|
||||
logGroups?: LogGroup[];
|
||||
logGroups?: raw.LogGroup[];
|
||||
/**
|
||||
* @deprecated use logGroups
|
||||
*/
|
||||
@@ -227,7 +155,7 @@ export interface StartQueryRequest {
|
||||
* The list of log groups to be queried. You can include up to 20 log groups. A StartQuery operation must include a logGroupNames or a logGroupName parameter, but not both.
|
||||
*/
|
||||
logGroupNames?: string[] /* not quite deprecated yet, but will be soon */;
|
||||
logGroups?: LogGroup[];
|
||||
logGroups?: raw.LogGroup[];
|
||||
/**
|
||||
* The query string to use. For more information, see CloudWatch Logs Insights Query Syntax.
|
||||
*/
|
||||
@@ -297,7 +225,7 @@ export interface VariableQuery extends DataQuery {
|
||||
region: string;
|
||||
metricName: string;
|
||||
dimensionKey: string;
|
||||
dimensionFilters?: Dimensions;
|
||||
dimensionFilters?: raw.Dimensions;
|
||||
ec2Filters?: MultiFilters;
|
||||
instanceID: string;
|
||||
attributeName: string;
|
||||
@@ -307,13 +235,13 @@ export interface VariableQuery extends DataQuery {
|
||||
accountId?: string;
|
||||
}
|
||||
|
||||
export interface LegacyAnnotationQuery extends MetricStat, DataQuery {
|
||||
export interface LegacyAnnotationQuery extends raw.MetricStat, DataQuery {
|
||||
actionPrefix: string;
|
||||
alarmNamePrefix: string;
|
||||
alias: string;
|
||||
builtIn: number;
|
||||
datasource: any;
|
||||
dimensions: Dimensions;
|
||||
dimensions: raw.Dimensions;
|
||||
enable: boolean;
|
||||
expression: string;
|
||||
hide: boolean;
|
||||
@@ -336,10 +264,3 @@ export interface LegacyAnnotationQuery extends MetricStat, DataQuery {
|
||||
};
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface LogGroup {
|
||||
arn: string;
|
||||
name: string;
|
||||
accountId?: string;
|
||||
accountLabel?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user