|
| 1 | +// Update a Splunk custom destination's destination preserves the null sourcetype returns "OK" |
| 2 | +// response |
| 3 | + |
| 4 | +import com.datadog.api.client.ApiClient; |
| 5 | +import com.datadog.api.client.ApiException; |
| 6 | +import com.datadog.api.client.v2.api.LogsCustomDestinationsApi; |
| 7 | +import com.datadog.api.client.v2.model.CustomDestinationForwardDestination; |
| 8 | +import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationSplunk; |
| 9 | +import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationSplunkType; |
| 10 | +import com.datadog.api.client.v2.model.CustomDestinationResponse; |
| 11 | +import com.datadog.api.client.v2.model.CustomDestinationType; |
| 12 | +import com.datadog.api.client.v2.model.CustomDestinationUpdateRequest; |
| 13 | +import com.datadog.api.client.v2.model.CustomDestinationUpdateRequestAttributes; |
| 14 | +import com.datadog.api.client.v2.model.CustomDestinationUpdateRequestDefinition; |
| 15 | + |
| 16 | +public class Example { |
| 17 | + public static void main(String[] args) { |
| 18 | + ApiClient defaultClient = ApiClient.getDefaultApiClient(); |
| 19 | + LogsCustomDestinationsApi apiInstance = new LogsCustomDestinationsApi(defaultClient); |
| 20 | + |
| 21 | + // there is a valid "custom_destination_splunk_with_null_sourcetype" in the system |
| 22 | + String CUSTOM_DESTINATION_SPLUNK_WITH_NULL_SOURCETYPE_DATA_ID = |
| 23 | + System.getenv("CUSTOM_DESTINATION_SPLUNK_WITH_NULL_SOURCETYPE_DATA_ID"); |
| 24 | + |
| 25 | + CustomDestinationUpdateRequest body = |
| 26 | + new CustomDestinationUpdateRequest() |
| 27 | + .data( |
| 28 | + new CustomDestinationUpdateRequestDefinition() |
| 29 | + .attributes( |
| 30 | + new CustomDestinationUpdateRequestAttributes() |
| 31 | + .forwarderDestination( |
| 32 | + new CustomDestinationForwardDestination( |
| 33 | + new CustomDestinationForwardDestinationSplunk() |
| 34 | + .type( |
| 35 | + CustomDestinationForwardDestinationSplunkType |
| 36 | + .SPLUNK_HEC) |
| 37 | + .endpoint("https://updated-example.com") |
| 38 | + .accessToken("my-access-token")))) |
| 39 | + .type(CustomDestinationType.CUSTOM_DESTINATION) |
| 40 | + .id(CUSTOM_DESTINATION_SPLUNK_WITH_NULL_SOURCETYPE_DATA_ID)); |
| 41 | + |
| 42 | + try { |
| 43 | + CustomDestinationResponse result = |
| 44 | + apiInstance.updateLogsCustomDestination( |
| 45 | + CUSTOM_DESTINATION_SPLUNK_WITH_NULL_SOURCETYPE_DATA_ID, body); |
| 46 | + System.out.println(result); |
| 47 | + } catch (ApiException e) { |
| 48 | + System.err.println( |
| 49 | + "Exception when calling LogsCustomDestinationsApi#updateLogsCustomDestination"); |
| 50 | + System.err.println("Status code: " + e.getCode()); |
| 51 | + System.err.println("Reason: " + e.getResponseBody()); |
| 52 | + System.err.println("Response headers: " + e.getResponseHeaders()); |
| 53 | + e.printStackTrace(); |
| 54 | + } |
| 55 | + } |
| 56 | +} |
0 commit comments