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:
Alex Khomenko
2023-03-07 14:39:52 +02:00
committed by GitHub
parent 69d3ae8ec1
commit 8999de4313
5 changed files with 192 additions and 228 deletions

View File

@@ -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