use of org.rundeck.client.api.model.JobFileItemList in project rundeck-cli by rundeck.
the class Files method list.
@Command(description = "List files uploaded for a Job or Execution (API v19). Specify Job ID or Execution ID")
public void list(FileListOpts opts, CommandOutput out) throws IOException, InputError {
if (!opts.isJobId() && !opts.isExecId() || opts.isExecId() && opts.isJobId()) {
throw new InputError("One of -j/--jobid or -e/--eid is required");
}
if (opts.isExecId() && opts.isFileState()) {
throw new InputError("-s/--state not a valid option for -e/--eid");
}
int offset = opts.isOffset() ? opts.getOffset() : 0;
int max = opts.isMax() ? opts.getMax() : 20;
JobFileItemList result;
if (opts.isJobId()) {
result = apiCall(api -> api.listJobFiles(opts.getJobId(), opts.isFileState() ? opts.getFileState().toString() : null, offset, max));
} else {
result = apiCall(api -> api.listExecutionFiles(opts.getExecId(), offset, max));
}
Paging paging = result.getPaging();
if (paging != null) {
out.info(paging);
}
out.output(result.asList());
if (paging != null && paging.hasMoreResults()) {
out.info(paging.moreResults("-o"));
}
}
Aggregations