Skip to content

Commit ea3750d

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 2aab4b8 of spec repo
1 parent 3fefc12 commit ea3750d

File tree

10 files changed

+555
-56
lines changed

10 files changed

+555
-56
lines changed

.generator/schemas/v1/openapi.yaml

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11409,6 +11409,60 @@ components:
1140911409
example: UTC
1141011410
type: string
1141111411
type: object
11412+
SLOCountCondition:
11413+
description: 'A count-based SLI specification, composed of three parts: the
11414+
good events formula, the total events formula,
11415+
11416+
and the involved queries.'
11417+
example:
11418+
good_events_formula: query1 - query2
11419+
queries:
11420+
- data_source: metrics
11421+
name: query1
11422+
query: sum:trace.servlet.request.success{*} by {env}.as_count()
11423+
- data_source: metrics
11424+
name: query2
11425+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11426+
total_events_formula: query2
11427+
properties:
11428+
good_events_formula:
11429+
$ref: '#/components/schemas/SLOFormula'
11430+
queries:
11431+
example:
11432+
- data_source: metrics
11433+
name: query1
11434+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11435+
items:
11436+
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
11437+
minItems: 1
11438+
type: array
11439+
total_events_formula:
11440+
$ref: '#/components/schemas/SLOFormula'
11441+
required:
11442+
- good_events_formula
11443+
- total_events_formula
11444+
- queries
11445+
type: object
11446+
SLOCountSpec:
11447+
additionalProperties: false
11448+
description: A count-based SLI specification.
11449+
example:
11450+
count:
11451+
good_events_formula: query1 - query2
11452+
queries:
11453+
- data_source: metrics
11454+
name: query1
11455+
query: sum:trace.servlet.request.success{*} by {env}.as_count()
11456+
- data_source: metrics
11457+
name: query2
11458+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11459+
total_events_formula: query2
11460+
properties:
11461+
count:
11462+
$ref: '#/components/schemas/SLOCountCondition'
11463+
required:
11464+
- count
11465+
type: object
1141211466
SLOCreator:
1141311467
description: The creator of the SLO
1141411468
nullable: true
@@ -12295,8 +12349,6 @@ components:
1229512349
type: array
1229612350
timeframe:
1229712351
$ref: '#/components/schemas/SLOTimeframe'
12298-
type:
12299-
$ref: '#/components/schemas/SLOType'
1230012352
warning_threshold:
1230112353
description: 'The optional warning threshold such that when the service
1230212354
level indicator is
@@ -12314,9 +12366,10 @@ components:
1231412366
type: object
1231512367
SLOSliSpec:
1231612368
description: A generic SLI specification. This is currently used for time-slice
12317-
SLOs only.
12369+
and count-based SLOs only.
1231812370
oneOf:
1231912371
- $ref: '#/components/schemas/SLOTimeSliceSpec'
12372+
- $ref: '#/components/schemas/SLOCountSpec'
1232012373
SLOState:
1232112374
description: State of the SLO.
1232212375
enum:
@@ -13468,8 +13521,7 @@ components:
1346813521
- type
1346913522
type: object
1347013523
ServiceLevelObjectiveQuery:
13471-
description: 'A metric-based SLO. **Required if type is `metric`**. Note that
13472-
Datadog only allows the sum by aggregator
13524+
description: 'A metric-based SLO. Note that Datadog only allows the sum by aggregator
1347313525

1347413526
to be used because this will sum up all request counts instead of averaging
1347513527
them, or taking the max or
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Create a new metric SLO object using sli_specification returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v1.api.ServiceLevelObjectivesApi;
6+
import com.datadog.api.client.v1.model.FormulaAndFunctionMetricDataSource;
7+
import com.datadog.api.client.v1.model.FormulaAndFunctionMetricQueryDefinition;
8+
import com.datadog.api.client.v1.model.SLOCountCondition;
9+
import com.datadog.api.client.v1.model.SLOCountSpec;
10+
import com.datadog.api.client.v1.model.SLODataSourceQueryDefinition;
11+
import com.datadog.api.client.v1.model.SLOFormula;
12+
import com.datadog.api.client.v1.model.SLOListResponse;
13+
import com.datadog.api.client.v1.model.SLOSliSpec;
14+
import com.datadog.api.client.v1.model.SLOThreshold;
15+
import com.datadog.api.client.v1.model.SLOTimeframe;
16+
import com.datadog.api.client.v1.model.SLOType;
17+
import com.datadog.api.client.v1.model.ServiceLevelObjectiveRequest;
18+
import java.util.Arrays;
19+
import java.util.Collections;
20+
21+
public class Example {
22+
public static void main(String[] args) {
23+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
24+
ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
25+
26+
ServiceLevelObjectiveRequest body =
27+
new ServiceLevelObjectiveRequest()
28+
.type(SLOType.METRIC)
29+
.description("Metric SLO using sli_specification")
30+
.name("Example-Service-Level-Objective")
31+
.sliSpecification(
32+
new SLOSliSpec(
33+
new SLOCountSpec()
34+
.count(
35+
new SLOCountCondition()
36+
.goodEventsFormula(new SLOFormula().formula("query1"))
37+
.totalEventsFormula(new SLOFormula().formula("query2"))
38+
.queries(
39+
Arrays.asList(
40+
new SLODataSourceQueryDefinition(
41+
new FormulaAndFunctionMetricQueryDefinition()
42+
.dataSource(
43+
FormulaAndFunctionMetricDataSource.METRICS)
44+
.name("query1")
45+
.query("sum:httpservice.success{*}.as_count()")),
46+
new SLODataSourceQueryDefinition(
47+
new FormulaAndFunctionMetricQueryDefinition()
48+
.dataSource(
49+
FormulaAndFunctionMetricDataSource.METRICS)
50+
.name("query2")
51+
.query("sum:httpservice.hits{*}.as_count()")))))))
52+
.tags(Arrays.asList("env:prod", "type:count"))
53+
.thresholds(
54+
Collections.singletonList(
55+
new SLOThreshold()
56+
.target(99.0)
57+
.targetDisplay("99.0")
58+
.timeframe(SLOTimeframe.SEVEN_DAYS)
59+
.warning(98.0)
60+
.warningDisplay("98.0")))
61+
.timeframe(SLOTimeframe.SEVEN_DAYS)
62+
.targetThreshold(99.0)
63+
.warningThreshold(98.0);
64+
65+
try {
66+
SLOListResponse result = apiInstance.createSLO(body);
67+
System.out.println(result);
68+
} catch (ApiException e) {
69+
System.err.println("Exception when calling ServiceLevelObjectivesApi#createSLO");
70+
System.err.println("Status code: " + e.getCode());
71+
System.err.println("Reason: " + e.getResponseBody());
72+
System.err.println("Response headers: " + e.getResponseHeaders());
73+
e.printStackTrace();
74+
}
75+
}
76+
}
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
/*
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2019-Present Datadog, Inc.
5+
*/
6+
7+
package com.datadog.api.client.v1.model;
8+
9+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
10+
import com.fasterxml.jackson.annotation.JsonAnySetter;
11+
import com.fasterxml.jackson.annotation.JsonCreator;
12+
import com.fasterxml.jackson.annotation.JsonIgnore;
13+
import com.fasterxml.jackson.annotation.JsonInclude;
14+
import com.fasterxml.jackson.annotation.JsonProperty;
15+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
16+
import java.util.ArrayList;
17+
import java.util.HashMap;
18+
import java.util.List;
19+
import java.util.Map;
20+
import java.util.Objects;
21+
22+
/**
23+
* A count-based SLI specification, composed of three parts: the good events formula, the total
24+
* events formula, and the involved queries.
25+
*/
26+
@JsonPropertyOrder({
27+
SLOCountCondition.JSON_PROPERTY_GOOD_EVENTS_FORMULA,
28+
SLOCountCondition.JSON_PROPERTY_QUERIES,
29+
SLOCountCondition.JSON_PROPERTY_TOTAL_EVENTS_FORMULA
30+
})
31+
@jakarta.annotation.Generated(
32+
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
33+
public class SLOCountCondition {
34+
@JsonIgnore public boolean unparsed = false;
35+
public static final String JSON_PROPERTY_GOOD_EVENTS_FORMULA = "good_events_formula";
36+
private SLOFormula goodEventsFormula;
37+
38+
public static final String JSON_PROPERTY_QUERIES = "queries";
39+
private List<SLODataSourceQueryDefinition> queries = new ArrayList<>();
40+
41+
public static final String JSON_PROPERTY_TOTAL_EVENTS_FORMULA = "total_events_formula";
42+
private SLOFormula totalEventsFormula;
43+
44+
public SLOCountCondition() {}
45+
46+
@JsonCreator
47+
public SLOCountCondition(
48+
@JsonProperty(required = true, value = JSON_PROPERTY_GOOD_EVENTS_FORMULA)
49+
SLOFormula goodEventsFormula,
50+
@JsonProperty(required = true, value = JSON_PROPERTY_QUERIES)
51+
List<SLODataSourceQueryDefinition> queries,
52+
@JsonProperty(required = true, value = JSON_PROPERTY_TOTAL_EVENTS_FORMULA)
53+
SLOFormula totalEventsFormula) {
54+
this.goodEventsFormula = goodEventsFormula;
55+
this.unparsed |= goodEventsFormula.unparsed;
56+
this.queries = queries;
57+
this.totalEventsFormula = totalEventsFormula;
58+
this.unparsed |= totalEventsFormula.unparsed;
59+
}
60+
61+
public SLOCountCondition goodEventsFormula(SLOFormula goodEventsFormula) {
62+
this.goodEventsFormula = goodEventsFormula;
63+
this.unparsed |= goodEventsFormula.unparsed;
64+
return this;
65+
}
66+
67+
/**
68+
* A formula that specifies how to combine the results of multiple queries.
69+
*
70+
* @return goodEventsFormula
71+
*/
72+
@JsonProperty(JSON_PROPERTY_GOOD_EVENTS_FORMULA)
73+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
74+
public SLOFormula getGoodEventsFormula() {
75+
return goodEventsFormula;
76+
}
77+
78+
public void setGoodEventsFormula(SLOFormula goodEventsFormula) {
79+
this.goodEventsFormula = goodEventsFormula;
80+
}
81+
82+
public SLOCountCondition queries(List<SLODataSourceQueryDefinition> queries) {
83+
this.queries = queries;
84+
for (SLODataSourceQueryDefinition item : queries) {
85+
this.unparsed |= item.unparsed;
86+
}
87+
return this;
88+
}
89+
90+
public SLOCountCondition addQueriesItem(SLODataSourceQueryDefinition queriesItem) {
91+
this.queries.add(queriesItem);
92+
this.unparsed |= queriesItem.unparsed;
93+
return this;
94+
}
95+
96+
/**
97+
* Getqueries
98+
*
99+
* @return queries
100+
*/
101+
@JsonProperty(JSON_PROPERTY_QUERIES)
102+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
103+
public List<SLODataSourceQueryDefinition> getQueries() {
104+
return queries;
105+
}
106+
107+
public void setQueries(List<SLODataSourceQueryDefinition> queries) {
108+
this.queries = queries;
109+
}
110+
111+
public SLOCountCondition totalEventsFormula(SLOFormula totalEventsFormula) {
112+
this.totalEventsFormula = totalEventsFormula;
113+
this.unparsed |= totalEventsFormula.unparsed;
114+
return this;
115+
}
116+
117+
/**
118+
* A formula that specifies how to combine the results of multiple queries.
119+
*
120+
* @return totalEventsFormula
121+
*/
122+
@JsonProperty(JSON_PROPERTY_TOTAL_EVENTS_FORMULA)
123+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
124+
public SLOFormula getTotalEventsFormula() {
125+
return totalEventsFormula;
126+
}
127+
128+
public void setTotalEventsFormula(SLOFormula totalEventsFormula) {
129+
this.totalEventsFormula = totalEventsFormula;
130+
}
131+
132+
/**
133+
* A container for additional, undeclared properties. This is a holder for any undeclared
134+
* properties as specified with the 'additionalProperties' keyword in the OAS document.
135+
*/
136+
private Map<String, Object> additionalProperties;
137+
138+
/**
139+
* Set the additional (undeclared) property with the specified name and value. If the property
140+
* does not already exist, create it otherwise replace it.
141+
*
142+
* @param key The arbitrary key to set
143+
* @param value The associated value
144+
* @return SLOCountCondition
145+
*/
146+
@JsonAnySetter
147+
public SLOCountCondition putAdditionalProperty(String key, Object value) {
148+
if (this.additionalProperties == null) {
149+
this.additionalProperties = new HashMap<String, Object>();
150+
}
151+
this.additionalProperties.put(key, value);
152+
return this;
153+
}
154+
155+
/**
156+
* Return the additional (undeclared) property.
157+
*
158+
* @return The additional properties
159+
*/
160+
@JsonAnyGetter
161+
public Map<String, Object> getAdditionalProperties() {
162+
return additionalProperties;
163+
}
164+
165+
/**
166+
* Return the additional (undeclared) property with the specified name.
167+
*
168+
* @param key The arbitrary key to get
169+
* @return The specific additional property for the given key
170+
*/
171+
public Object getAdditionalProperty(String key) {
172+
if (this.additionalProperties == null) {
173+
return null;
174+
}
175+
return this.additionalProperties.get(key);
176+
}
177+
178+
/** Return true if this SLOCountCondition object is equal to o. */
179+
@Override
180+
public boolean equals(Object o) {
181+
if (this == o) {
182+
return true;
183+
}
184+
if (o == null || getClass() != o.getClass()) {
185+
return false;
186+
}
187+
SLOCountCondition sloCountCondition = (SLOCountCondition) o;
188+
return Objects.equals(this.goodEventsFormula, sloCountCondition.goodEventsFormula)
189+
&& Objects.equals(this.queries, sloCountCondition.queries)
190+
&& Objects.equals(this.totalEventsFormula, sloCountCondition.totalEventsFormula)
191+
&& Objects.equals(this.additionalProperties, sloCountCondition.additionalProperties);
192+
}
193+
194+
@Override
195+
public int hashCode() {
196+
return Objects.hash(goodEventsFormula, queries, totalEventsFormula, additionalProperties);
197+
}
198+
199+
@Override
200+
public String toString() {
201+
StringBuilder sb = new StringBuilder();
202+
sb.append("class SLOCountCondition {\n");
203+
sb.append(" goodEventsFormula: ").append(toIndentedString(goodEventsFormula)).append("\n");
204+
sb.append(" queries: ").append(toIndentedString(queries)).append("\n");
205+
sb.append(" totalEventsFormula: ").append(toIndentedString(totalEventsFormula)).append("\n");
206+
sb.append(" additionalProperties: ")
207+
.append(toIndentedString(additionalProperties))
208+
.append("\n");
209+
sb.append('}');
210+
return sb.toString();
211+
}
212+
213+
/**
214+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
215+
*/
216+
private String toIndentedString(Object o) {
217+
if (o == null) {
218+
return "null";
219+
}
220+
return o.toString().replace("\n", "\n ");
221+
}
222+
}

0 commit comments

Comments
 (0)