-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathUpdateLogsCustomDestination_2034509257.java
More file actions
56 lines (51 loc) · 2.83 KB
/
UpdateLogsCustomDestination_2034509257.java
File metadata and controls
56 lines (51 loc) · 2.83 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
// Update a Splunk custom destination's destination preserves the null sourcetype returns "OK"
// response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.LogsCustomDestinationsApi;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestination;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationSplunk;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationSplunkType;
import com.datadog.api.client.v2.model.CustomDestinationResponse;
import com.datadog.api.client.v2.model.CustomDestinationType;
import com.datadog.api.client.v2.model.CustomDestinationUpdateRequest;
import com.datadog.api.client.v2.model.CustomDestinationUpdateRequestAttributes;
import com.datadog.api.client.v2.model.CustomDestinationUpdateRequestDefinition;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
LogsCustomDestinationsApi apiInstance = new LogsCustomDestinationsApi(defaultClient);
// there is a valid "custom_destination_splunk_with_null_sourcetype" in the system
String CUSTOM_DESTINATION_SPLUNK_WITH_NULL_SOURCETYPE_DATA_ID =
System.getenv("CUSTOM_DESTINATION_SPLUNK_WITH_NULL_SOURCETYPE_DATA_ID");
CustomDestinationUpdateRequest body =
new CustomDestinationUpdateRequest()
.data(
new CustomDestinationUpdateRequestDefinition()
.attributes(
new CustomDestinationUpdateRequestAttributes()
.forwarderDestination(
new CustomDestinationForwardDestination(
new CustomDestinationForwardDestinationSplunk()
.type(
CustomDestinationForwardDestinationSplunkType
.SPLUNK_HEC)
.endpoint("https://updated-example.com")
.accessToken("my-access-token"))))
.type(CustomDestinationType.CUSTOM_DESTINATION)
.id(CUSTOM_DESTINATION_SPLUNK_WITH_NULL_SOURCETYPE_DATA_ID));
try {
CustomDestinationResponse result =
apiInstance.updateLogsCustomDestination(
CUSTOM_DESTINATION_SPLUNK_WITH_NULL_SOURCETYPE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling LogsCustomDestinationsApi#updateLogsCustomDestination");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}