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-06-30 10:29:39.541125",
"spec_repo_commit": "be63084a"
"regenerated": "2025-06-30 17:05:04.655065",
"spec_repo_commit": "d8e7ee77"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-06-30 10:29:39.589743",
"spec_repo_commit": "be63084a"
"regenerated": "2025-06-30 17:05:04.670788",
"spec_repo_commit": "d8e7ee77"
}
}
}
13 changes: 13 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,13 @@ components:
example: host
nullable: true
type: string
type:
description: The type of variable. This is to differentiate between filter
variables (interpolated in query) and group by variables (interpolated
into group by).
example: group
nullable: true
type: string
required:
- name
type: object
Expand Down Expand Up @@ -12578,6 +12585,12 @@ components:
prefix:
description: The tag/attribute key associated with the template variable.
type: string
type:
description: The type of variable. This is to differentiate between filter
variables (interpolated in query) and group by variables (interpolated
into group by).
nullable: true
type: string
visible_tags:
description: List of visible tag values on the shared dashboard.
items:
Expand Down
48 changes: 47 additions & 1 deletion api/datadogV1/model_dashboard_template_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type DashboardTemplateVariable struct {
Name string `json:"name"`
// The tag prefix associated with the variable. Only tags with this prefix appear in the variable drop-down.
Prefix datadog.NullableString `json:"prefix,omitempty"`
// The type of variable. This is to differentiate between filter variables (interpolated in query) and group by variables (interpolated into group by).
Type datadog.NullableString `json:"type,omitempty"`
// 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:"-"`
Expand Down Expand Up @@ -217,6 +219,45 @@ func (o *DashboardTemplateVariable) UnsetPrefix() {
o.Prefix.Unset()
}

// GetType returns the Type field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *DashboardTemplateVariable) GetType() string {
if o == nil || o.Type.Get() == nil {
var ret string
return ret
}
return *o.Type.Get()
}

// GetTypeOk returns a tuple with the Type 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 *DashboardTemplateVariable) GetTypeOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Type.Get(), o.Type.IsSet()
}

// HasType returns a boolean if a field has been set.
func (o *DashboardTemplateVariable) HasType() bool {
return o != nil && o.Type.IsSet()
}

// SetType gets a reference to the given datadog.NullableString and assigns it to the Type field.
func (o *DashboardTemplateVariable) SetType(v string) {
o.Type.Set(&v)
}

// SetTypeNil sets the value for Type to be an explicit nil.
func (o *DashboardTemplateVariable) SetTypeNil() {
o.Type.Set(nil)
}

// UnsetType ensures that no value is present for Type, not even an explicit nil.
func (o *DashboardTemplateVariable) UnsetType() {
o.Type.Unset()
}

// MarshalJSON serializes the struct using spec logic.
func (o DashboardTemplateVariable) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
Expand All @@ -236,6 +277,9 @@ func (o DashboardTemplateVariable) MarshalJSON() ([]byte, error) {
if o.Prefix.IsSet() {
toSerialize["prefix"] = o.Prefix.Get()
}
if o.Type.IsSet() {
toSerialize["type"] = o.Type.Get()
}

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
Expand All @@ -251,6 +295,7 @@ func (o *DashboardTemplateVariable) UnmarshalJSON(bytes []byte) (err error) {
Defaults []string `json:"defaults,omitempty"`
Name *string `json:"name"`
Prefix datadog.NullableString `json:"prefix,omitempty"`
Type datadog.NullableString `json:"type,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
Expand All @@ -260,7 +305,7 @@ func (o *DashboardTemplateVariable) UnmarshalJSON(bytes []byte) (err error) {
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"available_values", "default", "defaults", "name", "prefix"})
datadog.DeleteKeys(additionalProperties, &[]string{"available_values", "default", "defaults", "name", "prefix", "type"})
} else {
return err
}
Expand All @@ -269,6 +314,7 @@ func (o *DashboardTemplateVariable) UnmarshalJSON(bytes []byte) (err error) {
o.Defaults = all.Defaults
o.Name = *all.Name
o.Prefix = all.Prefix
o.Type = all.Type

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
Expand Down
48 changes: 47 additions & 1 deletion api/datadogV1/model_selectable_template_variable_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type SelectableTemplateVariableItems struct {
Name *string `json:"name,omitempty"`
// The tag/attribute key associated with the template variable.
Prefix *string `json:"prefix,omitempty"`
// The type of variable. This is to differentiate between filter variables (interpolated in query) and group by variables (interpolated into group by).
Type datadog.NullableString `json:"type,omitempty"`
// List of visible tag values on the shared dashboard.
VisibleTags datadog.NullableList[string] `json:"visible_tags,omitempty"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
Expand Down Expand Up @@ -124,6 +126,45 @@ func (o *SelectableTemplateVariableItems) SetPrefix(v string) {
o.Prefix = &v
}

// GetType returns the Type field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *SelectableTemplateVariableItems) GetType() string {
if o == nil || o.Type.Get() == nil {
var ret string
return ret
}
return *o.Type.Get()
}

// GetTypeOk returns a tuple with the Type 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 *SelectableTemplateVariableItems) GetTypeOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Type.Get(), o.Type.IsSet()
}

// HasType returns a boolean if a field has been set.
func (o *SelectableTemplateVariableItems) HasType() bool {
return o != nil && o.Type.IsSet()
}

// SetType gets a reference to the given datadog.NullableString and assigns it to the Type field.
func (o *SelectableTemplateVariableItems) SetType(v string) {
o.Type.Set(&v)
}

// SetTypeNil sets the value for Type to be an explicit nil.
func (o *SelectableTemplateVariableItems) SetTypeNil() {
o.Type.Set(nil)
}

// UnsetType ensures that no value is present for Type, not even an explicit nil.
func (o *SelectableTemplateVariableItems) UnsetType() {
o.Type.Unset()
}

// GetVisibleTags returns the VisibleTags field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *SelectableTemplateVariableItems) GetVisibleTags() []string {
if o == nil || o.VisibleTags.Get() == nil {
Expand Down Expand Up @@ -178,6 +219,9 @@ func (o SelectableTemplateVariableItems) MarshalJSON() ([]byte, error) {
if o.Prefix != nil {
toSerialize["prefix"] = o.Prefix
}
if o.Type.IsSet() {
toSerialize["type"] = o.Type.Get()
}
if o.VisibleTags.IsSet() {
toSerialize["visible_tags"] = o.VisibleTags.Get()
}
Expand All @@ -194,20 +238,22 @@ func (o *SelectableTemplateVariableItems) UnmarshalJSON(bytes []byte) (err error
DefaultValue *string `json:"default_value,omitempty"`
Name *string `json:"name,omitempty"`
Prefix *string `json:"prefix,omitempty"`
Type datadog.NullableString `json:"type,omitempty"`
VisibleTags datadog.NullableList[string] `json:"visible_tags,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"default_value", "name", "prefix", "visible_tags"})
datadog.DeleteKeys(additionalProperties, &[]string{"default_value", "name", "prefix", "type", "visible_tags"})
} else {
return err
}
o.DefaultValue = all.DefaultValue
o.Name = all.Name
o.Prefix = all.Prefix
o.Type = all.Type
o.VisibleTags = all.VisibleTags

if len(additionalProperties) > 0 {
Expand Down
65 changes: 65 additions & 0 deletions examples/v1/dashboards/CreateDashboard_1751391372.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Create a new dashboard with template variable type field returns "OK" response

package main

import (
"context"
"encoding/json"
"fmt"
"os"

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

func main() {
body := datadogV1.Dashboard{
Description: *datadog.NewNullableString(nil),
LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED,
NotifyList: *datadog.NewNullableList(&[]string{}),
ReflowType: datadogV1.DASHBOARDREFLOWTYPE_AUTO.Ptr(),
RestrictedRoles: []string{},
TemplateVariables: []datadogV1.DashboardTemplateVariable{
{
AvailableValues: *datadog.NewNullableList(&[]string{
"service",
"datacenter",
"env",
}),
Defaults: []string{
"service",
"datacenter",
},
Name: "group_by_var",
Type: *datadog.NewNullableString(datadog.PtrString("group")),
},
},
Title: "",
Widgets: []datadogV1.Widget{
{
Definition: datadogV1.WidgetDefinition{
HostMapWidgetDefinition: &datadogV1.HostMapWidgetDefinition{
Requests: datadogV1.HostMapWidgetDefinitionRequests{
Fill: &datadogV1.HostMapRequest{
Q: datadog.PtrString("avg:system.cpu.user{*}"),
},
},
Type: datadogV1.HOSTMAPWIDGETDEFINITIONTYPE_HOSTMAP,
}},
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewDashboardsApi(apiClient)
resp, r, err := api.CreateDashboard(ctx, body)

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreateDashboard`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}

responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreateDashboard`:\n%s\n", responseContent)
}
51 changes: 51 additions & 0 deletions examples/v1/dashboards/CreatePublicDashboard_1668947073.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Create a shared dashboard with a group template variable returns "OK" response

package main

import (
"context"
"encoding/json"
"fmt"
"os"

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

func main() {
// there is a valid "dashboard" in the system
DashboardID := os.Getenv("DASHBOARD_ID")

body := datadogV1.SharedDashboard{
DashboardId: DashboardID,
DashboardType: datadogV1.DASHBOARDTYPE_CUSTOM_TIMEBOARD,
ShareType: *datadogV1.NewNullableDashboardShareType(datadogV1.DASHBOARDSHARETYPE_OPEN.Ptr()),
GlobalTime: &datadogV1.DashboardGlobalTime{
LiveSpan: datadogV1.DASHBOARDGLOBALTIMELIVESPAN_PAST_ONE_HOUR.Ptr(),
},
SelectableTemplateVars: []datadogV1.SelectableTemplateVariableItems{
{
DefaultValue: datadog.PtrString("*"),
Name: datadog.PtrString("group_by_var"),
Type: *datadog.NewNullableString(datadog.PtrString("group")),
VisibleTags: *datadog.NewNullableList(&[]string{
"selectableValue1",
"selectableValue2",
}),
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewDashboardsApi(apiClient)
resp, r, err := api.CreatePublicDashboard(ctx, body)

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreatePublicDashboard`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}

responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreatePublicDashboard`:\n%s\n", responseContent)
}
50 changes: 50 additions & 0 deletions examples/v1/dashboards/UpdatePublicDashboard_1708268778.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Update a shared dashboard with selectable_template_vars returns "OK" response

package main

import (
"context"
"encoding/json"
"fmt"
"os"

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

func main() {
// there is a valid "shared_dashboard" in the system
SharedDashboardToken := os.Getenv("SHARED_DASHBOARD_TOKEN")

body := datadogV1.SharedDashboardUpdateRequest{
GlobalTime: *datadogV1.NewNullableSharedDashboardUpdateRequestGlobalTime(&datadogV1.SharedDashboardUpdateRequestGlobalTime{
LiveSpan: datadogV1.DASHBOARDGLOBALTIMELIVESPAN_PAST_FIFTEEN_MINUTES.Ptr(),
}),
ShareList: *datadog.NewNullableList(&[]string{}),
ShareType: *datadogV1.NewNullableDashboardShareType(datadogV1.DASHBOARDSHARETYPE_OPEN.Ptr()),
SelectableTemplateVars: []datadogV1.SelectableTemplateVariableItems{
{
DefaultValue: datadog.PtrString("*"),
Name: datadog.PtrString("group_by_var"),
Type: *datadog.NewNullableString(datadog.PtrString("group")),
VisibleTags: *datadog.NewNullableList(&[]string{
"selectableValue1",
"selectableValue2",
}),
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewDashboardsApi(apiClient)
resp, r, err := api.UpdatePublicDashboard(ctx, SharedDashboardToken, body)

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.UpdatePublicDashboard`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}

responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.UpdatePublicDashboard`:\n%s\n", responseContent)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2025-06-30T15:47:16.966Z
Loading