Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.6",
"regenerated": "2025-02-19 19:09:46.814470",
"spec_repo_commit": "f0e5fdcf"
"regenerated": "2025-02-20 13:35:00.547017",
"spec_repo_commit": "c64543d0"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-02-19 19:09:46.830432",
"spec_repo_commit": "f0e5fdcf"
"regenerated": "2025-02-20 13:35:00.565048",
"spec_repo_commit": "c64543d0"
}
}
}
66 changes: 66 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9727,6 +9727,62 @@ components:
items:
$ref: '#/components/schemas/NotifyEndType'
type: array
NumberFormatUnit:
description: Number format unit.
oneOf:
- $ref: '#/components/schemas/NumberFormatUnitCanonical'
- $ref: '#/components/schemas/NumberFormatUnitCustom'
NumberFormatUnitCanonical:
description: Canonical unit.
properties:
per_unit_name:
description: The name of the unit per item.
example: bytes
type: string
type:
$ref: '#/components/schemas/NumberFormatUnitScaleType'
unit_name:
description: The name of the unit.
example: bytes
type: string
type: object
NumberFormatUnitCustom:
description: Custom unit.
properties:
label:
description: The label for the custom unit.
maxLength: 12
minLength: 1
type: string
type:
$ref: '#/components/schemas/NumberFormatUnitCustomType'
type: object
NumberFormatUnitCustomType:
description: The type of custom unit.
enum:
- custom_unit_label
type: string
x-enum-varnames:
- CUSTOM_UNIT_LABEL
NumberFormatUnitScale:
description: The definition of `NumberFormatUnitScale` object.
nullable: true
properties:
type:
$ref: '#/components/schemas/NumberFormatUnitScaleType'
unit_name:
description: The name of the unit.
example: bytes
type: string
type: object
NumberFormatUnitScaleType:
description: The type of unit scale.
enum:
- canonical_unit
example: canonical_unit
type: string
x-enum-varnames:
- CANONICAL_UNIT
OnMissingDataOption:
description: 'Controls how groups or monitors are treated if an evaluation does
not return any data points.
Expand Down Expand Up @@ -23044,6 +23100,8 @@ components:
type: string
limit:
$ref: '#/components/schemas/WidgetFormulaLimit'
number_format:
$ref: '#/components/schemas/WidgetNumberFormat'
style:
$ref: '#/components/schemas/WidgetFormulaStyle'
required:
Expand Down Expand Up @@ -23463,6 +23521,14 @@ components:
x-enum-varnames:
- HOST
- CONTAINER
WidgetNumberFormat:
description: Number format options for the widget.
properties:
unit:
$ref: '#/components/schemas/NumberFormatUnit'
unit_scale:
$ref: '#/components/schemas/NumberFormatUnitScale'
type: object
WidgetOrderBy:
description: What to order by.
enum:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2025-02-17T16:50:56.669Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions examples/v1/dashboards/CreateDashboard_3520534424.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Create a new dashboard with timeseries widget with custom_unit

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DashboardsAPI.new

body = DatadogAPIClient::V1::Dashboard.new({
title: "Example-Dashboard",
description: "",
widgets: [
DatadogAPIClient::V1::Widget.new({
definition: DatadogAPIClient::V1::TimeseriesWidgetDefinition.new({
title: "",
title_size: "16",
title_align: DatadogAPIClient::V1::WidgetTextAlign::LEFT,
show_legend: true,
legend_layout: DatadogAPIClient::V1::TimeseriesWidgetLegendLayout::AUTO,
time: DatadogAPIClient::V1::WidgetLegacyLiveSpan.new({}),
type: DatadogAPIClient::V1::TimeseriesWidgetDefinitionType::TIMESERIES,
requests: [
DatadogAPIClient::V1::TimeseriesWidgetRequest.new({
formulas: [
DatadogAPIClient::V1::WidgetFormula.new({
formula: "query1",
number_format: DatadogAPIClient::V1::WidgetNumberFormat.new({
unit_scale: DatadogAPIClient::V1::NumberFormatUnitScale.new({
type: DatadogAPIClient::V1::NumberFormatUnitScaleType::CANONICAL_UNIT,
unit_name: "apdex",
}),
unit: DatadogAPIClient::V1::NumberFormatUnitCanonical.new({
type: DatadogAPIClient::V1::NumberFormatUnitScaleType::CANONICAL_UNIT,
unit_name: "fraction",
}),
}),
}),
],
queries: [
DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({
data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS,
name: "query1",
query: "avg:system.cpu.user{*}",
}),
],
response_format: DatadogAPIClient::V1::FormulaAndFunctionResponseFormat::TIMESERIES,
display_type: DatadogAPIClient::V1::WidgetDisplayType::LINE,
}),
],
}),
layout: DatadogAPIClient::V1::WidgetLayout.new({
x: 0,
y: 0,
width: 12,
height: 5,
}),
}),
],
template_variables: [],
layout_type: DatadogAPIClient::V1::DashboardLayoutType::ORDERED,
notify_list: [],
reflow_type: DatadogAPIClient::V1::DashboardReflowType::FIXED,
})
p api_instance.create_dashboard(body)
12 changes: 12 additions & 0 deletions features/v1/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,18 @@ Feature: Dashboards
And the response "widgets[0].definition.requests[0].display_type" is equal to "bars"
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()"

@team:DataDog/dashboards-backend
Scenario: Create a new dashboard with timeseries widget with custom_unit
Given new "CreateDashboard" request
And body from file "dashboards_json_payload/timeseries_widget_with_custom_unit.json"
When the request is sent
Then the response status is 200 OK
And the response "widgets[0].definition.type" is equal to "timeseries"
And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit_scale.type" is equal to "canonical_unit"
And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit_scale.unit_name" is equal to "apdex"
And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit.type" is equal to "canonical_unit"
And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit.unit_name" is equal to "fraction"

@team:DataDog/dashboards-backend
Scenario: Create a new dashboard with toplist widget
Given new "CreateDashboard" request
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"title": "{{ unique }}",
"description": "",
"widgets": [
{
"definition": {
"title": "",
"title_size": "16",
"title_align": "left",
"show_legend": true,
"legend_layout": "auto",
"time": {},
"type": "timeseries",
"requests": [
{
"formulas": [
{
"formula": "query1",
"number_format": {
"unit_scale": {
"type": "canonical_unit",
"unit_name": "apdex"
},
"unit": {
"type": "canonical_unit",
"unit_name": "fraction"
}
}
}
],
"queries": [
{
"data_source": "metrics",
"name": "query1",
"query": "avg:system.cpu.user{*}"
}
],
"response_format": "timeseries",
"display_type": "line"
}
]
},
"layout": {
"x": 0,
"y": 0,
"width": 12,
"height": 5
}
}
],
"template_variables": [],
"layout_type": "ordered",
"notify_list": [],
"reflow_type": "fixed"
}
7 changes: 7 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,12 @@ def overrides
"v1.note_widget_definition_type" => "NoteWidgetDefinitionType",
"v1.notify_end_state" => "NotifyEndState",
"v1.notify_end_type" => "NotifyEndType",
"v1.number_format_unit" => "NumberFormatUnit",
"v1.number_format_unit_canonical" => "NumberFormatUnitCanonical",
"v1.number_format_unit_custom" => "NumberFormatUnitCustom",
"v1.number_format_unit_custom_type" => "NumberFormatUnitCustomType",
"v1.number_format_unit_scale" => "NumberFormatUnitScale",
"v1.number_format_unit_scale_type" => "NumberFormatUnitScaleType",
"v1.on_missing_data_option" => "OnMissingDataOption",
"v1.organization" => "Organization",
"v1.organization_billing" => "OrganizationBilling",
Expand Down Expand Up @@ -892,6 +898,7 @@ def overrides
"v1.widget_new_live_span" => "WidgetNewLiveSpan",
"v1.widget_new_live_span_type" => "WidgetNewLiveSpanType",
"v1.widget_node_type" => "WidgetNodeType",
"v1.widget_number_format" => "WidgetNumberFormat",
"v1.widget_order_by" => "WidgetOrderBy",
"v1.widget_palette" => "WidgetPalette",
"v1.widget_request_style" => "WidgetRequestStyle",
Expand Down
63 changes: 63 additions & 0 deletions lib/datadog_api_client/v1/models/number_format_unit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
=begin
#Datadog API V1 Collection

#Collection of all Datadog Public endpoints.

The version of the OpenAPI document: 1.0
Contact: support@datadoghq.com
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator

Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
This product includes software developed at Datadog (https://www.datadoghq.com/).
Copyright 2020-Present Datadog, Inc.

=end

require 'date'
require 'time'

module DatadogAPIClient::V1
# Number format unit.
module NumberFormatUnit
class << self
include BaseOneOfModel
include BaseOneOfModelNoDiscriminator

# List of class defined in oneOf (OpenAPI v3)
def openapi_one_of
[
:'NumberFormatUnitCanonical',
:'NumberFormatUnitCustom'
]
end
# Builds the object
# @param data [Mixed] Data to be matched against the list of oneOf items
# @return [Object] Returns the model or the data itself
def build(data)
# Go through the list of oneOf items and attempt to identify the appropriate one.
# Note:
# - We do not attempt to check whether exactly one item matches.
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
# - TODO: scalar values are de facto behaving as if they were nullable.
# - TODO: logging when debugging is set.
openapi_one_of.each do |klass|
begin
next if klass == :AnyType # "nullable: true"
typed_data = find_and_cast_into_type(klass, data)
next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed
return typed_data if typed_data
rescue # rescue all errors so we keep iterating even if the current item lookup raises
end
end

if openapi_one_of.include?(:AnyType)
data
else
self._unparsed = true
DatadogAPIClient::UnparsedObject.new(data)
end
end
end
end
end
Loading