Search in sources :

Example 1 with JobFileItemList

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"));
    }
}
Also used : Command(org.rundeck.toolbelt.Command) CommandOutput(org.rundeck.toolbelt.CommandOutput) CommandLineInterface(com.lexicalscope.jewel.cli.CommandLineInterface) Option(com.lexicalscope.jewel.cli.Option) AppCommand(org.rundeck.client.tool.commands.AppCommand) JobFileItemList(org.rundeck.client.api.model.JobFileItemList) Client(org.rundeck.client.util.Client) IOException(java.io.IOException) JobFileUploadResult(org.rundeck.client.api.model.JobFileUploadResult) File(java.io.File) RequestBody(okhttp3.RequestBody) InputError(org.rundeck.client.tool.InputError) RdApp(org.rundeck.client.tool.RdApp) Paging(org.rundeck.client.api.model.Paging) RdTool(org.rundeck.client.tool.extension.RdTool) PagingResultOptions(org.rundeck.client.tool.options.PagingResultOptions) JobFileItem(org.rundeck.client.api.model.JobFileItem) InputError(org.rundeck.client.tool.InputError) Paging(org.rundeck.client.api.model.Paging) JobFileItemList(org.rundeck.client.api.model.JobFileItemList) Command(org.rundeck.toolbelt.Command) AppCommand(org.rundeck.client.tool.commands.AppCommand)

Aggregations

CommandLineInterface (com.lexicalscope.jewel.cli.CommandLineInterface)1 Option (com.lexicalscope.jewel.cli.Option)1 File (java.io.File)1 IOException (java.io.IOException)1 RequestBody (okhttp3.RequestBody)1 JobFileItem (org.rundeck.client.api.model.JobFileItem)1 JobFileItemList (org.rundeck.client.api.model.JobFileItemList)1 JobFileUploadResult (org.rundeck.client.api.model.JobFileUploadResult)1 Paging (org.rundeck.client.api.model.Paging)1 InputError (org.rundeck.client.tool.InputError)1 RdApp (org.rundeck.client.tool.RdApp)1 AppCommand (org.rundeck.client.tool.commands.AppCommand)1 RdTool (org.rundeck.client.tool.extension.RdTool)1 PagingResultOptions (org.rundeck.client.tool.options.PagingResultOptions)1 Client (org.rundeck.client.util.Client)1 Command (org.rundeck.toolbelt.Command)1 CommandOutput (org.rundeck.toolbelt.CommandOutput)1