-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathCreateDeploymentRule.java
More file actions
49 lines (44 loc) · 2.24 KB
/
CreateDeploymentRule.java
File metadata and controls
49 lines (44 loc) · 2.24 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
// Create deployment rule returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.DeploymentGatesApi;
import com.datadog.api.client.v2.model.CreateDeploymentRuleParams;
import com.datadog.api.client.v2.model.CreateDeploymentRuleParamsData;
import com.datadog.api.client.v2.model.CreateDeploymentRuleParamsDataAttributes;
import com.datadog.api.client.v2.model.DeploymentRuleDataType;
import com.datadog.api.client.v2.model.DeploymentRuleOptionsFaultyDeploymentDetection;
import com.datadog.api.client.v2.model.DeploymentRuleResponse;
import com.datadog.api.client.v2.model.DeploymentRulesOptions;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setUnstableOperationEnabled("v2.createDeploymentRule", true);
DeploymentGatesApi apiInstance = new DeploymentGatesApi(defaultClient);
// there is a valid "deployment_gate" in the system
String DEPLOYMENT_GATE_DATA_ID = System.getenv("DEPLOYMENT_GATE_DATA_ID");
CreateDeploymentRuleParams body =
new CreateDeploymentRuleParams()
.data(
new CreateDeploymentRuleParamsData()
.attributes(
new CreateDeploymentRuleParamsDataAttributes()
.dryRun(false)
.name("My deployment rule")
.options(
new DeploymentRulesOptions(
new DeploymentRuleOptionsFaultyDeploymentDetection()))
.type("faulty_deployment_detection"))
.type(DeploymentRuleDataType.DEPLOYMENT_RULE));
try {
DeploymentRuleResponse result =
apiInstance.createDeploymentRule(DEPLOYMENT_GATE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DeploymentGatesApi#createDeploymentRule");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}