All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.pivotal.services.plugin.tasks.CfAppDetailsTask Maven / Gradle / Ivy

There is a newer version: 2.3.0-rc.6
Show newest version
package io.pivotal.services.plugin.tasks;

import io.pivotal.services.plugin.CfProperties;
import io.pivotal.services.plugin.tasks.helper.CfAppDetailsDelegate;
import org.cloudfoundry.operations.CloudFoundryOperations;
import org.cloudfoundry.operations.applications.ApplicationDetail;
import org.gradle.api.tasks.TaskAction;
import reactor.core.publisher.Mono;

import java.time.Duration;
import java.util.Optional;

/**
 * Responsible for exposing the details of an application
 *
 * @author Biju Kunjummen
 */
public class CfAppDetailsTask extends AbstractCfTask {

    private CfAppDetailsDelegate detailsTaskDelegate = new CfAppDetailsDelegate();

    @TaskAction
    public void appDetails() {

        CloudFoundryOperations cfOperations = getCfOperations();
        CfProperties cfProperties = getCfProperties();

        Mono> resp = detailsTaskDelegate.getAppDetails(cfOperations, cfProperties);

        Optional applicationDetail = resp.block(Duration.ofMillis(defaultWaitTimeout));

        setApplicationDetail(applicationDetail.orElseThrow(() -> new IllegalArgumentException("No application found")));
    }

    private void setApplicationDetail(ApplicationDetail applicationDetail) {
        this.getExtension().setApplicationDetail(applicationDetail);
    }

    @Override
    public String getDescription() {
        return "Get the application detail from Cloud Foundry";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy