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
37 changes: 37 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,13 @@ components:
description: A role UUID.
type: string
type: array
tabs:
description: List of tabs for organizing dashboard widgets into groups.
items:
$ref: '#/components/schemas/DashboardTab'
maxItems: 100
nullable: true
type: array
tags:
description: List of team names representing ownership of a dashboard.
items:
Expand Down Expand Up @@ -1681,6 +1688,36 @@ components:
description: URL of the dashboard.
type: string
type: object
DashboardTab:
description: Dashboard tab for organizing widgets.
properties:
id:
description: UUID of the tab.
example: ''
format: uuid
type: string
name:
description: Name of the tab.
example: L
maxLength: 100
minLength: 1
type: string
widget_ids:
description: 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.
example:
- 0
items:
description: Widget ID.
format: int64
type: integer
type: array
required:
- id
- name
- widget_ids
type: object
DashboardTemplateVariable:
description: Template variable.
properties:
Expand Down
38 changes: 37 additions & 1 deletion api/datadogV1/model_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type Dashboard struct {
ReflowType *DashboardReflowType `json:"reflow_type,omitempty"`
// A list of role identifiers. Only the author and users associated with at least one of these roles can edit this dashboard.
RestrictedRoles []string `json:"restricted_roles,omitempty"`
// List of tabs for organizing dashboard widgets into groups.
Tabs []DashboardTab `json:"tabs,omitempty"`
// List of team names representing ownership of a dashboard.
Tags datadog.NullableList[string] `json:"tags,omitempty"`
// Array of template variables saved views.
Expand Down Expand Up @@ -417,6 +419,35 @@ func (o *Dashboard) SetRestrictedRoles(v []string) {
o.RestrictedRoles = v
}

// GetTabs returns the Tabs field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *Dashboard) GetTabs() []DashboardTab {
if o == nil {
var ret []DashboardTab
return ret
}
return o.Tabs
}

// GetTabsOk returns a tuple with the Tabs field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned.
func (o *Dashboard) GetTabsOk() (*[]DashboardTab, bool) {
if o == nil || o.Tabs == nil {
return nil, false
}
return &o.Tabs, true
}

// HasTabs returns a boolean if a field has been set.
func (o *Dashboard) HasTabs() bool {
return o != nil && o.Tabs != nil
}

// SetTabs gets a reference to the given []DashboardTab and assigns it to the Tabs field.
func (o *Dashboard) SetTabs(v []DashboardTab) {
o.Tabs = v
}

// GetTags returns the Tags field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *Dashboard) GetTags() []string {
if o == nil || o.Tags.Get() == nil {
Expand Down Expand Up @@ -633,6 +664,9 @@ func (o Dashboard) MarshalJSON() ([]byte, error) {
if o.RestrictedRoles != nil {
toSerialize["restricted_roles"] = o.RestrictedRoles
}
if o.Tabs != nil {
toSerialize["tabs"] = o.Tabs
}
if o.Tags.IsSet() {
toSerialize["tags"] = o.Tags.Get()
}
Expand Down Expand Up @@ -668,6 +702,7 @@ func (o *Dashboard) UnmarshalJSON(bytes []byte) (err error) {
NotifyList datadog.NullableList[string] `json:"notify_list,omitempty"`
ReflowType *DashboardReflowType `json:"reflow_type,omitempty"`
RestrictedRoles []string `json:"restricted_roles,omitempty"`
Tabs []DashboardTab `json:"tabs,omitempty"`
Tags datadog.NullableList[string] `json:"tags,omitempty"`
TemplateVariablePresets []DashboardTemplateVariablePreset `json:"template_variable_presets,omitempty"`
TemplateVariables []DashboardTemplateVariable `json:"template_variables,omitempty"`
Expand All @@ -689,7 +724,7 @@ func (o *Dashboard) UnmarshalJSON(bytes []byte) (err error) {
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"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"})
datadog.DeleteKeys(additionalProperties, &[]string{"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"})
} else {
return err
}
Expand All @@ -714,6 +749,7 @@ func (o *Dashboard) UnmarshalJSON(bytes []byte) (err error) {
o.ReflowType = all.ReflowType
}
o.RestrictedRoles = all.RestrictedRoles
o.Tabs = all.Tabs
o.Tags = all.Tags
o.TemplateVariablePresets = all.TemplateVariablePresets
o.TemplateVariables = all.TemplateVariables
Expand Down
167 changes: 167 additions & 0 deletions api/datadogV1/model_dashboard_tab.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
// 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 2019-Present Datadog, Inc.

package datadogV1

import (
"fmt"

"github.com/google/uuid"

"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// DashboardTab Dashboard tab for organizing widgets.
type DashboardTab struct {
// UUID of the tab.
Id uuid.UUID `json:"id"`
// Name of the tab.
Name string `json:"name"`
// 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.
WidgetIds []int64 `json:"widget_ids"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject map[string]interface{} `json:"-"`
AdditionalProperties map[string]interface{} `json:"-"`
}

// NewDashboardTab instantiates a new DashboardTab object.
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed.
func NewDashboardTab(id uuid.UUID, name string, widgetIds []int64) *DashboardTab {
this := DashboardTab{}
this.Id = id
this.Name = name
this.WidgetIds = widgetIds
return &this
}

// NewDashboardTabWithDefaults instantiates a new DashboardTab object.
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set.
func NewDashboardTabWithDefaults() *DashboardTab {
this := DashboardTab{}
return &this
}

// GetId returns the Id field value.
func (o *DashboardTab) GetId() uuid.UUID {
if o == nil {
var ret uuid.UUID
return ret
}
return o.Id
}

// GetIdOk returns a tuple with the Id field value
// and a boolean to check if the value has been set.
func (o *DashboardTab) GetIdOk() (*uuid.UUID, bool) {
if o == nil {
return nil, false
}
return &o.Id, true
}

// SetId sets field value.
func (o *DashboardTab) SetId(v uuid.UUID) {
o.Id = v
}

// GetName returns the Name field value.
func (o *DashboardTab) GetName() string {
if o == nil {
var ret string
return ret
}
return o.Name
}

// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *DashboardTab) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}

// SetName sets field value.
func (o *DashboardTab) SetName(v string) {
o.Name = v
}

// GetWidgetIds returns the WidgetIds field value.
func (o *DashboardTab) GetWidgetIds() []int64 {
if o == nil {
var ret []int64
return ret
}
return o.WidgetIds
}

// GetWidgetIdsOk returns a tuple with the WidgetIds field value
// and a boolean to check if the value has been set.
func (o *DashboardTab) GetWidgetIdsOk() (*[]int64, bool) {
if o == nil {
return nil, false
}
return &o.WidgetIds, true
}

// SetWidgetIds sets field value.
func (o *DashboardTab) SetWidgetIds(v []int64) {
o.WidgetIds = v
}

// MarshalJSON serializes the struct using spec logic.
func (o DashboardTab) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
toSerialize["id"] = o.Id
toSerialize["name"] = o.Name
toSerialize["widget_ids"] = o.WidgetIds

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return datadog.Marshal(toSerialize)
}

// UnmarshalJSON deserializes the given payload.
func (o *DashboardTab) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Id *uuid.UUID `json:"id"`
Name *string `json:"name"`
WidgetIds *[]int64 `json:"widget_ids"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
if all.Id == nil {
return fmt.Errorf("required field id missing")
}
if all.Name == nil {
return fmt.Errorf("required field name missing")
}
if all.WidgetIds == nil {
return fmt.Errorf("required field widget_ids missing")
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"id", "name", "widget_ids"})
} else {
return err
}
o.Id = *all.Id
o.Name = *all.Name
o.WidgetIds = *all.WidgetIds

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
}

return nil
}
6 changes: 3 additions & 3 deletions tests/scenarios/features/v1/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,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": [], "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 {"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 @@ -1342,15 +1342,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": [], "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 {"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": [], "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 {"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