diff --git a/.apigentools-info b/.apigentools-info index fba89f25c38..70a0ac74502 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2023-10-05 18:58:08.893201", - "spec_repo_commit": "faa2c8d3" + "regenerated": "2023-10-05 20:05:27.468187", + "spec_repo_commit": "f7a95272" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2023-10-05 18:58:08.918484", - "spec_repo_commit": "faa2c8d3" + "regenerated": "2023-10-05 20:05:27.494649", + "spec_repo_commit": "f7a95272" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ee82ba9f101..0eca5ce93f5 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -5482,24 +5482,6 @@ components: type: string x-enum-varnames: - GCP_SERVICE_ACCOUNT - GetAllPowerpacksResponse: - description: Response object which includes all powerpack configurations. - properties: - data: - description: List of powerpack definitions. - items: - $ref: '#/components/schemas/PowerpackData' - type: array - included: - description: Array of objects related to the users. - items: - $ref: '#/components/schemas/User' - type: array - links: - $ref: '#/components/schemas/PowerpackResponseLinks' - meta: - $ref: '#/components/schemas/PowerpacksResponseMeta' - type: object GetFindingResponse: description: The expected response schema when getting a finding. properties: @@ -7677,6 +7659,24 @@ components: - data - meta type: object + ListPowerpacksResponse: + description: Response object which includes all powerpack configurations. + properties: + data: + description: List of powerpack definitions. + items: + $ref: '#/components/schemas/PowerpackData' + type: array + included: + description: Array of objects related to the users. + items: + $ref: '#/components/schemas/User' + type: array + links: + $ref: '#/components/schemas/PowerpackResponseLinks' + meta: + $ref: '#/components/schemas/PowerpacksResponseMeta' + type: object ListTeamsInclude: description: Included related resources optionally requested. enum: @@ -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: @@ -23570,13 +23694,13 @@ paths: /api/v2/powerpacks: get: description: Get a list of all powerpacks. - operationId: GetAllPowerpacks + operationId: ListPowerpacks responses: '200': content: application/json: schema: - $ref: '#/components/schemas/GetAllPowerpacksResponse' + $ref: '#/components/schemas/ListPowerpacksResponse' description: OK '429': $ref: '#/components/responses/TooManyRequestsResponse' diff --git a/api/datadogV2/api_powerpack.go b/api/datadogV2/api_powerpack.go index 0c98b0da7a8..533ed9a6897 100644 --- a/api/datadogV2/api_powerpack.go +++ b/api/datadogV2/api_powerpack.go @@ -150,21 +150,22 @@ func (a *PowerpackApi) DeletePowerpack(ctx _context.Context, powerpackId string) return localVarHTTPResponse, nil } -// GetAllPowerpacks Get all powerpacks. -// Get a list of all powerpacks. -func (a *PowerpackApi) GetAllPowerpacks(ctx _context.Context) (GetAllPowerpacksResponse, *_nethttp.Response, error) { +// GetPowerpack Get a Powerpack. +// Get a powerpack. +func (a *PowerpackApi) GetPowerpack(ctx _context.Context, powerpackId string) (PowerpackResponse, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue GetAllPowerpacksResponse + localVarReturnValue PowerpackResponse ) - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.PowerpackApi.GetAllPowerpacks") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.PowerpackApi.GetPowerpack") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/powerpacks" + localVarPath := localBasePath + "/api/v2/powerpacks/{powerpack_id}" + localVarPath = strings.Replace(localVarPath, "{"+"powerpack_id"+"}", _neturl.PathEscape(datadog.ParameterToString(powerpackId, "")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} @@ -197,7 +198,7 @@ func (a *PowerpackApi) GetAllPowerpacks(ctx _context.Context) (GetAllPowerpacksR ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 429 { + if localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { @@ -220,22 +221,21 @@ func (a *PowerpackApi) GetAllPowerpacks(ctx _context.Context) (GetAllPowerpacksR return localVarReturnValue, localVarHTTPResponse, nil } -// GetPowerpack Get a Powerpack. -// Get a powerpack. -func (a *PowerpackApi) GetPowerpack(ctx _context.Context, powerpackId string) (PowerpackResponse, *_nethttp.Response, error) { +// ListPowerpacks Get all powerpacks. +// Get a list of all powerpacks. +func (a *PowerpackApi) ListPowerpacks(ctx _context.Context) (ListPowerpacksResponse, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue PowerpackResponse + localVarReturnValue ListPowerpacksResponse ) - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.PowerpackApi.GetPowerpack") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.PowerpackApi.ListPowerpacks") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/powerpacks/{powerpack_id}" - localVarPath = strings.Replace(localVarPath, "{"+"powerpack_id"+"}", _neturl.PathEscape(datadog.ParameterToString(powerpackId, "")), -1) + localVarPath := localBasePath + "/api/v2/powerpacks" localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} @@ -268,7 +268,7 @@ func (a *PowerpackApi) GetPowerpack(ctx _context.Context, powerpackId string) (P ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + if localVarHTTPResponse.StatusCode == 429 { var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index ba63f041888..9ebfe0ae927 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -162,8 +162,8 @@ // - [OrganizationsApi.UploadIdPMetadata] // - [PowerpackApi.CreatePowerpack] // - [PowerpackApi.DeletePowerpack] -// - [PowerpackApi.GetAllPowerpacks] // - [PowerpackApi.GetPowerpack] +// - [PowerpackApi.ListPowerpacks] // - [PowerpackApi.UpdatePowerpack] // - [ProcessesApi.ListProcesses] // - [RUMApi.AggregateRUMEvents] diff --git a/api/datadogV2/model_get_all_powerpacks_response.go b/api/datadogV2/model_list_powerpacks_response.go similarity index 75% rename from api/datadogV2/model_get_all_powerpacks_response.go rename to api/datadogV2/model_list_powerpacks_response.go index 7260c788144..17577c28501 100644 --- a/api/datadogV2/model_get_all_powerpacks_response.go +++ b/api/datadogV2/model_list_powerpacks_response.go @@ -10,8 +10,8 @@ import ( "github.com/DataDog/datadog-api-client-go/v2/api/datadog" ) -// GetAllPowerpacksResponse Response object which includes all powerpack configurations. -type GetAllPowerpacksResponse struct { +// ListPowerpacksResponse Response object which includes all powerpack configurations. +type ListPowerpacksResponse struct { // List of powerpack definitions. Data []PowerpackData `json:"data,omitempty"` // Array of objects related to the users. @@ -25,25 +25,25 @@ type GetAllPowerpacksResponse struct { AdditionalProperties map[string]interface{} } -// NewGetAllPowerpacksResponse instantiates a new GetAllPowerpacksResponse object. +// NewListPowerpacksResponse instantiates a new ListPowerpacksResponse 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 NewGetAllPowerpacksResponse() *GetAllPowerpacksResponse { - this := GetAllPowerpacksResponse{} +func NewListPowerpacksResponse() *ListPowerpacksResponse { + this := ListPowerpacksResponse{} return &this } -// NewGetAllPowerpacksResponseWithDefaults instantiates a new GetAllPowerpacksResponse object. +// NewListPowerpacksResponseWithDefaults instantiates a new ListPowerpacksResponse 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 NewGetAllPowerpacksResponseWithDefaults() *GetAllPowerpacksResponse { - this := GetAllPowerpacksResponse{} +func NewListPowerpacksResponseWithDefaults() *ListPowerpacksResponse { + this := ListPowerpacksResponse{} return &this } // GetData returns the Data field value if set, zero value otherwise. -func (o *GetAllPowerpacksResponse) GetData() []PowerpackData { +func (o *ListPowerpacksResponse) GetData() []PowerpackData { if o == nil || o.Data == nil { var ret []PowerpackData return ret @@ -53,7 +53,7 @@ func (o *GetAllPowerpacksResponse) GetData() []PowerpackData { // GetDataOk returns a tuple with the Data field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *GetAllPowerpacksResponse) GetDataOk() (*[]PowerpackData, bool) { +func (o *ListPowerpacksResponse) GetDataOk() (*[]PowerpackData, bool) { if o == nil || o.Data == nil { return nil, false } @@ -61,17 +61,17 @@ func (o *GetAllPowerpacksResponse) GetDataOk() (*[]PowerpackData, bool) { } // HasData returns a boolean if a field has been set. -func (o *GetAllPowerpacksResponse) HasData() bool { +func (o *ListPowerpacksResponse) HasData() bool { return o != nil && o.Data != nil } // SetData gets a reference to the given []PowerpackData and assigns it to the Data field. -func (o *GetAllPowerpacksResponse) SetData(v []PowerpackData) { +func (o *ListPowerpacksResponse) SetData(v []PowerpackData) { o.Data = v } // GetIncluded returns the Included field value if set, zero value otherwise. -func (o *GetAllPowerpacksResponse) GetIncluded() []User { +func (o *ListPowerpacksResponse) GetIncluded() []User { if o == nil || o.Included == nil { var ret []User return ret @@ -81,7 +81,7 @@ func (o *GetAllPowerpacksResponse) GetIncluded() []User { // GetIncludedOk returns a tuple with the Included field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *GetAllPowerpacksResponse) GetIncludedOk() (*[]User, bool) { +func (o *ListPowerpacksResponse) GetIncludedOk() (*[]User, bool) { if o == nil || o.Included == nil { return nil, false } @@ -89,17 +89,17 @@ func (o *GetAllPowerpacksResponse) GetIncludedOk() (*[]User, bool) { } // HasIncluded returns a boolean if a field has been set. -func (o *GetAllPowerpacksResponse) HasIncluded() bool { +func (o *ListPowerpacksResponse) HasIncluded() bool { return o != nil && o.Included != nil } // SetIncluded gets a reference to the given []User and assigns it to the Included field. -func (o *GetAllPowerpacksResponse) SetIncluded(v []User) { +func (o *ListPowerpacksResponse) SetIncluded(v []User) { o.Included = v } // GetLinks returns the Links field value if set, zero value otherwise. -func (o *GetAllPowerpacksResponse) GetLinks() PowerpackResponseLinks { +func (o *ListPowerpacksResponse) GetLinks() PowerpackResponseLinks { if o == nil || o.Links == nil { var ret PowerpackResponseLinks return ret @@ -109,7 +109,7 @@ func (o *GetAllPowerpacksResponse) GetLinks() PowerpackResponseLinks { // GetLinksOk returns a tuple with the Links field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *GetAllPowerpacksResponse) GetLinksOk() (*PowerpackResponseLinks, bool) { +func (o *ListPowerpacksResponse) GetLinksOk() (*PowerpackResponseLinks, bool) { if o == nil || o.Links == nil { return nil, false } @@ -117,17 +117,17 @@ func (o *GetAllPowerpacksResponse) GetLinksOk() (*PowerpackResponseLinks, bool) } // HasLinks returns a boolean if a field has been set. -func (o *GetAllPowerpacksResponse) HasLinks() bool { +func (o *ListPowerpacksResponse) HasLinks() bool { return o != nil && o.Links != nil } // SetLinks gets a reference to the given PowerpackResponseLinks and assigns it to the Links field. -func (o *GetAllPowerpacksResponse) SetLinks(v PowerpackResponseLinks) { +func (o *ListPowerpacksResponse) SetLinks(v PowerpackResponseLinks) { o.Links = &v } // GetMeta returns the Meta field value if set, zero value otherwise. -func (o *GetAllPowerpacksResponse) GetMeta() PowerpacksResponseMeta { +func (o *ListPowerpacksResponse) GetMeta() PowerpacksResponseMeta { if o == nil || o.Meta == nil { var ret PowerpacksResponseMeta return ret @@ -137,7 +137,7 @@ func (o *GetAllPowerpacksResponse) GetMeta() PowerpacksResponseMeta { // GetMetaOk returns a tuple with the Meta field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *GetAllPowerpacksResponse) GetMetaOk() (*PowerpacksResponseMeta, bool) { +func (o *ListPowerpacksResponse) GetMetaOk() (*PowerpacksResponseMeta, bool) { if o == nil || o.Meta == nil { return nil, false } @@ -145,17 +145,17 @@ func (o *GetAllPowerpacksResponse) GetMetaOk() (*PowerpacksResponseMeta, bool) { } // HasMeta returns a boolean if a field has been set. -func (o *GetAllPowerpacksResponse) HasMeta() bool { +func (o *ListPowerpacksResponse) HasMeta() bool { return o != nil && o.Meta != nil } // SetMeta gets a reference to the given PowerpacksResponseMeta and assigns it to the Meta field. -func (o *GetAllPowerpacksResponse) SetMeta(v PowerpacksResponseMeta) { +func (o *ListPowerpacksResponse) SetMeta(v PowerpacksResponseMeta) { o.Meta = &v } // MarshalJSON serializes the struct using spec logic. -func (o GetAllPowerpacksResponse) MarshalJSON() ([]byte, error) { +func (o ListPowerpacksResponse) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} if o.UnparsedObject != nil { return json.Marshal(o.UnparsedObject) @@ -180,7 +180,7 @@ func (o GetAllPowerpacksResponse) MarshalJSON() ([]byte, error) { } // UnmarshalJSON deserializes the given payload. -func (o *GetAllPowerpacksResponse) UnmarshalJSON(bytes []byte) (err error) { +func (o *ListPowerpacksResponse) UnmarshalJSON(bytes []byte) (err error) { all := struct { Data []PowerpackData `json:"data,omitempty"` Included []User `json:"included,omitempty"` 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/GetAllPowerpacks.go b/examples/v2/powerpack/ListPowerpacks.go similarity index 71% rename from examples/v2/powerpack/GetAllPowerpacks.go rename to examples/v2/powerpack/ListPowerpacks.go index b245cf014f1..d9c0f278cc7 100644 --- a/examples/v2/powerpack/GetAllPowerpacks.go +++ b/examples/v2/powerpack/ListPowerpacks.go @@ -17,13 +17,13 @@ func main() { configuration := datadog.NewConfiguration() apiClient := datadog.NewAPIClient(configuration) api := datadogV2.NewPowerpackApi(apiClient) - resp, r, err := api.GetAllPowerpacks(ctx) + resp, r, err := api.ListPowerpacks(ctx) if err != nil { - fmt.Fprintf(os.Stderr, "Error when calling `PowerpackApi.GetAllPowerpacks`: %v\n", err) + fmt.Fprintf(os.Stderr, "Error when calling `PowerpackApi.ListPowerpacks`: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } responseContent, _ := json.MarshalIndent(resp, "", " ") - fmt.Fprintf(os.Stdout, "Response from `PowerpackApi.GetAllPowerpacks`:\n%s\n", responseContent) + fmt.Fprintf(os.Stdout, "Response from `PowerpackApi.ListPowerpacks`:\n%s\n", responseContent) } 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..e14ebfb6520 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 @@ -93,7 +86,7 @@ Feature: Powerpack @team:DataDog/dashboards-backend Scenario: Get all powerpacks returns "OK" response Given there is a valid "powerpack" in the system - And new "GetAllPowerpacks" request + And new "ListPowerpacks" request When the request is sent Then the response status is 200 OK And the response "data" has item with field "type" with value "powerpack" @@ -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 diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 0eacdd54f48..a127541e650 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1023,7 +1023,7 @@ "type": "safe" } }, - "GetAllPowerpacks": { + "ListPowerpacks": { "tag": "Powerpack", "undo": { "type": "safe"