Skip to content

Commit

Permalink
Powerpack Live Span Support (#2247)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Oct 25, 2023
1 parent b511bd6 commit 3dae329
Show file tree
Hide file tree
Showing 26 changed files with 252 additions and 108 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2023-10-25 09:00:14.250461",
"spec_repo_commit": "9ebdefa4"
"regenerated": "2023-10-25 13:57:30.477552",
"spec_repo_commit": "fb2f4134"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2023-10-25 09:00:14.266048",
"spec_repo_commit": "9ebdefa4"
"regenerated": "2023-10-25 13:57:30.510319",
"spec_repo_commit": "fb2f4134"
}
}
}
38 changes: 38 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11170,6 +11170,8 @@ components:
$ref: '#/components/schemas/PowerpackGroupWidgetDefinition'
layout:
$ref: '#/components/schemas/PowerpackGroupWidgetLayout'
live_span:
$ref: '#/components/schemas/WidgetLiveSpan'
required:
- definition
type: object
Expand Down Expand Up @@ -18581,6 +18583,42 @@ components:
type: string
x-enum-varnames:
- USERS
WidgetLiveSpan:
description: The available timeframes depend on the widget you are using.
enum:
- 1m
- 5m
- 10m
- 15m
- 30m
- 1h
- 4h
- 1d
- 2d
- 1w
- 1mo
- 3mo
- 6mo
- 1y
- alert
example: 5m
type: string
x-enum-varnames:
- PAST_ONE_MINUTE
- PAST_FIVE_MINUTES
- PAST_TEN_MINUTES
- PAST_FIFTEEN_MINUTES
- PAST_THIRTY_MINUTES
- PAST_ONE_HOUR
- PAST_FOUR_HOURS
- PAST_ONE_DAY
- PAST_TWO_DAYS
- PAST_ONE_WEEK
- PAST_ONE_MONTH
- PAST_THREE_MONTHS
- PAST_SIX_MONTHS
- PAST_ONE_YEAR
- ALERT
securitySchemes:
AuthZ:
description: This API uses OAuth 2 with the implicit grant flow.
Expand Down
41 changes: 40 additions & 1 deletion api/datadogV2/model_powerpack_group_widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type PowerpackGroupWidget struct {
Definition PowerpackGroupWidgetDefinition `json:"definition"`
// Powerpack group widget layout.
Layout *PowerpackGroupWidgetLayout `json:"layout,omitempty"`
// The available timeframes depend on the widget you are using.
LiveSpan *WidgetLiveSpan `json:"live_span,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{}
Expand Down Expand Up @@ -92,6 +94,34 @@ func (o *PowerpackGroupWidget) SetLayout(v PowerpackGroupWidgetLayout) {
o.Layout = &v
}

// GetLiveSpan returns the LiveSpan field value if set, zero value otherwise.
func (o *PowerpackGroupWidget) GetLiveSpan() WidgetLiveSpan {
if o == nil || o.LiveSpan == nil {
var ret WidgetLiveSpan
return ret
}
return *o.LiveSpan
}

// GetLiveSpanOk returns a tuple with the LiveSpan field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PowerpackGroupWidget) GetLiveSpanOk() (*WidgetLiveSpan, bool) {
if o == nil || o.LiveSpan == nil {
return nil, false
}
return o.LiveSpan, true
}

// HasLiveSpan returns a boolean if a field has been set.
func (o *PowerpackGroupWidget) HasLiveSpan() bool {
return o != nil && o.LiveSpan != nil
}

// SetLiveSpan gets a reference to the given WidgetLiveSpan and assigns it to the LiveSpan field.
func (o *PowerpackGroupWidget) SetLiveSpan(v WidgetLiveSpan) {
o.LiveSpan = &v
}

// MarshalJSON serializes the struct using spec logic.
func (o PowerpackGroupWidget) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
Expand All @@ -102,6 +132,9 @@ func (o PowerpackGroupWidget) MarshalJSON() ([]byte, error) {
if o.Layout != nil {
toSerialize["layout"] = o.Layout
}
if o.LiveSpan != nil {
toSerialize["live_span"] = o.LiveSpan
}

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
Expand All @@ -114,6 +147,7 @@ func (o *PowerpackGroupWidget) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Definition *PowerpackGroupWidgetDefinition `json:"definition"`
Layout *PowerpackGroupWidgetLayout `json:"layout,omitempty"`
LiveSpan *WidgetLiveSpan `json:"live_span,omitempty"`
}{}
if err = json.Unmarshal(bytes, &all); err != nil {
return json.Unmarshal(bytes, &o.UnparsedObject)
Expand All @@ -123,7 +157,7 @@ func (o *PowerpackGroupWidget) UnmarshalJSON(bytes []byte) (err error) {
}
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"definition", "layout"})
datadog.DeleteKeys(additionalProperties, &[]string{"definition", "layout", "live_span"})
} else {
return err
}
Expand All @@ -137,6 +171,11 @@ func (o *PowerpackGroupWidget) UnmarshalJSON(bytes []byte) (err error) {
hasInvalidField = true
}
o.Layout = all.Layout
if all.LiveSpan != nil && !all.LiveSpan.IsValid() {
hasInvalidField = true
} else {
o.LiveSpan = all.LiveSpan
}

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
Expand Down
92 changes: 92 additions & 0 deletions api/datadogV2/model_widget_live_span.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// 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"
)

// WidgetLiveSpan The available timeframes depend on the widget you are using.
type WidgetLiveSpan string

// List of WidgetLiveSpan.
const (
WIDGETLIVESPAN_PAST_ONE_MINUTE WidgetLiveSpan = "1m"
WIDGETLIVESPAN_PAST_FIVE_MINUTES WidgetLiveSpan = "5m"
WIDGETLIVESPAN_PAST_TEN_MINUTES WidgetLiveSpan = "10m"
WIDGETLIVESPAN_PAST_FIFTEEN_MINUTES WidgetLiveSpan = "15m"
WIDGETLIVESPAN_PAST_THIRTY_MINUTES WidgetLiveSpan = "30m"
WIDGETLIVESPAN_PAST_ONE_HOUR WidgetLiveSpan = "1h"
WIDGETLIVESPAN_PAST_FOUR_HOURS WidgetLiveSpan = "4h"
WIDGETLIVESPAN_PAST_ONE_DAY WidgetLiveSpan = "1d"
WIDGETLIVESPAN_PAST_TWO_DAYS WidgetLiveSpan = "2d"
WIDGETLIVESPAN_PAST_ONE_WEEK WidgetLiveSpan = "1w"
WIDGETLIVESPAN_PAST_ONE_MONTH WidgetLiveSpan = "1mo"
WIDGETLIVESPAN_PAST_THREE_MONTHS WidgetLiveSpan = "3mo"
WIDGETLIVESPAN_PAST_SIX_MONTHS WidgetLiveSpan = "6mo"
WIDGETLIVESPAN_PAST_ONE_YEAR WidgetLiveSpan = "1y"
WIDGETLIVESPAN_ALERT WidgetLiveSpan = "alert"
)

var allowedWidgetLiveSpanEnumValues = []WidgetLiveSpan{
WIDGETLIVESPAN_PAST_ONE_MINUTE,
WIDGETLIVESPAN_PAST_FIVE_MINUTES,
WIDGETLIVESPAN_PAST_TEN_MINUTES,
WIDGETLIVESPAN_PAST_FIFTEEN_MINUTES,
WIDGETLIVESPAN_PAST_THIRTY_MINUTES,
WIDGETLIVESPAN_PAST_ONE_HOUR,
WIDGETLIVESPAN_PAST_FOUR_HOURS,
WIDGETLIVESPAN_PAST_ONE_DAY,
WIDGETLIVESPAN_PAST_TWO_DAYS,
WIDGETLIVESPAN_PAST_ONE_WEEK,
WIDGETLIVESPAN_PAST_ONE_MONTH,
WIDGETLIVESPAN_PAST_THREE_MONTHS,
WIDGETLIVESPAN_PAST_SIX_MONTHS,
WIDGETLIVESPAN_PAST_ONE_YEAR,
WIDGETLIVESPAN_ALERT,
}

// GetAllowedValues reeturns the list of possible values.
func (v *WidgetLiveSpan) GetAllowedValues() []WidgetLiveSpan {
return allowedWidgetLiveSpanEnumValues
}

// UnmarshalJSON deserializes the given payload.
func (v *WidgetLiveSpan) UnmarshalJSON(src []byte) error {
var value string
err := json.Unmarshal(src, &value)
if err != nil {
return err
}
*v = WidgetLiveSpan(value)
return nil
}

// NewWidgetLiveSpanFromValue returns a pointer to a valid WidgetLiveSpan
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
func NewWidgetLiveSpanFromValue(v string) (*WidgetLiveSpan, error) {
ev := WidgetLiveSpan(v)
if ev.IsValid() {
return &ev, nil
}
return nil, fmt.Errorf("invalid value '%v' for WidgetLiveSpan: valid values are %v", v, allowedWidgetLiveSpanEnumValues)
}

// IsValid return true if the value is valid for the enum, false otherwise.
func (v WidgetLiveSpan) IsValid() bool {
for _, existing := range allowedWidgetLiveSpanEnumValues {
if existing == v {
return true
}
}
return false
}

// Ptr returns reference to WidgetLiveSpan value.
func (v WidgetLiveSpan) Ptr() *WidgetLiveSpan {
return &v
}
1 change: 1 addition & 0 deletions examples/v2/powerpack/CreatePowerpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func main() {
X: 0,
Y: 0,
},
LiveSpan: datadogV2.WIDGETLIVESPAN_PAST_ONE_HOUR.Ptr(),
},
Name: "Example-Powerpack",
Tags: []string{
Expand Down
1 change: 1 addition & 0 deletions examples/v2/powerpack/UpdatePowerpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func main() {
X: 0,
Y: 0,
},
LiveSpan: datadogV2.WIDGETLIVESPAN_PAST_ONE_HOUR.Ptr(),
},
Name: "Example-Powerpack",
Tags: []string{
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-10-11T18:44:47.026Z
2023-10-24T18:32:08.933Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: |
{"data":{"attributes":{"description":"Sample powerpack","group_widget":{"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}},"name":"Test-Create_a_new_dashboard_with_powerpack_widget-1697049887","tags":["tag:sample"],"template_variables":[{"defaults":["*"],"name":"sample"}]},"type":"powerpack"}}
{"data":{"attributes":{"description":"Sample powerpack","group_widget":{"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},"live_span":"1h"},"name":"Test-Create_a_new_dashboard_with_powerpack_widget-1698172328","tags":["tag:sample"],"template_variables":[{"defaults":["*"],"name":"sample"}]},"type":"powerpack"}}
form: {}
headers:
Accept:
Expand All @@ -11,9 +11,10 @@ interactions:
method: POST
url: https://api.datadoghq.com/api/v2/powerpacks
response:
body: '{"data":{"type":"powerpack","id":"40778356-6866-11ee-812e-da7ad0900002","attributes":{"name":"Test-Create_a_new_dashboard_with_powerpack_widget-1697049887","description":"Sample
body: '{"data":{"type":"powerpack","id":"a3e591c8-729b-11ee-bde6-da7ad0900002","attributes":{"name":"Test-Create_a_new_dashboard_with_powerpack_widget-1698172328","description":"Sample
powerpack","group_widget":{"definition":{"layout_type":"ordered","show_title":true,"title":"Sample
Powerpack","type":"group","widgets":[{"definition":{"content":"test","type":"note"},"id":6750168893668334}]},"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":1041433464205113}]},"layout":{"height":3,"width":12,"x":0,"y":0},"live_span":"1h"},"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
Expand All @@ -24,7 +25,7 @@ interactions:
status: 200 OK
- request:
body: |
{"description":"description","is_read_only":false,"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_powerpack_widget-1697049887 with powerpack widget","widgets":[{"definition":{"powerpack_id":"40778356-6866-11ee-812e-da7ad0900002","template_variables":{"controlled_by_powerpack":[{"name":"foo","prefix":"bar","values":["baz","qux","quuz"]}],"controlled_externally":[]},"type":"powerpack"},"layout":{"height":2,"is_column_break":false,"width":2,"x":1,"y":1}}]}
{"description":"description","is_read_only":false,"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_powerpack_widget-1698172328 with powerpack widget","widgets":[{"definition":{"powerpack_id":"a3e591c8-729b-11ee-bde6-da7ad0900002","template_variables":{"controlled_by_powerpack":[{"name":"foo","prefix":"bar","values":["baz","qux","quuz"]}],"controlled_externally":[]},"type":"powerpack"},"layout":{"height":2,"is_column_break":false,"width":2,"x":1,"y":1}}]}
form: {}
headers:
Accept:
Expand All @@ -34,8 +35,9 @@ interactions:
method: POST
url: https://api.datadoghq.com/api/v1/dashboard
response:
body: '{"id":"wap-jgr-c99","title":"Test-Create_a_new_dashboard_with_powerpack_widget-1697049887
with powerpack widget","description":"description","author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/wap-jgr-c99/test-createanewdashboardwithpowerpackwidget-1697049887-with-powerpack-widget","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"powerpack_id":"40778356-6866-11ee-812e-da7ad0900002","template_variables":{"controlled_by_powerpack":[{"name":"foo","prefix":"bar","values":["baz","qux","quuz"]}],"controlled_externally":[]},"type":"powerpack"},"layout":{"height":2,"is_column_break":false,"width":2,"x":1,"y":1},"id":2124665012947075}],"notify_list":null,"created_at":"2023-10-11T18:44:47.485150+00:00","modified_at":"2023-10-11T18:44:47.485150+00:00","restricted_roles":[]}
body: '{"id":"u4a-itq-xia","title":"Test-Create_a_new_dashboard_with_powerpack_widget-1698172328
with powerpack widget","description":"description","author_handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","author_name":"CI
Account","layout_type":"ordered","url":"/dashboard/u4a-itq-xia/test-createanewdashboardwithpowerpackwidget-1698172328-with-powerpack-widget","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"powerpack_id":"a3e591c8-729b-11ee-bde6-da7ad0900002","template_variables":{"controlled_by_powerpack":[{"name":"foo","prefix":"bar","values":["baz","qux","quuz"]}],"controlled_externally":[]},"type":"powerpack"},"layout":{"height":2,"is_column_break":false,"width":2,"x":1,"y":1},"id":1423357855337541}],"notify_list":null,"created_at":"2023-10-24T18:32:09.719784+00:00","modified_at":"2023-10-24T18:32:09.719784+00:00","restricted_roles":[]}
'
code: 200
Expand All @@ -51,9 +53,9 @@ interactions:
Accept:
- application/json
method: DELETE
url: https://api.datadoghq.com/api/v1/dashboard/wap-jgr-c99
url: https://api.datadoghq.com/api/v1/dashboard/u4a-itq-xia
response:
body: '{"deleted_dashboard_id":"wap-jgr-c99"}
body: '{"deleted_dashboard_id":"u4a-itq-xia"}
'
code: 200
Expand All @@ -69,7 +71,7 @@ interactions:
Accept:
- '*/*'
method: DELETE
url: https://api.datadoghq.com/api/v2/powerpacks/40778356-6866-11ee-812e-da7ad0900002
url: https://api.datadoghq.com/api/v2/powerpacks/a3e591c8-729b-11ee-bde6-da7ad0900002
response:
body: ''
code: 204
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-10-11T15:48:55.126Z
2023-10-24T18:32:10.926Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: |
{"data":{"attributes":{"description":"Sample powerpack","group_widget":{"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}},"name":"Test-Create_a_new_powerpack_returns_OK_response-1697039335","tags":["tag:sample"],"template_variables":[{"defaults":["*"],"name":"sample"}]},"type":"powerpack"}}
{"data":{"attributes":{"description":"Sample powerpack","group_widget":{"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},"live_span":"1h"},"name":"Test-Create_a_new_powerpack_returns_OK_response-1698172330","tags":["tag:sample"],"template_variables":[{"defaults":["*"],"name":"sample"}]},"type":"powerpack"}}
form: {}
headers:
Accept:
Expand All @@ -11,9 +11,10 @@ interactions:
method: POST
url: https://api.datadoghq.com/api/v2/powerpacks
response:
body: '{"data":{"type":"powerpack","id":"aef5d85a-684d-11ee-ae79-da7ad0900002","attributes":{"name":"Test-Create_a_new_powerpack_returns_OK_response-1697039335","description":"Sample
body: '{"data":{"type":"powerpack","id":"a5892a4e-729b-11ee-8449-da7ad0900002","attributes":{"name":"Test-Create_a_new_powerpack_returns_OK_response-1698172330","description":"Sample
powerpack","group_widget":{"definition":{"layout_type":"ordered","show_title":true,"title":"Sample
Powerpack","type":"group","widgets":[{"definition":{"content":"test","type":"note"},"id":5789473441337322}]},"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":2803120731030485}]},"layout":{"height":3,"width":12,"x":0,"y":0},"live_span":"1h"},"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
Expand All @@ -29,7 +30,7 @@ interactions:
Accept:
- '*/*'
method: DELETE
url: https://api.datadoghq.com/api/v2/powerpacks/aef5d85a-684d-11ee-ae79-da7ad0900002
url: https://api.datadoghq.com/api/v2/powerpacks/a5892a4e-729b-11ee-8449-da7ad0900002
response:
body: ''
code: 204
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-10-11T15:48:55.488Z
2023-10-24T18:32:12.418Z
Loading

0 comments on commit 3dae329

Please sign in to comment.