#' Get workflow and call-level metadata for a specified workflow
#'
#' @param x Cromwell API endpoint of \code{WorkflowIdAndStatus} object.
#' @param ... not used
#'
#' @return
#'
#' @examples
#' \dontrun{
#' host <- "http://localhost:8000"
#' workflow <- system.file("extdata/workflow.wdl", package = "CromwellClient")
#' inputs <- system.file("extdata/inputs.json", package = "CromwellClient")
#' job <- submit(host, workflow, inputs)
#' status(job)
#' }
#'
#' @rdname metadata
#' @export
metadata <- function(x, ...)
{
UseMethod("metadata", x)
}
#' @param id A workflow ID.
#' @param version Cromwell API Version.
#' @param includeKey When specified key(s) to include from the metadata.
#' Matches any key starting with the value. May not be used with excludeKey.
#' This applies to all keys in the response, including within nested blocks.
#' @param excludeKey When specified key(s) to exclude from the metadata.
#' Matches any key starting with the value. May not be used with includeKey.
#' This applies to all keys in the response, including within nested blocks.
#' @param expandSubWorkflows When true, metadata for sub workflows will be
#' fetched and inserted automatically in the metadata response.
#' @param ...
#'
#' @rdname metadata
#' @export
metadata.character <- function(x, id, version = "v1", includeKey = NULL, excludeKey = NULL, expandSubWorkflows = FALSE, ...)
{
url <- file.path(x, "api/workflows", version, id, "metadata")
query <- list(includeKey = includeKey, excludeKey = excludeKey, expandSubWorkflows = expandSubWorkflows)
response <- httr::GET(url, query = query, cromwellAgent())
if (httr::http_error(response)) {
stop(paste0("Cromwell API request failed.
Code: ", httr::status_code(response), "
Message: ", jsonlite::fromJSON(httr::content(response, "text"))$message), call. = FALSE)
}
if (httr::http_type(response) != "application/json") {
stop("API did not return json", call. = FALSE)
}
content <- jsonlite::fromJSON(httr::content(response, "text"))
structure(
list(
workflowName = content$workflowName,
submittedFiles = content$submittedFiles,
workflowRoot = content$workflowRoot,
workflowLog = content$workflowLog,
id = content$id,
submission = content$submission,
status = content$status,
start = content$start,
end = content$end,
inputs = content$inputs,
outputs = content$outputs,
labels = content$labels,
calls = content$calls,
failures = content$failures
),
class = "WorkflowMetadataResponse"
)
}
#' @param includeKey When specified key(s) to include from the metadata.
#' Matches any key starting with the value. May not be used with excludeKey.
#' This applies to all keys in the response, including within nested blocks.
#' @param excludeKey When specified key(s) to exclude from the metadata.
#' Matches any key starting with the value. May not be used with includeKey.
#' This applies to all keys in the response, including within nested blocks.
#' @param expandSubWorkflows When true, metadata for sub workflows will be
#' fetched and inserted automatically in the metadata response.
#' @rdname metadata
#' @export
metadata.WorkflowIdAndStatus <- function(x, includeKey = NULL, excludeKey = NULL, expandSubWorkflows = FALSE, ...)
{
metadata(x = x$host, id = x$id, version = x$version)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.