Synthetics

Synthetics

Datadog Synthetics は、シミュレートされたユーザーリクエストとブラウザレンダリングを使用して、アップタイムを確保し、地域の問題を特定し、アプリケーションのパフォーマンスを追跡します。Datadog Synthetics テストには、API テストブラウザテストの 2 つの異なる種類があります。Datadog の API を使用して、両方のテストタイプをプログラムで管理できます。

Synthetics の詳細については、Synthetics の概要を参照してください。

POST https://api.datadoghq.eu/api/v1/synthetics/tests/browserhttps://api.ddog-gov.com/api/v1/synthetics/tests/browserhttps://api.datadoghq.com/api/v1/synthetics/tests/browserhttps://api.us3.datadoghq.com/api/v1/synthetics/tests/browser

概要

Synthetic ブラウザテストを作成します。

リクエスト

Body Data (required)

作成するテストの詳細。

Expand All

フィールド

種類

説明

config

object

Configuration object for a Synthetic browser test.

assertions [required]

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

object

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator [required]

string

The specific operator to use on the path.

targetValue

object

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test steps.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,javascript,text

locations

[string]

Array of locations used to run the test.

message [required]

string

Notification message associated with the test. Message can either be text or an empty string.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism. Currently only available for Chrome.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The public ID of the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

The steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

int64

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementAttribute,assertElementContent,assertElementPresent,assertEmail,assertFileDownload,assertFromJavascript,assertPageContains,assertPageLacks,click,extractFromJavascript,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,runApiTest,scroll,selectOption,typeText,uploadFiles,wait

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, browser. Allowed enum values: browser

{
  "config": {
    "assertions": [
      {
        "operator": "string",
        "property": "string",
        "target": {},
        "type": "string"
      }
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "noSavingResponseBody": false,
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "string"
      }
    ]
  },
  "locations": [],
  "message": "",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "integer",
      "type": "string"
    }
  ],
  "tags": [],
  "type": "browser"
}

応答

OK - Returns the created test details.

Object containing details about a Synthetic browser test.

Expand All

フィールド

種類

説明

config

object

Configuration object for a Synthetic browser test.

assertions [required]

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

object

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator [required]

string

The specific operator to use on the path.

targetValue

object

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test steps.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,javascript,text

locations

[string]

Array of locations used to run the test.

message [required]

string

Notification message associated with the test. Message can either be text or an empty string.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism. Currently only available for Chrome.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The public ID of the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

The steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

int64

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementAttribute,assertElementContent,assertElementPresent,assertEmail,assertFileDownload,assertFromJavascript,assertPageContains,assertPageLacks,click,extractFromJavascript,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,runApiTest,scroll,selectOption,typeText,uploadFiles,wait

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, browser. Allowed enum values: browser

{
  "config": {
    "assertions": [
      {
        "operator": "string",
        "property": "string",
        "target": {},
        "type": "string"
      }
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "noSavingResponseBody": false,
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "string"
      }
    ]
  },
  "locations": [],
  "message": "",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "integer",
      "type": "string"
    }
  ],
  "tags": [],
  "type": "browser"
}

- JSON format is wrong - Creation failed

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Test quota is reached

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com/api/v1/synthetics/tests/browser" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {}
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      }
    },
    "variables": [
      {
        "name": "VARIABLE_NAME",
        "type": null
      }
    ]
  },
  "message": ""
}
EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    body := *datadog.NewSyntheticsBrowserTest("Message_example") // SyntheticsBrowserTest | Details of the test to create.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.CreateSyntheticsBrowserTest(ctx).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateSyntheticsBrowserTest``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateSyntheticsBrowserTest`: SyntheticsBrowserTest
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.CreateSyntheticsBrowserTest:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Import classes:
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsBrowserTest body = new SyntheticsBrowserTest(); // SyntheticsBrowserTest | Details of the test to create.
        try {
            SyntheticsBrowserTest result = apiInstance.createSyntheticsBrowserTest(body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#createSyntheticsBrowserTest");
            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:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    body = SyntheticsBrowserTest(
        config=SyntheticsBrowserTestConfig(
            assertions=[
                SyntheticsAssertion(),
            ],
            request=SyntheticsTestRequest(
                basic_auth=SyntheticsBasicAuth(
                    password="",
                    username="",
                ),
                body="body_example",
                certificate=SyntheticsTestRequestCertificate(
                    cert=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                    key=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                ),
                dns_server="dns_server_example",
                headers=SyntheticsTestHeaders(
                    key="key_example",
                ),
                host="host_example",
                method=HTTPMethod("GET"),
                no_saving_response_body=True,
                port=1,
                query={},
                timeout=3.14,
                url="url_example",
            ),
            variables=[
                SyntheticsBrowserVariable(
                    example="example_example",
                    id="id_example",
                    name="VARIABLE_NAME",
                    pattern="pattern_example",
                    type=SyntheticsBrowserVariableType("element"),
                ),
            ],
        ),
        locations=[
            "locations_example",
        ],
        message="",
        monitor_id=1,
        name="name_example",
        options=SyntheticsTestOptions(
            accept_self_signed=True,
            allow_insecure=True,
            device_ids=[
                SyntheticsDeviceID("laptop_large"),
            ],
            disable_cors=True,
            follow_redirects=True,
            min_failure_duration=1,
            min_location_failed=1,
            monitor_options=SyntheticsTestOptionsMonitorOptions(
                renotify_interval=0,
            ),
            no_screenshot=True,
            retry=SyntheticsTestOptionsRetry(
                count=1,
                interval=3.14,
            ),
            tick_every=SyntheticsTickInterval(60),
        ),
        public_id="public_id_example",
        status=SyntheticsTestPauseStatus("live"),
        steps=[
            SyntheticsStep(
                allow_failure=True,
                name="name_example",
                params={},
                timeout=1,
                type=SyntheticsStepType("assertCurrentUrl"),
            ),
        ],
        tags=[
            "tags_example",
        ],
        type=SyntheticsBrowserTestType("browser"),
    )  # SyntheticsBrowserTest | Details of the test to create.

    # example passing only required values which don't have defaults set
    try:
        # Create a browser test
        api_response = api_instance.create_synthetics_browser_test(body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->create_synthetics_browser_test: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
body = DatadogAPIClient::V1::SyntheticsBrowserTest.new({message: 'message_example'}) # SyntheticsBrowserTest | Details of the test to create.

begin
  # Create a browser test
  result = api_instance.create_synthetics_browser_test(body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->create_synthetics_browser_test: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"

POST https://api.datadoghq.eu/api/v1/synthetics/variableshttps://api.ddog-gov.com/api/v1/synthetics/variableshttps://api.datadoghq.com/api/v1/synthetics/variableshttps://api.us3.datadoghq.com/api/v1/synthetics/variables

概要

Synthetic グローバル変数を作成します。

リクエスト

Body Data (required)

作成するグローバル変数の詳細。

Expand All

フィールド

種類

説明

description [required]

string

Description of the global variable.

id

string

Unique identifier of the global variable.

name [required]

string

Name of the global variable.

parse_test_options

object

Parser options to use for retrieving a Synthetics global variable from a Synthetics Test. Used in conjunction with parse_test_public_id.

field

string

When type is http_header, name of the header to use to extract the value.

parser [required]

object

Details of the parser to use for the global variable.

type [required]

enum

Type of parser for a Synthetics global variable from a synthetics test. Allowed enum values: raw,json_path,regex

value

string

Regex or JSON path used for the parser. Not used with type raw.

type [required]

enum

Property of the Synthetics Test Response to use for a Synthetics global variable. Allowed enum values: http_body,http_header

parse_test_public_id

string

A Synthetic test ID to use as a test to generate the variable value.

tags [required]

[string]

Tags of the global variable.

value [required]

object

Value of the global variable.

secure

boolean

Determines if the variable is secure.

value [required]

string

Value of the global variable. When reading a global variable, the value will not be present if the variable is secure.

{
  "description": "Example description",
  "name": "MY_VARIABLE",
  "parse_test_options": {
    "field": "content-type",
    "parser": {
      "type": "string",
      "value": "string"
    },
    "type": "string"
  },
  "parse_test_public_id": "abc-def-123",
  "tags": [
    "team:front",
    "test:workflow-1"
  ],
  "value": {
    "secure": false,
    "value": "example-value"
  }
}

応答

OK

Synthetics global variable.

Expand All

フィールド

種類

説明

description [required]

string

Description of the global variable.

id

string

Unique identifier of the global variable.

name [required]

string

Name of the global variable.

parse_test_options

object

Parser options to use for retrieving a Synthetics global variable from a Synthetics Test. Used in conjunction with parse_test_public_id.

field

string

When type is http_header, name of the header to use to extract the value.

parser [required]

object

Details of the parser to use for the global variable.

type [required]

enum

Type of parser for a Synthetics global variable from a synthetics test. Allowed enum values: raw,json_path,regex

value

string

Regex or JSON path used for the parser. Not used with type raw.

type [required]

enum

Property of the Synthetics Test Response to use for a Synthetics global variable. Allowed enum values: http_body,http_header

parse_test_public_id

string

A Synthetic test ID to use as a test to generate the variable value.

tags [required]

[string]

Tags of the global variable.

value [required]

object

Value of the global variable.

secure

boolean

Determines if the variable is secure.

value [required]

string

Value of the global variable. When reading a global variable, the value will not be present if the variable is secure.

{
  "description": "Example description",
  "id": "string",
  "name": "MY_VARIABLE",
  "parse_test_options": {
    "field": "content-type",
    "parser": {
      "type": "string",
      "value": "string"
    },
    "type": "string"
  },
  "parse_test_public_id": "abc-def-123",
  "tags": [
    "team:front",
    "test:workflow-1"
  ],
  "value": {
    "secure": false,
    "value": "example-value"
  }
}

Invalid request

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com/api/v1/synthetics/variables" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "description": "Example description",
  "name": "MY_VARIABLE",
  "parse_test_options": {
    "parser": {
      "type": null
    },
    "type": null
  },
  "tags": [
    "team:front",
    "test:workflow-1"
  ],
  "value": {
    "value": "example-value"
  }
}
EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    body := *datadog.NewSyntheticsGlobalVariable("Example description", "MY_VARIABLE", []string{"Tags_example"}, *datadog.NewSyntheticsGlobalVariableValue("example-value")) // SyntheticsGlobalVariable | Details of the global variable to create.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.CreateGlobalVariable(ctx).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateGlobalVariable``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateGlobalVariable`: SyntheticsGlobalVariable
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.CreateGlobalVariable:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Import classes:
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsGlobalVariable body = new SyntheticsGlobalVariable(); // SyntheticsGlobalVariable | Details of the global variable to create.
        try {
            SyntheticsGlobalVariable result = apiInstance.createGlobalVariable(body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#createGlobalVariable");
            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:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    body = SyntheticsGlobalVariable(
        description="Example description",
        id="id_example",
        name="MY_VARIABLE",
        parse_test_options=SyntheticsGlobalVariableParseTestOptions(
            field="content-type",
            parser=SyntheticsVariableParser(
                type=SyntheticsGlobalVariableParserType("raw"),
                value="value_example",
            ),
            type=SyntheticsGlobalVariableParseTestOptionsType("http_body"),
        ),
        parse_test_public_id="abc-def-123",
        tags=["team:front","test:workflow-1"],
        value=SyntheticsGlobalVariableValue(
            secure=True,
            value="example-value",
        ),
    )  # SyntheticsGlobalVariable | Details of the global variable to create.

    # example passing only required values which don't have defaults set
    try:
        # Create a global variable
        api_response = api_instance.create_global_variable(body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->create_global_variable: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
body = DatadogAPIClient::V1::SyntheticsGlobalVariable.new({description: 'Example description', name: 'MY_VARIABLE', tags: ['tags_example'], value: DatadogAPIClient::V1::SyntheticsGlobalVariableValue.new({value: 'example-value'})}) # SyntheticsGlobalVariable | Details of the global variable to create.

begin
  # Create a global variable
  result = api_instance.create_global_variable(body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->create_global_variable: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"

POST https://api.datadoghq.eu/api/v1/synthetics/private-locationshttps://api.ddog-gov.com/api/v1/synthetics/private-locationshttps://api.datadoghq.com/api/v1/synthetics/private-locationshttps://api.us3.datadoghq.com/api/v1/synthetics/private-locations

概要

新しい Synthetics プライベートロケーションを作成します。

リクエスト

Body Data (required)

作成するプライベートロケーションの詳細。

Expand All

フィールド

種類

説明

description [required]

string

Description of the private location.

id

string

Unique identifier of the private location.

name [required]

string

Name of the private location.

secrets

object

Secrets for the private location. Only present in the response when creating the private location.

authentication

object

Authentication part of the secrets.

id

string

Access key for the private location.

key

string

Secret access key for the private location.

config_decryption

object

Private key for the private location.

key

string

Private key for the private location.

tags [required]

[string]

Array of tags attached to the private location.

{
  "description": "Description of private location",
  "name": "New private location",
  "tags": [
    "team:front"
  ]
}

応答

OK

Object that contains the new private location, the public key for result encryption, and the configuration skeleton.

Expand All

フィールド

種類

説明

config

object

Configuration skeleton for the private location. See installation instructions of the private location on how to use this configuration.

private_location

object

Object containing information about the private location to create.

description [required]

string

Description of the private location.

id

string

Unique identifier of the private location.

name [required]

string

Name of the private location.

secrets

object

Secrets for the private location. Only present in the response when creating the private location.

authentication

object

Authentication part of the secrets.

id

string

Access key for the private location.

key

string

Secret access key for the private location.

config_decryption

object

Private key for the private location.

key

string

Private key for the private location.

tags [required]

[string]

Array of tags attached to the private location.

result_encryption

object

Public key for the result encryption.

id

string

Fingerprint for the encryption key.

key

string

Public key for result encryption.

{
  "config": {},
  "private_location": {
    "description": "Description of private location",
    "id": "string",
    "name": "New private location",
    "secrets": {
      "authentication": {
        "id": "string",
        "key": "string"
      },
      "config_decryption": {
        "key": "string"
      }
    },
    "tags": [
      "team:front"
    ]
  },
  "result_encryption": {
    "id": "string",
    "key": "string"
  }
}

Quota reached for private locations

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Private locations are not activated for the user

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com/api/v1/synthetics/private-locations" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "description": "Description of private location",
  "name": "New private location",
  "tags": [
    "team:front"
  ]
}
EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    body := *datadog.NewSyntheticsPrivateLocation("Description of private location", "New private location", []string{"team:front"}) // SyntheticsPrivateLocation | Details of the private location to create.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.CreatePrivateLocation(ctx).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreatePrivateLocation``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreatePrivateLocation`: SyntheticsPrivateLocationCreationResponse
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.CreatePrivateLocation:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Import classes:
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsPrivateLocation body = new SyntheticsPrivateLocation(); // SyntheticsPrivateLocation | Details of the private location to create.
        try {
            SyntheticsPrivateLocationCreationResponse result = apiInstance.createPrivateLocation(body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#createPrivateLocation");
            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:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    body = SyntheticsPrivateLocation(
        description="Description of private location",
        id="id_example",
        name="New private location",
        secrets=SyntheticsPrivateLocationSecrets(
            authentication=SyntheticsPrivateLocationSecretsAuthentication(
                id="id_example",
                key="key_example",
            ),
            config_decryption=SyntheticsPrivateLocationSecretsConfigDecryption(
                key="key_example",
            ),
        ),
        tags=["team:front"],
    )  # SyntheticsPrivateLocation | Details of the private location to create.

    # example passing only required values which don't have defaults set
    try:
        # Create a private location
        api_response = api_instance.create_private_location(body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->create_private_location: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
body = DatadogAPIClient::V1::SyntheticsPrivateLocation.new({description: 'Description of private location', name: 'New private location', tags: ['team:front']}) # SyntheticsPrivateLocation | Details of the private location to create.

begin
  # Create a private location
  result = api_instance.create_private_location(body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->create_private_location: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"

POST https://api.datadoghq.eu/api/v1/synthetics/testshttps://api.ddog-gov.com/api/v1/synthetics/testshttps://api.datadoghq.com/api/v1/synthetics/testshttps://api.us3.datadoghq.com/api/v1/synthetics/tests

概要

Synthetic テストを作成します。

リクエスト

Body Data (required)

作成するテストの詳細。

Expand All

フィールド

種類

説明

config

object

Configuration object for a Synthetic test.

assertions [required]

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

object

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator [required]

string

The specific operator to use on the path.

targetValue

object

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

configVariables

[object]

API tests only - array of variables used for the test.

example [required]

string

Example for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: text

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Browser tests only - array of variables used for the test steps.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,javascript,text

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism. Currently only available for Chrome.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The test public ID.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

For browser test, the steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

int64

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementAttribute,assertElementContent,assertElementPresent,assertEmail,assertFileDownload,assertFromJavascript,assertPageContains,assertPageLacks,click,extractFromJavascript,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,runApiTest,scroll,selectOption,typeText,uploadFiles,wait

subtype

enum

The subtype of the Synthetic API test, http, ssl, tcp, dns or multi. Allowed enum values: http,ssl,tcp,dns,multi

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, either api or browser. Allowed enum values: api,browser

{
  "config": {
    "assertions": [
      {
        "operator": "string",
        "property": "string",
        "target": {},
        "type": "string"
      }
    ],
    "configVariables": [
      {
        "example": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "string"
      }
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "noSavingResponseBody": false,
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "string"
      }
    ]
  },
  "locations": [],
  "message": "string",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "integer",
      "type": "string"
    }
  ],
  "subtype": "string",
  "tags": [],
  "type": "string"
}

応答

OK - Returns the created test details.

Object containing details about your Synthetic test.

Expand All

フィールド

種類

説明

config

object

Configuration object for a Synthetic test.

assertions [required]

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

object

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator [required]

string

The specific operator to use on the path.

targetValue

object

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

configVariables

[object]

API tests only - array of variables used for the test.

example [required]

string

Example for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: text

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Browser tests only - array of variables used for the test steps.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,javascript,text

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism. Currently only available for Chrome.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The test public ID.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

For browser test, the steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

int64

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementAttribute,assertElementContent,assertElementPresent,assertEmail,assertFileDownload,assertFromJavascript,assertPageContains,assertPageLacks,click,extractFromJavascript,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,runApiTest,scroll,selectOption,typeText,uploadFiles,wait

subtype

enum

The subtype of the Synthetic API test, http, ssl, tcp, dns or multi. Allowed enum values: http,ssl,tcp,dns,multi

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, either api or browser. Allowed enum values: api,browser

{
  "config": {
    "assertions": [
      {
        "operator": "string",
        "property": "string",
        "target": {},
        "type": "string"
      }
    ],
    "configVariables": [
      {
        "example": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "string"
      }
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "noSavingResponseBody": false,
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "string"
      }
    ]
  },
  "locations": [],
  "message": "string",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "integer",
      "type": "string"
    }
  ],
  "subtype": "string",
  "tags": [],
  "type": "string"
}

- JSON format is wrong - Creation failed

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Test quota is reached

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com/api/v1/synthetics/tests" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {}
    ],
    "configVariables": [
      {
        "example": null,
        "name": "VARIABLE_NAME",
        "type": null
      }
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      }
    },
    "variables": [
      {
        "name": "VARIABLE_NAME",
        "type": null
      }
    ]
  }
}
EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    body := *datadog.NewSyntheticsTestDetails() // SyntheticsTestDetails | Details of the test to create.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.CreateTest(ctx).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateTest``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateTest`: SyntheticsTestDetails
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.CreateTest:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Import classes:
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsTestDetails body = new SyntheticsTestDetails(); // SyntheticsTestDetails | Details of the test to create.
        try {
            SyntheticsTestDetails result = apiInstance.createTest(body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#createTest");
            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:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    body = SyntheticsTestDetails(
        config=SyntheticsTestConfig(
            assertions=[
                SyntheticsAssertion(),
            ],
            config_variables=[
                SyntheticsConfigVariable(
                    example="example_example",
                    name="VARIABLE_NAME",
                    pattern="pattern_example",
                    type=SyntheticsConfigVariableType("text"),
                ),
            ],
            request=SyntheticsTestRequest(
                basic_auth=SyntheticsBasicAuth(
                    password="",
                    username="",
                ),
                body="body_example",
                certificate=SyntheticsTestRequestCertificate(
                    cert=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                    key=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                ),
                dns_server="dns_server_example",
                headers=SyntheticsTestHeaders(
                    key="key_example",
                ),
                host="host_example",
                method=HTTPMethod("GET"),
                no_saving_response_body=True,
                port=1,
                query={},
                timeout=3.14,
                url="url_example",
            ),
            variables=[
                SyntheticsBrowserVariable(
                    example="example_example",
                    id="id_example",
                    name="VARIABLE_NAME",
                    pattern="pattern_example",
                    type=SyntheticsBrowserVariableType("element"),
                ),
            ],
        ),
        locations=[
            "locations_example",
        ],
        message="message_example",
        monitor_id=1,
        name="name_example",
        options=SyntheticsTestOptions(
            accept_self_signed=True,
            allow_insecure=True,
            device_ids=[
                SyntheticsDeviceID("laptop_large"),
            ],
            disable_cors=True,
            follow_redirects=True,
            min_failure_duration=1,
            min_location_failed=1,
            monitor_options=SyntheticsTestOptionsMonitorOptions(
                renotify_interval=0,
            ),
            no_screenshot=True,
            retry=SyntheticsTestOptionsRetry(
                count=1,
                interval=3.14,
            ),
            tick_every=SyntheticsTickInterval(60),
        ),
        public_id="public_id_example",
        status=SyntheticsTestPauseStatus("live"),
        steps=[
            SyntheticsStep(
                allow_failure=True,
                name="name_example",
                params={},
                timeout=1,
                type=SyntheticsStepType("assertCurrentUrl"),
            ),
        ],
        subtype=SyntheticsTestDetailsSubType("http"),
        tags=[
            "tags_example",
        ],
        type=SyntheticsTestDetailsType("api"),
    )  # SyntheticsTestDetails | Details of the test to create.

    # example passing only required values which don't have defaults set
    try:
        # Create a test
        api_response = api_instance.create_test(body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->create_test: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
body = DatadogAPIClient::V1::SyntheticsTestDetails.new # SyntheticsTestDetails | Details of the test to create.

begin
  # Create a test
  result = api_instance.create_test(body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->create_test: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"

POST https://api.datadoghq.eu/api/v1/synthetics/tests/apihttps://api.ddog-gov.com/api/v1/synthetics/tests/apihttps://api.datadoghq.com/api/v1/synthetics/tests/apihttps://api.us3.datadoghq.com/api/v1/synthetics/tests/api

概要

Synthetic API テストを作成します。

リクエスト

Body Data (required)

作成するテストの詳細。

Expand All

フィールド

種類

説明

config

object

Configuration object for a Synthetic API test.

assertions [required]

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

object

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator [required]

string

The specific operator to use on the path.

targetValue

object

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

configVariables

[object]

Array of variables used for the test.

example [required]

string

Example for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: text

request

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

steps

[object]

When the test subtype is multi, the steps of the test.

assertions

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

object

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator [required]

string

The specific operator to use on the path.

targetValue

object

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

extractedValues

[object]

Array of values to parse and save as variables from the response.

field

string

When type is http_header, name of the header to use to extract the value.

name [required]

string

Name of the variable to extract.

parser

object

Details of the parser to use for the global variable.

type [required]

enum

Type of parser for a Synthetics global variable from a synthetics test. Allowed enum values: raw,json_path,regex

value

string

Regex or JSON path used for the parser. Not used with type raw.

type [required]

enum

Property of the Synthetics Test Response to use for a Synthetics global variable. Allowed enum values: http_body,http_header

name [required]

string

The name of the step.

request

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

subtype

enum

The subtype of the Synthetic multistep API test step, currently only supporting http. Allowed enum values: http

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism. Currently only available for Chrome.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The public ID for the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

subtype

enum

The subtype of the Synthetic API test, http, ssl, tcp, dns or multi. Allowed enum values: http,ssl,tcp,dns,multi

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, api. Allowed enum values: api

{
  "config": {
    "assertions": [
      {
        "operator": "string",
        "property": "string",
        "target": {},
        "type": "string"
      }
    ],
    "configVariables": [
      {
        "example": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "string"
      }
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "noSavingResponseBody": false,
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "steps": [
      {
        "assertions": [
          {
            "operator": "string",
            "property": "string",
            "target": {},
            "type": "string"
          }
        ],
        "extractedValues": [
          {
            "field": "content-type",
            "name": "string",
            "parser": {
              "type": "string",
              "value": "string"
            },
            "type": "string"
          }
        ],
        "name": "string",
        "request": {
          "basicAuth": {
            "password": "",
            "username": ""
          },
          "body": "string",
          "certificate": {
            "cert": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            },
            "key": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            }
          },
          "dnsServer": "string",
          "headers": {
            "<any-key>": "string"
          },
          "host": "string",
          "method": "string",
          "noSavingResponseBody": false,
          "port": "integer",
          "query": {},
          "timeout": "number",
          "url": "string"
        },
        "subtype": "string"
      }
    ]
  },
  "locations": [],
  "message": "string",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "subtype": "string",
  "tags": [],
  "type": "api"
}

応答

OK - Returns the created test details.

Object containing details about a Synthetic API test.

Expand All

フィールド

種類

説明

config

object

Configuration object for a Synthetic API test.

assertions [required]

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

object

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator [required]

string

The specific operator to use on the path.

targetValue

object

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

configVariables

[object]

Array of variables used for the test.

example [required]

string

Example for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of the configuration variable. Allowed enum values: text

request

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

steps

[object]

When the test subtype is multi, the steps of the test.

assertions

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

object

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator [required]

string

The specific operator to use on the path.

targetValue

object

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

extractedValues

[object]

Array of values to parse and save as variables from the response.

field

string

When type is http_header, name of the header to use to extract the value.

name [required]

string

Name of the variable to extract.

parser

object

Details of the parser to use for the global variable.

type [required]

enum

Type of parser for a Synthetics global variable from a synthetics test. Allowed enum values: raw,json_path,regex

value

string

Regex or JSON path used for the parser. Not used with type raw.

type [required]

enum

Property of the Synthetics Test Response to use for a Synthetics global variable. Allowed enum values: http_body,http_header

name [required]

string

The name of the step.

request

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

subtype

enum

The subtype of the Synthetic multistep API test step, currently only supporting http. Allowed enum values: http

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism. Currently only available for Chrome.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The public ID for the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

subtype

enum

The subtype of the Synthetic API test, http, ssl, tcp, dns or multi. Allowed enum values: http,ssl,tcp,dns,multi

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, api. Allowed enum values: api

{
  "config": {
    "assertions": [
      {
        "operator": "string",
        "property": "string",
        "target": {},
        "type": "string"
      }
    ],
    "configVariables": [
      {
        "example": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "string"
      }
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "noSavingResponseBody": false,
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "steps": [
      {
        "assertions": [
          {
            "operator": "string",
            "property": "string",
            "target": {},
            "type": "string"
          }
        ],
        "extractedValues": [
          {
            "field": "content-type",
            "name": "string",
            "parser": {
              "type": "string",
              "value": "string"
            },
            "type": "string"
          }
        ],
        "name": "string",
        "request": {
          "basicAuth": {
            "password": "",
            "username": ""
          },
          "body": "string",
          "certificate": {
            "cert": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            },
            "key": {
              "content": "string",
              "filename": "string",
              "updatedAt": "string"
            }
          },
          "dnsServer": "string",
          "headers": {
            "<any-key>": "string"
          },
          "host": "string",
          "method": "string",
          "noSavingResponseBody": false,
          "port": "integer",
          "query": {},
          "timeout": "number",
          "url": "string"
        },
        "subtype": "string"
      }
    ]
  },
  "locations": [],
  "message": "string",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "subtype": "string",
  "tags": [],
  "type": "api"
}

- JSON format is wrong - Creation failed

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Test quota is reached

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com/api/v1/synthetics/tests/api" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      {}
    ],
    "configVariables": [
      {
        "example": null,
        "name": "VARIABLE_NAME",
        "type": null
      }
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      }
    },
    "steps": [
      {
        "extractedValues": [
          {
            "parser": {
              "type": null
            }
          }
        ],
        "request": {
          "basicAuth": {
            "password": "",
            "username": ""
          }
        }
      }
    ]
  }
}
EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    body := *datadog.NewSyntheticsAPITest() // SyntheticsAPITest | Details of the test to create.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.CreateSyntheticsAPITest(ctx).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateSyntheticsAPITest``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateSyntheticsAPITest`: SyntheticsAPITest
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.CreateSyntheticsAPITest:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Import classes:
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsAPITest body = new SyntheticsAPITest(); // SyntheticsAPITest | Details of the test to create.
        try {
            SyntheticsAPITest result = apiInstance.createSyntheticsAPITest(body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#createSyntheticsAPITest");
            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:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    body = SyntheticsAPITest(
        config=SyntheticsAPITestConfig(
            assertions=[
                SyntheticsAssertion(),
            ],
            config_variables=[
                SyntheticsConfigVariable(
                    example="example_example",
                    name="VARIABLE_NAME",
                    pattern="pattern_example",
                    type=SyntheticsConfigVariableType("text"),
                ),
            ],
            request=SyntheticsTestRequest(
                basic_auth=SyntheticsBasicAuth(
                    password="",
                    username="",
                ),
                body="body_example",
                certificate=SyntheticsTestRequestCertificate(
                    cert=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                    key=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                ),
                dns_server="dns_server_example",
                headers=SyntheticsTestHeaders(
                    key="key_example",
                ),
                host="host_example",
                method=HTTPMethod("GET"),
                no_saving_response_body=True,
                port=1,
                query={},
                timeout=3.14,
                url="url_example",
            ),
            steps=[
                SyntheticsAPIStep(
                    assertions=[],
                    extracted_values=[
                        SyntheticsParsingOptions(
                            field="content-type",
                            name="name_example",
                            parser=SyntheticsVariableParser(
                                type=SyntheticsGlobalVariableParserType("raw"),
                                value="value_example",
                            ),
                            type=SyntheticsGlobalVariableParseTestOptionsType("http_body"),
                        ),
                    ],
                    name="name_example",
                    request=SyntheticsTestRequest(
                        basic_auth=SyntheticsBasicAuth(
                            password="",
                            username="",
                        ),
                        body="body_example",
                        certificate=SyntheticsTestRequestCertificate(
                            cert=SyntheticsTestRequestCertificateItem(
                                content="content_example",
                                filename="filename_example",
                                updated_at="updated_at_example",
                            ),
                            key=SyntheticsTestRequestCertificateItem(
                                content="content_example",
                                filename="filename_example",
                                updated_at="updated_at_example",
                            ),
                        ),
                        dns_server="dns_server_example",
                        headers=SyntheticsTestHeaders(SyntheticsTestHeaders),
                        host="host_example",
                        method=HTTPMethod("GET"),
                        no_saving_response_body=True,
                        port=1,
                        query={},
                        timeout=3.14,
                        url="url_example",
                    ),
                    subtype=SyntheticsAPIStepSubtype("http"),
                ),
            ],
        ),
        locations=[
            "locations_example",
        ],
        message="message_example",
        monitor_id=1,
        name="name_example",
        options=SyntheticsTestOptions(
            accept_self_signed=True,
            allow_insecure=True,
            device_ids=[
                SyntheticsDeviceID("laptop_large"),
            ],
            disable_cors=True,
            follow_redirects=True,
            min_failure_duration=1,
            min_location_failed=1,
            monitor_options=SyntheticsTestOptionsMonitorOptions(
                renotify_interval=0,
            ),
            no_screenshot=True,
            retry=SyntheticsTestOptionsRetry(
                count=1,
                interval=3.14,
            ),
            tick_every=SyntheticsTickInterval(60),
        ),
        public_id="public_id_example",
        status=SyntheticsTestPauseStatus("live"),
        subtype=SyntheticsTestDetailsSubType("http"),
        tags=[
            "tags_example",
        ],
        type=SyntheticsAPITestType("api"),
    )  # SyntheticsAPITest | Details of the test to create.

    # example passing only required values which don't have defaults set
    try:
        # Create an API test
        api_response = api_instance.create_synthetics_api_test(body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->create_synthetics_api_test: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
body = DatadogAPIClient::V1::SyntheticsAPITest.new # SyntheticsAPITest | Details of the test to create.

begin
  # Create an API test
  result = api_instance.create_synthetics_api_test(body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->create_synthetics_api_test: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"

DELETE https://api.datadoghq.eu/api/v1/synthetics/variables/{variable_id}https://api.ddog-gov.com/api/v1/synthetics/variables/{variable_id}https://api.datadoghq.com/api/v1/synthetics/variables/{variable_id}https://api.us3.datadoghq.com/api/v1/synthetics/variables/{variable_id}

概要

Synthetic グローバル変数を削除します。

引数

パスパラメーター

名前

種類

説明

variable_id [required]

string

The ID of the global variable.

応答

OK

JSON format is wrong

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Not found

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


# Path parameters
export variable_id="CHANGE_ME"
# Curl command curl -X DELETE "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com/api/v1/synthetics/variables/${variable_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    variableId := "variableId_example" // string | The ID of the global variable.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    r, err := apiClient.SyntheticsApi.DeleteGlobalVariable(ctx, variableId).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.DeleteGlobalVariable``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Import classes:
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String variableId = "variableId_example"; // String | The ID of the global variable.
        try {
            apiInstance.deleteGlobalVariable(variableId);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#deleteGlobalVariable");
            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:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    variable_id = "variable_id_example"  # str | The ID of the global variable.

    # example passing only required values which don't have defaults set
    try:
        # Delete a global variable
        api_instance.delete_global_variable(variable_id)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->delete_global_variable: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
variable_id = 'variable_id_example' # String | The ID of the global variable.

begin
  # Delete a global variable
  api_instance.delete_global_variable(variable_id)
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->delete_global_variable: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"

DELETE https://api.datadoghq.eu/api/v1/synthetics/private-locations/{location_id}https://api.ddog-gov.com/api/v1/synthetics/private-locations/{location_id}https://api.datadoghq.com/api/v1/synthetics/private-locations/{location_id}https://api.us3.datadoghq.com/api/v1/synthetics/private-locations/{location_id}

概要

Synthetics プライベートロケーションを削除します。

引数

パスパラメーター

名前

種類

説明

location_id [required]

string

The ID of the private location.

応答

OK

- Private locations are not activated for the user - Private location does not exist

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


# Path parameters
export location_id="CHANGE_ME"
# Curl command curl -X DELETE "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com/api/v1/synthetics/private-locations/${location_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    locationId := "locationId_example" // string | The ID of the private location.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    r, err := apiClient.SyntheticsApi.DeletePrivateLocation(ctx, locationId).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.DeletePrivateLocation``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Import classes:
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String locationId = "locationId_example"; // String | The ID of the private location.
        try {
            apiInstance.deletePrivateLocation(locationId);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#deletePrivateLocation");
            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:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    location_id = "location_id_example"  # str | The ID of the private location.

    # example passing only required values which don't have defaults set
    try:
        # Delete a private location
        api_instance.delete_private_location(location_id)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->delete_private_location: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
location_id = 'location_id_example' # String | The ID of the private location.

begin
  # Delete a private location
  api_instance.delete_private_location(location_id)
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->delete_private_location: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"

POST https://api.datadoghq.eu/api/v1/synthetics/tests/deletehttps://api.ddog-gov.com/api/v1/synthetics/tests/deletehttps://api.datadoghq.com/api/v1/synthetics/tests/deletehttps://api.us3.datadoghq.com/api/v1/synthetics/tests/delete

概要

複数の Synthetic テストを ID で削除します。

リクエスト

Body Data (required)

削除する Synthetic テストのパブリック ID リスト。

Expand All

フィールド

種類

説明

public_ids

[string]

An array of Synthetic test IDs you want to delete.

{
  "public_ids": [
    []
  ]
}

応答

OK.

Response object for deleting Synthetic tests.

Expand All

フィールド

種類

説明

deleted_tests

[object]

Array of objects containing a deleted Synthetic test ID with the associated deletion timestamp.

deleted_at

date-time

Deletion timestamp of the Synthetic test ID.

public_id

string

The Synthetic test ID deleted.

{
  "deleted_tests": [
    {
      "deleted_at": "2019-09-19T10:00:00.000Z",
      "public_id": "string"
    }
  ]
}

- JSON format is wrong - Test cannot be deleted as it's used elsewhere (as a sub-test or in an uptime widget) - Some IDs are not owned by the user

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

- Tests to be deleted can't be found - Synthetics is not activated for the user

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com/api/v1/synthetics/tests/delete" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{}
EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    body := *datadog.NewSyntheticsDeleteTestsPayload() // SyntheticsDeleteTestsPayload | Public ID list of the Synthetic tests to be deleted.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.DeleteTests(ctx).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.DeleteTests``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `DeleteTests`: SyntheticsDeleteTestsResponse
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.DeleteTests:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Import classes:
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsDeleteTestsPayload body = new SyntheticsDeleteTestsPayload(); // SyntheticsDeleteTestsPayload | Public ID list of the Synthetic tests to be deleted.
        try {
            SyntheticsDeleteTestsResponse result = apiInstance.deleteTests(body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#deleteTests");
            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:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

test_ids = ['<SYNTHETICS_TEST_PUBLIC_ID_1>','<SYNTHETICS_TEST_PUBLIC_ID_2>']

initialize(**options)

api.Synthetics.delete_test(public_ids=test_ids)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    body = SyntheticsDeleteTestsPayload(
        public_ids=[],
    )  # SyntheticsDeleteTestsPayload | Public ID list of the Synthetic tests to be deleted.

    # example passing only required values which don't have defaults set
    try:
        # Delete tests
        api_response = api_instance.delete_tests(body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->delete_tests: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

test_ids = ['<SYNTHETICS_TEST_PUBLIC_ID_1>','<SYNTHETICS_TEST_PUBLIC_ID_2>']

dog.delete_synthetics_tests('test_ids' => test_ids)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
body = DatadogAPIClient::V1::SyntheticsDeleteTestsPayload.new # SyntheticsDeleteTestsPayload | Public ID list of the Synthetic tests to be deleted.

begin
  # Delete tests
  result = api_instance.delete_tests(body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->delete_tests: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"

PUT https://api.datadoghq.eu/api/v1/synthetics/tests/browser/{public_id}https://api.ddog-gov.com/api/v1/synthetics/tests/browser/{public_id}https://api.datadoghq.com/api/v1/synthetics/tests/browser/{public_id}https://api.us3.datadoghq.com/api/v1/synthetics/tests/browser/{public_id}

概要

Synthetic ブラウザテストのコンフィギュレーションを編集します。

引数

パスパラメーター

名前

種類

説明

public_id [required]

string

The public ID of the test to get details from.

リクエスト

Body Data (required)

保存する新しいテストの詳細。

Expand All

フィールド

種類

説明

config

object

Configuration object for a Synthetic browser test.

assertions [required]

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

object

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator [required]

string

The specific operator to use on the path.

targetValue

object

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test steps.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,javascript,text

locations

[string]

Array of locations used to run the test.

message [required]

string

Notification message associated with the test. Message can either be text or an empty string.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism. Currently only available for Chrome.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The public ID of the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

The steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

int64

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementAttribute,assertElementContent,assertElementPresent,assertEmail,assertFileDownload,assertFromJavascript,assertPageContains,assertPageLacks,click,extractFromJavascript,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,runApiTest,scroll,selectOption,typeText,uploadFiles,wait

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, browser. Allowed enum values: browser

{
  "config": {
    "assertions": [
      {
        "operator": "string",
        "property": "string",
        "target": {},
        "type": "string"
      }
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "noSavingResponseBody": false,
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "string"
      }
    ]
  },
  "locations": [],
  "message": "",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "integer",
      "type": "string"
    }
  ],
  "tags": [],
  "type": "browser"
}

応答

OK

Object containing details about a Synthetic browser test.

Expand All

フィールド

種類

説明

config

object

Configuration object for a Synthetic browser test.

assertions [required]

[object <oneOf>]

Array of assertions used for the test.

Option 1

object

An assertion which uses a simple target.

operator [required]

enum

Assertion operator to apply. Allowed enum values: contains,doesNotContain,is,isNot,lessThan,lessThanOrEqual,moreThan,moreThanOrEqual,matches,doesNotMatch,validates,isInMoreThan,isInLessThan

property

string

The associated assertion property.

target

object

Value used by the operator.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

Option 2

object

An assertion for the validatesJSONPath operator.

operator [required]

enum

Assertion operator to apply. Allowed enum values: validatesJSONPath

property

string

The associated assertion property.

target

object

Composed target for validatesJSONPath operator.

jsonPath

string

The JSON path to assert.

operator [required]

string

The specific operator to use on the path.

targetValue

object

The path target value to compare to.

type [required]

enum

Type of the assertion. Allowed enum values: body,header,statusCode,certificate,responseTime,property,recordEvery,recordSome,tlsVersion,minTlsVersion

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

certificate

object

Client certificate to use when performing the test request.

cert

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

key

object

Define a request certificate.

content

string

Content of the certificate or key.

filename

string

File name for the certificate or key.

updatedAt

string

Date of update of the certificate or key, ISO format.

dnsServer

string

DNS server to use for DNS tests.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

noSavingResponseBody

boolean

Determines whether or not to save the response body.

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test steps.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,javascript,text

locations

[string]

Array of locations used to run the test.

message [required]

string

Notification message associated with the test. Message can either be text or an empty string.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

disableCors

boolean

Whether or not to disable CORS mechanism. Currently only available for Chrome.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (for example, renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

noScreenshot

boolean

Prevents saving screenshots of the steps.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The public ID of the test.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

The steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

int64

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementAttribute,assertElementContent,assertElementPresent,assertEmail,assertFileDownload,assertFromJavascript,assertPageContains,assertPageLacks,click,extractFromJavascript,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,runApiTest,scroll,selectOption,typeText,uploadFiles,wait

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, browser. Allowed enum values: browser

{
  "config": {
    "assertions": [
      {
        "operator": "string",
        "property": "string",
        "target": {},
        "type": "string"
      }
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "certificate": {
        "cert": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        },
        "key": {
          "content": "string",
          "filename": "string",
          "updatedAt": "string"
        }
      },
      "dnsServer": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "noSavingResponseBody": false,
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "VARIABLE_NAME",
        "pattern": "string",
        "type": "string"
      }
    ]
  },
  "locations": [],
  "message": "",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "disableCors": false,
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "noScreenshot": false,
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "integer",
      "type": "string"
    }
  ],
  "tags": [],
  "type": "browser"
}

- JSON format is wrong - Updating sub-type is forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

- Synthetic Monitoring is not activated for the user - Test is not owned by the user - Test can't be found

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


# Path parameters
export public_id="CHANGE_ME"
# Curl command curl -X PUT "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com/api/v1/synthetics/tests/browser/${public_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "config": { "assertions": [ {} ], "request": { "basicAuth": { "password": "", "username": "" } }, "variables": [ { "name": "VARIABLE_NAME", "type": null } ] }, "message": "" } EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    publicId := "publicId_example" // string | The public ID of the test to get details from.
    body := *datadog.NewSyntheticsBrowserTest("Message_example") // SyntheticsBrowserTest | New test details to be saved.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.UpdateBrowserTest(ctx, publicId).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.UpdateBrowserTest``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UpdateBrowserTest`: SyntheticsBrowserTest
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.UpdateBrowserTest:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Import classes:
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String publicId = "publicId_example"; // String | The public ID of the test to get details from.
        SyntheticsBrowserTest body = new SyntheticsBrowserTest(); // SyntheticsBrowserTest | New test details to be saved.
        try {
            SyntheticsBrowserTest result = apiInstance.updateBrowserTest(publicId, body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#updateBrowserTest");
            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:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    public_id = "public_id_example"  # str | The public ID of the test to get details from.
    body = SyntheticsBrowserTest(
        config=SyntheticsBrowserTestConfig(
            assertions=[
                SyntheticsAssertion(),
            ],
            request=SyntheticsTestRequest(
                basic_auth=SyntheticsBasicAuth(
                    password="",
                    username="",
                ),
                body="body_example",
                certificate=SyntheticsTestRequestCertificate(
                    cert=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                    key=SyntheticsTestRequestCertificateItem(
                        content="content_example",
                        filename="filename_example",
                        updated_at="updated_at_example",
                    ),
                ),
                dns_server="dns_server_example",
                headers=SyntheticsTestHeaders(
                    key="key_example",
                ),
                host="host_example",
                method=HTTPMethod("GET"),
                no_saving_response_body=True,
                port=1,
                query={},
                timeout=3.14,
                url="url_example",
            ),
            variables=[
                SyntheticsBrowserVariable(
                    example="example_example",
                    id="id_example",
                    name="VARIABLE_NAME",
                    pattern="pattern_example",
                    type=SyntheticsBrowserVariableType("element"),
                ),
            ],
        ),
        locations=[
            "locations_example",
        ],
        message="",
        monitor_id=1,
        name="name_example",
        options=SyntheticsTestOptions(
            accept_self_signed=True,
            allow_insecure=True,
            device_ids=[
                SyntheticsDeviceID("laptop_large"),
            ],
            disable_cors=True,
            follow_redirects=True,
            min_failure_duration=1,
            min_location_failed=1,
            monitor_options=SyntheticsTestOptionsMonitorOptions(
                renotify_interval=0,
            ),
            no_screenshot=True,
            retry=SyntheticsTestOptionsRetry(
                count=1,
                interval=3.14,
            ),
            tick_every=SyntheticsTickInterval(60),
        ),
        public_id="public_id_example",
        status=SyntheticsTestPauseStatus("live"),
        steps=[
            SyntheticsStep(
                allow_failure=True,
                name="name_example",
                params={},
                timeout=1,
                type=SyntheticsStepType("assertCurrentUrl"),
            ),
        ],
        tags=[
            "tags_example",
        ],
        type=SyntheticsBrowserTestType("browser"),
    )  # SyntheticsBrowserTest | New test details to be saved.

    # example passing only required values which don't have defaults set
    try:
        # Edit a browser test
        api_response = api_instance.update_browser_test(public_id, body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->update_browser_test: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
public_id = 'public_id_example' # String | The public ID of the test to get details from.
body = DatadogAPIClient::V1::SyntheticsBrowserTest.new({message: 'message_example'}) # SyntheticsBrowserTest | New test details to be saved.

begin
  # Edit a browser test
  result = api_instance.update_browser_test(public_id, body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts "Error when calling SyntheticsAPI->update_browser_test: #{e}"
end

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"

PUT https://api.datadoghq.eu/api/v1/synthetics/variables/{variable_id}https://api.ddog-gov.com/api/v1/synthetics/variables/{variable_id}https://api.datadoghq.com/api/v1/synthetics/variables/{variable_id}https://api.us3.datadoghq.com/api/v1/synthetics/variables/{variable_id}

概要

Synthetic グローバル変数を編集します。

引数

パスパラメーター

名前

種類

説明

variable_id [required]

string

The ID of the global variable.

リクエスト

Body Data (required)

更新するグローバル変数の詳細。

Expand All

フィールド

種類

説明

description [required]

string

Description of the global variable.

id

string

Unique identifier of the global variable.

name [required]

string

Name of the global variable.

parse_test_options

object

Parser options to use for retrieving a Synthetics global variable from a Synthetics Test. Used in conjunction with parse_test_public_id.

field

string

When type is http_header, name of the header to use to extract the value.

parser [required]

object

Details of the parser to use for the global variable.

type [required]

enum

Type of parser for a Synthetics global variable from a synthetics test. Allowed enum values: raw,json_path,regex

value

string

Regex or JSON path used for the parser. Not used with type raw.

type [required]

enum

Property of the Synthetics Test Response to use for a Synthetics global variable. Allowed enum values: http_body,http_header

parse_test_public_id

string

A Synthetic test ID to use as a test to generate the variable value.

tags [required]

[string]

Tags of the global variable.

value [required]

object

Value of the global variable.

secure

boolean

Determines if the variable is secure.

value [required]

string

Value of the global variable. When reading a global variable, the value will not be present if the variable is secure.

{
  "description": "Example description",
  "name": "MY_VARIABLE",
  "parse_test_options": {
    "field": "content-type",
    "parser": {
      "type": "string",
      "value": "string"
    },
    "type": "string"
  },
  "parse_test_public_id": "abc-def-123",
  "tags": [
    "team:front",
    "test:workflow-1"
  ],
  "value": {
    "secure": false,
    "value": "example-value"
  }
}

応答

OK

Synthetics global variable.

Expand All

フィールド

種類

説明

description [required]

string

Description of the global variable.

id

string

Unique identifier of the global variable.

name [required]

string

Name of the global variable.

parse_test_options

object

Parser options to use for retrieving a Synthetics global variable from a Synthetics Test. Used in conjunction with parse_test_public_id.

field

string

When type is http_header, name of the header to use to extract the value.

parser [required]

object

Details of the parser to use for the global variable.

type [required]

enum

Type of parser for a Synthetics global variable from a synthetics test. Allowed enum values: raw,json_path,regex

value

string

Regex or JSON path used for the parser. Not used with type raw.

type [required]

enum

Property of the Synthetics Test Response to use for a Synthetics global variable. Allowed enum values: http_body,http_header

parse_test_public_id

string

A Synthetic test ID to use as a test to generate the variable value.

tags [required]

[string]

Tags of the global variable.

value [required]

object

Value of the global variable.

secure

boolean

Determines if the variable is secure.

value [required]

string

Value of the global variable. When reading a global variable, the value will not be present if the variable is secure.

{
  "description": "Example description",
  "id": "string",
  "name": "MY_VARIABLE",
  "parse_test_options": {
    "field": "content-type",
    "parser": {
      "type": "string",
      "value": "string"
    },
    "type": "string"
  },
  "parse_test_public_id": "abc-def-123",
  "tags": [
    "team:front",
    "test:workflow-1"
  ],
  "value": {
    "secure": false,
    "value": "example-value"
  }
}

Invalid request

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


# Path parameters
export variable_id="CHANGE_ME"
# Curl command curl -X PUT "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com/api/v1/synthetics/variables/${variable_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "description": "Example description", "name": "MY_VARIABLE", "parse_test_options": { "parser": { "type": null }, "type": null }, "tags": [ "team:front", "test:workflow-1" ], "value": { "value": "example-value" } } EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := datadog.NewDefaultContext(context.Background())

    variableId := "variableId_example" // string | The ID of the global variable.
    body := *datadog.NewSyntheticsGlobalVariable("Example description", "MY_VARIABLE", []string{"Tags_example"}, *datadog.NewSyntheticsGlobalVariableValue("example-value")) // SyntheticsGlobalVariable | Details of the global variable to update.

    configuration := datadog.NewConfiguration()

    apiClient := datadog.NewAPIClient(configuration)
    resp, r, err := apiClient.SyntheticsApi.EditGlobalVariable(ctx, variableId).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.EditGlobalVariable``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `EditGlobalVariable`: SyntheticsGlobalVariable
    responseContent, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.EditGlobalVariable:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Import classes:
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String variableId = "variableId_example"; // String | The ID of the global variable.
        SyntheticsGlobalVariable body = new SyntheticsGlobalVariable(); // SyntheticsGlobalVariable | Details of the global variable to update.
        try {
            SyntheticsGlobalVariable result = apiInstance.editGlobalVariable(variableId, body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#editGlobalVariable");
            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:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    variable_id = "variable_id_example"  # str | The ID of the global variable.
    body = SyntheticsGlobalVariable(
        description="Example description",
        id="id_example",
        name="MY_VARIABLE",
        parse_test_options=SyntheticsGlobalVariableParseTestOptions(
            field="content-type",
            parser=SyntheticsVariableParser(
                type=SyntheticsGlobalVariableParserType("raw"),
                value="value_example",
            ),
            type=SyntheticsGlobalVariableParseTestOptionsType("http_body"),
        ),
        parse_test_public_id="abc-def-123",
        tags=["team:front","test:workflow-1"],
        value=SyntheticsGlobalVariableValue(
            secure=True,
            value="example-value",
        ),
    )  # SyntheticsGlobalVariable | Details of the global variable to update.

    # example passing only required values which don't have defaults set
    try:
        # Edit a global variable
        api_response = api_instance.edit_global_variable(variable_id, body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->edit_global_variable: %s\n" % e)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
export DD_SITE="datadoghq.comus3.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'datadog_api_client'
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
variable_id = 'variable_id_example' # String | The ID of the global variable.
body = DatadogAPIClient::V1::SyntheticsGlobalVariable.new({description: 'Example description', name: 'MY_VARIABLE', tags: ['tags_example'], value: DatadogAPIClient::V1::SyntheticsGlobalVariableValue.new({value: 'example-value'})}) # SyntheticsGlobalVariable | Details of the global variable to update.

begin
  # Edit a global variable
  result = api_instance.edit_global_variable(variable_id, body)
  p result
rescue DatadogAPIClient::V1::APIError => e
  puts