Skip to content

Commit fe7cd04

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
dashboards - Add DashboardTab schema and tabs property to Dashboard spec (#3011)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 3cbd973 commit fe7cd04

5 files changed

Lines changed: 241 additions & 4 deletions

File tree

.generator/schemas/v1/openapi.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,13 @@ components:
13141314
description: A role UUID.
13151315
type: string
13161316
type: array
1317+
tabs:
1318+
description: List of tabs for organizing dashboard widgets into groups.
1319+
items:
1320+
$ref: '#/components/schemas/DashboardTab'
1321+
maxItems: 100
1322+
nullable: true
1323+
type: array
13171324
tags:
13181325
description: List of team names representing ownership of a dashboard.
13191326
items:
@@ -1584,6 +1591,36 @@ components:
15841591
description: URL of the dashboard.
15851592
type: string
15861593
type: object
1594+
DashboardTab:
1595+
description: Dashboard tab for organizing widgets.
1596+
properties:
1597+
id:
1598+
description: UUID of the tab.
1599+
example: ''
1600+
format: uuid
1601+
type: string
1602+
name:
1603+
description: Name of the tab.
1604+
example: L
1605+
maxLength: 100
1606+
minLength: 1
1607+
type: string
1608+
widget_ids:
1609+
description: List of widget IDs belonging to this tab. The backend also
1610+
accepts positional references in @N format (1-indexed) as a convenience
1611+
for Terraform and other declarative tools.
1612+
example:
1613+
- 0
1614+
items:
1615+
description: Widget ID.
1616+
format: int64
1617+
type: integer
1618+
type: array
1619+
required:
1620+
- id
1621+
- name
1622+
- widget_ids
1623+
type: object
15871624
DashboardTemplateVariable:
15881625
description: Template variable.
15891626
properties:

features/v1/dashboards.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Feature: Dashboards
9090
@generated @skip @team:DataDog/dashboards-backend
9191
Scenario: Create a new dashboard returns "Bad Request" response
9292
Given new "CreateDashboard" request
93-
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "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"}}]}
93+
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"}}]}
9494
When the request is sent
9595
Then the response status is 400 Bad Request
9696

@@ -1373,15 +1373,15 @@ Feature: Dashboards
13731373
Scenario: Update a dashboard returns "Bad Request" response
13741374
Given new "UpdateDashboard" request
13751375
And request contains "dashboard_id" parameter from "REPLACE.ME"
1376-
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "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"}}]}
1376+
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"}}]}
13771377
When the request is sent
13781378
Then the response status is 400 Bad Request
13791379

13801380
@generated @skip @team:DataDog/dashboards-backend
13811381
Scenario: Update a dashboard returns "Item Not Found" response
13821382
Given new "UpdateDashboard" request
13831383
And request contains "dashboard_id" parameter from "REPLACE.ME"
1384-
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "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"}}]}
1384+
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"}}]}
13851385
When the request is sent
13861386
Then the response status is 404 Item Not Found
13871387

lib/datadog_api_client/inflector.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def overrides
9494
"v1.dashboard_share_type" => "DashboardShareType",
9595
"v1.dashboard_summary" => "DashboardSummary",
9696
"v1.dashboard_summary_definition" => "DashboardSummaryDefinition",
97+
"v1.dashboard_tab" => "DashboardTab",
9798
"v1.dashboard_template_variable" => "DashboardTemplateVariable",
9899
"v1.dashboard_template_variable_preset" => "DashboardTemplateVariablePreset",
99100
"v1.dashboard_template_variable_preset_value" => "DashboardTemplateVariablePresetValue",

lib/datadog_api_client/v1/models/dashboard.rb

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class Dashboard
5959
# A list of role identifiers. Only the author and users associated with at least one of these roles can edit this dashboard.
6060
attr_accessor :restricted_roles
6161

62+
# List of tabs for organizing dashboard widgets into groups.
63+
attr_reader :tabs
64+
6265
# List of team names representing ownership of a dashboard.
6366
attr_reader :tags
6467

@@ -94,6 +97,7 @@ def self.attribute_map
9497
:'notify_list' => :'notify_list',
9598
:'reflow_type' => :'reflow_type',
9699
:'restricted_roles' => :'restricted_roles',
100+
:'tabs' => :'tabs',
97101
:'tags' => :'tags',
98102
:'template_variable_presets' => :'template_variable_presets',
99103
:'template_variables' => :'template_variables',
@@ -118,6 +122,7 @@ def self.openapi_types
118122
:'notify_list' => :'Array<String>',
119123
:'reflow_type' => :'DashboardReflowType',
120124
:'restricted_roles' => :'Array<String>',
125+
:'tabs' => :'Array<DashboardTab>',
121126
:'tags' => :'Array<String>',
122127
:'template_variable_presets' => :'Array<DashboardTemplateVariablePreset>',
123128
:'template_variables' => :'Array<DashboardTemplateVariable>',
@@ -134,6 +139,7 @@ def self.openapi_nullable
134139
:'author_name',
135140
:'description',
136141
:'notify_list',
142+
:'tabs',
137143
:'tags',
138144
:'template_variable_presets',
139145
:'template_variables',
@@ -206,6 +212,12 @@ def initialize(attributes = {})
206212
end
207213
end
208214

215+
if attributes.key?(:'tabs')
216+
if (value = attributes[:'tabs']).is_a?(Array)
217+
self.tabs = value
218+
end
219+
end
220+
209221
if attributes.key?(:'tags')
210222
if (value = attributes[:'tags']).is_a?(Array)
211223
self.tags = value
@@ -244,6 +256,7 @@ def initialize(attributes = {})
244256
# @!visibility private
245257
def valid?
246258
return false if @layout_type.nil?
259+
return false if !@tabs.nil? && @tabs.length > 100
247260
return false if !@tags.nil? && @tags.length > 5
248261
return false if @title.nil?
249262
return false if @widgets.nil?
@@ -260,6 +273,16 @@ def layout_type=(layout_type)
260273
@layout_type = layout_type
261274
end
262275

276+
# Custom attribute writer method with validation
277+
# @param tabs [Object] Object to be assigned
278+
# @!visibility private
279+
def tabs=(tabs)
280+
if !tabs.nil? && tabs.length > 100
281+
fail ArgumentError, 'invalid value for "tabs", number of items must be less than or equal to 100.'
282+
end
283+
@tabs = tabs
284+
end
285+
263286
# Custom attribute writer method with validation
264287
# @param tags [Object] Object to be assigned
265288
# @!visibility private
@@ -327,6 +350,7 @@ def ==(o)
327350
notify_list == o.notify_list &&
328351
reflow_type == o.reflow_type &&
329352
restricted_roles == o.restricted_roles &&
353+
tabs == o.tabs &&
330354
tags == o.tags &&
331355
template_variable_presets == o.template_variable_presets &&
332356
template_variables == o.template_variables &&
@@ -340,7 +364,7 @@ def ==(o)
340364
# @return [Integer] Hash code
341365
# @!visibility private
342366
def hash
343-
[author_handle, author_name, created_at, description, id, is_read_only, layout_type, modified_at, notify_list, reflow_type, restricted_roles, tags, template_variable_presets, template_variables, title, url, widgets, additional_properties].hash
367+
[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
344368
end
345369
end
346370
end
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
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+
Contact: support@datadoghq.com
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+
# Dashboard tab for organizing widgets.
21+
class DashboardTab
22+
include BaseGenericModel
23+
24+
# UUID of the tab.
25+
attr_reader :id
26+
27+
# Name of the tab.
28+
attr_reader :name
29+
30+
# List of widget IDs belonging to this tab. The backend also accepts positional references in @N format (1-indexed) as a convenience for Terraform and other declarative tools.
31+
attr_reader :widget_ids
32+
33+
attr_accessor :additional_properties
34+
35+
# Attribute mapping from ruby-style variable name to JSON key.
36+
# @!visibility private
37+
def self.attribute_map
38+
{
39+
:'id' => :'id',
40+
:'name' => :'name',
41+
:'widget_ids' => :'widget_ids'
42+
}
43+
end
44+
45+
# Attribute type mapping.
46+
# @!visibility private
47+
def self.openapi_types
48+
{
49+
:'id' => :'UUID',
50+
:'name' => :'String',
51+
:'widget_ids' => :'Array<Integer>'
52+
}
53+
end
54+
55+
# Initializes the object
56+
# @param attributes [Hash] Model attributes in the form of hash
57+
# @!visibility private
58+
def initialize(attributes = {})
59+
if (!attributes.is_a?(Hash))
60+
fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::DashboardTab` initialize method"
61+
end
62+
63+
self.additional_properties = {}
64+
# check to see if the attribute exists and convert string to symbol for hash key
65+
attributes = attributes.each_with_object({}) { |(k, v), h|
66+
if (!self.class.attribute_map.key?(k.to_sym))
67+
self.additional_properties[k.to_sym] = v
68+
else
69+
h[k.to_sym] = v
70+
end
71+
}
72+
73+
if attributes.key?(:'id')
74+
self.id = attributes[:'id']
75+
end
76+
77+
if attributes.key?(:'name')
78+
self.name = attributes[:'name']
79+
end
80+
81+
if attributes.key?(:'widget_ids')
82+
if (value = attributes[:'widget_ids']).is_a?(Array)
83+
self.widget_ids = value
84+
end
85+
end
86+
end
87+
88+
# Check to see if the all the properties in the model are valid
89+
# @return true if the model is valid
90+
# @!visibility private
91+
def valid?
92+
return false if @id.nil?
93+
return false if @name.nil?
94+
return false if @name.to_s.length > 100
95+
return false if @name.to_s.length < 1
96+
return false if @widget_ids.nil?
97+
true
98+
end
99+
100+
# Custom attribute writer method with validation
101+
# @param id [Object] Object to be assigned
102+
# @!visibility private
103+
def id=(id)
104+
if id.nil?
105+
fail ArgumentError, 'invalid value for "id", id cannot be nil.'
106+
end
107+
@id = id
108+
end
109+
110+
# Custom attribute writer method with validation
111+
# @param name [Object] Object to be assigned
112+
# @!visibility private
113+
def name=(name)
114+
if name.nil?
115+
fail ArgumentError, 'invalid value for "name", name cannot be nil.'
116+
end
117+
if name.to_s.length > 100
118+
fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 100.'
119+
end
120+
if name.to_s.length < 1
121+
fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
122+
end
123+
@name = name
124+
end
125+
126+
# Custom attribute writer method with validation
127+
# @param widget_ids [Object] Object to be assigned
128+
# @!visibility private
129+
def widget_ids=(widget_ids)
130+
if widget_ids.nil?
131+
fail ArgumentError, 'invalid value for "widget_ids", widget_ids cannot be nil.'
132+
end
133+
@widget_ids = widget_ids
134+
end
135+
136+
# Returns the object in the form of hash, with additionalProperties support.
137+
# @return [Hash] Returns the object in the form of hash
138+
# @!visibility private
139+
def to_hash
140+
hash = {}
141+
self.class.attribute_map.each_pair do |attr, param|
142+
value = self.send(attr)
143+
if value.nil?
144+
is_nullable = self.class.openapi_nullable.include?(attr)
145+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
146+
end
147+
148+
hash[param] = _to_hash(value)
149+
end
150+
self.additional_properties.each_pair do |attr, value|
151+
hash[attr] = value
152+
end
153+
hash
154+
end
155+
156+
# Checks equality by comparing each attribute.
157+
# @param o [Object] Object to be compared
158+
# @!visibility private
159+
def ==(o)
160+
return true if self.equal?(o)
161+
self.class == o.class &&
162+
id == o.id &&
163+
name == o.name &&
164+
widget_ids == o.widget_ids &&
165+
additional_properties == o.additional_properties
166+
end
167+
168+
# Calculates hash code according to all attributes.
169+
# @return [Integer] Hash code
170+
# @!visibility private
171+
def hash
172+
[id, name, widget_ids, additional_properties].hash
173+
end
174+
end
175+
end

0 commit comments

Comments
 (0)