-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathCreateSyntheticsAPITest_1072503741.java
More file actions
63 lines (59 loc) · 2.98 KB
/
CreateSyntheticsAPITest_1072503741.java
File metadata and controls
63 lines (59 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Create an API SSL test returns "OK - Returns the created test details." 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.SyntheticsAPITest;
import com.datadog.api.client.v1.model.SyntheticsAPITestConfig;
import com.datadog.api.client.v1.model.SyntheticsAPITestType;
import com.datadog.api.client.v1.model.SyntheticsAssertion;
import com.datadog.api.client.v1.model.SyntheticsAssertionOperator;
import com.datadog.api.client.v1.model.SyntheticsAssertionTarget;
import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue;
import com.datadog.api.client.v1.model.SyntheticsAssertionType;
import com.datadog.api.client.v1.model.SyntheticsTestDetailsSubType;
import com.datadog.api.client.v1.model.SyntheticsTestOptions;
import com.datadog.api.client.v1.model.SyntheticsTestRequest;
import com.datadog.api.client.v1.model.SyntheticsTestRequestPort;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
SyntheticsAPITest body =
new SyntheticsAPITest()
.config(
new SyntheticsAPITestConfig()
.assertions(
Collections.singletonList(
new SyntheticsAssertion(
new SyntheticsAssertionTarget()
.operator(SyntheticsAssertionOperator.IS_IN_MORE_DAYS_THAN)
.target(new SyntheticsAssertionTargetValue(10.0))
.type(SyntheticsAssertionType.CERTIFICATE))))
.request(
new SyntheticsTestRequest()
.host("datadoghq.com")
.port(new SyntheticsTestRequestPort("{{ DATADOG_PORT }}"))))
.locations(Collections.singletonList("aws:us-east-2"))
.message("BDD test payload: synthetics_api_ssl_test_payload.json")
.name("Example-Synthetic")
.options(
new SyntheticsTestOptions()
.acceptSelfSigned(true)
.checkCertificateRevocation(true)
.tickEvery(60L))
.subtype(SyntheticsTestDetailsSubType.SSL)
.tags(Collections.singletonList("testing:api"))
.type(SyntheticsAPITestType.API);
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();
}
}
}