위젯 업데이트
https://api.datadoghq.com/api/v2/widgets/{experience_type}/{uuid}https://api.us3.datadoghq.com/api/v2/widgets/{experience_type}/{uuid}https://api.us5.datadoghq.com/api/v2/widgets/{experience_type}/{uuid}https://api.datadoghq.eu/api/v2/widgets/{experience_type}/{uuid}https://api.ap1.datadoghq.com/api/v2/widgets/{experience_type}/{uuid}https://api.ap2.datadoghq.com/api/v2/widgets/{experience_type}/{uuid}https://api.uk1.datadoghq.com/api/v2/widgets/{experience_type}/{uuid}https://api.ddog-gov.com/api/v2/widgets/{experience_type}/{uuid}https://api.us2.ddog-gov.com/api/v2/widgets/{experience_type}/{uuid}개요
지정된 경험 유형에 대해 UUID로 위젯을 업데이트합니다. 이는 위젯 정의를 완전히 교체합니다.
인수
경로 파라미터
experience_type [required]The experience type for the widget.
ccm_reports, logs_reports, csv_reports, product_analyticsuuid [required]The UUID of the widget.
요청
Body Data (required)
위젯 요청 본문입니다. definition 객체의 필수 필드는
widget.definition.type에 따라 달라집니다. 작업된 전체 페이로드는 위의 CreateWidget을
참조하세요. 업데이트는 위젯 정의를 완전히 교체하는 것입니다.
data [required]위젯을 생성하거나 업데이트하기 위한 요청 본문입니다.
attributes [required]Attributes for creating or updating a widget.
definition [required]The definition of a widget, including its type and configuration.
title [required]The display title of the widget.
type [required]Widget types that are allowed to be stored as individual records. This is not a complete list of dashboard and notebook widget types.
bar_chart, change, cloud_cost_summary, cohort, funnel, geomap, list_stream, query_table, query_value, retention_curveShow 5 more
sankey, sunburst, timeseries, toplist, treemaptagsUser-defined tags for organizing the widget.
type [required]Widgets resource type.
{
"data": {
"attributes": {
"definition": {
"title": "My Widget",
"type": "bar_chart"
},
"tags": []
},
"type": "widgets"
}
}응답
OK
Response containing a single widget.
data [required]A widget resource object.
attributes [required]Attributes of a widget resource.
created_at [required]ISO 8601 timestamp of when the widget was created.
definition [required]The definition of a widget, including its type and configuration.
title [required]The display title of the widget.
type [required]Widget types that are allowed to be stored as individual records. This is not a complete list of dashboard and notebook widget types.
bar_chart, change, cloud_cost_summary, cohort, funnel, geomap, list_stream, query_table, query_value, retention_curveShow 5 more
sankey, sunburst, timeseries, toplist, treemapis_favorited [required]Whether the current user has favorited this widget. Populated on get,
batch_get, update, and search responses; create responses always return
false because a widget can only be favorited after it exists.
Favoriting itself is performed through the shared favorites API, not
this service.
modified_at [required]ISO 8601 timestamp of when the widget was last modified.
tags [required]User-defined tags for organizing widgets.
id [required]The unique identifier of the widget.
relationshipsRelationships of the widget resource.
created_byThe user who created the widget.
dataRelationship data referencing a user resource.
id [required]The unique identifier of the user.
type [required]Users resource type.
modified_byThe user who last modified the widget.
dataRelationship data referencing a user resource.
id [required]The unique identifier of the user.
type [required]Users resource type.
type [required]Widgets resource type.
includedArray of user resources related to the widget.
attributesAttributes of an included user resource.
handleThe email handle of the user.
nameThe display name of the user.
id [required]The unique identifier of the user.
type [required]Users resource type.
{
"data": {
"attributes": {
"created_at": "2024-01-15T00:00:00.000Z",
"definition": {
"title": "My Widget",
"type": "bar_chart"
},
"is_favorited": false,
"modified_at": "2024-01-15T00:00:00.000Z",
"tags": [
"team:my-team"
]
},
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"relationships": {
"created_by": {
"data": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "users"
}
},
"modified_by": {
"data": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "users"
}
}
},
"type": "widgets"
},
"included": [
{
"attributes": {
"handle": "john.doe@example.com",
"name": "John Doe"
},
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "users"
}
]
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Forbidden
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}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"
]
}코드 예시
# Path parameters
export experience_type="ccm_reports"
export uuid="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 PUT "https://api.${DD_SITE}/api/v2/widgets/${experience_type}/${uuid}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"graph_options": [
{
"type": "query_value",
"view": "total"
},
{
"type": "query_value",
"view": "change"
},
{
"display_type": "bars",
"type": "timeseries"
},
{
"type": "cloud_cost_table",
"view": "summary"
}
],
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"queries": [
{
"data_source": "cloud_cost",
"name": "query1",
"query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
}
],
"response_format": "timeseries"
}
],
"time": {
"type": "live",
"unit": "day",
"value": 30
},
"title": "AWS spend by service (last 30 days)",
"type": "cloud_cost_summary"
},
"tags": [
"finops",
"aws"
]
},
"type": "widgets"
}
}
EOF# Path parameters
export experience_type="ccm_reports"
export uuid="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 PUT "https://api.${DD_SITE}/api/v2/widgets/${experience_type}/${uuid}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"graph_options": [
{
"type": "query_value",
"view": "total"
},
{
"type": "query_value",
"view": "change"
},
{
"display_type": "bars",
"type": "timeseries"
},
{
"type": "cloud_cost_table",
"view": "summary"
}
],
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"queries": [
{
"data_source": "cloud_cost",
"name": "query1",
"query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
}
],
"response_format": "timeseries"
}
],
"time": {
"type": "live",
"unit": "day",
"value": 30
},
"title": "AWS spend by service (last 30 days)",
"type": "cloud_cost_summary"
},
"tags": [
"finops",
"aws"
]
},
"type": "widgets"
}
}
EOF# Path parameters
export experience_type="ccm_reports"
export uuid="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 PUT "https://api.${DD_SITE}/api/v2/widgets/${experience_type}/${uuid}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"graph_options": [
{
"type": "query_value",
"view": "total"
},
{
"type": "query_value",
"view": "change"
},
{
"display_type": "bars",
"type": "timeseries"
},
{
"type": "cloud_cost_table",
"view": "summary"
}
],
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"queries": [
{
"data_source": "cloud_cost",
"name": "query1",
"query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
}
],
"response_format": "timeseries"
}
],
"time": {
"type": "live",
"unit": "day",
"value": 30
},
"title": "AWS spend by service (last 30 days)",
"type": "cloud_cost_summary"
},
"tags": [
"finops",
"aws"
]
},
"type": "widgets"
}
}
EOF# Path parameters
export experience_type="ccm_reports"
export uuid="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 PUT "https://api.${DD_SITE}/api/v2/widgets/${experience_type}/${uuid}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"graph_options": [
{
"type": "query_value",
"view": "total"
},
{
"type": "query_value",
"view": "change"
},
{
"display_type": "bars",
"type": "timeseries"
},
{
"type": "cloud_cost_table",
"view": "summary"
}
],
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"queries": [
{
"data_source": "cloud_cost",
"name": "query1",
"query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
}
],
"response_format": "timeseries"
}
],
"time": {
"type": "live",
"unit": "day",
"value": 30
},
"title": "AWS spend by service (last 30 days)",
"type": "cloud_cost_summary"
},
"tags": [
"finops",
"aws"
]
},
"type": "widgets"
}
}
EOF# Path parameters
export experience_type="ccm_reports"
export uuid="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 PUT "https://api.${DD_SITE}/api/v2/widgets/${experience_type}/${uuid}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"graph_options": [
{
"type": "query_value",
"view": "total"
},
{
"type": "query_value",
"view": "change"
},
{
"display_type": "bars",
"type": "timeseries"
},
{
"type": "cloud_cost_table",
"view": "summary"
}
],
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"queries": [
{
"data_source": "cloud_cost",
"name": "query1",
"query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
}
],
"response_format": "timeseries"
}
],
"time": {
"type": "live",
"unit": "day",
"value": 30
},
"title": "AWS spend by service (last 30 days)",
"type": "cloud_cost_summary"
},
"tags": [
"finops",
"aws"
]
},
"type": "widgets"
}
}
EOF# Path parameters
export experience_type="ccm_reports"
export uuid="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 PUT "https://api.${DD_SITE}/api/v2/widgets/${experience_type}/${uuid}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"graph_options": [
{
"type": "query_value",
"view": "total"
},
{
"type": "query_value",
"view": "change"
},
{
"display_type": "bars",
"type": "timeseries"
},
{
"type": "cloud_cost_table",
"view": "summary"
}
],
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"queries": [
{
"data_source": "cloud_cost",
"name": "query1",
"query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
}
],
"response_format": "timeseries"
}
],
"time": {
"type": "live",
"unit": "day",
"value": 30
},
"title": "AWS spend by service (last 30 days)",
"type": "cloud_cost_summary"
},
"tags": [
"finops",
"aws"
]
},
"type": "widgets"
}
}
EOF# Path parameters
export experience_type="ccm_reports"
export uuid="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 PUT "https://api.${DD_SITE}/api/v2/widgets/${experience_type}/${uuid}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"graph_options": [
{
"type": "query_value",
"view": "total"
},
{
"type": "query_value",
"view": "change"
},
{
"display_type": "bars",
"type": "timeseries"
},
{
"type": "cloud_cost_table",
"view": "summary"
}
],
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"queries": [
{
"data_source": "cloud_cost",
"name": "query1",
"query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
}
],
"response_format": "timeseries"
}
],
"time": {
"type": "live",
"unit": "day",
"value": 30
},
"title": "AWS spend by service (last 30 days)",
"type": "cloud_cost_summary"
},
"tags": [
"finops",
"aws"
]
},
"type": "widgets"
}
}
EOF# Path parameters
export experience_type="ccm_reports"
export uuid="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 PUT "https://api.${DD_SITE}/api/v2/widgets/${experience_type}/${uuid}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"graph_options": [
{
"type": "query_value",
"view": "total"
},
{
"type": "query_value",
"view": "change"
},
{
"display_type": "bars",
"type": "timeseries"
},
{
"type": "cloud_cost_table",
"view": "summary"
}
],
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"queries": [
{
"data_source": "cloud_cost",
"name": "query1",
"query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
}
],
"response_format": "timeseries"
}
],
"time": {
"type": "live",
"unit": "day",
"value": 30
},
"title": "AWS spend by service (last 30 days)",
"type": "cloud_cost_summary"
},
"tags": [
"finops",
"aws"
]
},
"type": "widgets"
}
}
EOF# Path parameters
export experience_type="ccm_reports"
export uuid="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 PUT "https://api.${DD_SITE}/api/v2/widgets/${experience_type}/${uuid}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"definition": {
"graph_options": [
{
"type": "query_value",
"view": "total"
},
{
"type": "query_value",
"view": "change"
},
{
"display_type": "bars",
"type": "timeseries"
},
{
"type": "cloud_cost_table",
"view": "summary"
}
],
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"queries": [
{
"data_source": "cloud_cost",
"name": "query1",
"query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
}
],
"response_format": "timeseries"
}
],
"time": {
"type": "live",
"unit": "day",
"value": 30
},
"title": "AWS spend by service (last 30 days)",
"type": "cloud_cost_summary"
},
"tags": [
"finops",
"aws"
]
},
"type": "widgets"
}
}
EOF// Update a widget 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"
"github.com/google/uuid"
)
func main() {
body := datadogV2.CreateOrUpdateWidgetRequest{
Data: datadogV2.CreateOrUpdateWidgetRequestData{
Attributes: datadogV2.CreateOrUpdateWidgetRequestAttributes{
Definition: datadogV2.WidgetDefinition{
Title: "My Widget",
Type: datadogV2.WIDGETTYPE_BAR_CHART,
},
Tags: *datadog.NewNullableList(&[]string{}),
},
Type: "widgets",
},
}
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.NewWidgetsApi(apiClient)
resp, r, err := api.UpdateWidget(ctx, datadogV2.WIDGETEXPERIENCETYPE_CCM_REPORTS, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `WidgetsApi.UpdateWidget`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `WidgetsApi.UpdateWidget`:\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 widget returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.WidgetsApi;
import com.datadog.api.client.v2.model.CreateOrUpdateWidgetRequest;
import com.datadog.api.client.v2.model.CreateOrUpdateWidgetRequestAttributes;
import com.datadog.api.client.v2.model.CreateOrUpdateWidgetRequestData;
import com.datadog.api.client.v2.model.WidgetDefinition;
import com.datadog.api.client.v2.model.WidgetExperienceType;
import com.datadog.api.client.v2.model.WidgetResponse;
import com.datadog.api.client.v2.model.WidgetType;
import java.util.UUID;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
WidgetsApi apiInstance = new WidgetsApi(defaultClient);
CreateOrUpdateWidgetRequest body =
new CreateOrUpdateWidgetRequest()
.data(
new CreateOrUpdateWidgetRequestData()
.attributes(
new CreateOrUpdateWidgetRequestAttributes()
.definition(
new WidgetDefinition()
.title("My Widget")
.type(WidgetType.BAR_CHART)))
.type("widgets"));
try {
WidgetResponse result =
apiInstance.updateWidget(
WidgetExperienceType.CCM_REPORTS,
UUID.fromString("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"),
body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling WidgetsApi#updateWidget");
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 widget returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.widgets_api import WidgetsApi
from datadog_api_client.v2.model.create_or_update_widget_request import CreateOrUpdateWidgetRequest
from datadog_api_client.v2.model.create_or_update_widget_request_attributes import CreateOrUpdateWidgetRequestAttributes
from datadog_api_client.v2.model.create_or_update_widget_request_data import CreateOrUpdateWidgetRequestData
from datadog_api_client.v2.model.widget_definition import WidgetDefinition
from datadog_api_client.v2.model.widget_experience_type import WidgetExperienceType
from datadog_api_client.v2.model.widget_type import WidgetType
from uuid import UUID
body = CreateOrUpdateWidgetRequest(
data=CreateOrUpdateWidgetRequestData(
attributes=CreateOrUpdateWidgetRequestAttributes(
definition=WidgetDefinition(
title="My Widget",
type=WidgetType.BAR_CHART,
),
tags=[],
),
type="widgets",
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = WidgetsApi(api_client)
response = api_instance.update_widget(
experience_type=WidgetExperienceType.CCM_REPORTS, uuid=UUID("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), 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 widget returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::WidgetsAPI.new
body = DatadogAPIClient::V2::CreateOrUpdateWidgetRequest.new({
data: DatadogAPIClient::V2::CreateOrUpdateWidgetRequestData.new({
attributes: DatadogAPIClient::V2::CreateOrUpdateWidgetRequestAttributes.new({
definition: DatadogAPIClient::V2::WidgetDefinition.new({
title: "My Widget",
type: DatadogAPIClient::V2::WidgetType::BAR_CHART,
}),
tags: [],
}),
type: "widgets",
}),
})
p api_instance.update_widget(WidgetExperienceType::CCM_REPORTS, "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", 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 widget returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_widgets::WidgetsAPI;
use datadog_api_client::datadogV2::model::CreateOrUpdateWidgetRequest;
use datadog_api_client::datadogV2::model::CreateOrUpdateWidgetRequestAttributes;
use datadog_api_client::datadogV2::model::CreateOrUpdateWidgetRequestData;
use datadog_api_client::datadogV2::model::WidgetDefinition;
use datadog_api_client::datadogV2::model::WidgetExperienceType;
use datadog_api_client::datadogV2::model::WidgetType;
use uuid::Uuid;
#[tokio::main]
async fn main() {
let body = CreateOrUpdateWidgetRequest::new(CreateOrUpdateWidgetRequestData::new(
CreateOrUpdateWidgetRequestAttributes::new(WidgetDefinition::new(
"My Widget".to_string(),
WidgetType::BAR_CHART,
))
.tags(Some(vec![])),
"widgets".to_string(),
));
let configuration = datadog::Configuration::new();
let api = WidgetsAPI::with_config(configuration);
let resp = api
.update_widget(
WidgetExperienceType::CCM_REPORTS,
Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"),
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 widget 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.WidgetsApi(configuration);
const params: v2.WidgetsApiUpdateWidgetRequest = {
body: {
data: {
attributes: {
definition: {
title: "My Widget",
type: "bar_chart",
},
tags: [],
},
type: "widgets",
},
},
experienceType: "ccm_reports",
uuid: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
};
apiInstance
.updateWidget(params)
.then((data: v2.WidgetResponse) => {
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"