CI/CD 파이프라인에서 테스트 트리거하기
https://api.datadoghq.com/api/v1/synthetics/tests/trigger/cihttps://api.us3.datadoghq.com/api/v1/synthetics/tests/trigger/cihttps://api.us5.datadoghq.com/api/v1/synthetics/tests/trigger/cihttps://api.datadoghq.eu/api/v1/synthetics/tests/trigger/cihttps://api.ap1.datadoghq.com/api/v1/synthetics/tests/trigger/cihttps://api.ap2.datadoghq.com/api/v1/synthetics/tests/trigger/cihttps://api.uk1.datadoghq.com/api/v1/synthetics/tests/trigger/cihttps://api.ddog-gov.com/api/v1/synthetics/tests/trigger/cihttps://api.us2.ddog-gov.com/api/v1/synthetics/tests/trigger/ci개요
지속적 통합을 위해 Synthetic 테스트 세트를 트리거합니다.
OAuth apps require the synthetics_write authorization scope to access this endpoint.
요청
Body Data (required)
트리거할 테스트의 세부 정보입니다.
tests트리거할 Synthetic 테스트를 설명하는 객체입니다.
allowInsecureCertificatesDisable certificate checks in API tests.
basicAuthObject to handle basic authentication when performing the test.
<type=web>Object to handle basic authentication when performing the test.
passwordPassword to use for the basic authentication.
typeThe type of basic authentication to use when performing the test.
webwebusernameUsername to use for the basic authentication.
<type=sigv4>Object to handle SIGV4 authentication when performing the test.
accessKey [required]Access key for the SIGV4 authentication.
regionRegion for the SIGV4 authentication.
secretKey [required]Secret key for the SIGV4 authentication.
serviceNameService name for the SIGV4 authentication.
sessionTokenSession token for the SIGV4 authentication.
type [required]The type of authentication to use when performing the test.
sigv4sigv4<type=ntlm>Object to handle NTLM authentication when performing the test.
domainDomain for the authentication to use when performing the test.
passwordPassword for the authentication to use when performing the test.
type [required]The type of authentication to use when performing the test.
ntlmntlmusernameUsername for the authentication to use when performing the test.
workstationWorkstation for the authentication to use when performing the test.
<type=digest>Object to handle digest authentication when performing the test.
password [required]Password to use for the digest authentication.
type [required]The type of basic authentication to use when performing the test.
digestdigestusername [required]Username to use for the digest authentication.
<type=oauth-client>Object to handle oauth client authentication when performing the test.
accessTokenUrl [required]Access token URL to use when performing the authentication.
audienceAudience to use when performing the authentication.
clientId [required]Client ID to use when performing the authentication.
clientSecret [required]Client secret to use when performing the authentication.
resourceResource to use when performing the authentication.
scopeScope to use when performing the authentication.
tokenApiAuthentication [required]Type of token to use when performing the authentication.
header, bodytype [required]The type of basic authentication to use when performing the test.
oauth-clientoauth-client<type=oauth-rop>Object to handle oauth rop authentication when performing the test.
accessTokenUrl [required]Access token URL to use when performing the authentication.
audienceAudience to use when performing the authentication.
clientIdClient ID to use when performing the authentication.
clientSecretClient secret to use when performing the authentication.
password [required]Password to use when performing the authentication.
resourceResource to use when performing the authentication.
scopeScope to use when performing the authentication.
tokenApiAuthentication [required]Type of token to use when performing the authentication.
header, bodytype [required]The type of basic authentication to use when performing the test.
oauth-ropoauth-ropusername [required]Username to use when performing the authentication.
<type=jwt>Object to handle JWT authentication when performing the test.
addClaimsStandard JWT claims to automatically inject.
expWhether to inject the exp (expiration) claim.
iatWhether to inject the iat (issued at) claim.
algorithm [required]Algorithm to use for the JWT authentication.
HS256, RS256, ES256expiresInToken time-to-live in seconds.
headerCustom JWT header as a JSON string.
payload [required]JWT claims as a JSON string.
secret [required]Signing key for the JWT authentication. Use the shared secret for HS256
or the private key (PEM format) for RS256 and ES256.
tokenPrefixPrefix added before the token in the Authorization header. Defaults to Bearer.
type [required]The type of authentication to use when performing the test.
jwtjwtbodyBody to include in the test.
bodyTypeType of the data sent in a Synthetic API test.
cookiesCookies for the request.
deviceIdsFor browser test, array with the different device IDs used to run the test.
followRedirectsFor API HTTP test, whether or not the test should follow redirects.
headersHeaders to include when performing the test.
<any-key>A single Header.
locationsArray of locations used to run the test.
metadataMetadata for the Synthetic tests run.
ciDescription of the CI provider.
pipelineDescription of the CI pipeline.
urlURL of the pipeline.
providerDescription of the CI provider.
nameName of the CI provider.
gitGit information.
branchBranch name.
commitShaThe commit SHA.
public_id [required]The public ID of the Synthetic test to trigger.
retryObject describing the retry strategy to apply to a Synthetic test.
countNumber of times a test needs to be retried before marking a location as failed. Defaults to 0.
intervalTime interval between retries (in milliseconds). Defaults to 300ms.
startUrlStarting URL for the browser test.
variablesVariables to replace in the test.
<any-key>A single variable.
versionThe version number of the Synthetic test version to trigger.
{
"tests": [
{
"allowInsecureCertificates": false,
"basicAuth": {
"password": "PaSSw0RD!",
"type": "web",
"username": "my_username"
},
"body": "string",
"bodyType": "string",
"cookies": "string",
"deviceIds": [
"chrome.laptop_large"
],
"followRedirects": false,
"headers": {
"<any-key>": "string"
},
"locations": [
"aws:eu-west-3"
],
"metadata": {
"ci": {
"pipeline": {
"url": "string"
},
"provider": {
"name": "string"
}
},
"git": {
"branch": "string",
"commitSha": "string"
}
},
"public_id": "aaa-aaa-aaa",
"retry": {
"count": "integer",
"interval": "number"
},
"startUrl": "string",
"variables": {
"<any-key>": "string"
},
"version": "integer"
}
]
}응답
OK
Object containing information about the tests triggered.
batch_idThe public ID of the batch triggered.
locationsList of Synthetic locations.
idUnique identifier of the location.
nameName of the location.
resultsInformation about the tests runs.
deviceThe device ID.
locationThe location ID of the test run.
public_idThe public ID of the Synthetic test.
result_idID of the result.
triggered_check_idsThe public IDs of the Synthetic test triggered.
{
"batch_id": "string",
"locations": [
{
"id": "integer",
"name": "string"
}
],
"results": [
{
"device": "chrome.laptop_large",
"location": "integer",
"public_id": "string",
"result_id": "string"
}
],
"triggered_check_ids": []
}JSON format is wrong
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Too many requests
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}코드 예시
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/trigger/ci" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"tests": [
{
"public_id": "aaa-aaa-aaa"
}
]
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/trigger/ci" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"tests": [
{
"public_id": "aaa-aaa-aaa"
}
]
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/trigger/ci" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"tests": [
{
"public_id": "aaa-aaa-aaa"
}
]
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/trigger/ci" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"tests": [
{
"public_id": "aaa-aaa-aaa"
}
]
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/trigger/ci" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"tests": [
{
"public_id": "aaa-aaa-aaa"
}
]
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/trigger/ci" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"tests": [
{
"public_id": "aaa-aaa-aaa"
}
]
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/trigger/ci" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"tests": [
{
"public_id": "aaa-aaa-aaa"
}
]
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/trigger/ci" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"tests": [
{
"public_id": "aaa-aaa-aaa"
}
]
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v1/synthetics/tests/trigger/ci" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"tests": [
{
"public_id": "aaa-aaa-aaa"
}
]
}
EOF// Trigger tests from CI/CD pipelines returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
body := datadogV1.SyntheticsCITestBody{
Tests: []datadogV1.SyntheticsCITest{
{
BasicAuth: &datadogV1.SyntheticsBasicAuth{
SyntheticsBasicAuthWeb: &datadogV1.SyntheticsBasicAuthWeb{
Password: datadog.PtrString("PaSSw0RD!"),
Type: datadogV1.SYNTHETICSBASICAUTHWEBTYPE_WEB.Ptr(),
Username: datadog.PtrString("my_username"),
}},
DeviceIds: []string{
"chrome.laptop_large",
},
Locations: []string{
"aws:eu-west-3",
},
Metadata: &datadogV1.SyntheticsCIBatchMetadata{
Ci: &datadogV1.SyntheticsCIBatchMetadataCI{
Pipeline: &datadogV1.SyntheticsCIBatchMetadataPipeline{},
Provider: &datadogV1.SyntheticsCIBatchMetadataProvider{},
},
Git: &datadogV1.SyntheticsCIBatchMetadataGit{},
},
PublicId: "aaa-aaa-aaa",
Retry: &datadogV1.SyntheticsTestOptionsRetry{},
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewSyntheticsApi(apiClient)
resp, r, err := api.TriggerCITests(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.TriggerCITests`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.TriggerCITests`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Trigger tests from CI/CD pipelines returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.SyntheticsApi;
import com.datadog.api.client.v1.model.SyntheticsBasicAuth;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthWeb;
import com.datadog.api.client.v1.model.SyntheticsBasicAuthWebType;
import com.datadog.api.client.v1.model.SyntheticsCIBatchMetadata;
import com.datadog.api.client.v1.model.SyntheticsCIBatchMetadataCI;
import com.datadog.api.client.v1.model.SyntheticsCIBatchMetadataGit;
import com.datadog.api.client.v1.model.SyntheticsCIBatchMetadataPipeline;
import com.datadog.api.client.v1.model.SyntheticsCIBatchMetadataProvider;
import com.datadog.api.client.v1.model.SyntheticsCITest;
import com.datadog.api.client.v1.model.SyntheticsCITestBody;
import com.datadog.api.client.v1.model.SyntheticsTestOptionsRetry;
import com.datadog.api.client.v1.model.SyntheticsTriggerCITestsResponse;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
SyntheticsCITestBody body =
new SyntheticsCITestBody()
.tests(
Collections.singletonList(
new SyntheticsCITest()
.basicAuth(
new SyntheticsBasicAuth(
new SyntheticsBasicAuthWeb()
.password("PaSSw0RD!")
.type(SyntheticsBasicAuthWebType.WEB)
.username("my_username")))
.deviceIds(Collections.singletonList("chrome.laptop_large"))
.locations(Collections.singletonList("aws:eu-west-3"))
.metadata(
new SyntheticsCIBatchMetadata()
.ci(
new SyntheticsCIBatchMetadataCI()
.pipeline(new SyntheticsCIBatchMetadataPipeline())
.provider(new SyntheticsCIBatchMetadataProvider()))
.git(new SyntheticsCIBatchMetadataGit()))
.publicId("aaa-aaa-aaa")
.retry(new SyntheticsTestOptionsRetry())));
try {
SyntheticsTriggerCITestsResponse result = apiInstance.triggerCITests(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling SyntheticsApi#triggerCITests");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Trigger tests from CI/CD pipelines returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.synthetics_api import SyntheticsApi
from datadog_api_client.v1.model.synthetics_basic_auth_web import SyntheticsBasicAuthWeb
from datadog_api_client.v1.model.synthetics_basic_auth_web_type import SyntheticsBasicAuthWebType
from datadog_api_client.v1.model.synthetics_ci_batch_metadata import SyntheticsCIBatchMetadata
from datadog_api_client.v1.model.synthetics_ci_batch_metadata_ci import SyntheticsCIBatchMetadataCI
from datadog_api_client.v1.model.synthetics_ci_batch_metadata_git import SyntheticsCIBatchMetadataGit
from datadog_api_client.v1.model.synthetics_ci_batch_metadata_pipeline import SyntheticsCIBatchMetadataPipeline
from datadog_api_client.v1.model.synthetics_ci_batch_metadata_provider import SyntheticsCIBatchMetadataProvider
from datadog_api_client.v1.model.synthetics_ci_test import SyntheticsCITest
from datadog_api_client.v1.model.synthetics_ci_test_body import SyntheticsCITestBody
from datadog_api_client.v1.model.synthetics_test_options_retry import SyntheticsTestOptionsRetry
body = SyntheticsCITestBody(
tests=[
SyntheticsCITest(
basic_auth=SyntheticsBasicAuthWeb(
password="PaSSw0RD!",
type=SyntheticsBasicAuthWebType.WEB,
username="my_username",
),
device_ids=[
"chrome.laptop_large",
],
locations=[
"aws:eu-west-3",
],
metadata=SyntheticsCIBatchMetadata(
ci=SyntheticsCIBatchMetadataCI(
pipeline=SyntheticsCIBatchMetadataPipeline(),
provider=SyntheticsCIBatchMetadataProvider(),
),
git=SyntheticsCIBatchMetadataGit(),
),
public_id="aaa-aaa-aaa",
retry=SyntheticsTestOptionsRetry(),
),
],
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = SyntheticsApi(api_client)
response = api_instance.trigger_ci_tests(body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Trigger tests from CI/CD pipelines returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V1::SyntheticsAPI.new
body = DatadogAPIClient::V1::SyntheticsCITestBody.new({
tests: [
DatadogAPIClient::V1::SyntheticsCITest.new({
basic_auth: DatadogAPIClient::V1::SyntheticsBasicAuthWeb.new({
password: "PaSSw0RD!",
type: DatadogAPIClient::V1::SyntheticsBasicAuthWebType::WEB,
username: "my_username",
}),
device_ids: [
"chrome.laptop_large",
],
locations: [
"aws:eu-west-3",
],
metadata: DatadogAPIClient::V1::SyntheticsCIBatchMetadata.new({
ci: DatadogAPIClient::V1::SyntheticsCIBatchMetadataCI.new({
pipeline: DatadogAPIClient::V1::SyntheticsCIBatchMetadataPipeline.new({}),
provider: DatadogAPIClient::V1::SyntheticsCIBatchMetadataProvider.new({}),
}),
git: DatadogAPIClient::V1::SyntheticsCIBatchMetadataGit.new({}),
}),
public_id: "aaa-aaa-aaa",
_retry: DatadogAPIClient::V1::SyntheticsTestOptionsRetry.new({}),
}),
],
})
p api_instance.trigger_ci_tests(body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Trigger tests from CI/CD pipelines returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_synthetics::SyntheticsAPI;
use datadog_api_client::datadogV1::model::SyntheticsBasicAuth;
use datadog_api_client::datadogV1::model::SyntheticsBasicAuthWeb;
use datadog_api_client::datadogV1::model::SyntheticsBasicAuthWebType;
use datadog_api_client::datadogV1::model::SyntheticsCIBatchMetadata;
use datadog_api_client::datadogV1::model::SyntheticsCIBatchMetadataCI;
use datadog_api_client::datadogV1::model::SyntheticsCIBatchMetadataGit;
use datadog_api_client::datadogV1::model::SyntheticsCIBatchMetadataPipeline;
use datadog_api_client::datadogV1::model::SyntheticsCIBatchMetadataProvider;
use datadog_api_client::datadogV1::model::SyntheticsCITest;
use datadog_api_client::datadogV1::model::SyntheticsCITestBody;
use datadog_api_client::datadogV1::model::SyntheticsTestOptionsRetry;
#[tokio::main]
async fn main() {
let body =
SyntheticsCITestBody::new().tests(vec![SyntheticsCITest::new("aaa-aaa-aaa".to_string())
.basic_auth(SyntheticsBasicAuth::SyntheticsBasicAuthWeb(Box::new(
SyntheticsBasicAuthWeb::new()
.password("PaSSw0RD!".to_string())
.type_(SyntheticsBasicAuthWebType::WEB)
.username("my_username".to_string()),
)))
.device_ids(vec!["chrome.laptop_large".to_string()])
.locations(vec!["aws:eu-west-3".to_string()])
.metadata(
SyntheticsCIBatchMetadata::new()
.ci(SyntheticsCIBatchMetadataCI::new()
.pipeline(SyntheticsCIBatchMetadataPipeline::new())
.provider(SyntheticsCIBatchMetadataProvider::new()))
.git(SyntheticsCIBatchMetadataGit::new()),
)
.retry(SyntheticsTestOptionsRetry::new())]);
let configuration = datadog::Configuration::new();
let api = SyntheticsAPI::with_config(configuration);
let resp = api.trigger_ci_tests(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Trigger tests from CI/CD pipelines returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v1.SyntheticsApi(configuration);
const params: v1.SyntheticsApiTriggerCITestsRequest = {
body: {
tests: [
{
basicAuth: {
password: "PaSSw0RD!",
type: "web",
username: "my_username",
},
deviceIds: ["chrome.laptop_large"],
locations: ["aws:eu-west-3"],
metadata: {
ci: {
pipeline: {},
provider: {},
},
git: {},
},
publicId: "aaa-aaa-aaa",
retry: {},
},
],
},
};
apiInstance
.triggerCITests(params)
.then((data: v1.SyntheticsTriggerCITestsResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"