From 8d84a612f537b255bc2071c4c4e23528bf1d3e3c Mon Sep 17 00:00:00 2001 From: Paul Hewlett Date: Thu, 28 Apr 2022 09:56:57 +0100 Subject: [PATCH] Add LOCATIONS_LIST to yaml runner Problem: Action LOCATIONS_LIST is missing from yaml runner. Solution: Added LOCATIONS_LIST and used the synsation functest as demomnstration. Signed-off-by: Paul Hewlett --- archivist/runner.py | 7 +++++++ docs/runner/index.rst | 1 + docs/runner/locations_list.rst | 19 +++++++++++++++++++ .../synsation_story.values.yaml | 3 --- .../test_resources/synsation_story.yaml.j2 | 13 +++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 docs/runner/locations_list.rst diff --git a/archivist/runner.py b/archivist/runner.py index 92ff0ecf..b6c1b20f 100644 --- a/archivist/runner.py +++ b/archivist/runner.py @@ -138,6 +138,13 @@ def __init__(self, archivist: "type_helper.Archivist"): "keywords": ("confirm",), "set_location_label": True, } + self["LOCATIONS_LIST"] = { + "action": archivist.locations.list, + "keywords": ( + "props", + "attrs", + ), + } self["LOCATIONS_READ"] = { "action": archivist.locations.read, "use_location_label": "add_arg_identity", diff --git a/docs/runner/index.rst b/docs/runner/index.rst index 1c9df32d..0de26bb0 100644 --- a/docs/runner/index.rst +++ b/docs/runner/index.rst @@ -67,6 +67,7 @@ For further reading: events_list locations_count locations_create + locations_list subjects_count.rst subjects_create.rst subjects_create_b64.rst diff --git a/docs/runner/locations_list.rst b/docs/runner/locations_list.rst new file mode 100644 index 00000000..7837dbea --- /dev/null +++ b/docs/runner/locations_list.rst @@ -0,0 +1,19 @@ +.. _locations_list_yamlref: + +Locations List Story Runner YAML +......................................... + +List all locations that match criteria.. + +Setting :code:`print_response: true` is necessary to print the full result. + +.. code-block:: yaml + + --- + steps: + - step: + action: LOCATIONS_LIST + description: List locations for which John Smith is director + print_response: true + attrs: + director: John Smith diff --git a/functests/test_resources/synsation_story.values.yaml b/functests/test_resources/synsation_story.values.yaml index c566db42..09e1d3cf 100644 --- a/functests/test_resources/synsation_story.values.yaml +++ b/functests/test_resources/synsation_story.values.yaml @@ -9,9 +9,6 @@ locations: facility_type: Satellite Office reception_email: reception_CT@synsation_io reception_phone: +27 (21) 123-456 - action: LOCATIONS_CREATE_IF_NOT_EXISTS - description: Create Asia Location - location_label: Asia Regional Sales Office - display_name: Asia Regional Sales Office description: Asia Regional Sales Headquarters latitude: 18.52027778 diff --git a/functests/test_resources/synsation_story.yaml.j2 b/functests/test_resources/synsation_story.yaml.j2 index 827d8c86..5ae449f4 100644 --- a/functests/test_resources/synsation_story.yaml.j2 +++ b/functests/test_resources/synsation_story.yaml.j2 @@ -29,6 +29,19 @@ steps: reception_email: {{ location.attributes.reception_email }} reception_phone: {{ location.attributes.reception_phone }} {% endfor %} + - step: + action: LOCATIONS_COUNT + description: Count locations in namespace + print_response: true + attrs: + namespace: "{{ env['ARCHIVIST_NAMESPACE'] or 'namespace' }}" + + - step: + action: LOCATIONS_LIST + description: List locations in namespace + print_response: true + attrs: + namespace: "{{ env['ARCHIVIST_NAMESPACE'] or 'namespace' }}" {% for asset in assets %} - step: