From 7db292612d53f7a334fc01075c20b62cfb1bca3c Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Thu, 5 Oct 2023 16:10:13 +0000 Subject: [PATCH] Regenerate client from commit 87fa0a0b of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 148 ++++++++++- api/datadogV2/model_powerpack_attributes.go | 25 +- api/datadogV2/model_powerpack_group_widget.go | 150 +++++++++++ ...model_powerpack_group_widget_definition.go | 237 ++++++++++++++++++ .../model_powerpack_group_widget_layout.go | 199 +++++++++++++++ .../model_powerpack_inner_widget_layout.go | 199 +++++++++++++++ .../model_powerpack_inner_widgets.go | 147 +++++++++++ examples/v2/powerpack/CreatePowerpack.go | 24 +- examples/v2/powerpack/UpdatePowerpack.go | 24 +- ...erpack_returns_Bad_Request_response.freeze | 2 +- ...owerpack_returns_Bad_Request_response.yaml | 29 +-- ...widget_returns_Bad_Request_response.freeze | 2 +- ...p_widget_returns_Bad_Request_response.yaml | 28 +-- ...erpack_returns_Bad_Request_response.freeze | 2 +- ...owerpack_returns_Bad_Request_response.yaml | 38 +-- tests/scenarios/features/v2/powerpack.feature | 11 +- 17 files changed, 1152 insertions(+), 121 deletions(-) create mode 100644 api/datadogV2/model_powerpack_group_widget.go create mode 100644 api/datadogV2/model_powerpack_group_widget_definition.go create mode 100644 api/datadogV2/model_powerpack_group_widget_layout.go create mode 100644 api/datadogV2/model_powerpack_inner_widget_layout.go create mode 100644 api/datadogV2/model_powerpack_inner_widgets.go diff --git a/.apigentools-info b/.apigentools-info index 7cfe7137a01..5ff4dc8d138 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2023-10-04 20:39:02.115398", - "spec_repo_commit": "79ab1c3c" + "regenerated": "2023-10-05 16:08:52.442884", + "spec_repo_commit": "87fa0a0b" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2023-10-04 20:39:02.139326", - "spec_repo_commit": "79ab1c3c" + "regenerated": "2023-10-05 16:08:52.457248", + "spec_repo_commit": "87fa0a0b" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ee82ba9f101..5ff9e456d07 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -10596,18 +10596,7 @@ components: example: Powerpack for ABC type: string group_widget: - additionalProperties: {} - description: Templated group of dashboard widgets for the powerpack. - example: - layout_type: ordered - tags: - - tag:foo1 - type: group - widgets: - - definition: - content: example - type: note - type: object + $ref: '#/components/schemas/PowerpackGroupWidget' name: description: Name of the powerpack. example: Sample Powerpack @@ -10649,6 +10638,141 @@ components: example: powerpack type: string type: object + PowerpackGroupWidget: + description: Powerpack group widget definition object. + properties: + definition: + $ref: '#/components/schemas/PowerpackGroupWidgetDefinition' + layout: + $ref: '#/components/schemas/PowerpackGroupWidgetLayout' + required: + - definition + type: object + PowerpackGroupWidgetDefinition: + description: Powerpack group widget object. + properties: + layout_type: + description: Layout type of widgets. + example: ordered + type: string + show_title: + description: Boolean indicating whether powerpack group title should be + visible or not. + example: true + type: boolean + title: + description: Name for the group widget. + example: Sample Powerpack + type: string + type: + description: Type of widget, must be group. + example: group + type: string + widgets: + description: Widgets inside the powerpack. + example: + - definition: + content: example + type: note + layout: + height: 5 + width: 10 + x: 0 + y: 0 + items: + $ref: '#/components/schemas/PowerpackInnerWidgets' + type: array + required: + - widgets + - layout_type + - type + type: object + PowerpackGroupWidgetLayout: + description: Powerpack group widget layout. + properties: + height: + description: The height of the widget. Should be a non-negative integer. + example: 0 + format: int64 + minimum: 0 + type: integer + width: + description: The width of the widget. Should be a non-negative integer. + example: 0 + format: int64 + minimum: 0 + type: integer + x: + description: The position of the widget on the x (horizontal) axis. Should + be a non-negative integer. + example: 0 + format: int64 + minimum: 0 + type: integer + y: + description: The position of the widget on the y (vertical) axis. Should + be a non-negative integer. + example: 0 + format: int64 + minimum: 0 + type: integer + required: + - x + - y + - width + - height + type: object + PowerpackInnerWidgetLayout: + description: Powerpack inner widget layout. + properties: + height: + description: The height of the widget. Should be a non-negative integer. + example: 0 + format: int64 + minimum: 0 + type: integer + width: + description: The width of the widget. Should be a non-negative integer. + example: 0 + format: int64 + minimum: 0 + type: integer + x: + description: The position of the widget on the x (horizontal) axis. Should + be a non-negative integer. + example: 0 + format: int64 + minimum: 0 + type: integer + y: + description: The position of the widget on the y (vertical) axis. Should + be a non-negative integer. + example: 0 + format: int64 + minimum: 0 + type: integer + required: + - x + - y + - width + - height + type: object + PowerpackInnerWidgets: + description: Powerpack group widget definition of individual widgets. + properties: + definition: + additionalProperties: {} + description: Information about widget. + example: + definition: + content: example + type: note + type: object + layout: + $ref: '#/components/schemas/PowerpackInnerWidgetLayout' + required: + - definition + type: object PowerpackRelationships: description: Powerpack relationship object. properties: diff --git a/api/datadogV2/model_powerpack_attributes.go b/api/datadogV2/model_powerpack_attributes.go index 858ff179a2f..672c6428750 100644 --- a/api/datadogV2/model_powerpack_attributes.go +++ b/api/datadogV2/model_powerpack_attributes.go @@ -16,8 +16,8 @@ import ( type PowerpackAttributes struct { // Description of this powerpack. Description *string `json:"description,omitempty"` - // Templated group of dashboard widgets for the powerpack. - GroupWidget map[string]interface{} `json:"group_widget"` + // Powerpack group widget definition object. + GroupWidget PowerpackGroupWidget `json:"group_widget"` // Name of the powerpack. Name string `json:"name"` // List of tags to identify this powerpack. @@ -33,7 +33,7 @@ type PowerpackAttributes struct { // 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 NewPowerpackAttributes(groupWidget map[string]interface{}, name string) *PowerpackAttributes { +func NewPowerpackAttributes(groupWidget PowerpackGroupWidget, name string) *PowerpackAttributes { this := PowerpackAttributes{} this.GroupWidget = groupWidget this.Name = name @@ -77,9 +77,9 @@ func (o *PowerpackAttributes) SetDescription(v string) { } // GetGroupWidget returns the GroupWidget field value. -func (o *PowerpackAttributes) GetGroupWidget() map[string]interface{} { +func (o *PowerpackAttributes) GetGroupWidget() PowerpackGroupWidget { if o == nil { - var ret map[string]interface{} + var ret PowerpackGroupWidget return ret } return o.GroupWidget @@ -87,7 +87,7 @@ func (o *PowerpackAttributes) GetGroupWidget() map[string]interface{} { // GetGroupWidgetOk returns a tuple with the GroupWidget field value // and a boolean to check if the value has been set. -func (o *PowerpackAttributes) GetGroupWidgetOk() (*map[string]interface{}, bool) { +func (o *PowerpackAttributes) GetGroupWidgetOk() (*PowerpackGroupWidget, bool) { if o == nil { return nil, false } @@ -95,7 +95,7 @@ func (o *PowerpackAttributes) GetGroupWidgetOk() (*map[string]interface{}, bool) } // SetGroupWidget sets field value. -func (o *PowerpackAttributes) SetGroupWidget(v map[string]interface{}) { +func (o *PowerpackAttributes) SetGroupWidget(v PowerpackGroupWidget) { o.GroupWidget = v } @@ -206,7 +206,7 @@ func (o PowerpackAttributes) MarshalJSON() ([]byte, error) { func (o *PowerpackAttributes) UnmarshalJSON(bytes []byte) (err error) { all := struct { Description *string `json:"description,omitempty"` - GroupWidget *map[string]interface{} `json:"group_widget"` + GroupWidget *PowerpackGroupWidget `json:"group_widget"` Name *string `json:"name"` Tags []string `json:"tags,omitempty"` TemplateVariables []PowerpackTemplateVariable `json:"template_variables,omitempty"` @@ -226,7 +226,12 @@ func (o *PowerpackAttributes) UnmarshalJSON(bytes []byte) (err error) { } else { return err } + + hasInvalidField := false o.Description = all.Description + if all.GroupWidget.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } o.GroupWidget = *all.GroupWidget o.Name = *all.Name o.Tags = all.Tags @@ -236,5 +241,9 @@ func (o *PowerpackAttributes) UnmarshalJSON(bytes []byte) (err error) { o.AdditionalProperties = additionalProperties } + if hasInvalidField { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + return nil } diff --git a/api/datadogV2/model_powerpack_group_widget.go b/api/datadogV2/model_powerpack_group_widget.go new file mode 100644 index 00000000000..5614c447a3b --- /dev/null +++ b/api/datadogV2/model_powerpack_group_widget.go @@ -0,0 +1,150 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PowerpackGroupWidget Powerpack group widget definition object. +type PowerpackGroupWidget struct { + // Powerpack group widget object. + Definition PowerpackGroupWidgetDefinition `json:"definition"` + // Powerpack group widget layout. + Layout *PowerpackGroupWidgetLayout `json:"layout,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{} +} + +// NewPowerpackGroupWidget instantiates a new PowerpackGroupWidget 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 NewPowerpackGroupWidget(definition PowerpackGroupWidgetDefinition) *PowerpackGroupWidget { + this := PowerpackGroupWidget{} + this.Definition = definition + return &this +} + +// NewPowerpackGroupWidgetWithDefaults instantiates a new PowerpackGroupWidget 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 NewPowerpackGroupWidgetWithDefaults() *PowerpackGroupWidget { + this := PowerpackGroupWidget{} + return &this +} + +// GetDefinition returns the Definition field value. +func (o *PowerpackGroupWidget) GetDefinition() PowerpackGroupWidgetDefinition { + if o == nil { + var ret PowerpackGroupWidgetDefinition + return ret + } + return o.Definition +} + +// GetDefinitionOk returns a tuple with the Definition field value +// and a boolean to check if the value has been set. +func (o *PowerpackGroupWidget) GetDefinitionOk() (*PowerpackGroupWidgetDefinition, bool) { + if o == nil { + return nil, false + } + return &o.Definition, true +} + +// SetDefinition sets field value. +func (o *PowerpackGroupWidget) SetDefinition(v PowerpackGroupWidgetDefinition) { + o.Definition = v +} + +// GetLayout returns the Layout field value if set, zero value otherwise. +func (o *PowerpackGroupWidget) GetLayout() PowerpackGroupWidgetLayout { + if o == nil || o.Layout == nil { + var ret PowerpackGroupWidgetLayout + return ret + } + return *o.Layout +} + +// GetLayoutOk returns a tuple with the Layout field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PowerpackGroupWidget) GetLayoutOk() (*PowerpackGroupWidgetLayout, bool) { + if o == nil || o.Layout == nil { + return nil, false + } + return o.Layout, true +} + +// HasLayout returns a boolean if a field has been set. +func (o *PowerpackGroupWidget) HasLayout() bool { + return o != nil && o.Layout != nil +} + +// SetLayout gets a reference to the given PowerpackGroupWidgetLayout and assigns it to the Layout field. +func (o *PowerpackGroupWidget) SetLayout(v PowerpackGroupWidgetLayout) { + o.Layout = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PowerpackGroupWidget) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["definition"] = o.Definition + if o.Layout != nil { + toSerialize["layout"] = o.Layout + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PowerpackGroupWidget) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Definition *PowerpackGroupWidgetDefinition `json:"definition"` + Layout *PowerpackGroupWidgetLayout `json:"layout,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Definition == nil { + return fmt.Errorf("required field definition missing") + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"definition", "layout"}) + } else { + return err + } + + hasInvalidField := false + if all.Definition.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Definition = *all.Definition + if all.Layout != nil && all.Layout.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Layout = all.Layout + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_powerpack_group_widget_definition.go b/api/datadogV2/model_powerpack_group_widget_definition.go new file mode 100644 index 00000000000..5be3022874a --- /dev/null +++ b/api/datadogV2/model_powerpack_group_widget_definition.go @@ -0,0 +1,237 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PowerpackGroupWidgetDefinition Powerpack group widget object. +type PowerpackGroupWidgetDefinition struct { + // Layout type of widgets. + LayoutType string `json:"layout_type"` + // Boolean indicating whether powerpack group title should be visible or not. + ShowTitle *bool `json:"show_title,omitempty"` + // Name for the group widget. + Title *string `json:"title,omitempty"` + // Type of widget, must be group. + Type string `json:"type"` + // Widgets inside the powerpack. + Widgets []PowerpackInnerWidgets `json:"widgets"` + // 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{} +} + +// NewPowerpackGroupWidgetDefinition instantiates a new PowerpackGroupWidgetDefinition 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 NewPowerpackGroupWidgetDefinition(layoutType string, typeVar string, widgets []PowerpackInnerWidgets) *PowerpackGroupWidgetDefinition { + this := PowerpackGroupWidgetDefinition{} + this.LayoutType = layoutType + this.Type = typeVar + this.Widgets = widgets + return &this +} + +// NewPowerpackGroupWidgetDefinitionWithDefaults instantiates a new PowerpackGroupWidgetDefinition 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 NewPowerpackGroupWidgetDefinitionWithDefaults() *PowerpackGroupWidgetDefinition { + this := PowerpackGroupWidgetDefinition{} + return &this +} + +// GetLayoutType returns the LayoutType field value. +func (o *PowerpackGroupWidgetDefinition) GetLayoutType() string { + if o == nil { + var ret string + return ret + } + return o.LayoutType +} + +// GetLayoutTypeOk returns a tuple with the LayoutType field value +// and a boolean to check if the value has been set. +func (o *PowerpackGroupWidgetDefinition) GetLayoutTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.LayoutType, true +} + +// SetLayoutType sets field value. +func (o *PowerpackGroupWidgetDefinition) SetLayoutType(v string) { + o.LayoutType = v +} + +// GetShowTitle returns the ShowTitle field value if set, zero value otherwise. +func (o *PowerpackGroupWidgetDefinition) GetShowTitle() bool { + if o == nil || o.ShowTitle == nil { + var ret bool + return ret + } + return *o.ShowTitle +} + +// GetShowTitleOk returns a tuple with the ShowTitle field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PowerpackGroupWidgetDefinition) GetShowTitleOk() (*bool, bool) { + if o == nil || o.ShowTitle == nil { + return nil, false + } + return o.ShowTitle, true +} + +// HasShowTitle returns a boolean if a field has been set. +func (o *PowerpackGroupWidgetDefinition) HasShowTitle() bool { + return o != nil && o.ShowTitle != nil +} + +// SetShowTitle gets a reference to the given bool and assigns it to the ShowTitle field. +func (o *PowerpackGroupWidgetDefinition) SetShowTitle(v bool) { + o.ShowTitle = &v +} + +// GetTitle returns the Title field value if set, zero value otherwise. +func (o *PowerpackGroupWidgetDefinition) GetTitle() string { + if o == nil || o.Title == nil { + var ret string + return ret + } + return *o.Title +} + +// GetTitleOk returns a tuple with the Title field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PowerpackGroupWidgetDefinition) GetTitleOk() (*string, bool) { + if o == nil || o.Title == nil { + return nil, false + } + return o.Title, true +} + +// HasTitle returns a boolean if a field has been set. +func (o *PowerpackGroupWidgetDefinition) HasTitle() bool { + return o != nil && o.Title != nil +} + +// SetTitle gets a reference to the given string and assigns it to the Title field. +func (o *PowerpackGroupWidgetDefinition) SetTitle(v string) { + o.Title = &v +} + +// GetType returns the Type field value. +func (o *PowerpackGroupWidgetDefinition) GetType() string { + if o == nil { + var ret string + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *PowerpackGroupWidgetDefinition) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *PowerpackGroupWidgetDefinition) SetType(v string) { + o.Type = v +} + +// GetWidgets returns the Widgets field value. +func (o *PowerpackGroupWidgetDefinition) GetWidgets() []PowerpackInnerWidgets { + if o == nil { + var ret []PowerpackInnerWidgets + return ret + } + return o.Widgets +} + +// GetWidgetsOk returns a tuple with the Widgets field value +// and a boolean to check if the value has been set. +func (o *PowerpackGroupWidgetDefinition) GetWidgetsOk() (*[]PowerpackInnerWidgets, bool) { + if o == nil { + return nil, false + } + return &o.Widgets, true +} + +// SetWidgets sets field value. +func (o *PowerpackGroupWidgetDefinition) SetWidgets(v []PowerpackInnerWidgets) { + o.Widgets = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PowerpackGroupWidgetDefinition) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["layout_type"] = o.LayoutType + if o.ShowTitle != nil { + toSerialize["show_title"] = o.ShowTitle + } + if o.Title != nil { + toSerialize["title"] = o.Title + } + toSerialize["type"] = o.Type + toSerialize["widgets"] = o.Widgets + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PowerpackGroupWidgetDefinition) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + LayoutType *string `json:"layout_type"` + ShowTitle *bool `json:"show_title,omitempty"` + Title *string `json:"title,omitempty"` + Type *string `json:"type"` + Widgets *[]PowerpackInnerWidgets `json:"widgets"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + if all.LayoutType == nil { + return fmt.Errorf("required field layout_type missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + if all.Widgets == nil { + return fmt.Errorf("required field widgets missing") + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"layout_type", "show_title", "title", "type", "widgets"}) + } else { + return err + } + o.LayoutType = *all.LayoutType + o.ShowTitle = all.ShowTitle + o.Title = all.Title + o.Type = *all.Type + o.Widgets = *all.Widgets + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_powerpack_group_widget_layout.go b/api/datadogV2/model_powerpack_group_widget_layout.go new file mode 100644 index 00000000000..277943ee136 --- /dev/null +++ b/api/datadogV2/model_powerpack_group_widget_layout.go @@ -0,0 +1,199 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PowerpackGroupWidgetLayout Powerpack group widget layout. +type PowerpackGroupWidgetLayout struct { + // The height of the widget. Should be a non-negative integer. + Height int64 `json:"height"` + // The width of the widget. Should be a non-negative integer. + Width int64 `json:"width"` + // The position of the widget on the x (horizontal) axis. Should be a non-negative integer. + X int64 `json:"x"` + // The position of the widget on the y (vertical) axis. Should be a non-negative integer. + Y int64 `json:"y"` + // 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{} +} + +// NewPowerpackGroupWidgetLayout instantiates a new PowerpackGroupWidgetLayout 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 NewPowerpackGroupWidgetLayout(height int64, width int64, x int64, y int64) *PowerpackGroupWidgetLayout { + this := PowerpackGroupWidgetLayout{} + this.Height = height + this.Width = width + this.X = x + this.Y = y + return &this +} + +// NewPowerpackGroupWidgetLayoutWithDefaults instantiates a new PowerpackGroupWidgetLayout 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 NewPowerpackGroupWidgetLayoutWithDefaults() *PowerpackGroupWidgetLayout { + this := PowerpackGroupWidgetLayout{} + return &this +} + +// GetHeight returns the Height field value. +func (o *PowerpackGroupWidgetLayout) GetHeight() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Height +} + +// GetHeightOk returns a tuple with the Height field value +// and a boolean to check if the value has been set. +func (o *PowerpackGroupWidgetLayout) GetHeightOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Height, true +} + +// SetHeight sets field value. +func (o *PowerpackGroupWidgetLayout) SetHeight(v int64) { + o.Height = v +} + +// GetWidth returns the Width field value. +func (o *PowerpackGroupWidgetLayout) GetWidth() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Width +} + +// GetWidthOk returns a tuple with the Width field value +// and a boolean to check if the value has been set. +func (o *PowerpackGroupWidgetLayout) GetWidthOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Width, true +} + +// SetWidth sets field value. +func (o *PowerpackGroupWidgetLayout) SetWidth(v int64) { + o.Width = v +} + +// GetX returns the X field value. +func (o *PowerpackGroupWidgetLayout) GetX() int64 { + if o == nil { + var ret int64 + return ret + } + return o.X +} + +// GetXOk returns a tuple with the X field value +// and a boolean to check if the value has been set. +func (o *PowerpackGroupWidgetLayout) GetXOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.X, true +} + +// SetX sets field value. +func (o *PowerpackGroupWidgetLayout) SetX(v int64) { + o.X = v +} + +// GetY returns the Y field value. +func (o *PowerpackGroupWidgetLayout) GetY() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Y +} + +// GetYOk returns a tuple with the Y field value +// and a boolean to check if the value has been set. +func (o *PowerpackGroupWidgetLayout) GetYOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Y, true +} + +// SetY sets field value. +func (o *PowerpackGroupWidgetLayout) SetY(v int64) { + o.Y = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PowerpackGroupWidgetLayout) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["height"] = o.Height + toSerialize["width"] = o.Width + toSerialize["x"] = o.X + toSerialize["y"] = o.Y + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PowerpackGroupWidgetLayout) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Height *int64 `json:"height"` + Width *int64 `json:"width"` + X *int64 `json:"x"` + Y *int64 `json:"y"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Height == nil { + return fmt.Errorf("required field height missing") + } + if all.Width == nil { + return fmt.Errorf("required field width missing") + } + if all.X == nil { + return fmt.Errorf("required field x missing") + } + if all.Y == nil { + return fmt.Errorf("required field y missing") + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"height", "width", "x", "y"}) + } else { + return err + } + o.Height = *all.Height + o.Width = *all.Width + o.X = *all.X + o.Y = *all.Y + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_powerpack_inner_widget_layout.go b/api/datadogV2/model_powerpack_inner_widget_layout.go new file mode 100644 index 00000000000..69c94941ded --- /dev/null +++ b/api/datadogV2/model_powerpack_inner_widget_layout.go @@ -0,0 +1,199 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PowerpackInnerWidgetLayout Powerpack inner widget layout. +type PowerpackInnerWidgetLayout struct { + // The height of the widget. Should be a non-negative integer. + Height int64 `json:"height"` + // The width of the widget. Should be a non-negative integer. + Width int64 `json:"width"` + // The position of the widget on the x (horizontal) axis. Should be a non-negative integer. + X int64 `json:"x"` + // The position of the widget on the y (vertical) axis. Should be a non-negative integer. + Y int64 `json:"y"` + // 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{} +} + +// NewPowerpackInnerWidgetLayout instantiates a new PowerpackInnerWidgetLayout 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 NewPowerpackInnerWidgetLayout(height int64, width int64, x int64, y int64) *PowerpackInnerWidgetLayout { + this := PowerpackInnerWidgetLayout{} + this.Height = height + this.Width = width + this.X = x + this.Y = y + return &this +} + +// NewPowerpackInnerWidgetLayoutWithDefaults instantiates a new PowerpackInnerWidgetLayout 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 NewPowerpackInnerWidgetLayoutWithDefaults() *PowerpackInnerWidgetLayout { + this := PowerpackInnerWidgetLayout{} + return &this +} + +// GetHeight returns the Height field value. +func (o *PowerpackInnerWidgetLayout) GetHeight() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Height +} + +// GetHeightOk returns a tuple with the Height field value +// and a boolean to check if the value has been set. +func (o *PowerpackInnerWidgetLayout) GetHeightOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Height, true +} + +// SetHeight sets field value. +func (o *PowerpackInnerWidgetLayout) SetHeight(v int64) { + o.Height = v +} + +// GetWidth returns the Width field value. +func (o *PowerpackInnerWidgetLayout) GetWidth() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Width +} + +// GetWidthOk returns a tuple with the Width field value +// and a boolean to check if the value has been set. +func (o *PowerpackInnerWidgetLayout) GetWidthOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Width, true +} + +// SetWidth sets field value. +func (o *PowerpackInnerWidgetLayout) SetWidth(v int64) { + o.Width = v +} + +// GetX returns the X field value. +func (o *PowerpackInnerWidgetLayout) GetX() int64 { + if o == nil { + var ret int64 + return ret + } + return o.X +} + +// GetXOk returns a tuple with the X field value +// and a boolean to check if the value has been set. +func (o *PowerpackInnerWidgetLayout) GetXOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.X, true +} + +// SetX sets field value. +func (o *PowerpackInnerWidgetLayout) SetX(v int64) { + o.X = v +} + +// GetY returns the Y field value. +func (o *PowerpackInnerWidgetLayout) GetY() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Y +} + +// GetYOk returns a tuple with the Y field value +// and a boolean to check if the value has been set. +func (o *PowerpackInnerWidgetLayout) GetYOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Y, true +} + +// SetY sets field value. +func (o *PowerpackInnerWidgetLayout) SetY(v int64) { + o.Y = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PowerpackInnerWidgetLayout) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["height"] = o.Height + toSerialize["width"] = o.Width + toSerialize["x"] = o.X + toSerialize["y"] = o.Y + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PowerpackInnerWidgetLayout) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Height *int64 `json:"height"` + Width *int64 `json:"width"` + X *int64 `json:"x"` + Y *int64 `json:"y"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Height == nil { + return fmt.Errorf("required field height missing") + } + if all.Width == nil { + return fmt.Errorf("required field width missing") + } + if all.X == nil { + return fmt.Errorf("required field x missing") + } + if all.Y == nil { + return fmt.Errorf("required field y missing") + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"height", "width", "x", "y"}) + } else { + return err + } + o.Height = *all.Height + o.Width = *all.Width + o.X = *all.X + o.Y = *all.Y + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_powerpack_inner_widgets.go b/api/datadogV2/model_powerpack_inner_widgets.go new file mode 100644 index 00000000000..53e1b023536 --- /dev/null +++ b/api/datadogV2/model_powerpack_inner_widgets.go @@ -0,0 +1,147 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PowerpackInnerWidgets Powerpack group widget definition of individual widgets. +type PowerpackInnerWidgets struct { + // Information about widget. + Definition map[string]interface{} `json:"definition"` + // Powerpack inner widget layout. + Layout *PowerpackInnerWidgetLayout `json:"layout,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{} +} + +// NewPowerpackInnerWidgets instantiates a new PowerpackInnerWidgets 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 NewPowerpackInnerWidgets(definition map[string]interface{}) *PowerpackInnerWidgets { + this := PowerpackInnerWidgets{} + this.Definition = definition + return &this +} + +// NewPowerpackInnerWidgetsWithDefaults instantiates a new PowerpackInnerWidgets 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 NewPowerpackInnerWidgetsWithDefaults() *PowerpackInnerWidgets { + this := PowerpackInnerWidgets{} + return &this +} + +// GetDefinition returns the Definition field value. +func (o *PowerpackInnerWidgets) GetDefinition() map[string]interface{} { + if o == nil { + var ret map[string]interface{} + return ret + } + return o.Definition +} + +// GetDefinitionOk returns a tuple with the Definition field value +// and a boolean to check if the value has been set. +func (o *PowerpackInnerWidgets) GetDefinitionOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + return &o.Definition, true +} + +// SetDefinition sets field value. +func (o *PowerpackInnerWidgets) SetDefinition(v map[string]interface{}) { + o.Definition = v +} + +// GetLayout returns the Layout field value if set, zero value otherwise. +func (o *PowerpackInnerWidgets) GetLayout() PowerpackInnerWidgetLayout { + if o == nil || o.Layout == nil { + var ret PowerpackInnerWidgetLayout + return ret + } + return *o.Layout +} + +// GetLayoutOk returns a tuple with the Layout field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PowerpackInnerWidgets) GetLayoutOk() (*PowerpackInnerWidgetLayout, bool) { + if o == nil || o.Layout == nil { + return nil, false + } + return o.Layout, true +} + +// HasLayout returns a boolean if a field has been set. +func (o *PowerpackInnerWidgets) HasLayout() bool { + return o != nil && o.Layout != nil +} + +// SetLayout gets a reference to the given PowerpackInnerWidgetLayout and assigns it to the Layout field. +func (o *PowerpackInnerWidgets) SetLayout(v PowerpackInnerWidgetLayout) { + o.Layout = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PowerpackInnerWidgets) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["definition"] = o.Definition + if o.Layout != nil { + toSerialize["layout"] = o.Layout + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PowerpackInnerWidgets) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Definition *map[string]interface{} `json:"definition"` + Layout *PowerpackInnerWidgetLayout `json:"layout,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Definition == nil { + return fmt.Errorf("required field definition missing") + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"definition", "layout"}) + } else { + return err + } + + hasInvalidField := false + o.Definition = *all.Definition + if all.Layout != nil && all.Layout.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Layout = all.Layout + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/examples/v2/powerpack/CreatePowerpack.go b/examples/v2/powerpack/CreatePowerpack.go index 6eac9d64d25..2fcd5ce2c01 100644 --- a/examples/v2/powerpack/CreatePowerpack.go +++ b/examples/v2/powerpack/CreatePowerpack.go @@ -17,9 +17,27 @@ func main() { Data: &datadogV2.PowerpackData{ Attributes: &datadogV2.PowerpackAttributes{ Description: datadog.PtrString("Sample powerpack"), - GroupWidget: map[string]interface{}{ - "definition": "{'layout_type': 'ordered', 'show_title': True, 'title': 'Sample Powerpack', 'type': 'group', 'widgets': [{'definition': {'content': 'test', 'type': 'note'}}]}", - "layout": "{'height': 3, 'width': 12, 'x': 0, 'y': 0}", + GroupWidget: datadogV2.PowerpackGroupWidget{ + Definition: datadogV2.PowerpackGroupWidgetDefinition{ + LayoutType: "ordered", + ShowTitle: datadog.PtrBool(true), + Title: datadog.PtrString("Sample Powerpack"), + Type: "group", + Widgets: []datadogV2.PowerpackInnerWidgets{ + { + Definition: map[string]interface{}{ + "content": "test", + "type": "note", + }, + }, + }, + }, + Layout: &datadogV2.PowerpackGroupWidgetLayout{ + Height: 3, + Width: 12, + X: 0, + Y: 0, + }, }, Name: "Sample Powerpack", Tags: []string{ diff --git a/examples/v2/powerpack/UpdatePowerpack.go b/examples/v2/powerpack/UpdatePowerpack.go index f5209f6915c..289ad586cf3 100644 --- a/examples/v2/powerpack/UpdatePowerpack.go +++ b/examples/v2/powerpack/UpdatePowerpack.go @@ -20,9 +20,27 @@ func main() { Data: &datadogV2.PowerpackData{ Attributes: &datadogV2.PowerpackAttributes{ Description: datadog.PtrString("Sample powerpack"), - GroupWidget: map[string]interface{}{ - "definition": "{'layout_type': 'ordered', 'show_title': True, 'title': 'Sample Powerpack', 'type': 'group', 'widgets': [{'definition': {'content': 'test', 'type': 'note'}}]}", - "layout": "{'height': 3, 'width': 12, 'x': 0, 'y': 0}", + GroupWidget: datadogV2.PowerpackGroupWidget{ + Definition: datadogV2.PowerpackGroupWidgetDefinition{ + LayoutType: "ordered", + ShowTitle: datadog.PtrBool(true), + Title: datadog.PtrString("Sample Powerpack"), + Type: "group", + Widgets: []datadogV2.PowerpackInnerWidgets{ + { + Definition: map[string]interface{}{ + "content": "test", + "type": "note", + }, + }, + }, + }, + Layout: &datadogV2.PowerpackGroupWidgetLayout{ + Height: 3, + Width: 12, + X: 0, + Y: 0, + }, }, Name: "Sample Powerpack", Tags: []string{ diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_returns_Bad_Request_response.freeze index 8de3b1c8fe4..572764c79fa 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_returns_Bad_Request_response.freeze +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_returns_Bad_Request_response.freeze @@ -1 +1 @@ -2023-09-19T20:34:17.937Z \ No newline at end of file +2023-10-05T15:56:23.491Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_returns_Bad_Request_response.yaml index 662148c099c..22c535d46b5 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_returns_Bad_Request_response.yaml +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_returns_Bad_Request_response.yaml @@ -1,7 +1,7 @@ interactions: - request: body: | - {"data":{"attributes":{"description":"Powerpack for ABC","group_widget":{"layout_type":"ordered","tags":["tag:foo1"],"type":"group","widgets":[{"definition":{"content":"example","type":"note"}}]},"name":"Sample Powerpack","tags":["tag:foo1"],"template_variables":[{"defaults":["*"],"name":"test"}]},"type":"powerpack"}} + {"data":{"attributes":{"description":"Powerpack for ABC","group_widget":{"definition":{"layout_type":"ordered","type":"group1","widgets":[]}},"name":"Sample Powerpack","tags":["tag:foo1"],"template_variables":[{"defaults":["*"],"name":"test"}]},"type":"powerpack"}} form: {} headers: Accept: @@ -11,30 +11,9 @@ interactions: method: POST url: https://api.datadoghq.com/api/v2/powerpacks response: - body: '{"errors":["Invalid group widget for powerpack. Error: ''type'' is a required - property\n\nFailed validating ''required'' in schema:\n {''additionalProperties'': - False,\n ''properties'': {''background_color'': {''type'': ''string''},\n ''banner_img'': - {''type'': ''string''},\n ''layout_type'': {''enum'': [''ordered'']},\n ''reflow_type'': - {''enum'': [''auto'', ''fixed'']},\n ''show_title'': {''type'': - ''boolean''},\n ''title'': {''type'': ''string''},\n ''title_align'': - {''enum'': [''center'', ''left'', ''right'']},\n ''type'': - {''enum'': [''group'']},\n ''widgets'': {''items'': {''additionalProperties'': - False,\n ''properties'': {''definition'': - {''additionalProperties'': True,\n ''properties'': - {''type'': {''enum'': [''alert_graph'',\n ''alert_value'',\n ''change'',\n ''check_status'',\n ''distribution'',\n ''geomap'',\n ''heatmap'',\n ''hostmap'',\n ''note'',\n ''query_value'',\n ''scatterplot'',\n ''servicemap'',\n ''topology_map'',\n ''query_table'',\n ''timeseries'',\n ''toplist'',\n ''list_stream'',\n ''treemap'',\n ''uptime'',\n ''slo'',\n ''funnel'',\n ''custom'',\n ''experimental'',\n ''sunburst'',\n ''wildcard'',\n ''slo_list'',\n ''flame_graph'',\n ''run_workflow'',\n ''embedded_app'',\n ''log_stream'',\n ''iframe'',\n ''free_text'',\n ''event_stream'',\n ''event_timeline'',\n ''manage_status'',\n ''trace_service'',\n ''image'']}},\n ''required'': - [''type''],\n ''type'': - ''object''},\n ''id'': - {''type'': ''integer''},\n ''layout'': - {''additionalProperties'': False,\n ''properties'': - {''height'': {''type'': ''number''},\n ''is_column_break'': - {''type'': ''boolean''},\n ''width'': - {''type'': ''number''},\n ''x'': - {''type'': ''number''},\n ''y'': - {''type'': ''number''}},\n ''type'': - ''object''}},\n ''required'': [''definition''],\n ''type'': - ''object''},\n ''type'': ''array''}},\n ''required'': - [''type'', ''layout_type'', ''widgets''],\n ''type'': ''object''}\n\nOn - instance:\n {}."]}' + body: '{"errors":["Invalid group widget for powerpack. Error: ''group1'' is not + one of [''group'']\n\nFailed validating ''enum'' in schema[''properties''][''type'']:\n {''enum'': + [''group'']}\n\nOn instance[''type'']:\n ''group1''."]}' code: 400 duration: '' headers: diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_with_missing_group_widget_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_with_missing_group_widget_returns_Bad_Request_response.freeze index 6636089c7a2..8693788b95e 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_with_missing_group_widget_returns_Bad_Request_response.freeze +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_with_missing_group_widget_returns_Bad_Request_response.freeze @@ -1 +1 @@ -2023-09-19T20:34:19.633Z \ No newline at end of file +2023-10-04T19:18:49.142Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_with_missing_group_widget_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_with_missing_group_widget_returns_Bad_Request_response.yaml index 2d3d91cfef1..ae03dd45a6a 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_with_missing_group_widget_returns_Bad_Request_response.yaml +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Create_a_new_powerpack_with_missing_group_widget_returns_Bad_Request_response.yaml @@ -1,7 +1,7 @@ interactions: - request: body: | - {"data":{"attributes":{"description":"Sample powerpack","group_widget":{},"name":"Sample Powerpack","tags":["tag:sample"],"template_variables":[{"defaults":["*"],"name":"sample"}]},"type":"powerpack"}} + {"data":{"attributes":{"description":"Sample powerpack","name":"Sample Powerpack","tags":["tag:sample"],"template_variables":[{"defaults":["*"],"name":"sample"}]},"type":"powerpack"}} form: {} headers: Accept: @@ -11,30 +11,8 @@ interactions: method: POST url: https://api.datadoghq.com/api/v2/powerpacks response: - body: '{"errors":["Invalid group widget for powerpack. Error: ''type'' is a required - property\n\nFailed validating ''required'' in schema:\n {''additionalProperties'': - False,\n ''properties'': {''background_color'': {''type'': ''string''},\n ''banner_img'': - {''type'': ''string''},\n ''layout_type'': {''enum'': [''ordered'']},\n ''reflow_type'': - {''enum'': [''auto'', ''fixed'']},\n ''show_title'': {''type'': - ''boolean''},\n ''title'': {''type'': ''string''},\n ''title_align'': - {''enum'': [''center'', ''left'', ''right'']},\n ''type'': - {''enum'': [''group'']},\n ''widgets'': {''items'': {''additionalProperties'': - False,\n ''properties'': {''definition'': - {''additionalProperties'': True,\n ''properties'': - {''type'': {''enum'': [''alert_graph'',\n ''alert_value'',\n ''change'',\n ''check_status'',\n ''distribution'',\n ''geomap'',\n ''heatmap'',\n ''hostmap'',\n ''note'',\n ''query_value'',\n ''scatterplot'',\n ''servicemap'',\n ''topology_map'',\n ''query_table'',\n ''timeseries'',\n ''toplist'',\n ''list_stream'',\n ''treemap'',\n ''uptime'',\n ''slo'',\n ''funnel'',\n ''custom'',\n ''experimental'',\n ''sunburst'',\n ''wildcard'',\n ''slo_list'',\n ''flame_graph'',\n ''run_workflow'',\n ''embedded_app'',\n ''log_stream'',\n ''iframe'',\n ''free_text'',\n ''event_stream'',\n ''event_timeline'',\n ''manage_status'',\n ''trace_service'',\n ''image'']}},\n ''required'': - [''type''],\n ''type'': - ''object''},\n ''id'': - {''type'': ''integer''},\n ''layout'': - {''additionalProperties'': False,\n ''properties'': - {''height'': {''type'': ''number''},\n ''is_column_break'': - {''type'': ''boolean''},\n ''width'': - {''type'': ''number''},\n ''x'': - {''type'': ''number''},\n ''y'': - {''type'': ''number''}},\n ''type'': - ''object''}},\n ''required'': [''definition''],\n ''type'': - ''object''},\n ''type'': ''array''}},\n ''required'': - [''type'', ''layout_type'', ''widgets''],\n ''type'': ''object''}\n\nOn - instance:\n {}."]}' + body: '{"errors":["API input validation failed: {''group_widget'': [''Missing + data for required field.'']}"]}' code: 400 duration: '' headers: diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Update_a_powerpack_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Update_a_powerpack_returns_Bad_Request_response.freeze index d30592128ac..8d5b8f21651 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Update_a_powerpack_returns_Bad_Request_response.freeze +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Update_a_powerpack_returns_Bad_Request_response.freeze @@ -1 +1 @@ -2023-09-19T20:34:23.150Z \ No newline at end of file +2023-10-05T15:56:24.178Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Update_a_powerpack_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Update_a_powerpack_returns_Bad_Request_response.yaml index 3240a9ab7b3..5a6ba693ac5 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Update_a_powerpack_returns_Bad_Request_response.yaml +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Powerpack/Scenario_Update_a_powerpack_returns_Bad_Request_response.yaml @@ -11,9 +11,10 @@ interactions: method: POST url: https://api.datadoghq.com/api/v2/powerpacks response: - body: '{"data":{"type":"powerpack","id":"eb0c0428-572b-11ee-92ec-da7ad0900002","attributes":{"name":"Sample + body: '{"data":{"type":"powerpack","id":"bc22abe4-6397-11ee-865e-da7ad0900002","attributes":{"name":"Sample Powerpack","description":"Sample powerpack","group_widget":{"definition":{"layout_type":"ordered","show_title":true,"title":"Sample - Powerpack","type":"group","widgets":[{"definition":{"content":"test","type":"note"},"id":8888289347240039}]},"layout":{"height":3,"width":12,"x":0,"y":0}},"template_variables":[{"defaults":["*"],"name":"sample"}],"tags":["tag:sample"]},"relationships":{"author":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}}}},"included":[{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0","attributes":{"name":null,"email":"frog@datadoghq.com"}}]} + Powerpack","type":"group","widgets":[{"definition":{"content":"test","type":"note"},"id":1043184765896296}]},"layout":{"height":3,"width":12,"x":0,"y":0}},"template_variables":[{"defaults":["*"],"name":"sample"}],"tags":["tag:sample"]},"relationships":{"author":{"data":{"type":"users","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}}},"included":[{"type":"users","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","attributes":{"name":"CI + Account","email":"team-intg-tools-libs-spam@datadoghq.com"}}]} ' code: 200 @@ -24,7 +25,7 @@ interactions: status: 200 OK - request: body: | - {"data":{"attributes":{"description":"Sample powerpack","group_widget":{},"name":"Sample Powerpack","tags":["tag:sample"],"template_variables":[{"defaults":["*"],"name":"sample"}]},"type":"powerpack"}} + {"data":{"attributes":{"description":"Sample powerpack","group_widget":{"definition":{"layout_type":"ordered","type":"group1","widgets":[]}},"name":"Sample Powerpack","tags":["tag:sample"],"template_variables":[{"defaults":["*"],"name":"sample"}]},"type":"powerpack"}} form: {} headers: Accept: @@ -32,32 +33,11 @@ interactions: Content-Type: - application/json method: PATCH - url: https://api.datadoghq.com/api/v2/powerpacks/eb0c0428-572b-11ee-92ec-da7ad0900002 + url: https://api.datadoghq.com/api/v2/powerpacks/bc22abe4-6397-11ee-865e-da7ad0900002 response: - body: '{"errors":["Invalid group widget for powerpack. Error: ''type'' is a required - property\n\nFailed validating ''required'' in schema:\n {''additionalProperties'': - False,\n ''properties'': {''background_color'': {''type'': ''string''},\n ''banner_img'': - {''type'': ''string''},\n ''layout_type'': {''enum'': [''ordered'']},\n ''reflow_type'': - {''enum'': [''auto'', ''fixed'']},\n ''show_title'': {''type'': - ''boolean''},\n ''title'': {''type'': ''string''},\n ''title_align'': - {''enum'': [''center'', ''left'', ''right'']},\n ''type'': - {''enum'': [''group'']},\n ''widgets'': {''items'': {''additionalProperties'': - False,\n ''properties'': {''definition'': - {''additionalProperties'': True,\n ''properties'': - {''type'': {''enum'': [''alert_graph'',\n ''alert_value'',\n ''change'',\n ''check_status'',\n ''distribution'',\n ''geomap'',\n ''heatmap'',\n ''hostmap'',\n ''note'',\n ''query_value'',\n ''scatterplot'',\n ''servicemap'',\n ''topology_map'',\n ''query_table'',\n ''timeseries'',\n ''toplist'',\n ''list_stream'',\n ''treemap'',\n ''uptime'',\n ''slo'',\n ''funnel'',\n ''custom'',\n ''experimental'',\n ''sunburst'',\n ''wildcard'',\n ''slo_list'',\n ''flame_graph'',\n ''run_workflow'',\n ''embedded_app'',\n ''log_stream'',\n ''iframe'',\n ''free_text'',\n ''event_stream'',\n ''event_timeline'',\n ''manage_status'',\n ''trace_service'',\n ''image'']}},\n ''required'': - [''type''],\n ''type'': - ''object''},\n ''id'': - {''type'': ''integer''},\n ''layout'': - {''additionalProperties'': False,\n ''properties'': - {''height'': {''type'': ''number''},\n ''is_column_break'': - {''type'': ''boolean''},\n ''width'': - {''type'': ''number''},\n ''x'': - {''type'': ''number''},\n ''y'': - {''type'': ''number''}},\n ''type'': - ''object''}},\n ''required'': [''definition''],\n ''type'': - ''object''},\n ''type'': ''array''}},\n ''required'': - [''type'', ''layout_type'', ''widgets''],\n ''type'': ''object''}\n\nOn - instance:\n {}."]}' + body: '{"errors":["Invalid group widget for powerpack. Error: ''group1'' is not + one of [''group'']\n\nFailed validating ''enum'' in schema[''properties''][''type'']:\n {''enum'': + [''group'']}\n\nOn instance[''type'']:\n ''group1''."]}' code: 400 duration: '' headers: @@ -71,7 +51,7 @@ interactions: Accept: - '*/*' method: DELETE - url: https://api.datadoghq.com/api/v2/powerpacks/eb0c0428-572b-11ee-92ec-da7ad0900002 + url: https://api.datadoghq.com/api/v2/powerpacks/bc22abe4-6397-11ee-865e-da7ad0900002 response: body: '' code: 204 diff --git a/tests/scenarios/features/v2/powerpack.feature b/tests/scenarios/features/v2/powerpack.feature index c3a474969ce..1e36d4a999c 100644 --- a/tests/scenarios/features/v2/powerpack.feature +++ b/tests/scenarios/features/v2/powerpack.feature @@ -13,7 +13,7 @@ Feature: Powerpack @team:DataDog/dashboards-backend Scenario: Create a new powerpack returns "Bad Request" response Given new "CreatePowerpack" request - And body with value {"data": {"attributes": {"description": "Powerpack for ABC", "group_widget": {"layout_type": "ordered", "tags": ["tag:foo1"], "type": "group", "widgets": [{"definition": {"content": "example", "type": "note"}}]}, "name": "Sample Powerpack", "tags": ["tag:foo1"], "template_variables": [{"defaults": ["*"], "name": "test"}]}, "type": "powerpack"}} + And body with value {"data": {"attributes": {"description": "Powerpack for ABC", "group_widget": {"definition": {"type": "group1", "layout_type": "ordered", "widgets": []}}, "name": "Sample Powerpack", "tags": ["tag:foo1"], "template_variables": [{"defaults": ["*"], "name": "test"}]}, "type": "powerpack"}} When the request is sent Then the response status is 400 Bad Request @@ -38,13 +38,6 @@ Feature: Powerpack And the response "data.attributes.group_widget.definition.title" is equal to "Sample Powerpack" And the response "data.attributes.group_widget.definition.widgets[0].definition.type" is equal to "note" - @team:DataDog/dashboards-backend - Scenario: Create a new powerpack with missing group_widget returns "Bad Request" response - Given new "CreatePowerpack" request - And body with value {"data":{"type": "powerpack","attributes": {"name": "Sample Powerpack","description": "Sample powerpack","group_widget": {},"template_variables": [{"name": "sample", "defaults": ["*"]}],"tags": ["tag:sample"]}}} - When the request is sent - Then the response status is 400 Bad Request - @team:DataDog/dashboards-backend Scenario: Delete a powerpack returns "OK" response Given there is a valid "powerpack" in the system @@ -117,7 +110,7 @@ Feature: Powerpack Given there is a valid "powerpack" in the system And new "UpdatePowerpack" request And request contains "powerpack_id" parameter from "powerpack.data.id" - And body with value {"data":{"type": "powerpack","attributes": {"name": "Sample Powerpack","description": "Sample powerpack","group_widget": {},"template_variables": [{"name": "sample", "defaults": ["*"]}],"tags": ["tag:sample"]}}} + And body with value {"data":{"type": "powerpack","attributes": {"name": "Sample Powerpack","description": "Sample powerpack","group_widget": {"definition": {"type": "group1", "layout_type": "ordered", "widgets": []}},"template_variables": [{"name": "sample", "defaults": ["*"]}],"tags": ["tag:sample"]}}} When the request is sent Then the response status is 400 Bad Request