Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit 25d2642

Browse files
committed
Updates SLO types
1 parent 8559410 commit 25d2642

File tree

1 file changed

+59
-8
lines changed

1 file changed

+59
-8
lines changed

slo.go

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,26 @@ type Slos struct {
1212
Slos []Slo `json:"slos"`
1313
}
1414

15+
// Defines values for QueryType.
1516
const (
1617
QueryTypeFreeform QueryType = "freeform"
1718
QueryTypeHistogram QueryType = "histogram"
1819
QueryTypeRatio QueryType = "ratio"
1920
QueryTypeThreshold QueryType = "threshold"
2021
)
2122

23+
// Defines values for StatusType.
24+
const (
25+
StatusTypeCreated StatusType = "created"
26+
StatusTypeCreating StatusType = "creating"
27+
StatusTypeDeleting StatusType = "deleting"
28+
StatusTypeError StatusType = "error"
29+
StatusTypeUnknown StatusType = "unknown"
30+
StatusTypeUpdated StatusType = "updated"
31+
StatusTypeUpdating StatusType = "updating"
32+
)
33+
34+
// Defines values for ThresholdOperator.
2235
const (
2336
ThresholdOperatorEmpty ThresholdOperator = "<"
2437
ThresholdOperatorEqualEqual ThresholdOperator = "=="
@@ -27,48 +40,63 @@ const (
2740
ThresholdOperatorN3 ThresholdOperator = ">"
2841
)
2942

43+
// Alerting defines model for Alerting.
3044
type Alerting struct {
3145
Annotations []Label `json:"annotations,omitempty"`
3246
FastBurn *AlertingMetadata `json:"fastBurn,omitempty"`
3347
Labels []Label `json:"labels,omitempty"`
3448
SlowBurn *AlertingMetadata `json:"slowBurn,omitempty"`
3549
}
3650

51+
// AlertingMetadata defines model for AlertingMetadata.
3752
type AlertingMetadata struct {
3853
Annotations []Label `json:"annotations,omitempty"`
3954
Labels []Label `json:"labels,omitempty"`
4055
}
4156

57+
// DashboardRef defines model for DashboardRef.
4258
type DashboardRef struct {
4359
UID string `json:"UID"`
4460
}
4561

62+
// DestinationDatasource defines model for DestinationDatasource.
63+
type DestinationDatasource struct {
64+
Type *string `json:"type,omitempty"`
65+
Uid *string `json:"uid,omitempty"`
66+
}
67+
68+
// FreeformQuery defines model for FreeformQuery.
4669
type FreeformQuery struct {
4770
Query string `json:"query"`
4871
}
4972

73+
// HistogramQuery defines model for HistogramQuery.
5074
type HistogramQuery struct {
5175
GroupByLabels []string `json:"groupByLabels,omitempty"`
5276
Metric MetricDef `json:"metric"`
5377
Percentile float64 `json:"percentile"`
5478
Threshold Threshold `json:"threshold"`
5579
}
5680

81+
// Label defines model for Label.
5782
type Label struct {
5883
Key string `json:"key"`
5984
Value string `json:"value"`
6085
}
6186

87+
// MetricDef defines model for MetricDef.
6288
type MetricDef struct {
6389
PrometheusMetric string `json:"prometheusMetric"`
6490
Type *string `json:"type,omitempty"`
6591
}
6692

93+
// Objective defines model for Objective.
6794
type Objective struct {
6895
Value float64 `json:"value"`
6996
Window string `json:"window"`
7097
}
7198

99+
// Query defines model for Query.
72100
type Query struct {
73101
Freeform *FreeformQuery `json:"freeform,omitempty"`
74102
Histogram *HistogramQuery `json:"histogram,omitempty"`
@@ -77,32 +105,55 @@ type Query struct {
77105
Type QueryType `json:"type"`
78106
}
79107

108+
// QueryType defines model for Query.Type.
80109
type QueryType string
81110

111+
// RatioQuery defines model for RatioQuery.
82112
type RatioQuery struct {
83113
GroupByLabels []string `json:"groupByLabels,omitempty"`
84114
SuccessMetric MetricDef `json:"successMetric"`
85115
TotalMetric MetricDef `json:"totalMetric"`
86116
}
87117

88-
type Slo struct {
89-
Alerting *Alerting `json:"alerting,omitempty"`
90-
Description string `json:"description"`
118+
// ReadOnly defines model for ReadOnly.
119+
type ReadOnly struct {
91120
DrillDownDashboardRef *DashboardRef `json:"drillDownDashboardRef,omitempty"`
92-
Labels []Label `json:"labels,omitempty"`
93-
Name string `json:"name"`
94-
Objectives []Objective `json:"objectives"`
95-
Query Query `json:"query"`
96-
UUID string `json:"uuid"`
121+
Provenance *string `json:"provenance,omitempty"`
122+
Status *Status `json:"status,omitempty"`
97123
}
98124

125+
// Slo defines model for Slo.
126+
type Slo struct {
127+
Alerting *Alerting `json:"alerting,omitempty"`
128+
Description string `json:"description"`
129+
DestinationDatasource *DestinationDatasource `json:"destinationDatasource,omitempty"`
130+
Labels []Label `json:"labels,omitempty"`
131+
Name string `json:"name"`
132+
Objectives []Objective `json:"objectives"`
133+
Query Query `json:"query"`
134+
ReadOnly *ReadOnly `json:"readOnly,omitempty"`
135+
Uuid string `json:"uuid"`
136+
}
137+
138+
// Status defines model for Status.
139+
type Status struct {
140+
Message *string `json:"message,omitempty"`
141+
Type StatusType `json:"type"`
142+
}
143+
144+
// StatusType defines model for Status.Type.
145+
type StatusType string
146+
147+
// Threshold defines model for Threshold.
99148
type Threshold struct {
100149
Operator ThresholdOperator `json:"operator"`
101150
Value float64 `json:"value"`
102151
}
103152

153+
// ThresholdOperator defines model for Threshold.Operator.
104154
type ThresholdOperator string
105155

156+
// ThresholdQuery defines model for ThresholdQuery.
106157
type ThresholdQuery struct {
107158
GroupByLabels []string `json:"groupByLabels,omitempty"`
108159
Metric MetricDef `json:"metric"`

0 commit comments

Comments
 (0)