Skip to content

Commit

Permalink
Regenerate client from commit bc0f83d2 of spec repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ci.datadog-api-spec committed Feb 15, 2023
1 parent ee7ecfa commit 7f5f29f
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.4",
"regenerated": "2023-02-14 19:39:22.891297",
"spec_repo_commit": "c0625360"
"regenerated": "2023-02-15 14:25:38.180916",
"spec_repo_commit": "bc0f83d2"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2023-02-14 19:39:22.905029",
"spec_repo_commit": "c0625360"
"regenerated": "2023-02-15 14:25:38.196359",
"spec_repo_commit": "bc0f83d2"
}
}
}
5 changes: 5 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9668,6 +9668,11 @@ components:
description: Widget query.
example: env:prod AND service:my-app
type: string
sort:
description: Options for sorting results.
items:
$ref: '#/components/schemas/WidgetFieldSort'
type: array
required:
- query_string
type: object
Expand Down
64 changes: 64 additions & 0 deletions examples/v1/dashboards/CreateDashboard_109450134.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""
Create a new dashboard with slo list widget with sort
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.dashboards_api import DashboardsApi
from datadog_api_client.v1.model.dashboard import Dashboard
from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType
from datadog_api_client.v1.model.slo_list_widget_definition import SLOListWidgetDefinition
from datadog_api_client.v1.model.slo_list_widget_definition_type import SLOListWidgetDefinitionType
from datadog_api_client.v1.model.slo_list_widget_query import SLOListWidgetQuery
from datadog_api_client.v1.model.slo_list_widget_request import SLOListWidgetRequest
from datadog_api_client.v1.model.slo_list_widget_request_type import SLOListWidgetRequestType
from datadog_api_client.v1.model.widget import Widget
from datadog_api_client.v1.model.widget_field_sort import WidgetFieldSort
from datadog_api_client.v1.model.widget_layout import WidgetLayout
from datadog_api_client.v1.model.widget_sort import WidgetSort
from datadog_api_client.v1.model.widget_text_align import WidgetTextAlign

body = Dashboard(
title="Example-Create_a_new_dashboard_with_slo_list_widget_with_sort",
description="",
widgets=[
Widget(
layout=WidgetLayout(
x=0,
y=0,
width=60,
height=21,
),
definition=SLOListWidgetDefinition(
title_size="16",
title_align=WidgetTextAlign.LEFT,
type=SLOListWidgetDefinitionType.SLO_LIST,
requests=[
SLOListWidgetRequest(
query=SLOListWidgetQuery(
query_string="env:prod AND service:my-app",
limit=75,
sort=[
WidgetFieldSort(
column="status.sli",
order=WidgetSort.ASCENDING,
),
],
),
request_type=SLOListWidgetRequestType.SLO_LIST,
),
],
),
),
],
template_variables=[],
layout_type=DashboardLayoutType.FREE,
is_read_only=False,
notify_list=[],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = DashboardsApi(api_client)
response = api_instance.create_dashboard(body=body)

print(response)
23 changes: 21 additions & 2 deletions src/datadog_api_client/v1/model/slo_list_widget_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Union
from typing import List, Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
Expand All @@ -13,6 +13,10 @@
)


if TYPE_CHECKING:
from datadog_api_client.v1.model.widget_field_sort import WidgetFieldSort


class SLOListWidgetQuery(ModelNormal):
validations = {
"limit": {
Expand All @@ -23,17 +27,27 @@ class SLOListWidgetQuery(ModelNormal):

@cached_property
def openapi_types(_):
from datadog_api_client.v1.model.widget_field_sort import WidgetFieldSort

return {
"limit": (int,),
"query_string": (str,),
"sort": ([WidgetFieldSort],),
}

attribute_map = {
"limit": "limit",
"query_string": "query_string",
"sort": "sort",
}

def __init__(self_, query_string: str, limit: Union[int, UnsetType] = unset, **kwargs):
def __init__(
self_,
query_string: str,
limit: Union[int, UnsetType] = unset,
sort: Union[List[WidgetFieldSort], UnsetType] = unset,
**kwargs,
):
"""
Updated SLO List widget.
Expand All @@ -42,9 +56,14 @@ def __init__(self_, query_string: str, limit: Union[int, UnsetType] = unset, **k
:param query_string: Widget query.
:type query_string: str
:param sort: Options for sorting results.
:type sort: [WidgetFieldSort], optional
"""
if limit is not unset:
kwargs["limit"] = limit
if sort is not unset:
kwargs["sort"] = sort
super().__init__(kwargs)

self_.query_string = query_string
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-02-14T18:54:56.599Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
interactions:
- request:
body: '{"name":"Test-Create_a_new_dashboard_with_slo_list_widget_with_sort-1676400896","query":{"denominator":"sum:httpservice.hits{!code:3xx}.as_count()","numerator":"sum:httpservice.hits{code:2xx}.as_count()"},"thresholds":[{"target":95,"timeframe":"7d","warning":98}],"type":"metric"}'
headers:
accept:
- application/json
content-type:
- application/json
method: POST
uri: https://api.datadoghq.com/api/v1/slo
response:
body:
string: '{"data":[{"id":"80091437d0165587a0831040981e44f9","name":"Test-Create_a_new_dashboard_with_slo_list_widget_with_sort-1676400896","tags":[],"monitor_tags":[],"thresholds":[{"timeframe":"7d","target":95.0,"target_display":"95.","warning":98.0,"warning_display":"98."}],"type":"metric","type_id":1,"description":"","timeframe":"7d","warning_threshold":98,"target_threshold":95,"query":{"denominator":"sum:httpservice.hits{!code:3xx}.as_count()","numerator":"sum:httpservice.hits{code:2xx}.as_count()"},"creator":{"name":null,"handle":"frog@datadoghq.com","email":"frog@datadoghq.com"},"created_at":1676400896,"modified_at":1676400896}],"error":null}
'
headers:
content-type:
- application/json
status:
code: 200
message: OK
- request:
body: '{"description":"","is_read_only":false,"layout_type":"free","notify_list":[],"template_variables":[],"title":"Test-Create_a_new_dashboard_with_slo_list_widget_with_sort-1676400896","widgets":[{"definition":{"requests":[{"query":{"limit":75,"query_string":"env:prod
AND service:my-app","sort":[{"column":"status.sli","order":"asc"}]},"request_type":"slo_list"}],"title_align":"left","title_size":"16","type":"slo_list"},"layout":{"height":21,"width":60,"x":0,"y":0}}]}'
headers:
accept:
- application/json
content-type:
- application/json
method: POST
uri: https://api.datadoghq.com/api/v1/dashboard
response:
body:
string: '{"id":"6hq-ih3-tzg","title":"Test-Create_a_new_dashboard_with_slo_list_widget_with_sort-1676400896","description":"","author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"free","url":"/dashboard/6hq-ih3-tzg/test-createanewdashboardwithslolistwidgetwithsort-1676400896","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"requests":[{"query":{"limit":75,"query_string":"env:prod
AND service:my-app","sort":[{"column":"status.sli","order":"asc"}]},"request_type":"slo_list"}],"title_align":"left","title_size":"16","type":"slo_list"},"layout":{"height":21,"width":60,"x":0,"y":0},"id":1642439378480719}],"notify_list":[],"created_at":"2023-02-14T18:54:57.012649+00:00","modified_at":"2023-02-14T18:54:57.012649+00:00","restricted_roles":[]}
'
headers:
content-type:
- application/json
status:
code: 200
message: OK
- request:
body: null
headers:
accept:
- application/json
method: DELETE
uri: https://api.datadoghq.com/api/v1/dashboard/6hq-ih3-tzg
response:
body:
string: '{"deleted_dashboard_id":"6hq-ih3-tzg"}
'
headers:
content-type:
- application/json
status:
code: 200
message: OK
- request:
body: null
headers:
accept:
- application/json
method: DELETE
uri: https://api.datadoghq.com/api/v1/slo/80091437d0165587a0831040981e44f9
response:
body:
string: '{"data":["80091437d0165587a0831040981e44f9"],"error":null}
'
headers:
content-type:
- application/json
status:
code: 200
message: OK
version: 1
13 changes: 13 additions & 0 deletions tests/v1/features/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,19 @@ Feature: Dashboards
And the response "widgets[0].definition.requests[0].query.query_string" is equal to "env:prod AND service:my-app"
And the response "widgets[0].definition.requests[0].query.limit" is equal to 75

@team:DataDog/dashboards
Scenario: Create a new dashboard with slo list widget with sort
Given there is a valid "slo" in the system
And new "CreateDashboard" request
And body from file "dashboards_json_payload/slo_list_widget_with_sort.json"
When the request is sent
Then the response status is 200 OK
And the response "widgets[0].definition.type" is equal to "slo_list"
And the response "widgets[0].definition.requests[0].query.query_string" is equal to "env:prod AND service:my-app"
And the response "widgets[0].definition.requests[0].query.limit" is equal to 75
And the response "widgets[0].definition.requests[0].query.sort[0].column" is equal to "status.sli"
And the response "widgets[0].definition.requests[0].query.sort[0].order" is equal to "asc"

@team:DataDog/dashboards
Scenario: Create a new dashboard with slo widget
Given there is a valid "slo" in the system
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"title": "{{ unique }}",
"description": "",
"widgets": [
{
"layout": {
"x": 0,
"y": 0,
"width": 60,
"height": 21
},
"definition": {
"title_size": "16",
"title_align": "left",
"type": "slo_list",
"requests": [
{
"query": {
"query_string": "env:prod AND service:my-app",
"limit": 75,
"sort": [
{
"column": "status.sli",
"order": "asc"
}
]
},
"request_type": "slo_list"
}
]
}
}
],
"template_variables": [],
"layout_type": "free",
"is_read_only": false,
"notify_list": []
}

0 comments on commit 7f5f29f

Please sign in to comment.