Skip to content

Commit 11879e2

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 2aab4b8 of spec repo
1 parent bc3a708 commit 11879e2

File tree

12 files changed

+304
-26
lines changed

12 files changed

+304
-26
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

docs/datadog_api_client.v1.model.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3644,6 +3644,20 @@ datadog\_api\_client.v1.model.slo\_correction\_update\_request\_attributes modul
36443644
:members:
36453645
:show-inheritance:
36463646

3647+
datadog\_api\_client.v1.model.slo\_count\_condition module
3648+
----------------------------------------------------------
3649+
3650+
.. automodule:: datadog_api_client.v1.model.slo_count_condition
3651+
:members:
3652+
:show-inheritance:
3653+
3654+
datadog\_api\_client.v1.model.slo\_count\_spec module
3655+
-----------------------------------------------------
3656+
3657+
.. automodule:: datadog_api_client.v1.model.slo_count_spec
3658+
:members:
3659+
:show-inheritance:
3660+
36473661
datadog\_api\_client.v1.model.slo\_creator module
36483662
-------------------------------------------------
36493663

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
"""
2+
Create a new metric SLO object using sli_specification returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v1.api.service_level_objectives_api import ServiceLevelObjectivesApi
7+
from datadog_api_client.v1.model.formula_and_function_metric_data_source import FormulaAndFunctionMetricDataSource
8+
from datadog_api_client.v1.model.formula_and_function_metric_query_definition import (
9+
FormulaAndFunctionMetricQueryDefinition,
10+
)
11+
from datadog_api_client.v1.model.service_level_objective_request import ServiceLevelObjectiveRequest
12+
from datadog_api_client.v1.model.slo_count_condition import SLOCountCondition
13+
from datadog_api_client.v1.model.slo_count_spec import SLOCountSpec
14+
from datadog_api_client.v1.model.slo_formula import SLOFormula
15+
from datadog_api_client.v1.model.slo_threshold import SLOThreshold
16+
from datadog_api_client.v1.model.slo_timeframe import SLOTimeframe
17+
from datadog_api_client.v1.model.slo_type import SLOType
18+
19+
body = ServiceLevelObjectiveRequest(
20+
type=SLOType.METRIC,
21+
description="Metric SLO using sli_specification",
22+
name="Example-Service-Level-Objective",
23+
sli_specification=SLOCountSpec(
24+
count=SLOCountCondition(
25+
good_events_formula=SLOFormula(
26+
formula="query1",
27+
),
28+
total_events_formula=SLOFormula(
29+
formula="query2",
30+
),
31+
queries=[
32+
FormulaAndFunctionMetricQueryDefinition(
33+
data_source=FormulaAndFunctionMetricDataSource.METRICS,
34+
name="query1",
35+
query="sum:httpservice.success{*}.as_count()",
36+
),
37+
FormulaAndFunctionMetricQueryDefinition(
38+
data_source=FormulaAndFunctionMetricDataSource.METRICS,
39+
name="query2",
40+
query="sum:httpservice.hits{*}.as_count()",
41+
),
42+
],
43+
),
44+
),
45+
tags=[
46+
"env:prod",
47+
"type:count",
48+
],
49+
thresholds=[
50+
SLOThreshold(
51+
target=99.0,
52+
target_display="99.0",
53+
timeframe=SLOTimeframe.SEVEN_DAYS,
54+
warning=98.0,
55+
warning_display="98.0",
56+
),
57+
],
58+
timeframe=SLOTimeframe.SEVEN_DAYS,
59+
target_threshold=99.0,
60+
warning_threshold=98.0,
61+
)
62+
63+
configuration = Configuration()
64+
with ApiClient(configuration) as api_client:
65+
api_instance = ServiceLevelObjectivesApi(api_client)
66+
response = api_instance.create_slo(body=body)
67+
68+
print(response)

src/datadog_api_client/v1/model/service_level_objective.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from datadog_api_client.v1.model.slo_timeframe import SLOTimeframe
2323
from datadog_api_client.v1.model.slo_type import SLOType
2424
from datadog_api_client.v1.model.slo_time_slice_spec import SLOTimeSliceSpec
25+
from datadog_api_client.v1.model.slo_count_spec import SLOCountSpec
2526

2627

2728
class ServiceLevelObjective(ModelNormal):
@@ -94,7 +95,7 @@ def __init__(
9495
monitor_ids: Union[List[int], UnsetType] = unset,
9596
monitor_tags: Union[List[str], UnsetType] = unset,
9697
query: Union[ServiceLevelObjectiveQuery, UnsetType] = unset,
97-
sli_specification: Union[SLOSliSpec, SLOTimeSliceSpec, UnsetType] = unset,
98+
sli_specification: Union[SLOSliSpec, SLOTimeSliceSpec, SLOCountSpec, UnsetType] = unset,
9899
tags: Union[List[str], UnsetType] = unset,
99100
target_threshold: Union[float, UnsetType] = unset,
100101
timeframe: Union[SLOTimeframe, UnsetType] = unset,
@@ -151,12 +152,12 @@ def __init__(
151152
:param name: The name of the service level objective object.
152153
:type name: str
153154
154-
:param query: A metric-based SLO. **Required if type is metric**. Note that Datadog only allows the sum by aggregator
155+
:param query: A metric-based SLO. Note that Datadog only allows the sum by aggregator
155156
to be used because this will sum up all request counts instead of averaging them, or taking the max or
156157
min of all of those requests.
157158
:type query: ServiceLevelObjectiveQuery, optional
158159
159-
:param sli_specification: A generic SLI specification. This is currently used for time-slice SLOs only.
160+
:param sli_specification: A generic SLI specification. This is currently used for time-slice and count-based SLOs only.
160161
:type sli_specification: SLOSliSpec, optional
161162
162163
:param tags: A list of tags associated with this service level objective.

src/datadog_api_client/v1/model/service_level_objective_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def openapi_types(_):
2525

2626
def __init__(self_, denominator: str, numerator: str, **kwargs):
2727
"""
28-
A metric-based SLO. **Required if type is metric**. Note that Datadog only allows the sum by aggregator
28+
A metric-based SLO. Note that Datadog only allows the sum by aggregator
2929
to be used because this will sum up all request counts instead of averaging them, or taking the max or
3030
min of all of those requests.
3131

src/datadog_api_client/v1/model/service_level_objective_request.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from datadog_api_client.v1.model.slo_timeframe import SLOTimeframe
2222
from datadog_api_client.v1.model.slo_type import SLOType
2323
from datadog_api_client.v1.model.slo_time_slice_spec import SLOTimeSliceSpec
24+
from datadog_api_client.v1.model.slo_count_spec import SLOCountSpec
2425

2526

2627
class ServiceLevelObjectiveRequest(ModelNormal):
@@ -71,7 +72,7 @@ def __init__(
7172
groups: Union[List[str], UnsetType] = unset,
7273
monitor_ids: Union[List[int], UnsetType] = unset,
7374
query: Union[ServiceLevelObjectiveQuery, UnsetType] = unset,
74-
sli_specification: Union[SLOSliSpec, SLOTimeSliceSpec, UnsetType] = unset,
75+
sli_specification: Union[SLOSliSpec, SLOTimeSliceSpec, SLOCountSpec, UnsetType] = unset,
7576
tags: Union[List[str], UnsetType] = unset,
7677
target_threshold: Union[float, UnsetType] = unset,
7778
timeframe: Union[SLOTimeframe, UnsetType] = unset,
@@ -102,12 +103,12 @@ def __init__(
102103
:param name: The name of the service level objective object.
103104
:type name: str
104105
105-
:param query: A metric-based SLO. **Required if type is metric**. Note that Datadog only allows the sum by aggregator
106+
:param query: A metric-based SLO. Note that Datadog only allows the sum by aggregator
106107
to be used because this will sum up all request counts instead of averaging them, or taking the max or
107108
min of all of those requests.
108109
:type query: ServiceLevelObjectiveQuery, optional
109110
110-
:param sli_specification: A generic SLI specification. This is currently used for time-slice SLOs only.
111+
:param sli_specification: A generic SLI specification. This is currently used for time-slice and count-based SLOs only.
111112
:type sli_specification: SLOSliSpec, optional
112113
113114
:param tags: A list of tags associated with this service level objective.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import List, Union, TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
)
12+
13+
14+
if TYPE_CHECKING:
15+
from datadog_api_client.v1.model.slo_formula import SLOFormula
16+
from datadog_api_client.v1.model.slo_data_source_query_definition import SLODataSourceQueryDefinition
17+
from datadog_api_client.v1.model.formula_and_function_metric_query_definition import (
18+
FormulaAndFunctionMetricQueryDefinition,
19+
)
20+
21+
22+
class SLOCountCondition(ModelNormal):
23+
validations = {
24+
"queries": {
25+
"min_items": 1,
26+
},
27+
}
28+
29+
@cached_property
30+
def openapi_types(_):
31+
from datadog_api_client.v1.model.slo_formula import SLOFormula
32+
from datadog_api_client.v1.model.slo_data_source_query_definition import SLODataSourceQueryDefinition
33+
34+
return {
35+
"good_events_formula": (SLOFormula,),
36+
"queries": ([SLODataSourceQueryDefinition],),
37+
"total_events_formula": (SLOFormula,),
38+
}
39+
40+
attribute_map = {
41+
"good_events_formula": "good_events_formula",
42+
"queries": "queries",
43+
"total_events_formula": "total_events_formula",
44+
}
45+
46+
def __init__(
47+
self_,
48+
good_events_formula: SLOFormula,
49+
queries: List[Union[SLODataSourceQueryDefinition, FormulaAndFunctionMetricQueryDefinition]],
50+
total_events_formula: SLOFormula,
51+
**kwargs,
52+
):
53+
"""
54+
A count-based SLI specification, composed of three parts: the good events formula, the total events formula,
55+
and the involved queries.
56+
57+
:param good_events_formula: A formula that specifies how to combine the results of multiple queries.
58+
:type good_events_formula: SLOFormula
59+
60+
:param queries:
61+
:type queries: [SLODataSourceQueryDefinition]
62+
63+
:param total_events_formula: A formula that specifies how to combine the results of multiple queries.
64+
:type total_events_formula: SLOFormula
65+
"""
66+
super().__init__(kwargs)
67+
68+
self_.good_events_formula = good_events_formula
69+
self_.queries = queries
70+
self_.total_events_formula = total_events_formula
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
)
12+
13+
14+
if TYPE_CHECKING:
15+
from datadog_api_client.v1.model.slo_count_condition import SLOCountCondition
16+
17+
18+
class SLOCountSpec(ModelNormal):
19+
@cached_property
20+
def additional_properties_type(_):
21+
return None
22+
23+
@cached_property
24+
def openapi_types(_):
25+
from datadog_api_client.v1.model.slo_count_condition import SLOCountCondition
26+
27+
return {
28+
"count": (SLOCountCondition,),
29+
}
30+
31+
attribute_map = {
32+
"count": "count",
33+
}
34+
35+
def __init__(self_, count: SLOCountCondition, **kwargs):
36+
"""
37+
A count-based SLI specification.
38+
39+
:param count: A count-based SLI specification, composed of three parts: the good events formula, the total events formula,
40+
and the involved queries.
41+
:type count: SLOCountCondition
42+
"""
43+
super().__init__(kwargs)
44+
45+
self_.count = count

0 commit comments

Comments
 (0)