Skip to content
Open
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
65 changes: 65 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,10 @@ components:
format: date-time
readOnly: true
type: string
default_timeframe:
$ref: "#/components/schemas/DashboardDefaultTimeframeSetting"
description: The default timeframe applied when opening the dashboard. Set to `null` to clear.
nullable: true
description:
description: Description of the dashboard.
nullable: true
Expand Down Expand Up @@ -1557,13 +1561,48 @@ components:
required:
- data
type: object
DashboardDefaultTimeframeSetting:
description: The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe.
oneOf:
- $ref: "#/components/schemas/DashboardLiveTimeframe"
- $ref: "#/components/schemas/DashboardFixedTimeframe"
DashboardDeleteResponse:
description: Response from the delete dashboard call.
properties:
deleted_dashboard_id:
description: ID of the deleted dashboard.
type: string
type: object
DashboardFixedTimeframe:
description: A fixed dashboard timeframe.
properties:
from:
description: Start time in milliseconds since epoch.
example: 1712080128000
format: int64
minimum: 0
type: integer
to:
description: End time in milliseconds since epoch.
example: 1712083128000
format: int64
minimum: 0
type: integer
type:
$ref: "#/components/schemas/DashboardFixedTimeframeType"
required:
- type
- from
- to
type: object
DashboardFixedTimeframeType:
description: Type of fixed timeframe.
enum:
- fixed
example: fixed
type: string
x-enum-varnames:
- FIXED
DashboardGlobalTime:
description: Object containing the live span selection for the dashboard.
properties:
Expand Down Expand Up @@ -1672,6 +1711,32 @@ components:
$ref: "#/components/schemas/DashboardList"
type: array
type: object
DashboardLiveTimeframe:
description: A live dashboard timeframe.
properties:
type:
$ref: "#/components/schemas/DashboardLiveTimeframeType"
unit:
$ref: "#/components/schemas/WidgetLiveSpanUnit"
value:
description: Value of the live timeframe span.
example: 4
format: int64
minimum: 1
type: integer
required:
- type
- value
- unit
type: object
DashboardLiveTimeframeType:
description: Type of live timeframe.
enum:
- live
example: live
type: string
x-enum-varnames:
- LIVE
DashboardReflowType:
description: |-
Reflow type for a **new dashboard layout** dashboard. Set this only when layout type is 'ordered'.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2026-06-22T17:48:02.651Z

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

29 changes: 29 additions & 0 deletions examples/v1/dashboards/CreateDashboard_4032568083.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Create a new dashboard with a live default_timeframe returns "OK" response

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

body = DatadogAPIClient::V1::Dashboard.new({
title: "Example-Dashboard",
layout_type: DatadogAPIClient::V1::DashboardLayoutType::ORDERED,
widgets: [
DatadogAPIClient::V1::Widget.new({
definition: DatadogAPIClient::V1::NoteWidgetDefinition.new({
type: DatadogAPIClient::V1::NoteWidgetDefinitionType::NOTE,
content: "test",
background_color: "white",
font_size: "14",
text_align: DatadogAPIClient::V1::WidgetTextAlign::LEFT,
show_tick: false,
tick_pos: "50%",
tick_edge: DatadogAPIClient::V1::WidgetTickEdge::LEFT,
}),
}),
],
default_timeframe: DatadogAPIClient::V1::DashboardLiveTimeframe.new({
type: DatadogAPIClient::V1::DashboardLiveTimeframeType::LIVE,
unit: DatadogAPIClient::V1::WidgetLiveSpanUnit::HOUR,
value: 4,
}),
})
p api_instance.create_dashboard(body)
16 changes: 13 additions & 3 deletions features/v1/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Feature: Dashboards
@generated @skip @team:DataDog/dashboards-backend
Scenario: Create a new dashboard returns "Bad Request" response
Given new "CreateDashboard" request
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}
And body with value {"default_timeframe": {"type": "live", "unit": "minute", "value": 4}, "description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}
When the request is sent
Then the response status is 400 Bad Request

Expand Down Expand Up @@ -171,6 +171,16 @@ Feature: Dashboards
And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "hour_before(query1)"
And the response "widgets[0].definition.requests[0].formulas[1].formula" is equal to "query1"

@team:DataDog/dashboards-backend
Scenario: Create a new dashboard with a live default_timeframe returns "OK" response
Given new "CreateDashboard" request
And body with value {"title": "{{ unique }}", "layout_type": "ordered", "widgets": [{"definition": {"type": "note", "content": "test", "background_color": "white", "font_size": "14", "text_align": "left", "show_tick": false, "tick_pos": "50%", "tick_edge": "left"}}], "default_timeframe": {"type": "live", "unit": "hour", "value": 4}}
When the request is sent
Then the response status is 200 OK
And the response "default_timeframe.type" is equal to "live"
And the response "default_timeframe.unit" is equal to "hour"
And the response "default_timeframe.value" is equal to 4

@team:DataDog/dashboards-backend
Scenario: Create a new dashboard with a query value widget using the percentile aggregator
Given new "CreateDashboard" request
Expand Down Expand Up @@ -1463,15 +1473,15 @@ Feature: Dashboards
Scenario: Update a dashboard returns "Bad Request" response
Given new "UpdateDashboard" request
And request contains "dashboard_id" parameter from "REPLACE.ME"
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}
And body with value {"default_timeframe": {"type": "live", "unit": "minute", "value": 4}, "description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/dashboards-backend
Scenario: Update a dashboard returns "Item Not Found" response
Given new "UpdateDashboard" request
And request contains "dashboard_id" parameter from "REPLACE.ME"
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}
And body with value {"default_timeframe": {"type": "live", "unit": "minute", "value": 4}, "description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}
When the request is sent
Then the response status is 404 Item Not Found

Expand Down
5 changes: 5 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,19 @@ def overrides
"v1.dashboard" => "Dashboard",
"v1.dashboard_bulk_action_data" => "DashboardBulkActionData",
"v1.dashboard_bulk_delete_request" => "DashboardBulkDeleteRequest",
"v1.dashboard_default_timeframe_setting" => "DashboardDefaultTimeframeSetting",
"v1.dashboard_delete_response" => "DashboardDeleteResponse",
"v1.dashboard_fixed_timeframe" => "DashboardFixedTimeframe",
"v1.dashboard_fixed_timeframe_type" => "DashboardFixedTimeframeType",
"v1.dashboard_global_time" => "DashboardGlobalTime",
"v1.dashboard_global_time_live_span" => "DashboardGlobalTimeLiveSpan",
"v1.dashboard_invite_type" => "DashboardInviteType",
"v1.dashboard_layout_type" => "DashboardLayoutType",
"v1.dashboard_list" => "DashboardList",
"v1.dashboard_list_delete_response" => "DashboardListDeleteResponse",
"v1.dashboard_list_list_response" => "DashboardListListResponse",
"v1.dashboard_live_timeframe" => "DashboardLiveTimeframe",
"v1.dashboard_live_timeframe_type" => "DashboardLiveTimeframeType",
"v1.dashboard_reflow_type" => "DashboardReflowType",
"v1.dashboard_resource_type" => "DashboardResourceType",
"v1.dashboard_restore_request" => "DashboardRestoreRequest",
Expand Down
12 changes: 11 additions & 1 deletion lib/datadog_api_client/v1/models/dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class Dashboard
# Creation date of the dashboard.
attr_accessor :created_at

# The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe.
attr_accessor :default_timeframe

# Description of the dashboard.
attr_accessor :description

Expand Down Expand Up @@ -89,6 +92,7 @@ def self.attribute_map
:'author_handle' => :'author_handle',
:'author_name' => :'author_name',
:'created_at' => :'created_at',
:'default_timeframe' => :'default_timeframe',
:'description' => :'description',
:'id' => :'id',
:'is_read_only' => :'is_read_only',
Expand All @@ -114,6 +118,7 @@ def self.openapi_types
:'author_handle' => :'String',
:'author_name' => :'String',
:'created_at' => :'Time',
:'default_timeframe' => :'DashboardDefaultTimeframeSetting',
:'description' => :'String',
:'id' => :'String',
:'is_read_only' => :'Boolean',
Expand Down Expand Up @@ -176,6 +181,10 @@ def initialize(attributes = {})
self.created_at = attributes[:'created_at']
end

if attributes.key?(:'default_timeframe')
self.default_timeframe = attributes[:'default_timeframe']
end

if attributes.key?(:'description')
self.description = attributes[:'description']
end
Expand Down Expand Up @@ -342,6 +351,7 @@ def ==(o)
author_handle == o.author_handle &&
author_name == o.author_name &&
created_at == o.created_at &&
default_timeframe == o.default_timeframe &&
description == o.description &&
id == o.id &&
is_read_only == o.is_read_only &&
Expand All @@ -364,7 +374,7 @@ def ==(o)
# @return [Integer] Hash code
# @!visibility private
def hash
[author_handle, author_name, created_at, description, id, is_read_only, layout_type, modified_at, notify_list, reflow_type, restricted_roles, tabs, tags, template_variable_presets, template_variables, title, url, widgets, additional_properties].hash
[author_handle, author_name, created_at, default_timeframe, description, id, is_read_only, layout_type, modified_at, notify_list, reflow_type, restricted_roles, tabs, tags, template_variable_presets, template_variables, title, url, widgets, additional_properties].hash
end
end
end
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
# The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe.
module DashboardDefaultTimeframeSetting
class << self
include BaseOneOfModel
include BaseOneOfModelNoDiscriminator

# List of class defined in oneOf (OpenAPI v3)
def openapi_one_of
[
:'DashboardLiveTimeframe',
:'DashboardFixedTimeframe'
]
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
Loading