org.cloudfoundry.operations.applications.GetApplicationRequest Java Examples

The following examples show how to use org.cloudfoundry.operations.applications.GetApplicationRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloudFoundryService.java    From spring-cloud-app-broker with Apache License 2.0 6 votes vote down vote up
public Mono<Void> updateBrokerApp(String appName, String brokerClientId, List<String> appBrokerProperties) {
	return cloudFoundryOperations.applications().get(GetApplicationRequest.builder().name(appName).build())
		.map(ApplicationDetail::getId)
		.flatMap(applicationId -> cloudFoundryClient.applicationsV2().update(UpdateApplicationRequest
			.builder()
			.applicationId(applicationId)
			.putAllEnvironmentJsons(appBrokerDeployerEnvironmentVariables(brokerClientId))
			.putAllEnvironmentJsons(propertiesToEnvironment(appBrokerProperties))
			.name(appName)
			.memory(1024)
			.build())
			.thenReturn(applicationId))
		.then(cloudFoundryOperations.applications().restart(RestartApplicationRequest.builder()
			.name(appName)
			.build()))
		.doOnSuccess(item -> LOG.info("Updated broker app " + appName))
		.doOnError(error -> LOG.error("Error updating broker app " + appName + ": " + error))
		.then();
}
 
Example #2
Source File: CloudFoundryService.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
public Mono<String> getApplicationRoute(String appName) {
	return cloudFoundryOperations.applications().get(GetApplicationRequest.builder()
		.name(appName)
		.build())
		.doOnSuccess(item -> LOG.info("Success getting route for app. appName={}", appName))
		.doOnError(e -> LOG.error(String.format("Error getting route for app. appName=%s, error=%s", appName,
			e.getMessage()), e))
		.map(ApplicationDetail::getUrls)
		.flatMapMany(Flux::fromIterable)
		.next()
		.map(url -> "https://" + url);
}
 
Example #3
Source File: CloudFoundryManifestApplicationDeployer.java    From spring-cloud-skipper with Apache License 2.0 5 votes vote down vote up
public Mono<AppStatus> getStatus(String applicationName, String platformName) {
	GetApplicationRequest getApplicationRequest = GetApplicationRequest.builder().name(applicationName).build();
	return this.platformCloudFoundryOperations.getCloudFoundryOperations(platformName)
			.applications().get(getApplicationRequest)
			.map(applicationDetail -> createAppStatus(applicationDetail, applicationName))
			.onErrorResume(IllegalArgumentException.class, t -> {
				logger.debug("Application for {} does not exist.", applicationName);
				return Mono.just(createEmptyAppStatus(applicationName));
			})
			.onErrorResume(Throwable.class, t -> {
				logger.error("Error: " + t);
				return Mono.just(createErrorAppStatus(applicationName));
			});
}
 
Example #4
Source File: CfAppDetailsDelegate.java    From ya-cf-app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
public Mono<Optional<ApplicationDetail>> getAppDetails(
    CloudFoundryOperations cfOperations, CfProperties cfProperties) {
    Mono<ApplicationDetail> 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()));
}
 
Example #5
Source File: CloudFoundryTaskLauncherTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
private void givenRequestGetApplication(String name, Mono<ApplicationDetail> response) {
	given(this.operations.applications()
		.get(GetApplicationRequest.builder()
			.name(name)
			.build()))
		.willReturn(response);
}
 
Example #6
Source File: CloudFoundryService.java    From spring-cloud-cloudfoundry with Apache License 2.0 5 votes vote down vote up
public Flux<Tuple2<ApplicationDetail, InstanceDetail>> getApplicationInstances(
		String serviceId) {
	GetApplicationRequest applicationRequest = GetApplicationRequest.builder()
			.name(serviceId).build();
	return this.cloudFoundryOperations.applications().get(applicationRequest)
			.flatMapMany(applicationDetail -> {
				Flux<InstanceDetail> ids = Flux
						.fromStream(applicationDetail.getInstanceDetails().stream())
						.filter(id -> id.getState().equalsIgnoreCase("RUNNING"));
				Flux<ApplicationDetail> generate = Flux
						.generate(sink -> sink.next(applicationDetail));
				return generate.zipWith(ids);
			});
}
 
Example #7
Source File: CloudFoundryService.java    From spring-cloud-app-broker with Apache License 2.0 4 votes vote down vote up
public Mono<ApplicationDetail> getApplication(String appName) {
	return cloudFoundryOperations.applications().get(GetApplicationRequest.builder()
		.name(appName)
		.build());
}
 
Example #8
Source File: CfGetDetailsTaskDelegateTest.java    From ya-cf-app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetDetailsNoException() {
    CloudFoundryOperations cfOperations = mock(CloudFoundryOperations.class);
    CfProperties cfAppProperties = sampleApp();

    ApplicationDetail appDetail = sampleApplicationDetail();

    Applications mockApplications = mock(Applications.class);
    when(cfOperations.applications()).thenReturn(mockApplications);

    when(mockApplications.get(any(GetApplicationRequest.class))).thenReturn(Mono.just(appDetail));

    Mono<Optional<ApplicationDetail>> appDetailsMono = detailsTaskDelegate.getAppDetails(cfOperations, cfAppProperties);

    assertThat(appDetailsMono.block().isPresent()).isTrue();
}
 
Example #9
Source File: CfGetDetailsTaskDelegateTest.java    From ya-cf-app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetDetailsNoApplication() {
    CloudFoundryOperations cfOperations = mock(CloudFoundryOperations.class);
    CfProperties cfAppProperties = sampleApp();

    Applications mockApplications = mock(Applications.class);
    when(cfOperations.applications()).thenReturn(mockApplications);

    when(mockApplications.get(any(GetApplicationRequest.class))).thenReturn(Mono.error(new RuntimeException("No such app")));

    Mono<Optional<ApplicationDetail>> appDetailsMono = detailsTaskDelegate.getAppDetails(cfOperations, cfAppProperties);

    Optional<ApplicationDetail> appDetailOptional = appDetailsMono.block();

    assertThat(appDetailOptional.isPresent()).isFalse();
}
 
Example #10
Source File: CloudFoundryTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private Mono<ApplicationDetail> requestGetApplication(String name) {
	return this.operations.applications()
		.get(GetApplicationRequest.builder()
			.name(name)
			.build());
}
 
Example #11
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private Mono<ApplicationDetail> getApplicationDetail(String id) {
	return this.operations.applications()
		.get(GetApplicationRequest.builder()
			.name(id)
			.build());
}
 
Example #12
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void givenRequestGetApplication(String id, Mono<ApplicationDetail> response,
	Mono<ApplicationDetail>... responses) {
	given(this.operations.applications().get(GetApplicationRequest.builder().name(id).build())).willReturn(response,
		responses);
}