io.pivotal.services.plugin.tasks.helper.CfServicesDetailHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ya-cf-app-gradle-plugin Show documentation
Show all versions of ya-cf-app-gradle-plugin Show documentation
Gradle Plugin to push an application to Cloud Foundry
package io.pivotal.services.plugin.tasks.helper;
import org.cloudfoundry.operations.CloudFoundryOperations;
import org.cloudfoundry.operations.services.GetServiceInstanceRequest;
import org.cloudfoundry.operations.services.ServiceInstance;
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 service instance given a service name
*/
public class CfServicesDetailHelper {
private static final Logger LOGGER = Logging.getLogger(CfServicesDetailHelper.class);
public Mono> getServiceInstanceDetail(CloudFoundryOperations cfOperations,
String serviceName) {
LOGGER.lifecycle("Checking details of service '{}'", serviceName);
Mono serviceInstanceMono = cfOperations.services()
.getInstance(
GetServiceInstanceRequest.builder()
.name(serviceName)
.build());
return serviceInstanceMono
.map(serviceInstance -> Optional.ofNullable(serviceInstance))
.onErrorResume(Exception.class, e -> Mono.just(Optional.empty()));
}
}