Actualizar un powerpack
https://api.datadoghq.com/api/v2/powerpacks/{powerpack_id}https://api.us3.datadoghq.com/api/v2/powerpacks/{powerpack_id}https://api.us5.datadoghq.com/api/v2/powerpacks/{powerpack_id}https://api.datadoghq.eu/api/v2/powerpacks/{powerpack_id}https://api.ap1.datadoghq.com/api/v2/powerpacks/{powerpack_id}https://api.ap2.datadoghq.com/api/v2/powerpacks/{powerpack_id}https://api.uk1.datadoghq.com/api/v2/powerpacks/{powerpack_id}https://api.ddog-gov.com/api/v2/powerpacks/{powerpack_id}https://api.us2.ddog-gov.com/api/v2/powerpacks/{powerpack_id}Descripción general
Actualiza un powerpack.
OAuth apps require the dashboards_write authorization scope to access this endpoint.
Argumentos
Parámetros de ruta
powerpack_id [required]ID of the powerpack.
Solicitud
Body Data (required)
Actualiza el cuerpo de una solicitud de powerpack.
dataLos powerpacks son grupos de plantillas de widgets de dashboard que puedes guardar de un dashboard existente y convertir en paquetes reutilizables en la bandeja de widget.
attributesPowerpack attribute object.
descriptionDescription of this powerpack.
group_widget [required]Powerpack group widget definition object.
definition [required]Powerpack group widget object.
layout_type [required]Layout type of widgets.
show_titleBoolean indicating whether powerpack group title should be visible or not.
titleName for the group widget.
type [required]Type of widget, must be group.
widgets [required]Widgets inside the powerpack.
definition [required]Information about widget.
layoutPowerpack inner widget layout.
height [required]The height of the widget. Should be a non-negative integer.
width [required]The width of the widget. Should be a non-negative integer.
x [required]The position of the widget on the x (horizontal) axis. Should be a non-negative integer.
y [required]The position of the widget on the y (vertical) axis. Should be a non-negative integer.
layoutPowerpack group widget layout.
height [required]The height of the widget. Should be a non-negative integer.
width [required]The width of the widget. Should be a non-negative integer.
x [required]The position of the widget on the x (horizontal) axis. Should be a non-negative integer.
y [required]The position of the widget on the y (vertical) axis. Should be a non-negative integer.
live_spanThe available timeframes depend on the widget you are using.
1m, 5m, 10m, 15m, 30m, 1h, 4h, 1d, 2d, 1wShow 5 more
1mo, 3mo, 6mo, 1y, alertname [required]Name of the powerpack.
tagsList of tags to identify this powerpack.
template_variablesList of template variables for this powerpack.
available_valuesThe list of values that the template variable drop-down is limited to.
defaultsOne or many template variable default values within the saved view, which are unioned together using OR if more than one is specified.
name [required]The name of the variable.
prefixThe tag prefix associated with the variable. Only tags with this prefix appear in the variable drop-down.
idID of the powerpack.
relationshipsPowerpack relationship object.
authorRelationship to user.
data [required]Relationship to user object.
id [required]A unique identifier that represents the user.
type [required]Users resource type.
usersuserstypeType of widget, must be powerpack.
{
"data": {
"attributes": {
"description": "Powerpack for ABC",
"group_widget": {
"definition": {
"layout_type": "ordered",
"show_title": true,
"title": "Sample Powerpack",
"type": "group",
"widgets": [
{
"definition": {
"content": "example",
"type": "note"
},
"layout": {
"height": 5,
"width": 10,
"x": 0,
"y": 0
}
}
]
},
"layout": {
"height": 0,
"width": 0,
"x": 0,
"y": 0
},
"live_span": "5m"
},
"name": "Sample Powerpack",
"tags": [
"tag:foo1"
],
"template_variables": [
{
"defaults": [
"*"
],
"name": "test"
}
]
},
"relationships": {
"author": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
}
},
"type": "powerpack"
}
}Respuesta
OK
Response object which includes a single powerpack configuration.
dataPowerpack data object.
attributesPowerpack attribute object.
descriptionDescription of this powerpack.
group_widget [required]Powerpack group widget definition object.
definition [required]Powerpack group widget object.
layout_type [required]Layout type of widgets.
show_titleBoolean indicating whether powerpack group title should be visible or not.
titleName for the group widget.
type [required]Type of widget, must be group.
widgets [required]Widgets inside the powerpack.
definition [required]Information about widget.
layoutPowerpack inner widget layout.
height [required]The height of the widget. Should be a non-negative integer.
width [required]The width of the widget. Should be a non-negative integer.
x [required]The position of the widget on the x (horizontal) axis. Should be a non-negative integer.
y [required]The position of the widget on the y (vertical) axis. Should be a non-negative integer.
layoutPowerpack group widget layout.
height [required]The height of the widget. Should be a non-negative integer.
width [required]The width of the widget. Should be a non-negative integer.
x [required]The position of the widget on the x (horizontal) axis. Should be a non-negative integer.
y [required]The position of the widget on the y (vertical) axis. Should be a non-negative integer.
live_spanThe available timeframes depend on the widget you are using.
1m, 5m, 10m, 15m, 30m, 1h, 4h, 1d, 2d, 1wShow 5 more
1mo, 3mo, 6mo, 1y, alertname [required]Name of the powerpack.
tagsList of tags to identify this powerpack.
template_variablesList of template variables for this powerpack.
available_valuesThe list of values that the template variable drop-down is limited to.
defaultsOne or many template variable default values within the saved view, which are unioned together using OR if more than one is specified.
name [required]The name of the variable.
prefixThe tag prefix associated with the variable. Only tags with this prefix appear in the variable drop-down.
idID of the powerpack.
relationshipsPowerpack relationship object.
authorRelationship to user.
data [required]Relationship to user object.
id [required]A unique identifier that represents the user.
type [required]Users resource type.
usersuserstypeType of widget, must be powerpack.
includedArray of objects related to the users.
attributesAttributes of user object returned by the API.
created_atThe ISO 8601 timestamp of when the user account was created.
disabledWhether the user account is deactivated. Disabled users cannot log in.
emailThe email address of the user, used for login and notifications.
handleThe unique handle (username) of the user, typically matching their email prefix.
iconURL of the user's profile icon, typically a Gravatar URL derived from the email address.
last_login_timeThe ISO 8601 timestamp of the user's most recent login, or null if the user has never logged in.
mfa_enabledWhether multi-factor authentication (MFA) is enabled for the user's account.
modified_atThe ISO 8601 timestamp of when the user account was last modified.
nameThe full display name of the user as shown in the Datadog UI.
service_accountWhether this is a service account rather than a human user. Service accounts are used for programmatic API access.
statusThe current status of the user account (for example, Active, Pending, or Disabled).
titleThe job title of the user (for example, "Senior Engineer" or "Product Manager").
uuidThe globally unique identifier (UUID) of the user.
verifiedWhether the user's email address has been verified.
idID of the user.
relationshipsRelationships of the user object returned by the API.
orgRelationship to an organization.
data [required]Relationship to organization object.
id [required]ID of the organization.
type [required]Organizations resource type.
orgsorgsother_orgsRelationship to organizations.
data [required]Relationships to organization objects.
id [required]ID of the organization.
type [required]Organizations resource type.
orgsorgsother_usersRelationship to users.
data [required]Relationships to user objects.
id [required]A unique identifier that represents the user.
type [required]Users resource type.
usersusersrolesRelationship to roles.
dataAn array containing type and the unique identifier of a role.
idThe unique identifier of the role.
typeRoles type.
rolesrolestypeUsers resource type.
usersusers{
"data": {
"attributes": {
"description": "Powerpack for ABC",
"group_widget": {
"definition": {
"layout_type": "ordered",
"show_title": true,
"title": "Sample Powerpack",
"type": "group",
"widgets": [
{
"definition": {
"definition": {
"content": "example",
"type": "note"
}
},
"layout": {
"height": 0,
"width": 0,
"x": 0,
"y": 0
}
}
]
},
"layout": {
"height": 0,
"width": 0,
"x": 0,
"y": 0
},
"live_span": "5m"
},
"name": "Sample Powerpack",
"tags": [
"tag:foo1"
],
"template_variables": [
{
"available_values": [
"my-host",
"host1",
"host2"
],
"defaults": [
"*"
],
"name": "datacenter",
"prefix": "host"
}
]
},
"id": "string",
"relationships": {
"author": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
}
},
"type": "powerpack"
},
"included": [
{
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"disabled": false,
"email": "string",
"handle": "string",
"icon": "string",
"last_login_time": "2019-09-19T10:00:00.000Z",
"mfa_enabled": false,
"modified_at": "2019-09-19T10:00:00.000Z",
"name": "string",
"service_account": false,
"status": "string",
"title": "string",
"uuid": "string",
"verified": false
},
"id": "string",
"relationships": {
"org": {
"data": {
"id": "00000000-0000-beef-0000-000000000000",
"type": "orgs"
}
},
"other_orgs": {
"data": [
{
"id": "00000000-0000-beef-0000-000000000000",
"type": "orgs"
}
]
},
"other_users": {
"data": [
{
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
]
},
"roles": {
"data": [
{
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"type": "roles"
}
]
}
},
"type": "users"
}
]
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Powerpack Not Found
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Ejemplo de código
# Path parameters
export powerpack_id="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/powerpacks/${powerpack_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Powerpack for ABC",
"group_widget": {
"definition": {
"layout_type": "ordered",
"show_title": true,
"title": "Sample Powerpack",
"type": "group",
"widgets": [
{
"definition": {
"content": "example",
"type": "note"
},
"layout": {
"height": 5,
"width": 10,
"x": 0,
"y": 0
}
}
]
},
"layout": {
"height": 0,
"width": 0,
"x": 0,
"y": 0
},
"live_span": "5m"
},
"name": "Sample Powerpack",
"tags": [
"tag:foo1"
],
"template_variables": [
{
"defaults": [
"*"
],
"name": "test"
}
]
},
"relationships": {
"author": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
}
},
"type": "powerpack"
}
}
EOF# Path parameters
export powerpack_id="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/powerpacks/${powerpack_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Powerpack for ABC",
"group_widget": {
"definition": {
"layout_type": "ordered",
"show_title": true,
"title": "Sample Powerpack",
"type": "group",
"widgets": [
{
"definition": {
"content": "example",
"type": "note"
},
"layout": {
"height": 5,
"width": 10,
"x": 0,
"y": 0
}
}
]
},
"layout": {
"height": 0,
"width": 0,
"x": 0,
"y": 0
},
"live_span": "5m"
},
"name": "Sample Powerpack",
"tags": [
"tag:foo1"
],
"template_variables": [
{
"defaults": [
"*"
],
"name": "test"
}
]
},
"relationships": {
"author": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
}
},
"type": "powerpack"
}
}
EOF# Path parameters
export powerpack_id="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/powerpacks/${powerpack_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Powerpack for ABC",
"group_widget": {
"definition": {
"layout_type": "ordered",
"show_title": true,
"title": "Sample Powerpack",
"type": "group",
"widgets": [
{
"definition": {
"content": "example",
"type": "note"
},
"layout": {
"height": 5,
"width": 10,
"x": 0,
"y": 0
}
}
]
},
"layout": {
"height": 0,
"width": 0,
"x": 0,
"y": 0
},
"live_span": "5m"
},
"name": "Sample Powerpack",
"tags": [
"tag:foo1"
],
"template_variables": [
{
"defaults": [
"*"
],
"name": "test"
}
]
},
"relationships": {
"author": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
}
},
"type": "powerpack"
}
}
EOF# Path parameters
export powerpack_id="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/powerpacks/${powerpack_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Powerpack for ABC",
"group_widget": {
"definition": {
"layout_type": "ordered",
"show_title": true,
"title": "Sample Powerpack",
"type": "group",
"widgets": [
{
"definition": {
"content": "example",
"type": "note"
},
"layout": {
"height": 5,
"width": 10,
"x": 0,
"y": 0
}
}
]
},
"layout": {
"height": 0,
"width": 0,
"x": 0,
"y": 0
},
"live_span": "5m"
},
"name": "Sample Powerpack",
"tags": [
"tag:foo1"
],
"template_variables": [
{
"defaults": [
"*"
],
"name": "test"
}
]
},
"relationships": {
"author": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
}
},
"type": "powerpack"
}
}
EOF# Path parameters
export powerpack_id="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/powerpacks/${powerpack_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Powerpack for ABC",
"group_widget": {
"definition": {
"layout_type": "ordered",
"show_title": true,
"title": "Sample Powerpack",
"type": "group",
"widgets": [
{
"definition": {
"content": "example",
"type": "note"
},
"layout": {
"height": 5,
"width": 10,
"x": 0,
"y": 0
}
}
]
},
"layout": {
"height": 0,
"width": 0,
"x": 0,
"y": 0
},
"live_span": "5m"
},
"name": "Sample Powerpack",
"tags": [
"tag:foo1"
],
"template_variables": [
{
"defaults": [
"*"
],
"name": "test"
}
]
},
"relationships": {
"author": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
}
},
"type": "powerpack"
}
}
EOF# Path parameters
export powerpack_id="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/powerpacks/${powerpack_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Powerpack for ABC",
"group_widget": {
"definition": {
"layout_type": "ordered",
"show_title": true,
"title": "Sample Powerpack",
"type": "group",
"widgets": [
{
"definition": {
"content": "example",
"type": "note"
},
"layout": {
"height": 5,
"width": 10,
"x": 0,
"y": 0
}
}
]
},
"layout": {
"height": 0,
"width": 0,
"x": 0,
"y": 0
},
"live_span": "5m"
},
"name": "Sample Powerpack",
"tags": [
"tag:foo1"
],
"template_variables": [
{
"defaults": [
"*"
],
"name": "test"
}
]
},
"relationships": {
"author": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
}
},
"type": "powerpack"
}
}
EOF# Path parameters
export powerpack_id="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/powerpacks/${powerpack_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Powerpack for ABC",
"group_widget": {
"definition": {
"layout_type": "ordered",
"show_title": true,
"title": "Sample Powerpack",
"type": "group",
"widgets": [
{
"definition": {
"content": "example",
"type": "note"
},
"layout": {
"height": 5,
"width": 10,
"x": 0,
"y": 0
}
}
]
},
"layout": {
"height": 0,
"width": 0,
"x": 0,
"y": 0
},
"live_span": "5m"
},
"name": "Sample Powerpack",
"tags": [
"tag:foo1"
],
"template_variables": [
{
"defaults": [
"*"
],
"name": "test"
}
]
},
"relationships": {
"author": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
}
},
"type": "powerpack"
}
}
EOF# Path parameters
export powerpack_id="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/powerpacks/${powerpack_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Powerpack for ABC",
"group_widget": {
"definition": {
"layout_type": "ordered",
"show_title": true,
"title": "Sample Powerpack",
"type": "group",
"widgets": [
{
"definition": {
"content": "example",
"type": "note"
},
"layout": {
"height": 5,
"width": 10,
"x": 0,
"y": 0
}
}
]
},
"layout": {
"height": 0,
"width": 0,
"x": 0,
"y": 0
},
"live_span": "5m"
},
"name": "Sample Powerpack",
"tags": [
"tag:foo1"
],
"template_variables": [
{
"defaults": [
"*"
],
"name": "test"
}
]
},
"relationships": {
"author": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
}
},
"type": "powerpack"
}
}
EOF# Path parameters
export powerpack_id="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/powerpacks/${powerpack_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Powerpack for ABC",
"group_widget": {
"definition": {
"layout_type": "ordered",
"show_title": true,
"title": "Sample Powerpack",
"type": "group",
"widgets": [
{
"definition": {
"content": "example",
"type": "note"
},
"layout": {
"height": 5,
"width": 10,
"x": 0,
"y": 0
}
}
]
},
"layout": {
"height": 0,
"width": 0,
"x": 0,
"y": 0
},
"live_span": "5m"
},
"name": "Sample Powerpack",
"tags": [
"tag:foo1"
],
"template_variables": [
{
"defaults": [
"*"
],
"name": "test"
}
]
},
"relationships": {
"author": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
}
},
"type": "powerpack"
}
}
EOF// Update a powerpack 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/datadogV2"
)
func main() {
// there is a valid "powerpack" in the system
PowerpackDataID := os.Getenv("POWERPACK_DATA_ID")
body := datadogV2.Powerpack{
Data: &datadogV2.PowerpackData{
Attributes: &datadogV2.PowerpackAttributes{
Description: datadog.PtrString("Sample powerpack"),
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,
},
LiveSpan: datadogV2.WIDGETLIVESPAN_PAST_ONE_HOUR.Ptr(),
},
Name: "Example-Powerpack",
Tags: []string{
"tag:sample",
},
TemplateVariables: []datadogV2.PowerpackTemplateVariable{
{
Defaults: []string{
"*",
},
Name: "sample",
},
},
},
Type: datadog.PtrString("powerpack"),
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewPowerpackApi(apiClient)
resp, r, err := api.UpdatePowerpack(ctx, PowerpackDataID, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `PowerpackApi.UpdatePowerpack`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `PowerpackApi.UpdatePowerpack`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Update a powerpack returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.PowerpackApi;
import com.datadog.api.client.v2.model.Powerpack;
import com.datadog.api.client.v2.model.PowerpackAttributes;
import com.datadog.api.client.v2.model.PowerpackData;
import com.datadog.api.client.v2.model.PowerpackGroupWidget;
import com.datadog.api.client.v2.model.PowerpackGroupWidgetDefinition;
import com.datadog.api.client.v2.model.PowerpackGroupWidgetLayout;
import com.datadog.api.client.v2.model.PowerpackInnerWidgets;
import com.datadog.api.client.v2.model.PowerpackResponse;
import com.datadog.api.client.v2.model.PowerpackTemplateVariable;
import com.datadog.api.client.v2.model.WidgetLiveSpan;
import java.util.Collections;
import java.util.Map;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
PowerpackApi apiInstance = new PowerpackApi(defaultClient);
// there is a valid "powerpack" in the system
String POWERPACK_DATA_ID = System.getenv("POWERPACK_DATA_ID");
Powerpack body =
new Powerpack()
.data(
new PowerpackData()
.attributes(
new PowerpackAttributes()
.description("Sample powerpack")
.groupWidget(
new PowerpackGroupWidget()
.definition(
new PowerpackGroupWidgetDefinition()
.layoutType("ordered")
.showTitle(true)
.title("Sample Powerpack")
.type("group")
.widgets(
Collections.singletonList(
new PowerpackInnerWidgets()
.definition(
Map.ofEntries(
Map.entry("content", "test"),
Map.entry("type", "note"))))))
.layout(
new PowerpackGroupWidgetLayout()
.height(3L)
.width(12L)
.x(0L)
.y(0L))
.liveSpan(WidgetLiveSpan.PAST_ONE_HOUR))
.name("Example-Powerpack")
.tags(Collections.singletonList("tag:sample"))
.templateVariables(
Collections.singletonList(
new PowerpackTemplateVariable()
.defaults(Collections.singletonList("*"))
.name("sample"))))
.type("powerpack"));
try {
PowerpackResponse result = apiInstance.updatePowerpack(POWERPACK_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PowerpackApi#updatePowerpack");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Update a powerpack returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.powerpack_api import PowerpackApi
from datadog_api_client.v2.model.powerpack import Powerpack
from datadog_api_client.v2.model.powerpack_attributes import PowerpackAttributes
from datadog_api_client.v2.model.powerpack_data import PowerpackData
from datadog_api_client.v2.model.powerpack_group_widget import PowerpackGroupWidget
from datadog_api_client.v2.model.powerpack_group_widget_definition import PowerpackGroupWidgetDefinition
from datadog_api_client.v2.model.powerpack_group_widget_layout import PowerpackGroupWidgetLayout
from datadog_api_client.v2.model.powerpack_inner_widgets import PowerpackInnerWidgets
from datadog_api_client.v2.model.powerpack_template_variable import PowerpackTemplateVariable
from datadog_api_client.v2.model.widget_live_span import WidgetLiveSpan
# there is a valid "powerpack" in the system
POWERPACK_DATA_ID = environ["POWERPACK_DATA_ID"]
body = Powerpack(
data=PowerpackData(
attributes=PowerpackAttributes(
description="Sample powerpack",
group_widget=PowerpackGroupWidget(
definition=PowerpackGroupWidgetDefinition(
layout_type="ordered",
show_title=True,
title="Sample Powerpack",
type="group",
widgets=[
PowerpackInnerWidgets(
definition=dict([("content", "test"), ("type", "note")]),
),
],
),
layout=PowerpackGroupWidgetLayout(
height=3,
width=12,
x=0,
y=0,
),
live_span=WidgetLiveSpan.PAST_ONE_HOUR,
),
name="Example-Powerpack",
tags=[
"tag:sample",
],
template_variables=[
PowerpackTemplateVariable(
defaults=[
"*",
],
name="sample",
),
],
),
type="powerpack",
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = PowerpackApi(api_client)
response = api_instance.update_powerpack(powerpack_id=POWERPACK_DATA_ID, body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Update a powerpack returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::PowerpackAPI.new
# there is a valid "powerpack" in the system
POWERPACK_DATA_ID = ENV["POWERPACK_DATA_ID"]
body = DatadogAPIClient::V2::Powerpack.new({
data: DatadogAPIClient::V2::PowerpackData.new({
attributes: DatadogAPIClient::V2::PowerpackAttributes.new({
description: "Sample powerpack",
group_widget: DatadogAPIClient::V2::PowerpackGroupWidget.new({
definition: DatadogAPIClient::V2::PowerpackGroupWidgetDefinition.new({
layout_type: "ordered",
show_title: true,
title: "Sample Powerpack",
type: "group",
widgets: [
DatadogAPIClient::V2::PowerpackInnerWidgets.new({
definition: {
"content": "test", "type": "note",
},
}),
],
}),
layout: DatadogAPIClient::V2::PowerpackGroupWidgetLayout.new({
height: 3,
width: 12,
x: 0,
y: 0,
}),
live_span: DatadogAPIClient::V2::WidgetLiveSpan::PAST_ONE_HOUR,
}),
name: "Example-Powerpack",
tags: [
"tag:sample",
],
template_variables: [
DatadogAPIClient::V2::PowerpackTemplateVariable.new({
defaults: [
"*",
],
name: "sample",
}),
],
}),
type: "powerpack",
}),
})
p api_instance.update_powerpack(POWERPACK_DATA_ID, body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Update a powerpack returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_powerpack::PowerpackAPI;
use datadog_api_client::datadogV2::model::Powerpack;
use datadog_api_client::datadogV2::model::PowerpackAttributes;
use datadog_api_client::datadogV2::model::PowerpackData;
use datadog_api_client::datadogV2::model::PowerpackGroupWidget;
use datadog_api_client::datadogV2::model::PowerpackGroupWidgetDefinition;
use datadog_api_client::datadogV2::model::PowerpackGroupWidgetLayout;
use datadog_api_client::datadogV2::model::PowerpackInnerWidgets;
use datadog_api_client::datadogV2::model::PowerpackTemplateVariable;
use datadog_api_client::datadogV2::model::WidgetLiveSpan;
use serde_json::Value;
use std::collections::BTreeMap;
#[tokio::main]
async fn main() {
// there is a valid "powerpack" in the system
let powerpack_data_id = std::env::var("POWERPACK_DATA_ID").unwrap();
let body = Powerpack::new().data(
PowerpackData::new()
.attributes(
PowerpackAttributes::new(
PowerpackGroupWidget::new(
PowerpackGroupWidgetDefinition::new(
"ordered".to_string(),
"group".to_string(),
vec![PowerpackInnerWidgets::new(BTreeMap::from([
("content".to_string(), Value::from("test")),
("type".to_string(), Value::from("note")),
]))],
)
.show_title(true)
.title("Sample Powerpack".to_string()),
)
.layout(PowerpackGroupWidgetLayout::new(3, 12, 0, 0))
.live_span(WidgetLiveSpan::PAST_ONE_HOUR),
"Example-Powerpack".to_string(),
)
.description("Sample powerpack".to_string())
.tags(vec!["tag:sample".to_string()])
.template_variables(vec![PowerpackTemplateVariable::new("sample".to_string())
.defaults(vec!["*".to_string()])]),
)
.type_("powerpack".to_string()),
);
let configuration = datadog::Configuration::new();
let api = PowerpackAPI::with_config(configuration);
let resp = api.update_powerpack(powerpack_data_id.clone(), body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Update a powerpack returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.PowerpackApi(configuration);
// there is a valid "powerpack" in the system
const POWERPACK_DATA_ID = process.env.POWERPACK_DATA_ID as string;
const params: v2.PowerpackApiUpdatePowerpackRequest = {
body: {
data: {
attributes: {
description: "Sample powerpack",
groupWidget: {
definition: {
layoutType: "ordered",
showTitle: true,
title: "Sample Powerpack",
type: "group",
widgets: [
{
definition: {
content: "test",
type: "note",
},
},
],
},
layout: {
height: 3,
width: 12,
x: 0,
y: 0,
},
liveSpan: "1h",
},
name: "Example-Powerpack",
tags: ["tag:sample"],
templateVariables: [
{
defaults: ["*"],
name: "sample",
},
],
},
type: "powerpack",
},
},
powerpackId: POWERPACK_DATA_ID,
};
apiInstance
.updatePowerpack(params)
.then((data: v2.PowerpackResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"