From b1680d5ec6885e6a9d9c5baa6559e378180c9831 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 14 Sep 2022 15:21:05 +0000 Subject: [PATCH] Regenerate client from commit 0519e4c3 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v1/openapi.yaml | 32 +++++++- .../model_dashboard_template_variable.go | 45 ++++++++++- ...ashboard_template_variable_preset_value.go | 49 +++++++++++- .../dashboards/CreateDashboard_2850365602.go | 79 +++++++++++++++++++ .../dashboards/CreateDashboard_858397694.go | 65 +++++++++++++++ ...efault_returns_Bad_Request_response.freeze | 1 + ..._default_returns_Bad_Request_response.yaml | 23 ++++++ ...riable_defaults_returns_OK_response.freeze | 1 + ...variable_defaults_returns_OK_response.yaml | 41 ++++++++++ ...length_returns_Bad_Request_response.freeze | 1 + ...o_length_returns_Bad_Request_response.yaml | 23 ++++++ ..._value_returns_Bad_Request_response.freeze | 1 + ...nd_value_returns_Bad_Request_response.yaml | 23 ++++++ ...ts_using_values_returns_OK_response.freeze | 1 + ...sets_using_values_returns_OK_response.yaml | 42 ++++++++++ ...length_returns_Bad_Request_response.freeze | 1 + ...o_length_returns_Bad_Request_response.yaml | 23 ++++++ .../scenarios/features/v1/dashboards.feature | 48 ++++++++++- 19 files changed, 494 insertions(+), 13 deletions(-) create mode 100644 examples/v1/dashboards/CreateDashboard_2850365602.go create mode 100644 examples/v1/dashboards/CreateDashboard_858397694.go create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_and_default_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_and_default_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_whose_value_has_no_length_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_whose_value_has_no_length_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_and_value_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_and_value_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_with_no_length_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_with_no_length_returns_Bad_Request_response.yaml diff --git a/.apigentools-info b/.apigentools-info index da3fc455ba2..d3a5d8c5f05 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2022-09-14 07:52:39.048467", - "spec_repo_commit": "4e5b7510" + "regenerated": "2022-09-14 15:19:55.860052", + "spec_repo_commit": "0519e4c3" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2022-09-14 07:52:39.066098", - "spec_repo_commit": "4e5b7510" + "regenerated": "2022-09-14 15:19:55.873610", + "spec_repo_commit": "0519e4c3" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 8260d429787..2990ab08c55 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -1250,10 +1250,25 @@ components: nullable: true type: array default: - description: The default value for the template variable on dashboard load. + deprecated: true + description: (deprecated) The default value for the template variable on + dashboard load. Cannot be used in conjunction with `defaults`. example: my-host nullable: true type: string + defaults: + description: 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`. + example: + - my-host-1 + - my-host-2 + items: + description: One of many default values for the template variable on dashboard + load. + minLength: 1 + type: string + type: array name: description: The name of the variable. example: host1 @@ -1286,8 +1301,21 @@ components: description: The name of the variable. type: string value: - description: The value of the template variable within the saved view. + deprecated: true + description: (deprecated) The value of the template variable within the + saved view. Cannot be used in conjunction with `values`. type: string + values: + description: 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`. + items: + description: One or many values of the template variable within the saved + view. + minLength: 1 + type: string + minItems: 1 + type: array type: object DeletedMonitor: description: Response from the delete monitor call. diff --git a/api/datadogV1/model_dashboard_template_variable.go b/api/datadogV1/model_dashboard_template_variable.go index ede781d0552..d677cdc0ccf 100644 --- a/api/datadogV1/model_dashboard_template_variable.go +++ b/api/datadogV1/model_dashboard_template_variable.go @@ -15,8 +15,11 @@ import ( type DashboardTemplateVariable struct { // The list of values that the template variable drop-down is limited to. AvailableValues []string `json:"available_values,omitempty"` - // The default value for the template variable on dashboard load. + // (deprecated) The default value for the template variable on dashboard load. Cannot be used in conjunction with `defaults`. + // Deprecated Default datadog.NullableString `json:"default,omitempty"` + // 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`. + Defaults []string `json:"defaults,omitempty"` // The name of the variable. Name string `json:"name"` // 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) { } // GetDefault returns the Default field value if set, zero value otherwise (both if not set or set to explicit null). +// Deprecated func (o *DashboardTemplateVariable) GetDefault() string { if o == nil || o.Default.Get() == nil { var ret string @@ -89,6 +93,7 @@ func (o *DashboardTemplateVariable) GetDefault() string { // GetDefaultOk returns a tuple with the Default 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. +// Deprecated func (o *DashboardTemplateVariable) GetDefaultOk() (*string, bool) { if o == nil { return nil, false @@ -106,6 +111,7 @@ func (o *DashboardTemplateVariable) HasDefault() bool { } // SetDefault gets a reference to the given datadog.NullableString and assigns it to the Default field. +// Deprecated func (o *DashboardTemplateVariable) SetDefault(v string) { o.Default.Set(&v) } @@ -120,6 +126,38 @@ func (o *DashboardTemplateVariable) UnsetDefault() { o.Default.Unset() } +// GetDefaults returns the Defaults field value if set, zero value otherwise. +func (o *DashboardTemplateVariable) GetDefaults() []string { + if o == nil || o.Defaults == nil { + var ret []string + return ret + } + return o.Defaults +} + +// GetDefaultsOk returns a tuple with the Defaults field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DashboardTemplateVariable) GetDefaultsOk() (*[]string, bool) { + if o == nil || o.Defaults == nil { + return nil, false + } + return &o.Defaults, true +} + +// HasDefaults returns a boolean if a field has been set. +func (o *DashboardTemplateVariable) HasDefaults() bool { + if o != nil && o.Defaults != nil { + return true + } + + return false +} + +// SetDefaults gets a reference to the given []string and assigns it to the Defaults field. +func (o *DashboardTemplateVariable) SetDefaults(v []string) { + o.Defaults = v +} + // GetName returns the Name field value. func (o *DashboardTemplateVariable) GetName() string { if o == nil { @@ -198,6 +236,9 @@ func (o DashboardTemplateVariable) MarshalJSON() ([]byte, error) { if o.Default.IsSet() { toSerialize["default"] = o.Default.Get() } + if o.Defaults != nil { + toSerialize["defaults"] = o.Defaults + } toSerialize["name"] = o.Name if o.Prefix.IsSet() { toSerialize["prefix"] = o.Prefix.Get() @@ -218,6 +259,7 @@ func (o *DashboardTemplateVariable) UnmarshalJSON(bytes []byte) (err error) { all := struct { AvailableValues []string `json:"available_values,omitempty"` Default datadog.NullableString `json:"default,omitempty"` + Defaults []string `json:"defaults,omitempty"` Name string `json:"name"` Prefix datadog.NullableString `json:"prefix,omitempty"` }{} @@ -239,6 +281,7 @@ func (o *DashboardTemplateVariable) UnmarshalJSON(bytes []byte) (err error) { } o.AvailableValues = all.AvailableValues o.Default = all.Default + o.Defaults = all.Defaults o.Name = all.Name o.Prefix = all.Prefix return nil diff --git a/api/datadogV1/model_dashboard_template_variable_preset_value.go b/api/datadogV1/model_dashboard_template_variable_preset_value.go index 712fd1eb5f5..39b188db38c 100644 --- a/api/datadogV1/model_dashboard_template_variable_preset_value.go +++ b/api/datadogV1/model_dashboard_template_variable_preset_value.go @@ -12,8 +12,11 @@ import ( type DashboardTemplateVariablePresetValue struct { // The name of the variable. Name *string `json:"name,omitempty"` - // The value of the template variable within the saved view. + // (deprecated) The value of the template variable within the saved view. Cannot be used in conjunction with `values`. + // Deprecated Value *string `json:"value,omitempty"` + // 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`. + Values []string `json:"values,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{} @@ -69,6 +72,7 @@ func (o *DashboardTemplateVariablePresetValue) SetName(v string) { } // GetValue returns the Value field value if set, zero value otherwise. +// Deprecated func (o *DashboardTemplateVariablePresetValue) GetValue() string { if o == nil || o.Value == nil { var ret string @@ -79,6 +83,7 @@ func (o *DashboardTemplateVariablePresetValue) GetValue() string { // GetValueOk returns a tuple with the Value field value if set, nil otherwise // and a boolean to check if the value has been set. +// Deprecated func (o *DashboardTemplateVariablePresetValue) GetValueOk() (*string, bool) { if o == nil || o.Value == nil { return nil, false @@ -96,10 +101,43 @@ func (o *DashboardTemplateVariablePresetValue) HasValue() bool { } // SetValue gets a reference to the given string and assigns it to the Value field. +// Deprecated func (o *DashboardTemplateVariablePresetValue) SetValue(v string) { o.Value = &v } +// GetValues returns the Values field value if set, zero value otherwise. +func (o *DashboardTemplateVariablePresetValue) GetValues() []string { + if o == nil || o.Values == nil { + var ret []string + return ret + } + return o.Values +} + +// GetValuesOk returns a tuple with the Values field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DashboardTemplateVariablePresetValue) GetValuesOk() (*[]string, bool) { + if o == nil || o.Values == nil { + return nil, false + } + return &o.Values, true +} + +// HasValues returns a boolean if a field has been set. +func (o *DashboardTemplateVariablePresetValue) HasValues() bool { + if o != nil && o.Values != nil { + return true + } + + return false +} + +// SetValues gets a reference to the given []string and assigns it to the Values field. +func (o *DashboardTemplateVariablePresetValue) SetValues(v []string) { + o.Values = v +} + // MarshalJSON serializes the struct using spec logic. func (o DashboardTemplateVariablePresetValue) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} @@ -112,6 +150,9 @@ func (o DashboardTemplateVariablePresetValue) MarshalJSON() ([]byte, error) { if o.Value != nil { toSerialize["value"] = o.Value } + if o.Values != nil { + toSerialize["values"] = o.Values + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -123,8 +164,9 @@ func (o DashboardTemplateVariablePresetValue) MarshalJSON() ([]byte, error) { func (o *DashboardTemplateVariablePresetValue) UnmarshalJSON(bytes []byte) (err error) { raw := map[string]interface{}{} all := struct { - Name *string `json:"name,omitempty"` - Value *string `json:"value,omitempty"` + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` + Values []string `json:"values,omitempty"` }{} err = json.Unmarshal(bytes, &all) if err != nil { @@ -137,5 +179,6 @@ func (o *DashboardTemplateVariablePresetValue) UnmarshalJSON(bytes []byte) (err } o.Name = all.Name o.Value = all.Value + o.Values = all.Values return nil } diff --git a/examples/v1/dashboards/CreateDashboard_2850365602.go b/examples/v1/dashboards/CreateDashboard_2850365602.go new file mode 100644 index 00000000000..b6cf181b2b4 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_2850365602.go @@ -0,0 +1,79 @@ +// Create a new dashboard with template variable presets using values 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), + IsReadOnly: datadog.PtrBool(false), + LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED, + NotifyList: []string{}, + ReflowType: datadogV1.DASHBOARDREFLOWTYPE_AUTO.Ptr(), + RestrictedRoles: []string{}, + TemplateVariablePresets: []datadogV1.DashboardTemplateVariablePreset{ + { + Name: datadog.PtrString("my saved view"), + TemplateVariables: []datadogV1.DashboardTemplateVariablePresetValue{ + { + Name: datadog.PtrString("datacenter"), + Values: []string{ + "*", + "my-host", + }, + }, + }, + }, + }, + TemplateVariables: []datadogV1.DashboardTemplateVariable{ + { + AvailableValues: []string{ + "my-host", + "host1", + "host2", + }, + Defaults: []string{ + "my-host", + }, + Name: "host1", + Prefix: *datadog.NewNullableString(datadog.PtrString("host")), + }, + }, + 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) +} diff --git a/examples/v1/dashboards/CreateDashboard_858397694.go b/examples/v1/dashboards/CreateDashboard_858397694.go new file mode 100644 index 00000000000..7715de42380 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_858397694.go @@ -0,0 +1,65 @@ +// Create a new dashboard with template variable defaults 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), + IsReadOnly: datadog.PtrBool(false), + LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED, + NotifyList: []string{}, + ReflowType: datadogV1.DASHBOARDREFLOWTYPE_AUTO.Ptr(), + RestrictedRoles: []string{}, + TemplateVariables: []datadogV1.DashboardTemplateVariable{ + { + AvailableValues: []string{ + "my-host", + "host1", + "host2", + }, + Defaults: []string{ + "my-host", + }, + Name: "host1", + Prefix: *datadog.NewNullableString(datadog.PtrString("host")), + }, + }, + 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) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_and_default_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_and_default_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..78f1b346754 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_and_default_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2022-09-12T20:05:48.540Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_and_default_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_and_default_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..5ea1de7a8d5 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_and_default_returns_Bad_Request_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {"description":null,"is_read_only":false,"layout_type":"ordered","notify_list":[],"reflow_type":"auto","restricted_roles":[],"template_variables":[{"available_values":["my-host","host1","host2"],"default":"my-host","defaults":["my-host"],"name":"host1","prefix":"host"}],"title":"","widgets":[{"definition":{"requests":{"fill":{"q":"avg:system.cpu.user{*}"}},"type":"hostmap"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"errors":["''template_variables'' is invalid"]} + + ' + code: 400 + duration: '' + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_returns_OK_response.freeze new file mode 100644 index 00000000000..3e445cbb73b --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_returns_OK_response.freeze @@ -0,0 +1 @@ +2022-09-12T20:05:48.730Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_returns_OK_response.yaml new file mode 100644 index 00000000000..11f64299662 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_returns_OK_response.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: | + {"description":null,"is_read_only":false,"layout_type":"ordered","notify_list":[],"reflow_type":"auto","restricted_roles":[],"template_variables":[{"available_values":["my-host","host1","host2"],"defaults":["my-host"],"name":"host1","prefix":"host"}],"title":"","widgets":[{"definition":{"requests":{"fill":{"q":"avg:system.cpu.user{*}"}},"type":"hostmap"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"notify_list":[],"description":null,"restricted_roles":[],"author_name":null,"template_variables":[{"prefix":"host","defaults":["my-host"],"available_values":["my-host","host1","host2"],"name":"host1"}],"is_read_only":false,"id":"39h-cn5-kyd","title":"","url":"/dashboard/39h-cn5-kyd/","created_at":"2022-09-12T20:05:49.753763+00:00","modified_at":"2022-09-12T20:05:49.753763+00:00","reflow_type":"auto","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":{"fill":{"q":"avg:system.cpu.user{*}"}},"type":"hostmap"},"id":4911408545233424}],"layout_type":"ordered"} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: DELETE + url: https://api.datadoghq.com/api/v1/dashboard/39h-cn5-kyd + response: + body: '{"deleted_dashboard_id":"39h-cn5-kyd"} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_whose_value_has_no_length_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_whose_value_has_no_length_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..3c19cc01451 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_whose_value_has_no_length_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2022-09-12T20:05:50.024Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_whose_value_has_no_length_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_whose_value_has_no_length_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..da3d9a83082 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_defaults_whose_value_has_no_length_returns_Bad_Request_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {"description":null,"is_read_only":false,"layout_type":"ordered","notify_list":[],"reflow_type":"auto","restricted_roles":[],"template_variables":[{"available_values":["my-host","host1","host2"],"defaults":[""],"name":"host1","prefix":"host"}],"title":"","widgets":[{"definition":{"requests":{"fill":{"q":"avg:system.cpu.user{*}"}},"type":"hostmap"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"errors":["Minimum length of parameter ''defaults'' should be 1"]} + + ' + code: 400 + duration: '' + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_and_value_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_and_value_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..d0a05df8598 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_and_value_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2022-09-12T20:05:50.123Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_and_value_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_and_value_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..e5e7f1cb2df --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_and_value_returns_Bad_Request_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {"description":null,"is_read_only":false,"layout_type":"ordered","notify_list":[],"reflow_type":"auto","restricted_roles":[],"template_variable_presets":[{"template_variables":[{"name":"my saved view","template_variables":[{"name":"datacenter","value":"*","values":["*"]}]}]}],"template_variables":[{"available_values":["my-host","host1","host2"],"defaults":["my-host"],"name":"host1","prefix":"host"}],"title":"","widgets":[{"definition":{"requests":{"fill":{"q":"avg:system.cpu.user{*}"}},"type":"hostmap"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"errors":["Required parameter ''value'' is missing"]} + + ' + code: 400 + duration: '' + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_returns_OK_response.freeze new file mode 100644 index 00000000000..f502316d52c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_returns_OK_response.freeze @@ -0,0 +1 @@ +2022-09-12T20:05:50.228Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_returns_OK_response.yaml new file mode 100644 index 00000000000..8b5dc8b154c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_returns_OK_response.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: | + {"description":null,"is_read_only":false,"layout_type":"ordered","notify_list":[],"reflow_type":"auto","restricted_roles":[],"template_variable_presets":[{"name":"my saved view","template_variables":[{"name":"datacenter","values":["*","my-host"]}]}],"template_variables":[{"available_values":["my-host","host1","host2"],"defaults":["my-host"],"name":"host1","prefix":"host"}],"title":"","widgets":[{"definition":{"requests":{"fill":{"q":"avg:system.cpu.user{*}"}},"type":"hostmap"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"notify_list":[],"description":null,"restricted_roles":[],"author_name":null,"template_variable_presets":[{"template_variables":[{"values":["*","my-host"],"name":"datacenter"}],"name":"my + saved view"}],"template_variables":[{"prefix":"host","defaults":["my-host"],"available_values":["my-host","host1","host2"],"name":"host1"}],"is_read_only":false,"id":"6j2-ja3-r9z","title":"","url":"/dashboard/6j2-ja3-r9z/","created_at":"2022-09-12T20:05:50.380181+00:00","modified_at":"2022-09-12T20:05:50.380181+00:00","reflow_type":"auto","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":{"fill":{"q":"avg:system.cpu.user{*}"}},"type":"hostmap"},"id":8337056750682432}],"layout_type":"ordered"} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: DELETE + url: https://api.datadoghq.com/api/v1/dashboard/6j2-ja3-r9z + response: + body: '{"deleted_dashboard_id":"6j2-ja3-r9z"} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_with_no_length_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_with_no_length_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..a1264dea8f8 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_with_no_length_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2022-09-12T20:05:50.586Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_with_no_length_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_with_no_length_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..90e2c0b7d22 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_template_variable_presets_using_values_with_no_length_returns_Bad_Request_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {"description":null,"is_read_only":false,"layout_type":"ordered","notify_list":[],"reflow_type":"auto","restricted_roles":[],"template_variable_presets":[{"name":"datacenter","values":[]}],"template_variables":[{"available_values":["my-host","host1","host2"],"defaults":["my-host"],"name":"host1","prefix":"host"}],"title":"","widgets":[{"definition":{"requests":{"fill":{"q":"avg:system.cpu.user{*}"}},"type":"hostmap"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"errors":["Additional properties are not allowed (u''values'' was unexpected)"]} + + ' + code: 400 + duration: '' + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 1 diff --git a/tests/scenarios/features/v1/dashboards.feature b/tests/scenarios/features/v1/dashboards.feature index ef0406843d3..9332567d558 100644 --- a/tests/scenarios/features/v1/dashboards.feature +++ b/tests/scenarios/features/v1/dashboards.feature @@ -57,7 +57,7 @@ Feature: Dashboards @generated @skip @team:DataDog/dashboards 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": [], "template_variable_presets": [{"template_variables": [{}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "name": "host1", "prefix": "host"}], "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": [], "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"}], "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 @@ -413,6 +413,48 @@ Feature: Dashboards And the response "widgets[0].definition.requests[0].queries[0].aggregator" is equal to "sum" And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "query1" + @team:DataDog/dashboards + Scenario: Create a new dashboard with template variable defaults and default 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": [], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host"], "name": "host1", "prefix": "host"}], "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 + + @team:DataDog/dashboards + Scenario: Create a new dashboard with template variable defaults returns "OK" 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": [], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "defaults": ["my-host"], "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/dashboards + Scenario: Create a new dashboard with template variable defaults whose value has no length 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": [], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "defaults": [""], "name": "host1", "prefix": "host"}], "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 + + @team:DataDog/dashboards + Scenario: Create a new dashboard with template variable presets using values and value 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": [], "template_variable_presets": [{"template_variables": [{"name": "my saved view", "template_variables": [{ "name": "datacenter", "value": "*", "values": ["*"]}]}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "defaults": ["my-host"], "name": "host1", "prefix": "host"}], "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 + + @team:DataDog/dashboards + Scenario: Create a new dashboard with template variable presets using values returns "OK" 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": [], "template_variable_presets": [{"name": "my saved view", "template_variables": [{"name": "datacenter", "values": ["*", "my-host"]}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "defaults": ["my-host"], "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/dashboards + Scenario: Create a new dashboard with template variable presets using values with no length 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": [], "template_variable_presets": [{"name": "datacenter", "values": []}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "defaults": ["my-host"], "name": "host1", "prefix": "host"}], "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 + @team:DataDog/dashboards Scenario: Create a new dashboard with timeseries widget containing style attributes Given new "CreateDashboard" request @@ -569,7 +611,7 @@ 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": [], "template_variable_presets": [{"template_variables": [{}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "name": "host1", "prefix": "host"}], "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": [], "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"}], "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 @@ -577,7 +619,7 @@ Feature: Dashboards 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": [], "template_variable_presets": [{"template_variables": [{}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "name": "host1", "prefix": "host"}], "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": [], "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"}], "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