-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tags field to dashboard API spec (#1907)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
- Loading branch information
1 parent
dc40827
commit cc32fd4
Showing
12 changed files
with
359 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Create a new dashboard with team tags returns "OK" response | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/DataDog/datadog-api-client-go/v2/api/datadog" | ||
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1" | ||
) | ||
|
||
func main() { | ||
body := datadogV1.Dashboard{ | ||
Title: "Example-Create_a_new_dashboard_with_team_tags_returns_OK_response", | ||
Widgets: []datadogV1.Widget{ | ||
{ | ||
Definition: datadogV1.WidgetDefinition{ | ||
ChangeWidgetDefinition: &datadogV1.ChangeWidgetDefinition{ | ||
Title: datadog.PtrString(""), | ||
TitleSize: datadog.PtrString("16"), | ||
TitleAlign: datadogV1.WIDGETTEXTALIGN_LEFT.Ptr(), | ||
Time: &datadogV1.WidgetTime{}, | ||
Type: datadogV1.CHANGEWIDGETDEFINITIONTYPE_CHANGE, | ||
Requests: []datadogV1.ChangeWidgetRequest{ | ||
{ | ||
Formulas: []datadogV1.WidgetFormula{ | ||
{ | ||
Formula: "hour_before(query1)", | ||
}, | ||
{ | ||
Formula: "query1", | ||
}, | ||
}, | ||
Queries: []datadogV1.FormulaAndFunctionQueryDefinition{ | ||
datadogV1.FormulaAndFunctionQueryDefinition{ | ||
FormulaAndFunctionEventQueryDefinition: &datadogV1.FormulaAndFunctionEventQueryDefinition{ | ||
DataSource: datadogV1.FORMULAANDFUNCTIONEVENTSDATASOURCE_LOGS, | ||
Name: "query1", | ||
Search: &datadogV1.FormulaAndFunctionEventQueryDefinitionSearch{ | ||
Query: "", | ||
}, | ||
Indexes: []string{ | ||
"*", | ||
}, | ||
Compute: datadogV1.FormulaAndFunctionEventQueryDefinitionCompute{ | ||
Aggregation: datadogV1.FORMULAANDFUNCTIONEVENTAGGREGATION_COUNT, | ||
}, | ||
GroupBy: []datadogV1.FormulaAndFunctionEventQueryGroupBy{}, | ||
}}, | ||
}, | ||
ResponseFormat: datadogV1.FORMULAANDFUNCTIONRESPONSEFORMAT_SCALAR.Ptr(), | ||
CompareTo: datadogV1.WIDGETCOMPARETO_HOUR_BEFORE.Ptr(), | ||
IncreaseGood: datadog.PtrBool(true), | ||
OrderBy: datadogV1.WIDGETORDERBY_CHANGE.Ptr(), | ||
ChangeType: datadogV1.WIDGETCHANGETYPE_ABSOLUTE.Ptr(), | ||
OrderDir: datadogV1.WIDGETSORT_DESCENDING.Ptr(), | ||
}, | ||
}, | ||
}}, | ||
Layout: &datadogV1.WidgetLayout{ | ||
X: 0, | ||
Y: 0, | ||
Width: 4, | ||
Height: 4, | ||
}, | ||
}, | ||
}, | ||
Tags: []string{ | ||
"team:foobar", | ||
}, | ||
LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED, | ||
} | ||
ctx := datadog.NewDefaultContext(context.Background()) | ||
configuration := datadog.NewConfiguration() | ||
apiClient := datadog.NewAPIClient(configuration) | ||
api := datadogV1.NewDashboardsApi(apiClient) | ||
resp, r, err := api.CreateDashboard(ctx, body) | ||
|
||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreateDashboard`: %v\n", err) | ||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) | ||
} | ||
|
||
responseContent, _ := json.MarshalIndent(resp, "", " ") | ||
fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreateDashboard`:\n%s\n", responseContent) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Update a dashboard with tags returns "OK" response | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/DataDog/datadog-api-client-go/v2/api/datadog" | ||
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1" | ||
) | ||
|
||
func main() { | ||
// there is a valid "dashboard" in the system | ||
DashboardID := os.Getenv("DASHBOARD_ID") | ||
|
||
body := datadogV1.Dashboard{ | ||
LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED, | ||
Title: "Example-Update_a_dashboard_with_tags_returns_OK_response with list_stream widget", | ||
Description: *datadog.NewNullableString(datadog.PtrString("Updated description")), | ||
Tags: []string{ | ||
"team:foo", | ||
"team:bar", | ||
}, | ||
Widgets: []datadogV1.Widget{ | ||
{ | ||
Definition: datadogV1.WidgetDefinition{ | ||
ListStreamWidgetDefinition: &datadogV1.ListStreamWidgetDefinition{ | ||
Type: datadogV1.LISTSTREAMWIDGETDEFINITIONTYPE_LIST_STREAM, | ||
Requests: []datadogV1.ListStreamWidgetRequest{ | ||
{ | ||
Columns: []datadogV1.ListStreamColumn{ | ||
{ | ||
Width: datadogV1.LISTSTREAMCOLUMNWIDTH_AUTO, | ||
Field: "timestamp", | ||
}, | ||
}, | ||
Query: datadogV1.ListStreamQuery{ | ||
DataSource: datadogV1.LISTSTREAMSOURCE_APM_ISSUE_STREAM, | ||
QueryString: "", | ||
}, | ||
ResponseFormat: datadogV1.LISTSTREAMRESPONSEFORMAT_EVENT_LIST, | ||
}, | ||
}, | ||
}}, | ||
}, | ||
}, | ||
} | ||
ctx := datadog.NewDefaultContext(context.Background()) | ||
configuration := datadog.NewConfiguration() | ||
apiClient := datadog.NewAPIClient(configuration) | ||
api := datadogV1.NewDashboardsApi(apiClient) | ||
resp, r, err := api.UpdateDashboard(ctx, DashboardID, body) | ||
|
||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.UpdateDashboard`: %v\n", err) | ||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) | ||
} | ||
|
||
responseContent, _ := json.MarshalIndent(resp, "", " ") | ||
fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.UpdateDashboard`:\n%s\n", responseContent) | ||
} |
1 change: 1 addition & 0 deletions
1
...cenario_Create_a_new_dashboard_with_invalid_team_tags_returns_Bad_Request_response.freeze
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2023-03-08T22:44:59.472Z |
21 changes: 21 additions & 0 deletions
21
.../Scenario_Create_a_new_dashboard_with_invalid_team_tags_returns_Bad_Request_response.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
interactions: | ||
- request: | ||
body: | | ||
{"layout_type":"ordered","tags":["tm:foobar"],"title":"Test-Create_a_new_dashboard_with_invalid_team_tags_returns_Bad_Request_response-1678315499","widgets":[{"definition":{"requests":[{"change_type":"absolute","compare_to":"hour_before","formulas":[{"formula":"hour_before(query1)"},{"formula":"query1"}],"increase_good":true,"order_by":"change","order_dir":"desc","queries":[{"compute":{"aggregation":"count"},"data_source":"logs","group_by":[],"indexes":["*"],"name":"query1","search":{"query":""}}],"response_format":"scalar"}],"time":{},"title":"","title_align":"left","title_size":"16","type":"change"},"layout":{"height":4,"width":4,"x":0,"y":0}}]} | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
Content-Type: | ||
- application/json | ||
method: POST | ||
url: https://api.datadoghq.com/api/v1/dashboard | ||
response: | ||
body: '{"errors":["Invalid tag format. Tag key must be `team`."]}' | ||
code: 400 | ||
duration: '' | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 400 Bad Request | ||
version: 1 |
1 change: 1 addition & 0 deletions
1
...ture_Dashboards/Scenario_Create_a_new_dashboard_with_team_tags_returns_OK_response.freeze
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2023-03-08T20:53:52.326Z |
41 changes: 41 additions & 0 deletions
41
...eature_Dashboards/Scenario_Create_a_new_dashboard_with_team_tags_returns_OK_response.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
interactions: | ||
- request: | ||
body: | | ||
{"layout_type":"ordered","tags":["team:foobar"],"title":"Test-Create_a_new_dashboard_with_team_tags_returns_OK_response-1678308832","widgets":[{"definition":{"requests":[{"change_type":"absolute","compare_to":"hour_before","formulas":[{"formula":"hour_before(query1)"},{"formula":"query1"}],"increase_good":true,"order_by":"change","order_dir":"desc","queries":[{"compute":{"aggregation":"count"},"data_source":"logs","group_by":[],"indexes":["*"],"name":"query1","search":{"query":""}}],"response_format":"scalar"}],"time":{},"title":"","title_align":"left","title_size":"16","type":"change"},"layout":{"height":4,"width":4,"x":0,"y":0}}]} | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
Content-Type: | ||
- application/json | ||
method: POST | ||
url: https://api.datadoghq.com/api/v1/dashboard | ||
response: | ||
body: '{"id":"cvx-m2c-ntf","title":"Test-Create_a_new_dashboard_with_team_tags_returns_OK_response-1678308832","description":null,"author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/cvx-m2c-ntf/test-createanewdashboardwithteamtagsreturnsokresponse-1678308832","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"requests":[{"change_type":"absolute","compare_to":"hour_before","formulas":[{"formula":"hour_before(query1)"},{"formula":"query1"}],"increase_good":true,"order_by":"change","order_dir":"desc","queries":[{"compute":{"aggregation":"count"},"data_source":"logs","group_by":[],"indexes":["*"],"name":"query1","search":{"query":""}}],"response_format":"scalar"}],"time":{},"title":"","title_align":"left","title_size":"16","type":"change"},"layout":{"height":4,"width":4,"x":0,"y":0},"id":3494387223047491}],"notify_list":null,"created_at":"2023-03-08T20:53:52.690739+00:00","modified_at":"2023-03-08T20:53:52.690739+00:00","tags":["team:foobar"],"restricted_roles":[]} | ||
|
||
' | ||
code: 200 | ||
duration: '' | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
- request: | ||
body: '' | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
method: DELETE | ||
url: https://api.datadoghq.com/api/v1/dashboard/cvx-m2c-ntf | ||
response: | ||
body: '{"deleted_dashboard_id":"cvx-m2c-ntf"} | ||
|
||
' | ||
code: 200 | ||
duration: '' | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
version: 1 |
1 change: 1 addition & 0 deletions
1
...os/v1/Feature_Dashboards/Scenario_Update_a_dashboard_with_tags_returns_OK_response.freeze
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2023-03-10T23:23:35.716Z |
64 changes: 64 additions & 0 deletions
64
...rios/v1/Feature_Dashboards/Scenario_Update_a_dashboard_with_tags_returns_OK_response.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
interactions: | ||
- request: | ||
body: | | ||
{"layout_type":"ordered","title":"Test-Update_a_dashboard_with_tags_returns_OK_response-1678490615 with Profile Metrics Query","widgets":[{"definition":{"requests":[{"profile_metrics_query":{"compute":{"aggregation":"sum","facet":"@prof_core_cpu_cores"},"group_by":[{"facet":"service","limit":10,"sort":{"aggregation":"sum","facet":"@prof_core_cpu_cores","order":"desc"}}],"search":{"query":"runtime:jvm"}}}],"type":"timeseries"}}]} | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
Content-Type: | ||
- application/json | ||
method: POST | ||
url: https://api.datadoghq.com/api/v1/dashboard | ||
response: | ||
body: '{"id":"ad2-8ch-y8s","title":"Test-Update_a_dashboard_with_tags_returns_OK_response-1678490615 | ||
with Profile Metrics Query","description":null,"author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/ad2-8ch-y8s/test-updateadashboardwithtagsreturnsokresponse-1678490615-with-profile-metrics-q","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"requests":[{"profile_metrics_query":{"compute":{"aggregation":"sum","facet":"@prof_core_cpu_cores"},"group_by":[{"facet":"service","limit":10,"sort":{"aggregation":"sum","facet":"@prof_core_cpu_cores","order":"desc"}}],"search":{"query":"runtime:jvm"}}}],"type":"timeseries"},"id":6897153580739865}],"notify_list":null,"created_at":"2023-03-10T23:23:35.908079+00:00","modified_at":"2023-03-10T23:23:35.908079+00:00","tags":[],"restricted_roles":[]} | ||
' | ||
code: 200 | ||
duration: '' | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
- request: | ||
body: | | ||
{"description":"Updated description","layout_type":"ordered","tags":["team:foo","team:bar"],"title":"Test-Update_a_dashboard_with_tags_returns_OK_response-1678490615 with list_stream widget","widgets":[{"definition":{"requests":[{"columns":[{"field":"timestamp","width":"auto"}],"query":{"data_source":"apm_issue_stream","query_string":""},"response_format":"event_list"}],"type":"list_stream"}}]} | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
Content-Type: | ||
- application/json | ||
method: PUT | ||
url: https://api.datadoghq.com/api/v1/dashboard/ad2-8ch-y8s | ||
response: | ||
body: '{"id":"ad2-8ch-y8s","title":"Test-Update_a_dashboard_with_tags_returns_OK_response-1678490615 | ||
with list_stream widget","description":"Updated description","author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/ad2-8ch-y8s/test-updateadashboardwithtagsreturnsokresponse-1678490615-with-liststream-widget","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"requests":[{"columns":[{"field":"timestamp","width":"auto"}],"query":{"data_source":"apm_issue_stream","query_string":""},"response_format":"event_list"}],"type":"list_stream"},"id":4545330920817753}],"notify_list":null,"created_at":"2023-03-10T23:23:35.908079+00:00","modified_at":"2023-03-10T23:23:36.124521+00:00","tags":["team:foo","team:bar"],"restricted_roles":[]} | ||
' | ||
code: 200 | ||
duration: '' | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
- request: | ||
body: '' | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
method: DELETE | ||
url: https://api.datadoghq.com/api/v1/dashboard/ad2-8ch-y8s | ||
response: | ||
body: '{"deleted_dashboard_id":"ad2-8ch-y8s"} | ||
' | ||
code: 200 | ||
duration: '' | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
version: 1 |
Oops, something went wrong.