-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathCreateSyntheticsAPITest_1402674167.java
More file actions
83 lines (79 loc) · 4.17 KB
/
CreateSyntheticsAPITest_1402674167.java
File metadata and controls
83 lines (79 loc) · 4.17 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Create an API GRPC 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.SyntheticsTestOptionsMonitorOptions;
import com.datadog.api.client.v1.model.SyntheticsTestRequest;
import com.datadog.api.client.v1.model.SyntheticsTestRequestPort;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
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(
Arrays.asList(
new SyntheticsAssertion(
new SyntheticsAssertionTarget()
.operator(SyntheticsAssertionOperator.IS)
.target(new SyntheticsAssertionTargetValue(1.0))
.type(SyntheticsAssertionType.GRPC_HEALTHCHECK_STATUS)),
new SyntheticsAssertion(
new SyntheticsAssertionTarget()
.operator(SyntheticsAssertionOperator.IS)
.target(new SyntheticsAssertionTargetValue("proto target"))
.type(SyntheticsAssertionType.GRPC_PROTO)),
new SyntheticsAssertion(
new SyntheticsAssertionTarget()
.operator(SyntheticsAssertionOperator.IS)
.target(new SyntheticsAssertionTargetValue("123"))
.property("property")
.type(SyntheticsAssertionType.GRPC_METADATA))))
.request(
new SyntheticsTestRequest()
.host("localhost")
.port(new SyntheticsTestRequestPort(50051L))
.service("Hello")
.method("GET")
.message("")
.metadata(Map.ofEntries())))
.locations(Collections.singletonList("aws:us-east-2"))
.message("BDD test payload: synthetics_api_grpc_test_payload.json")
.name("Example-Synthetic")
.options(
new SyntheticsTestOptions()
.minFailureDuration(0L)
.minLocationFailed(1L)
.monitorOptions(new SyntheticsTestOptionsMonitorOptions().renotifyInterval(0L))
.monitorName("Example-Synthetic")
.tickEvery(60L))
.subtype(SyntheticsTestDetailsSubType.GRPC)
.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();
}
}
}