-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathCreateServiceNowTemplate.java
More file actions
50 lines (46 loc) · 2.4 KB
/
CreateServiceNowTemplate.java
File metadata and controls
50 lines (46 loc) · 2.4 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
// Create ServiceNow template returns "Created" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ServiceNowIntegrationApi;
import com.datadog.api.client.v2.model.ServiceNowTemplateCreateRequest;
import com.datadog.api.client.v2.model.ServiceNowTemplateCreateRequestAttributes;
import com.datadog.api.client.v2.model.ServiceNowTemplateCreateRequestData;
import com.datadog.api.client.v2.model.ServiceNowTemplateResponse;
import com.datadog.api.client.v2.model.ServiceNowTemplateType;
import java.util.Map;
import java.util.UUID;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
ServiceNowIntegrationApi apiInstance = new ServiceNowIntegrationApi(defaultClient);
ServiceNowTemplateCreateRequest body =
new ServiceNowTemplateCreateRequest()
.data(
new ServiceNowTemplateCreateRequestData()
.attributes(
new ServiceNowTemplateCreateRequestAttributes()
.assignmentGroupId(
UUID.fromString("65b3341b-0680-47f9-a6d4-134db45c603e"))
.businessServiceId(
UUID.fromString("65b3341b-0680-47f9-a6d4-134db45c603e"))
.fieldsMapping(
Map.ofEntries(
Map.entry("category", "software"), Map.entry("priority", "1")))
.handleName("incident-template")
.instanceId(UUID.fromString("65b3341b-0680-47f9-a6d4-134db45c603e"))
.servicenowTablename("incident")
.userId(UUID.fromString("65b3341b-0680-47f9-a6d4-134db45c603e")))
.type(ServiceNowTemplateType.SERVICENOW_TEMPLATES));
try {
ServiceNowTemplateResponse result = apiInstance.createServiceNowTemplate(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling ServiceNowIntegrationApi#createServiceNowTemplate");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}