Skip to content

Commit bbc416f

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-specskarimo
authored
Regenerate client from commit acc0b78b of spec repo (#1668)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: skarimo <[email protected]>
1 parent 565ce9d commit bbc416f

File tree

19 files changed

+485
-13
lines changed

19 files changed

+485
-13
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2022-09-16 08:46:36.930376",
8-
"spec_repo_commit": "f1faacea"
7+
"regenerated": "2022-09-16 13:42:49.599994",
8+
"spec_repo_commit": "acc0b78b"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-09-16 08:46:36.947672",
13-
"spec_repo_commit": "f1faacea"
12+
"regenerated": "2022-09-16 13:42:49.615641",
13+
"spec_repo_commit": "acc0b78b"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,10 +1250,25 @@ components:
12501250
nullable: true
12511251
type: array
12521252
default:
1253-
description: The default value for the template variable on dashboard load.
1253+
deprecated: true
1254+
description: (deprecated) The default value for the template variable on
1255+
dashboard load. Cannot be used in conjunction with `defaults`.
12541256
example: my-host
12551257
nullable: true
12561258
type: string
1259+
defaults:
1260+
description: One or many default values for template variables on load.
1261+
If more than one default is specified, they will be unioned together with
1262+
`OR`. Cannot be used in conjunction with `default`.
1263+
example:
1264+
- my-host-1
1265+
- my-host-2
1266+
items:
1267+
description: One of many default values for the template variable on dashboard
1268+
load.
1269+
minLength: 1
1270+
type: string
1271+
type: array
12571272
name:
12581273
description: The name of the variable.
12591274
example: host1
@@ -1286,8 +1301,21 @@ components:
12861301
description: The name of the variable.
12871302
type: string
12881303
value:
1289-
description: The value of the template variable within the saved view.
1304+
deprecated: true
1305+
description: (deprecated) The value of the template variable within the
1306+
saved view. Cannot be used in conjunction with `values`.
12901307
type: string
1308+
values:
1309+
description: One or many template variable values within the saved view,
1310+
which will be unioned together using `OR` if more than one is specified.
1311+
Cannot be used in conjunction with `value`.
1312+
items:
1313+
description: One or many values of the template variable within the saved
1314+
view.
1315+
minLength: 1
1316+
type: string
1317+
minItems: 1
1318+
type: array
12911319
type: object
12921320
DeletedMonitor:
12931321
description: Response from the delete monitor call.

api/datadogV1/model_dashboard_template_variable.go

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ import (
1515
type DashboardTemplateVariable struct {
1616
// The list of values that the template variable drop-down is limited to.
1717
AvailableValues []string `json:"available_values,omitempty"`
18-
// The default value for the template variable on dashboard load.
18+
// (deprecated) The default value for the template variable on dashboard load. Cannot be used in conjunction with `defaults`.
19+
// Deprecated
1920
Default datadog.NullableString `json:"default,omitempty"`
21+
// One or many default values for template variables on load. If more than one default is specified, they will be unioned together with `OR`. Cannot be used in conjunction with `default`.
22+
Defaults []string `json:"defaults,omitempty"`
2023
// The name of the variable.
2124
Name string `json:"name"`
2225
// The tag prefix associated with the variable. Only tags with this prefix appear in the variable drop-down.
@@ -78,6 +81,7 @@ func (o *DashboardTemplateVariable) SetAvailableValues(v []string) {
7881
}
7982

8083
// GetDefault returns the Default field value if set, zero value otherwise (both if not set or set to explicit null).
84+
// Deprecated
8185
func (o *DashboardTemplateVariable) GetDefault() string {
8286
if o == nil || o.Default.Get() == nil {
8387
var ret string
@@ -89,6 +93,7 @@ func (o *DashboardTemplateVariable) GetDefault() string {
8993
// GetDefaultOk returns a tuple with the Default field value if set, nil otherwise
9094
// and a boolean to check if the value has been set.
9195
// NOTE: If the value is an explicit nil, `nil, true` will be returned.
96+
// Deprecated
9297
func (o *DashboardTemplateVariable) GetDefaultOk() (*string, bool) {
9398
if o == nil {
9499
return nil, false
@@ -106,6 +111,7 @@ func (o *DashboardTemplateVariable) HasDefault() bool {
106111
}
107112

108113
// SetDefault gets a reference to the given datadog.NullableString and assigns it to the Default field.
114+
// Deprecated
109115
func (o *DashboardTemplateVariable) SetDefault(v string) {
110116
o.Default.Set(&v)
111117
}
@@ -120,6 +126,38 @@ func (o *DashboardTemplateVariable) UnsetDefault() {
120126
o.Default.Unset()
121127
}
122128

129+
// GetDefaults returns the Defaults field value if set, zero value otherwise.
130+
func (o *DashboardTemplateVariable) GetDefaults() []string {
131+
if o == nil || o.Defaults == nil {
132+
var ret []string
133+
return ret
134+
}
135+
return o.Defaults
136+
}
137+
138+
// GetDefaultsOk returns a tuple with the Defaults field value if set, nil otherwise
139+
// and a boolean to check if the value has been set.
140+
func (o *DashboardTemplateVariable) GetDefaultsOk() (*[]string, bool) {
141+
if o == nil || o.Defaults == nil {
142+
return nil, false
143+
}
144+
return &o.Defaults, true
145+
}
146+
147+
// HasDefaults returns a boolean if a field has been set.
148+
func (o *DashboardTemplateVariable) HasDefaults() bool {
149+
if o != nil && o.Defaults != nil {
150+
return true
151+
}
152+
153+
return false
154+
}
155+
156+
// SetDefaults gets a reference to the given []string and assigns it to the Defaults field.
157+
func (o *DashboardTemplateVariable) SetDefaults(v []string) {
158+
o.Defaults = v
159+
}
160+
123161
// GetName returns the Name field value.
124162
func (o *DashboardTemplateVariable) GetName() string {
125163
if o == nil {
@@ -198,6 +236,9 @@ func (o DashboardTemplateVariable) MarshalJSON() ([]byte, error) {
198236
if o.Default.IsSet() {
199237
toSerialize["default"] = o.Default.Get()
200238
}
239+
if o.Defaults != nil {
240+
toSerialize["defaults"] = o.Defaults
241+
}
201242
toSerialize["name"] = o.Name
202243
if o.Prefix.IsSet() {
203244
toSerialize["prefix"] = o.Prefix.Get()
@@ -218,6 +259,7 @@ func (o *DashboardTemplateVariable) UnmarshalJSON(bytes []byte) (err error) {
218259
all := struct {
219260
AvailableValues []string `json:"available_values,omitempty"`
220261
Default datadog.NullableString `json:"default,omitempty"`
262+
Defaults []string `json:"defaults,omitempty"`
221263
Name string `json:"name"`
222264
Prefix datadog.NullableString `json:"prefix,omitempty"`
223265
}{}
@@ -239,6 +281,7 @@ func (o *DashboardTemplateVariable) UnmarshalJSON(bytes []byte) (err error) {
239281
}
240282
o.AvailableValues = all.AvailableValues
241283
o.Default = all.Default
284+
o.Defaults = all.Defaults
242285
o.Name = all.Name
243286
o.Prefix = all.Prefix
244287
return nil

api/datadogV1/model_dashboard_template_variable_preset_value.go

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ import (
1212
type DashboardTemplateVariablePresetValue struct {
1313
// The name of the variable.
1414
Name *string `json:"name,omitempty"`
15-
// The value of the template variable within the saved view.
15+
// (deprecated) The value of the template variable within the saved view. Cannot be used in conjunction with `values`.
16+
// Deprecated
1617
Value *string `json:"value,omitempty"`
18+
// One or many template variable values within the saved view, which will be unioned together using `OR` if more than one is specified. Cannot be used in conjunction with `value`.
19+
Values []string `json:"values,omitempty"`
1720
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
1821
UnparsedObject map[string]interface{} `json:-`
1922
AdditionalProperties map[string]interface{}
@@ -69,6 +72,7 @@ func (o *DashboardTemplateVariablePresetValue) SetName(v string) {
6972
}
7073

7174
// GetValue returns the Value field value if set, zero value otherwise.
75+
// Deprecated
7276
func (o *DashboardTemplateVariablePresetValue) GetValue() string {
7377
if o == nil || o.Value == nil {
7478
var ret string
@@ -79,6 +83,7 @@ func (o *DashboardTemplateVariablePresetValue) GetValue() string {
7983

8084
// GetValueOk returns a tuple with the Value field value if set, nil otherwise
8185
// and a boolean to check if the value has been set.
86+
// Deprecated
8287
func (o *DashboardTemplateVariablePresetValue) GetValueOk() (*string, bool) {
8388
if o == nil || o.Value == nil {
8489
return nil, false
@@ -96,10 +101,43 @@ func (o *DashboardTemplateVariablePresetValue) HasValue() bool {
96101
}
97102

98103
// SetValue gets a reference to the given string and assigns it to the Value field.
104+
// Deprecated
99105
func (o *DashboardTemplateVariablePresetValue) SetValue(v string) {
100106
o.Value = &v
101107
}
102108

109+
// GetValues returns the Values field value if set, zero value otherwise.
110+
func (o *DashboardTemplateVariablePresetValue) GetValues() []string {
111+
if o == nil || o.Values == nil {
112+
var ret []string
113+
return ret
114+
}
115+
return o.Values
116+
}
117+
118+
// GetValuesOk returns a tuple with the Values field value if set, nil otherwise
119+
// and a boolean to check if the value has been set.
120+
func (o *DashboardTemplateVariablePresetValue) GetValuesOk() (*[]string, bool) {
121+
if o == nil || o.Values == nil {
122+
return nil, false
123+
}
124+
return &o.Values, true
125+
}
126+
127+
// HasValues returns a boolean if a field has been set.
128+
func (o *DashboardTemplateVariablePresetValue) HasValues() bool {
129+
if o != nil && o.Values != nil {
130+
return true
131+
}
132+
133+
return false
134+
}
135+
136+
// SetValues gets a reference to the given []string and assigns it to the Values field.
137+
func (o *DashboardTemplateVariablePresetValue) SetValues(v []string) {
138+
o.Values = v
139+
}
140+
103141
// MarshalJSON serializes the struct using spec logic.
104142
func (o DashboardTemplateVariablePresetValue) MarshalJSON() ([]byte, error) {
105143
toSerialize := map[string]interface{}{}
@@ -112,6 +150,9 @@ func (o DashboardTemplateVariablePresetValue) MarshalJSON() ([]byte, error) {
112150
if o.Value != nil {
113151
toSerialize["value"] = o.Value
114152
}
153+
if o.Values != nil {
154+
toSerialize["values"] = o.Values
155+
}
115156

116157
for key, value := range o.AdditionalProperties {
117158
toSerialize[key] = value
@@ -123,8 +164,9 @@ func (o DashboardTemplateVariablePresetValue) MarshalJSON() ([]byte, error) {
123164
func (o *DashboardTemplateVariablePresetValue) UnmarshalJSON(bytes []byte) (err error) {
124165
raw := map[string]interface{}{}
125166
all := struct {
126-
Name *string `json:"name,omitempty"`
127-
Value *string `json:"value,omitempty"`
167+
Name *string `json:"name,omitempty"`
168+
Value *string `json:"value,omitempty"`
169+
Values []string `json:"values,omitempty"`
128170
}{}
129171
err = json.Unmarshal(bytes, &all)
130172
if err != nil {
@@ -137,5 +179,6 @@ func (o *DashboardTemplateVariablePresetValue) UnmarshalJSON(bytes []byte) (err
137179
}
138180
o.Name = all.Name
139181
o.Value = all.Value
182+
o.Values = all.Values
140183
return nil
141184
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Create a new dashboard with template variable presets using values returns "OK" response
2+
3+
package main
4+
5+
import (
6+
"context"
7+
"encoding/json"
8+
"fmt"
9+
"os"
10+
11+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
12+
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
13+
)
14+
15+
func main() {
16+
body := datadogV1.Dashboard{
17+
Description: *datadog.NewNullableString(nil),
18+
IsReadOnly: datadog.PtrBool(false),
19+
LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED,
20+
NotifyList: []string{},
21+
ReflowType: datadogV1.DASHBOARDREFLOWTYPE_AUTO.Ptr(),
22+
RestrictedRoles: []string{},
23+
TemplateVariablePresets: []datadogV1.DashboardTemplateVariablePreset{
24+
{
25+
Name: datadog.PtrString("my saved view"),
26+
TemplateVariables: []datadogV1.DashboardTemplateVariablePresetValue{
27+
{
28+
Name: datadog.PtrString("datacenter"),
29+
Values: []string{
30+
"*",
31+
"my-host",
32+
},
33+
},
34+
},
35+
},
36+
},
37+
TemplateVariables: []datadogV1.DashboardTemplateVariable{
38+
{
39+
AvailableValues: []string{
40+
"my-host",
41+
"host1",
42+
"host2",
43+
},
44+
Defaults: []string{
45+
"my-host",
46+
},
47+
Name: "host1",
48+
Prefix: *datadog.NewNullableString(datadog.PtrString("host")),
49+
},
50+
},
51+
Title: "",
52+
Widgets: []datadogV1.Widget{
53+
{
54+
Definition: datadogV1.WidgetDefinition{
55+
HostMapWidgetDefinition: &datadogV1.HostMapWidgetDefinition{
56+
Requests: datadogV1.HostMapWidgetDefinitionRequests{
57+
Fill: &datadogV1.HostMapRequest{
58+
Q: datadog.PtrString("avg:system.cpu.user{*}"),
59+
},
60+
},
61+
Type: datadogV1.HOSTMAPWIDGETDEFINITIONTYPE_HOSTMAP,
62+
}},
63+
},
64+
},
65+
}
66+
ctx := datadog.NewDefaultContext(context.Background())
67+
configuration := datadog.NewConfiguration()
68+
apiClient := datadog.NewAPIClient(configuration)
69+
api := datadogV1.NewDashboardsApi(apiClient)
70+
resp, r, err := api.CreateDashboard(ctx, body)
71+
72+
if err != nil {
73+
fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreateDashboard`: %v\n", err)
74+
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
75+
}
76+
77+
responseContent, _ := json.MarshalIndent(resp, "", " ")
78+
fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreateDashboard`:\n%s\n", responseContent)
79+
}

0 commit comments

Comments
 (0)