Skip to content

Commit 22b8ad0

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit e162a41 of spec repo
1 parent bef6090 commit 22b8ad0

14 files changed

+347
-14
lines changed

.generator/schemas/v1/openapi.yaml

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11900,6 +11900,60 @@ components:
1190011900
example: UTC
1190111901
type: string
1190211902
type: object
11903+
SLOCountDefinition:
11904+
description: 'A count-based (metric) SLI specification, composed of three parts:
11905+
the good events formula, the total events formula,
11906+
11907+
and the underlying queries.'
11908+
example:
11909+
good_events_formula: query1 - query2
11910+
queries:
11911+
- data_source: metrics
11912+
name: query1
11913+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11914+
- data_source: metrics
11915+
name: query2
11916+
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
11917+
total_events_formula: query1
11918+
properties:
11919+
good_events_formula:
11920+
$ref: '#/components/schemas/SLOFormula'
11921+
queries:
11922+
example:
11923+
- data_source: metrics
11924+
name: query1
11925+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11926+
items:
11927+
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
11928+
minItems: 1
11929+
type: array
11930+
total_events_formula:
11931+
$ref: '#/components/schemas/SLOFormula'
11932+
required:
11933+
- good_events_formula
11934+
- total_events_formula
11935+
- queries
11936+
type: object
11937+
SLOCountSpec:
11938+
additionalProperties: false
11939+
description: A metric SLI specification.
11940+
example:
11941+
count:
11942+
good_events_formula: query1 - query2
11943+
queries:
11944+
- data_source: metrics
11945+
name: query1
11946+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11947+
- data_source: metrics
11948+
name: query2
11949+
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
11950+
total_events_formula: query1
11951+
properties:
11952+
count:
11953+
$ref: '#/components/schemas/SLOCountDefinition'
11954+
required:
11955+
- count
11956+
type: object
1190311957
SLOCreator:
1190411958
description: The creator of the SLO
1190511959
nullable: true
@@ -12747,8 +12801,12 @@ components:
1274712801
type: string
1274812802
query:
1274912803
$ref: '#/components/schemas/ServiceLevelObjectiveQuery'
12804+
description: The metric query used to define a count-based SLO as the ratio
12805+
of good events to total events.
1275012806
sli_specification:
1275112807
$ref: '#/components/schemas/SLOSliSpec'
12808+
description: A generic SLI specification. This is currently used for time-slice
12809+
and count-based (metric) SLOs only.
1275212810
tags:
1275312811
description: 'A list of tags associated with this service level objective.
1275412812

@@ -12804,10 +12862,11 @@ components:
1280412862
type: number
1280512863
type: object
1280612864
SLOSliSpec:
12807-
description: A generic SLI specification. This is currently used for time-slice
12808-
SLOs only.
12865+
description: A generic SLI specification. This is used for time-slice and count-based
12866+
(metric) SLOs only.
1280912867
oneOf:
1281012868
- $ref: '#/components/schemas/SLOTimeSliceSpec'
12869+
- $ref: '#/components/schemas/SLOCountSpec'
1281112870
SLOState:
1281212871
description: State of the SLO.
1281312872
enum:
@@ -13959,7 +14018,8 @@ components:
1395914018
- type
1396014019
type: object
1396114020
ServiceLevelObjectiveQuery:
13962-
description: 'A metric-based SLO. **Required if type is `metric`**. Note that
14021+
description: 'A count-based (metric) SLO query. This field is superseded by
14022+
`sli_specification` but is retained for backwards compatibility. Note that
1396314023
Datadog only allows the sum by aggregator
1396414024

1396514025
to be used because this will sum up all request counts instead of averaging

docs/datadog_api_client.v1.model.rst

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

3787+
datadog\_api\_client.v1.model.slo\_count\_definition module
3788+
-----------------------------------------------------------
3789+
3790+
.. automodule:: datadog_api_client.v1.model.slo_count_definition
3791+
:members:
3792+
:show-inheritance:
3793+
3794+
datadog\_api\_client.v1.model.slo\_count\_spec module
3795+
-----------------------------------------------------
3796+
3797+
.. automodule:: datadog_api_client.v1.model.slo_count_spec
3798+
:members:
3799+
:show-inheritance:
3800+
37873801
datadog\_api\_client.v1.model.slo\_creator module
37883802
-------------------------------------------------
37893803

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_definition import SLOCountDefinition
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=SLOCountDefinition(
25+
good_events_formula=SLOFormula(
26+
formula="query1 - query2",
27+
),
28+
total_events_formula=SLOFormula(
29+
formula="query1",
30+
),
31+
queries=[
32+
FormulaAndFunctionMetricQueryDefinition(
33+
data_source=FormulaAndFunctionMetricDataSource.METRICS,
34+
name="query1",
35+
query="sum:httpservice.hits{*}.as_count()",
36+
),
37+
FormulaAndFunctionMetricQueryDefinition(
38+
data_source=FormulaAndFunctionMetricDataSource.METRICS,
39+
name="query2",
40+
query="sum:httpservice.errors{*}.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=99.5,
55+
warning_display="99.5",
56+
),
57+
],
58+
timeframe=SLOTimeframe.SEVEN_DAYS,
59+
target_threshold=99.0,
60+
warning_threshold=99.5,
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 count-based (metric) SLO query. This field is superseded by ``sli_specification`` but is retained for backwards compatibility. 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 used for time-slice and count-based (metric) 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 count-based (metric) SLO query. This field is superseded by ``sli_specification`` but is retained for backwards compatibility. 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 count-based (metric) SLO query. This field is superseded by ``sli_specification`` but is retained for backwards compatibility. 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 used for time-slice and count-based (metric) 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 SLOCountDefinition(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 (metric) SLI specification, composed of three parts: the good events formula, the total events formula,
55+
and the underlying 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_definition import SLOCountDefinition
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_definition import SLOCountDefinition
26+
27+
return {
28+
"count": (SLOCountDefinition,),
29+
}
30+
31+
attribute_map = {
32+
"count": "count",
33+
}
34+
35+
def __init__(self_, count: SLOCountDefinition, **kwargs):
36+
"""
37+
A metric SLI specification.
38+
39+
:param count: A count-based (metric) SLI specification, composed of three parts: the good events formula, the total events formula,
40+
and the underlying queries.
41+
:type count: SLOCountDefinition
42+
"""
43+
super().__init__(kwargs)
44+
45+
self_.count = count

0 commit comments

Comments
 (0)