def do_list_artifact(args, config): """ Lists out all the state associating with the UUIDs in the Transaction Family : Artifact Args: config (ConfigParser): ConfigParser which contains the default url Returns: type: str String representing JSON object which allows the client to know that the call was either a success or a failure. Raises: ArtifactException: * If failed to retrieve the list """ b_url = config.get("DEFAULT", "url") client = ArtifactBatch(base_url=b_url) result = client.list_artifact() if result is not None: result.sort(key=lambda x: x["timestamp"], reverse=True) result = json.dumps(result) output = ret_msg("success", "OK", "ListOf:ArtifactRecord", result) print(output) else: raise ArtifactException("Could not retrieve artifact listing.")
def do_list_artifact(args, config): url = config.get('DEFAULT', 'url') client = ArtifactBatch(base_url=url) result = client.list_artifact() if (result is not None): result = refine_output_artifact(str(result)) result = amend_artifact_fields(result) output = ret_msg("success","OK","ListOf:ArtifactRecord",result) print(output) else: raise ArtifactException("Could not retrieve artifact listing")
def api_do_list_artifact(config): """ API version of "do_list_artifact" function. """ b_url = config.get("DEFAULT", "url") client = ArtifactBatch(base_url=b_url) artifact_list = client.list_artifact() if artifact_list is not None: artifact_list.sort(key=lambda x: x["timestamp"], reverse=True) result = json.dumps(artifact_list) output = ret_msg("success", "OK", "ListOf:ArtifactRecord", result) return output else: return ret_msg( "failed", "ArtifactException : Could not retrieve artifact listing.", "ArtifactRecord", "{}")