Skip to content

Commit

Permalink
Re-work
Browse files Browse the repository at this point in the history
Signed-off-by: Alina Buzachis <[email protected]>
  • Loading branch information
alinabuzachis committed Oct 9, 2024
1 parent 3f64ad6 commit 75f0148
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
25 changes: 7 additions & 18 deletions plugins/modules/event_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,12 @@
type: str
default: ''
version_added: 2.1.0
test_mode:
forward_events:
description:
- Enable the event stream to forward events to the rulebook activation where it is configured.
- The O(forward_events) alias has been deprecated and will be removed in release 4.0.0.
type: bool
default: true
version_added: 2.1.0
aliases:
- forward_events
state:
description:
- Desired state of the resource.
Expand Down Expand Up @@ -120,8 +117,11 @@ def create_params(module: AnsibleModule, controller: Controller) -> dict[str, An
if module.params.get("event_stream_type"):
credential_params["event_stream_type"] = module.params["event_stream_type"]

if module.params.get("test_mode") is not None:
credential_params["test_mode"] = module.params["test_mode"]
if module.params.get("forward_events") is not None:
if module.params["forward_events"]:
credential_params["test_mode"] = False
else:
credential_params["test_mode"] = True

if module.params.get("headers"):
credential_params["additional_data_headers"] = module.params["headers"]
Expand Down Expand Up @@ -159,18 +159,7 @@ def main() -> None:
organization_name=dict(type="str", aliases=["organization"]),
event_stream_type=dict(type="str", aliases=["type"]),
headers=dict(type="str", default=""),
test_mode=dict(
type="bool",
default=True,
aliases=["forward_events"],
deprecated_aliases=[
dict(
name="forward_events",
version="4.0.0",
collection_name="ansible.eda",
)
],
),
forward_events=dict(type="bool", default=True),
state=dict(choices=["present", "absent"], default="present"),
)

Expand Down
10 changes: 5 additions & 5 deletions tests/integration/targets/event_stream/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
name: "{{ event_stream_name }}"
credential_name: "{{ credential_name }}"
organization_name: Default
test_mode: false
forward_events: false
event_stream_type: Basic Event Stream
check_mode: true
register: _result
Expand Down Expand Up @@ -133,15 +133,15 @@
that:
- _result.event_streams[0].name == new_event_stream_name

- name: Update event stream headers and test_mode
- name: Update event stream headers and forward_events
ansible.eda.event_stream:
state: present
name: "{{ new_event_stream_name }}"
credential_name: "{{ credential_name }}"
organization_name: Default
event_stream_type: "Basic Event Stream"
headers: "Authorization,Custom-Header"
test_mode: false
forward_events: false
register: _result

- name: Check event stream is updated
Expand All @@ -154,12 +154,12 @@
name: "{{ new_event_stream_name }}"
register: _result

- name: Check if event stream headers and test_mode are updated
- name: Check if event stream headers and forward_events are updated
assert:
that:
- _result.event_streams[0].name == new_event_stream_name
- _result.event_streams[0].additional_data_headers == "Authorization,Custom-Header"
- _result.event_streams[0].test_mode == False
- _result.event_streams[0].forward_events == True

- name: List all event stream
ansible.eda.event_stream_info:
Expand Down

0 comments on commit 75f0148

Please sign in to comment.