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

io.pivotal.services.plugin.tasks.helper.CfMapRouteDelegate 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.routes.MapRouteRequest;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import reactor.core.publisher.Mono;

/**
 * Helper class for mapping a route
 *
 * @author Biju Kunjummen
 */
public class CfMapRouteDelegate {

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

    public Mono mapRoute(CloudFoundryOperations cfOperations,
                               CfProperties cfProperties) {

        Mono resp = cfOperations.routes()
            .map(MapRouteRequest
                .builder()
                .applicationName(cfProperties.name())
                .domain(cfProperties.domain())
                .host(cfProperties.host())
                .path(cfProperties.path()).build()).then().doOnSubscribe((s) -> {
                LOGGER.lifecycle("Mapping hostname '{}' in domain '{}' with path '{}' of app '{}'", cfProperties.host(),
                    cfProperties.domain(), cfProperties.path(), cfProperties.name());
            });

        return resp;

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy