Print a report
https://api.datadoghq.com/api/v2/reporting/printhttps://api.us3.datadoghq.com/api/v2/reporting/printhttps://api.us5.datadoghq.com/api/v2/reporting/printhttps://api.datadoghq.eu/api/v2/reporting/printhttps://api.ap1.datadoghq.com/api/v2/reporting/printhttps://api.ap2.datadoghq.com/api/v2/reporting/printhttps://api.uk1.datadoghq.com/api/v2/reporting/printhttps://api.ddog-gov.com/api/v2/reporting/printhttps://api.us2.ddog-gov.com/api/v2/reporting/print概要
Initiate a one-off, print-only report for a dashboard or integration dashboard. The report is rendered as a PDF and made available for download through the URL returned in the response. Requires a reporting permission appropriate to the targeted resource type.
リクエスト
Body Data (required)
data [required]The JSON:API data object for a print report request.
attributes [required]The configuration for a print-only report. Specify exactly one of timeframe (for a
relative time window) or both from_ts and to_ts (for an absolute time range).
from_tsThe start of an absolute time range, as a Unix timestamp in milliseconds.
Required when timeframe is omitted.
resource_id [required]The identifier of the dashboard or integration dashboard to render.
resource_type [required]The type of dashboard resource the report schedule targets.
dashboard, integration_dashboardtemplate_variables [required]The dashboard template variables applied when rendering the report.
name [required]The name of the template variable.
values [required]The selected values for the template variable.
timeframeA relative time window (for example 1w or calendar_month). Mutually
exclusive with from_ts and to_ts.
timezone [required]The IANA time zone identifier used to evaluate the time window.
to_tsThe end of an absolute time range, as a Unix timestamp in milliseconds.
Required when timeframe is omitted.
type [required]JSON:API resource type for a print-only report.
report{
"data": {
"attributes": {
"from_ts": 1780318800000,
"resource_id": "abc-def-ghi",
"resource_type": "dashboard",
"template_variables": [
{
"name": "env",
"values": [
"prod"
]
}
],
"timeframe": "1w",
"timezone": "America/New_York",
"to_ts": 1780923600000
},
"type": "report"
}
}応答
OK
Response containing the initiated print-only report.
data [required]The JSON:API data object for a print-only report.
attributes [required]The configuration and download URL for the initiated print-only report.
download_url [required]The URL from which the rendered PDF report can be downloaded.
from_ts [required]The start of the rendered time range, as a Unix timestamp in milliseconds.
resource_id [required]The identifier of the dashboard or integration dashboard.
resource_type [required]The type of dashboard resource the report schedule targets.
dashboard, integration_dashboardtemplate_variables [required]The dashboard template variables applied when rendering the report.
name [required]The name of the template variable.
values [required]The selected values for the template variable.
timeframeThe relative time window used, if one was specified in the request.
timezone [required]The IANA time zone identifier used when rendering the report.
to_ts [required]The end of the rendered time range, as a Unix timestamp in milliseconds.
id [required]The unique identifier of the report.
type [required]JSON:API resource type for a print-only report.
report{
"data": {
"attributes": {
"download_url": "https://app.datadoghq.com/...",
"from_ts": 1780318800000,
"resource_id": "abc-def-ghi",
"resource_type": "dashboard",
"template_variables": [
{
"name": "env",
"values": [
"prod"
]
}
],
"timeframe": "1w",
"timezone": "America/New_York",
"to_ts": 1780923600000
},
"id": "11111111-2222-3333-4444-555555555555",
"type": "report"
}
}Bad Request
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Forbidden
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Not Found
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Unprocessable Entity
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}コード例
# 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 POST "https://api.${DD_SITE}/api/v2/reporting/print" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"resource_id": "abc-def-ghi",
"resource_type": "dashboard",
"template_variables": [
{
"name": "env",
"values": [
"prod"
]
}
],
"timeframe": "1w",
"timezone": "America/New_York"
},
"type": "report"
}
}
EOF# 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 POST "https://api.${DD_SITE}/api/v2/reporting/print" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"resource_id": "abc-def-ghi",
"resource_type": "dashboard",
"template_variables": [
{
"name": "env",
"values": [
"prod"
]
}
],
"timeframe": "1w",
"timezone": "America/New_York"
},
"type": "report"
}
}
EOF# 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 POST "https://api.${DD_SITE}/api/v2/reporting/print" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"resource_id": "abc-def-ghi",
"resource_type": "dashboard",
"template_variables": [
{
"name": "env",
"values": [
"prod"
]
}
],
"timeframe": "1w",
"timezone": "America/New_York"
},
"type": "report"
}
}
EOF# 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 POST "https://api.${DD_SITE}/api/v2/reporting/print" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"resource_id": "abc-def-ghi",
"resource_type": "dashboard",
"template_variables": [
{
"name": "env",
"values": [
"prod"
]
}
],
"timeframe": "1w",
"timezone": "America/New_York"
},
"type": "report"
}
}
EOF# 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 POST "https://api.${DD_SITE}/api/v2/reporting/print" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"resource_id": "abc-def-ghi",
"resource_type": "dashboard",
"template_variables": [
{
"name": "env",
"values": [
"prod"
]
}
],
"timeframe": "1w",
"timezone": "America/New_York"
},
"type": "report"
}
}
EOF# 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 POST "https://api.${DD_SITE}/api/v2/reporting/print" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"resource_id": "abc-def-ghi",
"resource_type": "dashboard",
"template_variables": [
{
"name": "env",
"values": [
"prod"
]
}
],
"timeframe": "1w",
"timezone": "America/New_York"
},
"type": "report"
}
}
EOF# 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 POST "https://api.${DD_SITE}/api/v2/reporting/print" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"resource_id": "abc-def-ghi",
"resource_type": "dashboard",
"template_variables": [
{
"name": "env",
"values": [
"prod"
]
}
],
"timeframe": "1w",
"timezone": "America/New_York"
},
"type": "report"
}
}
EOF# 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 POST "https://api.${DD_SITE}/api/v2/reporting/print" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"resource_id": "abc-def-ghi",
"resource_type": "dashboard",
"template_variables": [
{
"name": "env",
"values": [
"prod"
]
}
],
"timeframe": "1w",
"timezone": "America/New_York"
},
"type": "report"
}
}
EOF# 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 POST "https://api.${DD_SITE}/api/v2/reporting/print" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"resource_id": "abc-def-ghi",
"resource_type": "dashboard",
"template_variables": [
{
"name": "env",
"values": [
"prod"
]
}
],
"timeframe": "1w",
"timezone": "America/New_York"
},
"type": "report"
}
}
EOF// Print a report 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() {
body := datadogV2.PrintReportRequest{
Data: datadogV2.PrintReportRequestData{
Attributes: datadogV2.PrintReportRequestAttributes{
FromTs: datadog.PtrInt64(1780318800000),
ResourceId: "abc-def-ghi",
ResourceType: datadogV2.REPORTSCHEDULERESOURCETYPE_DASHBOARD,
TemplateVariables: []datadogV2.ReportScheduleTemplateVariable{
{
Name: "env",
Values: []string{
"prod",
},
},
},
Timeframe: datadog.PtrString("1w"),
Timezone: "America/New_York",
ToTs: datadog.PtrInt64(1780923600000),
},
Type: datadogV2.PRINTREPORTTYPE_REPORT,
},
}
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.NewReportSchedulesApi(apiClient)
resp, r, err := api.PrintReport(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ReportSchedulesApi.PrintReport`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ReportSchedulesApi.PrintReport`:\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"// Print a report returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ReportSchedulesApi;
import com.datadog.api.client.v2.model.PrintReportRequest;
import com.datadog.api.client.v2.model.PrintReportRequestAttributes;
import com.datadog.api.client.v2.model.PrintReportRequestData;
import com.datadog.api.client.v2.model.PrintReportResponse;
import com.datadog.api.client.v2.model.PrintReportType;
import com.datadog.api.client.v2.model.ReportScheduleResourceType;
import com.datadog.api.client.v2.model.ReportScheduleTemplateVariable;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
ReportSchedulesApi apiInstance = new ReportSchedulesApi(defaultClient);
PrintReportRequest body =
new PrintReportRequest()
.data(
new PrintReportRequestData()
.attributes(
new PrintReportRequestAttributes()
.fromTs(1780318800000L)
.resourceId("abc-def-ghi")
.resourceType(ReportScheduleResourceType.DASHBOARD)
.templateVariables(
Collections.singletonList(
new ReportScheduleTemplateVariable()
.name("env")
.values(Collections.singletonList("prod"))))
.timeframe("1w")
.timezone("America/New_York")
.toTs(1780923600000L))
.type(PrintReportType.REPORT));
try {
PrintReportResponse result = apiInstance.printReport(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ReportSchedulesApi#printReport");
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""""
Print a report returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.report_schedules_api import ReportSchedulesApi
from datadog_api_client.v2.model.print_report_request import PrintReportRequest
from datadog_api_client.v2.model.print_report_request_attributes import PrintReportRequestAttributes
from datadog_api_client.v2.model.print_report_request_data import PrintReportRequestData
from datadog_api_client.v2.model.print_report_type import PrintReportType
from datadog_api_client.v2.model.report_schedule_resource_type import ReportScheduleResourceType
from datadog_api_client.v2.model.report_schedule_template_variable import ReportScheduleTemplateVariable
body = PrintReportRequest(
data=PrintReportRequestData(
attributes=PrintReportRequestAttributes(
from_ts=1780318800000,
resource_id="abc-def-ghi",
resource_type=ReportScheduleResourceType.DASHBOARD,
template_variables=[
ReportScheduleTemplateVariable(
name="env",
values=[
"prod",
],
),
],
timeframe="1w",
timezone="America/New_York",
to_ts=1780923600000,
),
type=PrintReportType.REPORT,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = ReportSchedulesApi(api_client)
response = api_instance.print_report(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"# Print a report returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::ReportSchedulesAPI.new
body = DatadogAPIClient::V2::PrintReportRequest.new({
data: DatadogAPIClient::V2::PrintReportRequestData.new({
attributes: DatadogAPIClient::V2::PrintReportRequestAttributes.new({
from_ts: 1780318800000,
resource_id: "abc-def-ghi",
resource_type: DatadogAPIClient::V2::ReportScheduleResourceType::DASHBOARD,
template_variables: [
DatadogAPIClient::V2::ReportScheduleTemplateVariable.new({
name: "env",
values: [
"prod",
],
}),
],
timeframe: "1w",
timezone: "America/New_York",
to_ts: 1780923600000,
}),
type: DatadogAPIClient::V2::PrintReportType::REPORT,
}),
})
p api_instance.print_report(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"// Print a report returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_report_schedules::ReportSchedulesAPI;
use datadog_api_client::datadogV2::model::PrintReportRequest;
use datadog_api_client::datadogV2::model::PrintReportRequestAttributes;
use datadog_api_client::datadogV2::model::PrintReportRequestData;
use datadog_api_client::datadogV2::model::PrintReportType;
use datadog_api_client::datadogV2::model::ReportScheduleResourceType;
use datadog_api_client::datadogV2::model::ReportScheduleTemplateVariable;
#[tokio::main]
async fn main() {
let body = PrintReportRequest::new(PrintReportRequestData::new(
PrintReportRequestAttributes::new(
"abc-def-ghi".to_string(),
ReportScheduleResourceType::DASHBOARD,
vec![ReportScheduleTemplateVariable::new(
"env".to_string(),
vec!["prod".to_string()],
)],
"America/New_York".to_string(),
)
.from_ts(1780318800000)
.timeframe("1w".to_string())
.to_ts(1780923600000),
PrintReportType::REPORT,
));
let configuration = datadog::Configuration::new();
let api = ReportSchedulesAPI::with_config(configuration);
let resp = api.print_report(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="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Print a report 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.ReportSchedulesApi(configuration);
const params: v2.ReportSchedulesApiPrintReportRequest = {
body: {
data: {
attributes: {
fromTs: 1780318800000,
resourceId: "abc-def-ghi",
resourceType: "dashboard",
templateVariables: [
{
name: "env",
values: ["prod"],
},
],
timeframe: "1w",
timezone: "America/New_York",
toTs: 1780923600000,
},
type: "report",
},
},
};
apiInstance
.printReport(params)
.then((data: v2.PrintReportResponse) => {
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"