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])
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)
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)
def test_none_passes_through(self): assert utils.convert_v1_to_v2_response(None) is None
def _get(client, path): return utils.convert_v1_to_v2_response(utils.get(client, path))