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

io.pivotal.services.plugin.tasks.CfCreateServicesTask 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.CfCreateServiceHelper;
import io.pivotal.services.plugin.tasks.helper.CfCreateUserProvidedServiceHelper;
import org.cloudfoundry.operations.CloudFoundryOperations;
import org.cloudfoundry.operations.applications.ApplicationDetail;
import org.gradle.api.tasks.TaskAction;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.List;
import java.util.stream.Collectors;

/**
 * Responsible for creating the list of services
 *
 * @author Biju Kunjummen
 */
public class CfCreateServicesTask extends AbstractCfTask {

    private CfCreateServiceHelper createServiceHelper = new CfCreateServiceHelper();
    private CfCreateUserProvidedServiceHelper userProvidedServiceHelper = new CfCreateUserProvidedServiceHelper();

    @TaskAction
    public void cfCreateServiceTask() {

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

        List> createServicesResult = cfProperties.cfServices()
            .stream()
            .map(service -> createServiceHelper.createService(cfOperations, service).then())
            .collect(Collectors.toList());

        List> createUserProvidedServicesResult = cfProperties.cfUserProvidedServices()
            .stream()
            .map(service -> userProvidedServiceHelper.createUserProvidedService(cfOperations, service))
            .collect(Collectors.toList());

        Flux.merge(createServicesResult).toIterable().forEach(r -> {
        });
        Flux.merge(createUserProvidedServicesResult).toIterable().forEach(r -> {
        });
    }

    @Override
    public String getDescription() {
        return "Create a set of services";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy