Search in sources :

Example 1 with ServiceClient

use of org.rundeck.client.util.ServiceClient in project rundeck-cli by rundeck.

the class Archives method loopStatus.

public static boolean loopStatus(final ServiceClient<RundeckApi> client, final ProjectExportStatus status, String project, File outputfile, CommandOutput out, BooleanSupplier waitFunc) throws IOException {
    boolean done = false;
    int perc = status.getPercentage();
    while (!done) {
        ProjectExportStatus status1 = client.apiCall(api -> api.exportProjectStatus(project, status.getToken()));
        if (status1.getPercentage() > perc) {
            out.output(".");
            perc = status1.getPercentage();
        }
        done = status1.getReady();
        if (!done && !waitFunc.getAsBoolean()) {
            break;
        }
    }
    if (done) {
        receiveArchiveFile(out, client.apiCall(api -> api.exportProjectDownload(project, status.getToken())), outputfile);
    }
    return done;
}
Also used : Command(org.rundeck.toolbelt.Command) CommandOutput(org.rundeck.toolbelt.CommandOutput) CommandLineInterface(com.lexicalscope.jewel.cli.CommandLineInterface) ProjectExportStatus(org.rundeck.client.api.model.ProjectExportStatus) ProjectImportStatus(org.rundeck.client.api.model.ProjectImportStatus) Util(org.rundeck.client.util.Util) Option(com.lexicalscope.jewel.cli.Option) AppCommand(org.rundeck.client.tool.commands.AppCommand) ProjectNameOptions(org.rundeck.client.tool.options.ProjectNameOptions) FileOutputStream(java.io.FileOutputStream) Set(java.util.Set) Client(org.rundeck.client.util.Client) IOException(java.io.IOException) File(java.io.File) RequestBody(okhttp3.RequestBody) BooleanSupplier(java.util.function.BooleanSupplier) HashSet(java.util.HashSet) InputError(org.rundeck.client.tool.InputError) RdApp(org.rundeck.client.tool.RdApp) List(java.util.List) ServiceClient(org.rundeck.client.util.ServiceClient) RundeckApi(org.rundeck.client.api.RundeckApi) ResponseBody(okhttp3.ResponseBody) InputStream(java.io.InputStream) ProjectExportStatus(org.rundeck.client.api.model.ProjectExportStatus)

Aggregations

CommandLineInterface (com.lexicalscope.jewel.cli.CommandLineInterface)1 Option (com.lexicalscope.jewel.cli.Option)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 BooleanSupplier (java.util.function.BooleanSupplier)1 RequestBody (okhttp3.RequestBody)1 ResponseBody (okhttp3.ResponseBody)1 RundeckApi (org.rundeck.client.api.RundeckApi)1 ProjectExportStatus (org.rundeck.client.api.model.ProjectExportStatus)1 ProjectImportStatus (org.rundeck.client.api.model.ProjectImportStatus)1 InputError (org.rundeck.client.tool.InputError)1 RdApp (org.rundeck.client.tool.RdApp)1 AppCommand (org.rundeck.client.tool.commands.AppCommand)1 ProjectNameOptions (org.rundeck.client.tool.options.ProjectNameOptions)1 Client (org.rundeck.client.util.Client)1