Skip to content

Commit adce03d

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 23bba1f of spec repo
1 parent 1889cb0 commit adce03d

File tree

12 files changed

+311
-18
lines changed

12 files changed

+311
-18
lines changed

.generator/schemas/v1/openapi.yaml

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11548,6 +11548,61 @@ components:
1154811548
example: UTC
1154911549
type: string
1155011550
type: object
11551+
SLOCountDefinition:
11552+
description: 'A count-based (metric) SLI specification, composed of three parts:
11553+
the good events formula, the total events formula,
11554+
11555+
and the underlying queries. Usage is not permitted when request payload contains
11556+
`query` field.'
11557+
example:
11558+
good_events_formula: query1 - query2
11559+
queries:
11560+
- data_source: metrics
11561+
name: query1
11562+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11563+
- data_source: metrics
11564+
name: query2
11565+
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
11566+
total_events_formula: query1
11567+
properties:
11568+
good_events_formula:
11569+
$ref: '#/components/schemas/SLOFormula'
11570+
queries:
11571+
example:
11572+
- data_source: metrics
11573+
name: query1
11574+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11575+
items:
11576+
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
11577+
minItems: 1
11578+
type: array
11579+
total_events_formula:
11580+
$ref: '#/components/schemas/SLOFormula'
11581+
required:
11582+
- good_events_formula
11583+
- total_events_formula
11584+
- queries
11585+
type: object
11586+
SLOCountSpec:
11587+
additionalProperties: false
11588+
description: A metric SLI specification.
11589+
example:
11590+
count:
11591+
good_events_formula: query1 - query2
11592+
queries:
11593+
- data_source: metrics
11594+
name: query1
11595+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11596+
- data_source: metrics
11597+
name: query2
11598+
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
11599+
total_events_formula: query1
11600+
properties:
11601+
count:
11602+
$ref: '#/components/schemas/SLOCountDefinition'
11603+
required:
11604+
- count
11605+
type: object
1155111606
SLOCreator:
1155211607
description: The creator of the SLO
1155311608
nullable: true
@@ -12395,8 +12450,16 @@ components:
1239512450
type: string
1239612451
query:
1239712452
$ref: '#/components/schemas/ServiceLevelObjectiveQuery'
12453+
description: 'The metric query of good / total events. This is not allowed
12454+
if the `sli_specification` field
12455+
12456+
is used in the same request.'
1239812457
sli_specification:
1239912458
$ref: '#/components/schemas/SLOSliSpec'
12459+
description: 'A generic SLI specification. This is currently used for time-slice
12460+
and count-based (metric) SLOs only.
12461+
12462+
This is not allowed if the `query` field is used in the same request.'
1240012463
tags:
1240112464
description: 'A list of tags associated with this service level objective.
1240212465

@@ -12453,9 +12516,10 @@ components:
1245312516
type: object
1245412517
SLOSliSpec:
1245512518
description: A generic SLI specification. This is currently used for time-slice
12456-
SLOs only.
12519+
and count-based (metric) SLOs only.
1245712520
oneOf:
1245812521
- $ref: '#/components/schemas/SLOTimeSliceSpec'
12522+
- $ref: '#/components/schemas/SLOCountSpec'
1245912523
SLOState:
1246012524
description: State of the SLO.
1246112525
enum:
@@ -13607,13 +13671,15 @@ components:
1360713671
- type
1360813672
type: object
1360913673
ServiceLevelObjectiveQuery:
13610-
description: 'A metric-based SLO. **Required if type is `metric`**. Note that
13674+
description: 'A count-based (metric) SLO query. This field has been superseded
13675+
by `sli_specification` but is retained for backwards compatibility. Note that
1361113676
Datadog only allows the sum by aggregator
1361213677

1361313678
to be used because this will sum up all request counts instead of averaging
1361413679
them, or taking the max or
1361513680

13616-
min of all of those requests.'
13681+
min of all of those requests. Usage is not permitted when request payload
13682+
contains `sli_specification` field.'
1361713683
properties:
1361813684
denominator:
1361913685
description: A Datadog metric query for total (valid) events.

docs/datadog_api_client.v1.model.rst

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

3682+
datadog\_api\_client.v1.model.slo\_count\_definition module
3683+
-----------------------------------------------------------
3684+
3685+
.. automodule:: datadog_api_client.v1.model.slo_count_definition
3686+
:members:
3687+
:show-inheritance:
3688+
3689+
datadog\_api\_client.v1.model.slo\_count\_spec module
3690+
-----------------------------------------------------
3691+
3692+
.. automodule:: datadog_api_client.v1.model.slo_count_spec
3693+
:members:
3694+
:show-inheritance:
3695+
36823696
datadog\_api\_client.v1.model.slo\_creator module
36833697
-------------------------------------------------
36843698

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: 5 additions & 4 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 has been 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
156-
min of all of those requests.
157+
min of all of those requests. Usage is not permitted when request payload contains ``sli_specification`` field.
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 (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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ 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 has been 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
30-
min of all of those requests.
30+
min of all of those requests. Usage is not permitted when request payload contains ``sli_specification`` field.
3131
3232
:param denominator: A Datadog metric query for total (valid) events.
3333
:type denominator: str

src/datadog_api_client/v1/model/service_level_objective_request.py

Lines changed: 5 additions & 4 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 has been 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
107-
min of all of those requests.
108+
min of all of those requests. Usage is not permitted when request payload contains ``sli_specification`` field.
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 (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. Usage is not permitted when request payload contains ``query`` field.
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. Usage is not permitted when request payload contains ``query`` field.
41+
:type count: SLOCountDefinition
42+
"""
43+
super().__init__(kwargs)
44+
45+
self_.count = count

0 commit comments

Comments
 (0)