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(
host = "https://api.datadoghq.com",
api_key= {"apiKeyAuth": "<YOUR_API_KEY>","appKeyAuth": "<YOUR_APPLICATION_KEY>"}
)
// Enter a context with an instance of the API client where the ApiClient configuration is set as api_client:
// Create an instance of the API class
api_instance = synthetics_api.SyntheticsApi(api_client)
body = SyntheticsAPITest(
config=SyntheticsAPITestConfig(
assertions=[
SyntheticsAssertion(
operator="lessThan",
type="responseTime",
target=1000
),
],
request=SyntheticsTestRequest(
body="body_example",
headers=SyntheticsTestHeaders(
**{"User-Agent": "value"}),
method=HTTPMethod("GET"),
no_saving_response_body=True,
query={},
timeout=60.0,
url="https://httpbin.org/get",
),
),
locations=[
"aws:eu-west-2",
],
message="message_example",
name="name_example",
options=SyntheticsTestOptions(
follow_redirects=True,
min_failure_duration=1,
min_location_failed=1,
#monitor_name="monitor_name_example",
monitor_options=SyntheticsTestOptionsMonitorOptions(
renotify_interval=0,
),
monitor_priority=1,
tick_every=30
),
status=SyntheticsTestPauseStatus("live"),
subtype=SyntheticsTestDetailsSubType("http"),
tags=[
"python-client",
],
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)