Skip to content

Add powerpack widget to dashboard schema #1355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-02 18:58:17.891416",
"spec_repo_commit": "aee9e14a"
"regenerated": "2023-10-04 17:33:10.783188",
"spec_repo_commit": "adf28ce4"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2023-10-02 18:58:17.905529",
"spec_repo_commit": "aee9e14a"
"regenerated": "2023-10-04 17:33:10.804133",
"spec_repo_commit": "adf28ce4"
}
}
}
81 changes: 81 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9085,6 +9085,86 @@ components:
maxItems: 2
minItems: 2
type: array
PowerpackTemplateVariableContents:
description: Powerpack template variable contents.
properties:
name:
description: The name of the variable.
example: host1
type: string
prefix:
description: The tag prefix associated with the variable.
type: string
values:
description: One or many template variable values within the saved view,
which will be unioned together using `OR` if more than one is specified.
example:
- my-host
- host1
- host2
items:
description: One or more possible values of the template variable.
minLength: 1
type: string
type: array
required:
- name
- values
type: object
PowerpackTemplateVariables:
description: Powerpack template variables.
properties:
controlled_by_powerpack:
description: Template variables controlled at the powerpack level.
items:
$ref: '#/components/schemas/PowerpackTemplateVariableContents'
type: array
controlled_externally:
description: Template variables controlled by the external resource, such
as the dashboard this powerpack is on.
items:
$ref: '#/components/schemas/PowerpackTemplateVariableContents'
type: array
type: object
PowerpackWidgetDefinition:
description: The powerpack widget allows you to keep similar graphs together
on your timeboard. Each group has a custom header, can hold one to many graphs,
and is collapsible.
properties:
background_color:
description: Background color of the powerpack title.
type: string
banner_img:
description: URL of image to display as a banner for the powerpack.
type: string
powerpack_id:
description: UUID of the associated powerpack.
example: df43cf2a-6475-490d-b686-6fbc6cb9a49c
type: string
show_title:
default: true
description: Whether to show the title or not.
type: boolean
template_variables:
$ref: '#/components/schemas/PowerpackTemplateVariables'
title:
description: Title of the widget.
type: string
type:
$ref: '#/components/schemas/PowerpackWidgetDefinitionType'
required:
- type
- powerpack_id
type: object
PowerpackWidgetDefinitionType:
default: powerpack
description: Type of the powerpack widget.
enum:
- powerpack
example: powerpack
type: string
x-enum-varnames:
- POWERPACK
ProcessQueryDefinition:
description: The process query to use in the widget.
properties:
Expand Down Expand Up @@ -19975,6 +20055,7 @@ components:
- $ref: '#/components/schemas/LogStreamWidgetDefinition'
- $ref: '#/components/schemas/MonitorSummaryWidgetDefinition'
- $ref: '#/components/schemas/NoteWidgetDefinition'
- $ref: '#/components/schemas/PowerpackWidgetDefinition'
- $ref: '#/components/schemas/QueryValueWidgetDefinition'
- $ref: '#/components/schemas/RunWorkflowWidgetDefinition'
- $ref: '#/components/schemas/SLOListWidgetDefinition'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2023-09-26T21:29:30.230Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
{
"log": {
"_recordingName": "Dashboards/Create a new dashboard with powerpack widget",
"creator": {
"comment": "persister:fs",
"name": "Polly.JS",
"version": "6.0.5"
},
"entries": [
{
"_id": "8305fb3779a403a2aa69f085c06f0597",
"_order": 0,
"cache": {},
"request": {
"bodySize": 404,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 559,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"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\":\"Sample Powerpack\",\"tags\":[\"tag:sample\"],\"template_variables\":[{\"defaults\":[\"*\"],\"name\":\"sample\"}]},\"type\":\"powerpack\"}}"
},
"queryString": [],
"url": "https://api.datadoghq.com/api/v2/powerpacks"
},
"response": {
"bodySize": 698,
"content": {
"mimeType": "application/json",
"size": 698,
"text": "{\"data\":{\"type\":\"powerpack\",\"id\":\"c71559ce-5cb3-11ee-9164-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\":8492163139927418}]},\"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\"}}]}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 652,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2023-09-26T21:29:30.244Z",
"time": 221
},
{
"_id": "d8ab64132eff60527bbe0ca82fcf0d6c",
"_order": 0,
"cache": {},
"request": {
"bodySize": 475,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 558,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"description\":\"description\",\"is_read_only\":false,\"layout_type\":\"ordered\",\"title\":\"Test-Create_a_new_dashboard_with_powerpack_widget-1695763770 with powerpack widget\",\"widgets\":[{\"definition\":{\"powerpack_id\":\"c71559ce-5cb3-11ee-9164-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}}]}"
},
"queryString": [],
"url": "https://api.datadoghq.com/api/v1/dashboard"
},
"response": {
"bodySize": 845,
"content": {
"mimeType": "application/json",
"size": 845,
"text": "{\"id\":\"qk3-bn8-9pa\",\"title\":\"Test-Create_a_new_dashboard_with_powerpack_widget-1695763770 with powerpack widget\",\"description\":\"description\",\"author_handle\":\"frog@datadoghq.com\",\"author_name\":null,\"layout_type\":\"ordered\",\"url\":\"/dashboard/qk3-bn8-9pa/test-createanewdashboardwithpowerpackwidget-1695763770-with-powerpack-widget\",\"is_read_only\":false,\"template_variables\":null,\"widgets\":[{\"definition\":{\"powerpack_id\":\"c71559ce-5cb3-11ee-9164-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\":5618921727592736}],\"notify_list\":null,\"created_at\":\"2023-09-26T21:29:30.677263+00:00\",\"modified_at\":\"2023-09-26T21:29:30.677263+00:00\",\"restricted_roles\":[]}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 517,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2023-09-26T21:29:30.475Z",
"time": 282
},
{
"_id": "665b2997a64faf9f478024ce79a28eef",
"_order": 0,
"cache": {},
"request": {
"bodySize": 0,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
}
],
"headersSize": 519,
"httpVersion": "HTTP/1.1",
"method": "DELETE",
"queryString": [],
"url": "https://api.datadoghq.com/api/v1/dashboard/qk3-bn8-9pa"
},
"response": {
"bodySize": 39,
"content": {
"mimeType": "application/json",
"size": 39,
"text": "{\"deleted_dashboard_id\":\"qk3-bn8-9pa\"}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 516,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2023-09-26T21:29:30.766Z",
"time": 236
},
{
"_id": "d8baa7c8cbe4b53a57847782abf4c72e",
"_order": 0,
"cache": {},
"request": {
"bodySize": 0,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "*/*"
}
],
"headersSize": 532,
"httpVersion": "HTTP/1.1",
"method": "DELETE",
"queryString": [],
"url": "https://api.datadoghq.com/api/v2/powerpacks/c71559ce-5cb3-11ee-9164-da7ad0900002"
},
"response": {
"bodySize": 0,
"content": {
"mimeType": "text/html; charset=utf-8",
"size": 0
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "text/html; charset=utf-8"
}
],
"headersSize": 639,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 204,
"statusText": "No Content"
},
"startedDateTime": "2023-09-26T21:29:31.006Z",
"time": 223
}
],
"pages": [],
"version": "1.2"
}
}
54 changes: 54 additions & 0 deletions examples/v1/dashboards/CreateDashboard_1754992756.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Create a new dashboard with powerpack widget
*/

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DashboardsApi(configuration);

// there is a valid "powerpack" in the system
const POWERPACK_DATA_ID = process.env.POWERPACK_DATA_ID as string;

const params: v1.DashboardsApiCreateDashboardRequest = {
body: {
title: "Example-Dashboard with powerpack widget",
layoutType: "ordered",
widgets: [
{
definition: {
type: "powerpack",
powerpackId: POWERPACK_DATA_ID,
templateVariables: {
controlledExternally: [],
controlledByPowerpack: [
{
name: "foo",
prefix: "bar",
values: ["baz", "qux", "quuz"],
},
],
},
},
layout: {
x: 1,
y: 1,
width: 2,
height: 2,
isColumnBreak: false,
},
},
],
description: "description",
isReadOnly: false,
},
};

apiInstance
.createDashboard(params)
.then((data: v1.Dashboard) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
10 changes: 10 additions & 0 deletions features/v1/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,16 @@ Feature: Dashboards
And the response "widgets[0].definition.type" is equal to "note"
And the response "widgets[0].definition.content" is equal to "# Example Note"

@team:DataDog/dashboards-backend
Scenario: Create a new dashboard with powerpack widget
Given new "CreateDashboard" request
And there is a valid "powerpack" in the system
And body from file "dashboards_json_payload/powerpack_widget.json"
When the request is sent
Then the response status is 200 OK
And the response "widgets[0].definition.type" is equal to "powerpack"
And the response "widgets[0].definition.powerpack_id" has the same value as "powerpack.data.id"

@team:DataDog/dashboards-backend
Scenario: Create a new dashboard with query_table widget
Given new "CreateDashboard" request
Expand Down
Loading