def main():
    module = AnsibleModule(
        supports_check_mode=True,
        argument_spec=dict(
            arguments.get_spec("auth"),
            name=dict(),  # Name is not required in info modules.
        ),
    )

    client = arguments.get_sensu_client(module.params["auth"])
    path = utils.build_url_path(
        API_GROUP,
        API_VERSION,
        None,
        "provider",
        module.params["name"],
    )

    try:
        stores = utils.prepare_result_list(utils.get(client, path))
    except errors.Error as e:
        module.fail_json(msg=str(e))

    # We simulate the behavior of v2 API here and only return the spec.
    module.exit_json(
        changed=False,
        objects=[utils.convert_v1_to_v2_response(s) for s in stores])
Ejemplo n.º 2
0
 def test_add_metadata_from_toplevel(self):
     assert utils.convert_v1_to_v2_response(
         dict(
             metadata=dict(name="sample"),
             spec=dict(a=1, b=2),
         )) == dict(metadata=dict(name="sample"), a=1, b=2)
Ejemplo n.º 3
0
 def test_spec_only_if_metadata_is_missing(self):
     assert utils.convert_v1_to_v2_response(dict(spec=dict(
         a=1, b=2), )) == dict(a=1, b=2)
Ejemplo n.º 4
0
 def test_none_passes_through(self):
     assert utils.convert_v1_to_v2_response(None) is None
Ejemplo n.º 5
0
def _get(client, path):
    return utils.convert_v1_to_v2_response(utils.get(client, path))