Skip to content

Commit

Permalink
Add ci_pipelines enum to FormulaAndFunctionEventsDataSource (#1363)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Mar 2, 2023
1 parent 9dc3887 commit 4210af3
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 5 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-03-02 15:38:14.789500",
"spec_repo_commit": "0ec7fe9d"
"regenerated": "2023-03-02 16:19:50.759538",
"spec_repo_commit": "e71b6cea"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2023-03-02 15:38:14.801240",
"spec_repo_commit": "0ec7fe9d"
"regenerated": "2023-03-02 16:19:50.770722",
"spec_repo_commit": "e71b6cea"
}
}
}
2 changes: 2 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,7 @@ components:
- audit
- events
- ci_tests
- ci_pipelines
example: logs
type: string
x-enum-varnames:
Expand All @@ -2530,6 +2531,7 @@ components:
- AUDIT
- EVENTS
- CI_TESTS
- CI_PIPELINES
FormulaAndFunctionMetricAggregation:
description: The aggregation methods available for metrics queries.
enum:
Expand Down
97 changes: 97 additions & 0 deletions examples/v1/dashboards/CreateDashboard_2800096921.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"""
Create a new timeseries widget with ci_pipelines data source
"""

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.dashboard_reflow_type import DashboardReflowType
from datadog_api_client.v1.model.formula_and_function_event_aggregation import FormulaAndFunctionEventAggregation
from datadog_api_client.v1.model.formula_and_function_event_query_definition import (
FormulaAndFunctionEventQueryDefinition,
)
from datadog_api_client.v1.model.formula_and_function_event_query_definition_compute import (
FormulaAndFunctionEventQueryDefinitionCompute,
)
from datadog_api_client.v1.model.formula_and_function_event_query_definition_search import (
FormulaAndFunctionEventQueryDefinitionSearch,
)
from datadog_api_client.v1.model.formula_and_function_events_data_source import FormulaAndFunctionEventsDataSource
from datadog_api_client.v1.model.formula_and_function_response_format import FormulaAndFunctionResponseFormat
from datadog_api_client.v1.model.timeseries_widget_definition import TimeseriesWidgetDefinition
from datadog_api_client.v1.model.timeseries_widget_definition_type import TimeseriesWidgetDefinitionType
from datadog_api_client.v1.model.timeseries_widget_legend_column import TimeseriesWidgetLegendColumn
from datadog_api_client.v1.model.timeseries_widget_legend_layout import TimeseriesWidgetLegendLayout
from datadog_api_client.v1.model.timeseries_widget_request import TimeseriesWidgetRequest
from datadog_api_client.v1.model.widget import Widget
from datadog_api_client.v1.model.widget_display_type import WidgetDisplayType
from datadog_api_client.v1.model.widget_formula import WidgetFormula
from datadog_api_client.v1.model.widget_line_type import WidgetLineType
from datadog_api_client.v1.model.widget_line_width import WidgetLineWidth
from datadog_api_client.v1.model.widget_request_style import WidgetRequestStyle
from datadog_api_client.v1.model.widget_time import WidgetTime

body = Dashboard(
title="Example-Create_a_new_timeseries_widget_with_ci_pipelines_data_source with ci_pipelines datasource",
widgets=[
Widget(
definition=TimeseriesWidgetDefinition(
title="",
show_legend=True,
legend_layout=TimeseriesWidgetLegendLayout.AUTO,
legend_columns=[
TimeseriesWidgetLegendColumn.AVG,
TimeseriesWidgetLegendColumn.MIN,
TimeseriesWidgetLegendColumn.MAX,
TimeseriesWidgetLegendColumn.VALUE,
TimeseriesWidgetLegendColumn.SUM,
],
time=WidgetTime(),
type=TimeseriesWidgetDefinitionType.TIMESERIES,
requests=[
TimeseriesWidgetRequest(
formulas=[
WidgetFormula(
formula="query1",
),
],
queries=[
FormulaAndFunctionEventQueryDefinition(
data_source=FormulaAndFunctionEventsDataSource.CI_PIPELINES,
name="query1",
search=FormulaAndFunctionEventQueryDefinitionSearch(
query="ci_level:job",
),
indexes=[
"*",
],
compute=FormulaAndFunctionEventQueryDefinitionCompute(
aggregation=FormulaAndFunctionEventAggregation.COUNT,
metric="@ci.queue_time",
),
group_by=[],
),
],
response_format=FormulaAndFunctionResponseFormat.TIMESERIES,
style=WidgetRequestStyle(
palette="dog_classic",
line_type=WidgetLineType.SOLID,
line_width=WidgetLineWidth.NORMAL,
),
display_type=WidgetDisplayType.LINE,
),
],
),
),
],
layout_type=DashboardLayoutType.ORDERED,
reflow_type=DashboardReflowType.AUTO,
)

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

print(response)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FormulaAndFunctionEventsDataSource(ModelSimple):
"""
Data source for event platform-based queries.
:param value: Must be one of ["logs", "spans", "network", "rum", "security_signals", "profiles", "audit", "events", "ci_tests"].
:param value: Must be one of ["logs", "spans", "network", "rum", "security_signals", "profiles", "audit", "events", "ci_tests", "ci_pipelines"].
:type value: str
"""

Expand All @@ -30,6 +30,7 @@ class FormulaAndFunctionEventsDataSource(ModelSimple):
"audit",
"events",
"ci_tests",
"ci_pipelines",
}
LOGS: ClassVar["FormulaAndFunctionEventsDataSource"]
SPANS: ClassVar["FormulaAndFunctionEventsDataSource"]
Expand All @@ -40,6 +41,7 @@ class FormulaAndFunctionEventsDataSource(ModelSimple):
AUDIT: ClassVar["FormulaAndFunctionEventsDataSource"]
EVENTS: ClassVar["FormulaAndFunctionEventsDataSource"]
CI_TESTS: ClassVar["FormulaAndFunctionEventsDataSource"]
CI_PIPELINES: ClassVar["FormulaAndFunctionEventsDataSource"]

@cached_property
def openapi_types(_):
Expand All @@ -57,3 +59,4 @@ def openapi_types(_):
FormulaAndFunctionEventsDataSource.AUDIT = FormulaAndFunctionEventsDataSource("audit")
FormulaAndFunctionEventsDataSource.EVENTS = FormulaAndFunctionEventsDataSource("events")
FormulaAndFunctionEventsDataSource.CI_TESTS = FormulaAndFunctionEventsDataSource("ci_tests")
FormulaAndFunctionEventsDataSource.CI_PIPELINES = FormulaAndFunctionEventsDataSource("ci_pipelines")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-03-02T15:41:16.500Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
interactions:
- request:
body: '{"layout_type":"ordered","reflow_type":"auto","title":"Test-Create_a_new_timeseries_widget_with_ci_pipelines_data_source-1677771676
with ci_pipelines datasource","widgets":[{"definition":{"legend_columns":["avg","min","max","value","sum"],"legend_layout":"auto","requests":[{"display_type":"line","formulas":[{"formula":"query1"}],"queries":[{"compute":{"aggregation":"count","metric":"@ci.queue_time"},"data_source":"ci_pipelines","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"ci_level:job"}}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"show_legend":true,"time":{},"title":"","type":"timeseries"}}]}'
headers:
accept:
- application/json
content-type:
- application/json
method: POST
uri: https://api.datadoghq.com/api/v1/dashboard
response:
body:
string: '{"id":"iu9-viw-buz","title":"Test-Create_a_new_timeseries_widget_with_ci_pipelines_data_source-1677771676
with ci_pipelines datasource","description":null,"author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/iu9-viw-buz/test-createanewtimeserieswidgetwithcipipelinesdatasource-1677771676-with-cipipel","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"legend_columns":["avg","min","max","value","sum"],"legend_layout":"auto","requests":[{"display_type":"line","formulas":[{"formula":"query1"}],"queries":[{"compute":{"aggregation":"count","metric":"@ci.queue_time"},"data_source":"ci_pipelines","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"ci_level:job"}}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"show_legend":true,"time":{},"title":"","type":"timeseries"},"id":2105687409669278}],"notify_list":null,"created_at":"2023-03-02T15:41:16.697612+00:00","modified_at":"2023-03-02T15:41:16.697612+00:00","reflow_type":"auto","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/iu9-viw-buz
response:
body:
string: '{"deleted_dashboard_id":"iu9-viw-buz"}
'
headers:
content-type:
- application/json
status:
code: 200
message: OK
version: 1
9 changes: 9 additions & 0 deletions tests/v1/features/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,15 @@ Feature: Dashboards
And the response "widgets[0].definition.type" is equal to "trace_service"
And the response "widgets[0].definition.env" is equal to "none"

@team:DataDog/dashboards
Scenario: Create a new timeseries widget with ci_pipelines data source
Given new "CreateDashboard" request
And body with value {"title":"{{ unique }} with ci_pipelines datasource","widgets":[{"definition":{"title":"","show_legend":true,"legend_layout":"auto","legend_columns":["avg","min","max","value","sum"],"time":{},"type":"timeseries","requests":[{"formulas":[{"formula":"query1"}],"queries":[{"data_source":"ci_pipelines","name":"query1","search":{"query":"ci_level:job"},"indexes":["*"],"compute":{"aggregation":"count", "metric": "@ci.queue_time"},"group_by":[]}],"response_format":"timeseries","style":{"palette":"dog_classic","line_type":"solid","line_width":"normal"},"display_type":"line"}]}}],"layout_type":"ordered","reflow_type":"auto"}
When the request is sent
Then the response status is 200 OK
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "ci_pipelines"
And the response "widgets[0].definition.requests[0].queries[0].search.query" is equal to "ci_level:job"

@team:DataDog/dashboards
Scenario: Create a new timeseries widget with ci_tests data source
Given new "CreateDashboard" request
Expand Down

0 comments on commit 4210af3

Please sign in to comment.