From c9cf641188bad51cc214598e1816da880ee90d8b Mon Sep 17 00:00:00 2001 From: Anas Date: Thu, 17 Jun 2021 19:05:35 +0200 Subject: [PATCH] datadog_event : Adding api_host as an optional parameter (#2775) * 2774 Module datadog_event _ Adding api_host as an optional parameter * Update changelogs/fragments/2774-datadog_event_api_parameter.yml Co-authored-by: Felix Fontein * Update plugins/modules/monitoring/datadog/datadog_event.py Co-authored-by: Felix Fontein * Update datadog_event.py * Update datadog_event.py * Update datadog_event.py * Update datadog_event.py * Update datadog_event.py * Update datadog_event.py * Update datadog_event.py * Update datadog_event.py * Update plugins/modules/monitoring/datadog/datadog_event.py Co-authored-by: Felix Fontein * Update plugins/modules/monitoring/datadog/datadog_event.py Co-authored-by: Felix Fontein * Update plugins/modules/monitoring/datadog/datadog_event.py Co-authored-by: Felix Fontein * Update plugins/modules/monitoring/datadog/datadog_event.py Co-authored-by: Felix Fontein * Update plugins/modules/monitoring/datadog/datadog_event.py Co-authored-by: Amin Vakil * Update plugins/modules/monitoring/datadog/datadog_event.py Co-authored-by: Amin Vakil Co-authored-by: Anas Hamadeh Co-authored-by: Felix Fontein Co-authored-by: Amin Vakil --- .../2774-datadog_event_api_parameter.yml | 2 ++ .../monitoring/datadog/datadog_event.py | 23 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/2774-datadog_event_api_parameter.yml diff --git a/changelogs/fragments/2774-datadog_event_api_parameter.yml b/changelogs/fragments/2774-datadog_event_api_parameter.yml new file mode 100644 index 0000000000..6144b89400 --- /dev/null +++ b/changelogs/fragments/2774-datadog_event_api_parameter.yml @@ -0,0 +1,2 @@ +minor_changes: +- "datadog_event - adding parameter ``api_host`` to allow selecting a datadog API endpoint instead of using the default one (https://github.com/ansible-collections/community.general/issues/2774, https://github.com/ansible-collections/community.general/pull/2775)." diff --git a/plugins/modules/monitoring/datadog/datadog_event.py b/plugins/modules/monitoring/datadog/datadog_event.py index c3a3920aee..3f6500f11f 100644 --- a/plugins/modules/monitoring/datadog/datadog_event.py +++ b/plugins/modules/monitoring/datadog/datadog_event.py @@ -54,6 +54,11 @@ options: description: - Host name to associate with the event. - If not specified, it defaults to the remote system's hostname. + api_host: + type: str + description: + - DataDog API endpoint URL. + version_added: '3.3.0' tags: type: list elements: str @@ -90,6 +95,19 @@ EXAMPLES = ''' api_key: 9775a026f1ca7d1c6c5af9d94d9595a4 app_key: j4JyCYfefWHhgFgiZUqRm63AXHNZQyPGBfJtAzmN tags: 'aa,bb,#host:{{ inventory_hostname }}' + +- name: Post an event with several tags to another endpoint + community.general.datadog_event: + title: Testing from ansible + text: Test + api_key: 9775a026f1ca7d1c6c5af9d94d9595a4 + app_key: j4JyCYfefWHhgFgiZUqRm63AXHNZQyPGBfJtAzmN + api_host: 'https://example.datadoghq.eu' + tags: + - aa + - b + - '#host:{{ inventory_hostname }}' + ''' import platform @@ -113,6 +131,7 @@ def main(): argument_spec=dict( api_key=dict(required=True, no_log=True), app_key=dict(required=True, no_log=True), + api_host=dict(type='str'), title=dict(required=True), text=dict(required=True), date_happened=dict(type='int'), @@ -131,8 +150,10 @@ def main(): options = { 'api_key': module.params['api_key'], - 'app_key': module.params['app_key'] + 'app_key': module.params['app_key'], } + if module.params['api_host'] is not None: + options['api_host'] = module.params['api_host'] initialize(**options)