|
| 1 | +""" |
| 2 | +Update a Splunk custom destination's destination preserves the null sourcetype returns "OK" response |
| 3 | +""" |
| 4 | + |
| 5 | +from os import environ |
| 6 | +from datadog_api_client import ApiClient, Configuration |
| 7 | +from datadog_api_client.v2.api.logs_custom_destinations_api import LogsCustomDestinationsApi |
| 8 | +from datadog_api_client.v2.model.custom_destination_forward_destination_splunk import ( |
| 9 | + CustomDestinationForwardDestinationSplunk, |
| 10 | +) |
| 11 | +from datadog_api_client.v2.model.custom_destination_forward_destination_splunk_type import ( |
| 12 | + CustomDestinationForwardDestinationSplunkType, |
| 13 | +) |
| 14 | +from datadog_api_client.v2.model.custom_destination_type import CustomDestinationType |
| 15 | +from datadog_api_client.v2.model.custom_destination_update_request import CustomDestinationUpdateRequest |
| 16 | +from datadog_api_client.v2.model.custom_destination_update_request_attributes import ( |
| 17 | + CustomDestinationUpdateRequestAttributes, |
| 18 | +) |
| 19 | +from datadog_api_client.v2.model.custom_destination_update_request_definition import ( |
| 20 | + CustomDestinationUpdateRequestDefinition, |
| 21 | +) |
| 22 | + |
| 23 | +# there is a valid "custom_destination_splunk_with_null_sourcetype" in the system |
| 24 | +CUSTOM_DESTINATION_SPLUNK_WITH_NULL_SOURCETYPE_DATA_ID = environ[ |
| 25 | + "CUSTOM_DESTINATION_SPLUNK_WITH_NULL_SOURCETYPE_DATA_ID" |
| 26 | +] |
| 27 | + |
| 28 | +body = CustomDestinationUpdateRequest( |
| 29 | + data=CustomDestinationUpdateRequestDefinition( |
| 30 | + attributes=CustomDestinationUpdateRequestAttributes( |
| 31 | + forwarder_destination=CustomDestinationForwardDestinationSplunk( |
| 32 | + type=CustomDestinationForwardDestinationSplunkType.SPLUNK_HEC, |
| 33 | + endpoint="https://updated-example.com", |
| 34 | + access_token="my-access-token", |
| 35 | + ), |
| 36 | + ), |
| 37 | + type=CustomDestinationType.CUSTOM_DESTINATION, |
| 38 | + id=CUSTOM_DESTINATION_SPLUNK_WITH_NULL_SOURCETYPE_DATA_ID, |
| 39 | + ), |
| 40 | +) |
| 41 | + |
| 42 | +configuration = Configuration() |
| 43 | +with ApiClient(configuration) as api_client: |
| 44 | + api_instance = LogsCustomDestinationsApi(api_client) |
| 45 | + response = api_instance.update_logs_custom_destination( |
| 46 | + custom_destination_id=CUSTOM_DESTINATION_SPLUNK_WITH_NULL_SOURCETYPE_DATA_ID, body=body |
| 47 | + ) |
| 48 | + |
| 49 | + print(response) |
0 commit comments