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

io.pivotal.services.plugin.tasks.helper.CfAppDetailsDelegate Maven / Gradle / Ivy

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

import io.pivotal.services.plugin.CfProperties;
import org.cloudfoundry.operations.CloudFoundryOperations;
import org.cloudfoundry.operations.applications.ApplicationDetail;
import org.cloudfoundry.operations.applications.GetApplicationRequest;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import reactor.core.publisher.Mono;

import java.util.Optional;

/**
 * Responsible for getting the details of an app
 *
 * @author Biju Kunjummen
 */
public class CfAppDetailsDelegate {

    private static final Logger LOGGER = Logging.getLogger(CfAppDetailsDelegate.class);

    public Mono> getAppDetails(
        CloudFoundryOperations cfOperations, CfProperties cfProperties) {
        Mono applicationDetailMono = cfOperations.applications()
            .get(GetApplicationRequest.builder().name(cfProperties.name()).build())
            .doOnSubscribe((c) -> {
                LOGGER.lifecycle("Checking details of app '{}'", cfProperties.name());
            });

        return applicationDetailMono
            .map(appDetail -> Optional.ofNullable(appDetail))
            .onErrorResume(Exception.class, e -> Mono.just(Optional.empty()));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy