-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathUpdateServiceNowTemplate.java
More file actions
52 lines (48 loc) · 2.48 KB
/
UpdateServiceNowTemplate.java
File metadata and controls
52 lines (48 loc) · 2.48 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
// Update ServiceNow template returns "OK" 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.ServiceNowTemplateResponse;
import com.datadog.api.client.v2.model.ServiceNowTemplateType;
import com.datadog.api.client.v2.model.ServiceNowTemplateUpdateRequest;
import com.datadog.api.client.v2.model.ServiceNowTemplateUpdateRequestAttributes;
import com.datadog.api.client.v2.model.ServiceNowTemplateUpdateRequestData;
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);
ServiceNowTemplateUpdateRequest body =
new ServiceNowTemplateUpdateRequest()
.data(
new ServiceNowTemplateUpdateRequestData()
.attributes(
new ServiceNowTemplateUpdateRequestAttributes()
.assignmentGroupId(
UUID.fromString("65b3341b-0680-47f9-a6d4-134db45c603e"))
.businessServiceId(
UUID.fromString("65b3341b-0680-47f9-a6d4-134db45c603e"))
.fieldsMapping(
Map.ofEntries(
Map.entry("category", "hardware"), Map.entry("priority", "2")))
.handleName("incident-template-updated")
.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.updateServiceNowTemplate(
UUID.fromString("65b3341b-0680-47f9-a6d4-134db45c603e"), body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling ServiceNowIntegrationApi#updateServiceNowTemplate");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}