Skip to content

Commit 4183948

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 0e00b9fc of spec repo
1 parent 81f8c0e commit 4183948

16 files changed

+878
-5
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-02-14 15:03:43.770632",
8-
"spec_repo_commit": "a739b49f"
7+
"regenerated": "2025-02-17 17:00:51.862850",
8+
"spec_repo_commit": "0e00b9fc"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-02-14 15:03:43.786179",
13-
"spec_repo_commit": "a739b49f"
12+
"regenerated": "2025-02-17 17:00:51.878399",
13+
"spec_repo_commit": "0e00b9fc"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9727,6 +9727,62 @@ components:
97279727
items:
97289728
$ref: '#/components/schemas/NotifyEndType'
97299729
type: array
9730+
NumberFormatUnit:
9731+
description: Number format unit.
9732+
oneOf:
9733+
- $ref: '#/components/schemas/NumberFormatUnitCanonical'
9734+
- $ref: '#/components/schemas/NumberFormatUnitCustom'
9735+
NumberFormatUnitCanonical:
9736+
description: Canonical unit.
9737+
properties:
9738+
per_unit_name:
9739+
description: The name of the unit per item.
9740+
example: bytes
9741+
type: string
9742+
type:
9743+
$ref: '#/components/schemas/NumberFormatUnitScaleType'
9744+
unit_name:
9745+
description: The name of the unit.
9746+
example: bytes
9747+
type: string
9748+
type: object
9749+
NumberFormatUnitCustom:
9750+
description: Custom unit.
9751+
properties:
9752+
label:
9753+
description: The label for the custom unit.
9754+
maxLength: 12
9755+
minLength: 1
9756+
type: string
9757+
type:
9758+
$ref: '#/components/schemas/NumberFormatUnitCustomType'
9759+
type: object
9760+
NumberFormatUnitCustomType:
9761+
description: The type of custom unit.
9762+
enum:
9763+
- custom_unit_label
9764+
type: string
9765+
x-enum-varnames:
9766+
- CUSTOM_UNIT_LABEL
9767+
NumberFormatUnitScale:
9768+
description: The definition of `NumberFormatUnitScale` object.
9769+
nullable: true
9770+
properties:
9771+
type:
9772+
$ref: '#/components/schemas/NumberFormatUnitScaleType'
9773+
unit_name:
9774+
description: The name of the unit.
9775+
example: bytes
9776+
type: string
9777+
type: object
9778+
NumberFormatUnitScaleType:
9779+
description: The type of unit scale.
9780+
enum:
9781+
- canonical_unit
9782+
example: canonical_unit
9783+
type: string
9784+
x-enum-varnames:
9785+
- CANONICAL_UNIT
97309786
OnMissingDataOption:
97319787
description: 'Controls how groups or monitors are treated if an evaluation does
97329788
not return any data points.
@@ -23044,6 +23100,8 @@ components:
2304423100
type: string
2304523101
limit:
2304623102
$ref: '#/components/schemas/WidgetFormulaLimit'
23103+
number_format:
23104+
$ref: '#/components/schemas/WidgetNumberFormat'
2304723105
style:
2304823106
$ref: '#/components/schemas/WidgetFormulaStyle'
2304923107
required:
@@ -23463,6 +23521,14 @@ components:
2346323521
x-enum-varnames:
2346423522
- HOST
2346523523
- CONTAINER
23524+
WidgetNumberFormat:
23525+
description: Number format options for the widget.
23526+
properties:
23527+
unit:
23528+
$ref: '#/components/schemas/NumberFormatUnit'
23529+
unit_scale:
23530+
$ref: '#/components/schemas/NumberFormatUnitScale'
23531+
type: object
2346623532
WidgetOrderBy:
2346723533
description: What to order by.
2346823534
enum:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-02-17T16:50:56.669Z

cassettes/features/v1/dashboards/Create-a-new-dashboard-with-timeseries-widget-with-custom-unit.yml

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Create a new dashboard with timeseries widget with custom_unit
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V1::DashboardsAPI.new
5+
6+
body = DatadogAPIClient::V1::Dashboard.new({
7+
title: "Example-Dashboard",
8+
description: "",
9+
widgets: [
10+
DatadogAPIClient::V1::Widget.new({
11+
definition: DatadogAPIClient::V1::TimeseriesWidgetDefinition.new({
12+
title: "",
13+
title_size: "16",
14+
title_align: DatadogAPIClient::V1::WidgetTextAlign::LEFT,
15+
show_legend: true,
16+
legend_layout: DatadogAPIClient::V1::TimeseriesWidgetLegendLayout::AUTO,
17+
time: DatadogAPIClient::V1::WidgetLegacyLiveSpan.new({}),
18+
type: DatadogAPIClient::V1::TimeseriesWidgetDefinitionType::TIMESERIES,
19+
requests: [
20+
DatadogAPIClient::V1::TimeseriesWidgetRequest.new({
21+
formulas: [
22+
DatadogAPIClient::V1::WidgetFormula.new({
23+
formula: "query1",
24+
number_format: DatadogAPIClient::V1::WidgetNumberFormat.new({
25+
unit_scale: DatadogAPIClient::V1::NumberFormatUnitScale.new({
26+
type: DatadogAPIClient::V1::NumberFormatUnitScaleType::CANONICAL_UNIT,
27+
unit_name: "apdex",
28+
}),
29+
unit: DatadogAPIClient::V1::NumberFormatUnitCanonical.new({
30+
type: DatadogAPIClient::V1::NumberFormatUnitScaleType::CANONICAL_UNIT,
31+
unit_name: "fraction",
32+
}),
33+
}),
34+
}),
35+
],
36+
queries: [
37+
DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({
38+
data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS,
39+
name: "query1",
40+
query: "avg:system.cpu.user{*}",
41+
}),
42+
],
43+
response_format: DatadogAPIClient::V1::FormulaAndFunctionResponseFormat::TIMESERIES,
44+
display_type: DatadogAPIClient::V1::WidgetDisplayType::LINE,
45+
}),
46+
],
47+
}),
48+
layout: DatadogAPIClient::V1::WidgetLayout.new({
49+
x: 0,
50+
y: 0,
51+
width: 12,
52+
height: 5,
53+
}),
54+
}),
55+
],
56+
template_variables: [],
57+
layout_type: DatadogAPIClient::V1::DashboardLayoutType::ORDERED,
58+
notify_list: [],
59+
reflow_type: DatadogAPIClient::V1::DashboardReflowType::FIXED,
60+
})
61+
p api_instance.create_dashboard(body)

features/v1/dashboards.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,18 @@ Feature: Dashboards
817817
And the response "widgets[0].definition.requests[0].display_type" is equal to "bars"
818818
And the response "widgets[0].definition.requests[0].q" is equal to "sum:trace.test.errors{env:prod,service:datadog-api-spec} by {resource_name}.as_count()"
819819

820+
@team:DataDog/dashboards-backend
821+
Scenario: Create a new dashboard with timeseries widget with custom_unit
822+
Given new "CreateDashboard" request
823+
And body from file "dashboards_json_payload/timeseries_widget_with_custom_unit.json"
824+
When the request is sent
825+
Then the response status is 200 OK
826+
And the response "widgets[0].definition.type" is equal to "timeseries"
827+
And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit_scale.type" is equal to "canonical_unit"
828+
And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit_scale.unit_name" is equal to "apdex"
829+
And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit.type" is equal to "canonical_unit"
830+
And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit.unit_name" is equal to "fraction"
831+
820832
@team:DataDog/dashboards-backend
821833
Scenario: Create a new dashboard with toplist widget
822834
Given new "CreateDashboard" request
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"title": "{{ unique }}",
3+
"description": "",
4+
"widgets": [
5+
{
6+
"definition": {
7+
"title": "",
8+
"title_size": "16",
9+
"title_align": "left",
10+
"show_legend": true,
11+
"legend_layout": "auto",
12+
"time": {},
13+
"type": "timeseries",
14+
"requests": [
15+
{
16+
"formulas": [
17+
{
18+
"formula": "query1",
19+
"number_format": {
20+
"unit_scale": {
21+
"type": "canonical_unit",
22+
"unit_name": "apdex"
23+
},
24+
"unit": {
25+
"type": "canonical_unit",
26+
"unit_name": "fraction"
27+
}
28+
}
29+
}
30+
],
31+
"queries": [
32+
{
33+
"data_source": "metrics",
34+
"name": "query1",
35+
"query": "avg:system.cpu.user{*}"
36+
}
37+
],
38+
"response_format": "timeseries",
39+
"display_type": "line"
40+
}
41+
]
42+
},
43+
"layout": {
44+
"x": 0,
45+
"y": 0,
46+
"width": 12,
47+
"height": 5
48+
}
49+
}
50+
],
51+
"template_variables": [],
52+
"layout_type": "ordered",
53+
"notify_list": [],
54+
"reflow_type": "fixed"
55+
}

lib/datadog_api_client/inflector.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,12 @@ def overrides
381381
"v1.note_widget_definition_type" => "NoteWidgetDefinitionType",
382382
"v1.notify_end_state" => "NotifyEndState",
383383
"v1.notify_end_type" => "NotifyEndType",
384+
"v1.number_format_unit" => "NumberFormatUnit",
385+
"v1.number_format_unit_canonical" => "NumberFormatUnitCanonical",
386+
"v1.number_format_unit_custom" => "NumberFormatUnitCustom",
387+
"v1.number_format_unit_custom_type" => "NumberFormatUnitCustomType",
388+
"v1.number_format_unit_scale" => "NumberFormatUnitScale",
389+
"v1.number_format_unit_scale_type" => "NumberFormatUnitScaleType",
384390
"v1.on_missing_data_option" => "OnMissingDataOption",
385391
"v1.organization" => "Organization",
386392
"v1.organization_billing" => "OrganizationBilling",
@@ -892,6 +898,7 @@ def overrides
892898
"v1.widget_new_live_span" => "WidgetNewLiveSpan",
893899
"v1.widget_new_live_span_type" => "WidgetNewLiveSpanType",
894900
"v1.widget_node_type" => "WidgetNodeType",
901+
"v1.widget_number_format" => "WidgetNumberFormat",
895902
"v1.widget_order_by" => "WidgetOrderBy",
896903
"v1.widget_palette" => "WidgetPalette",
897904
"v1.widget_request_style" => "WidgetRequestStyle",
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
=begin
2+
#Datadog API V1 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V1
20+
# Number format unit.
21+
module NumberFormatUnit
22+
class << self
23+
include BaseOneOfModel
24+
include BaseOneOfModelNoDiscriminator
25+
26+
# List of class defined in oneOf (OpenAPI v3)
27+
def openapi_one_of
28+
[
29+
:'NumberFormatUnitCanonical',
30+
:'NumberFormatUnitCustom'
31+
]
32+
end
33+
# Builds the object
34+
# @param data [Mixed] Data to be matched against the list of oneOf items
35+
# @return [Object] Returns the model or the data itself
36+
def build(data)
37+
# Go through the list of oneOf items and attempt to identify the appropriate one.
38+
# Note:
39+
# - We do not attempt to check whether exactly one item matches.
40+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
41+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
42+
# - TODO: scalar values are de facto behaving as if they were nullable.
43+
# - TODO: logging when debugging is set.
44+
openapi_one_of.each do |klass|
45+
begin
46+
next if klass == :AnyType # "nullable: true"
47+
typed_data = find_and_cast_into_type(klass, data)
48+
next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed
49+
return typed_data if typed_data
50+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
51+
end
52+
end
53+
54+
if openapi_one_of.include?(:AnyType)
55+
data
56+
else
57+
self._unparsed = true
58+
DatadogAPIClient::UnparsedObject.new(data)
59+
end
60+
end
61+
end
62+
end
63+
end

0 commit comments

Comments
 (0)