org.cloudfoundry.operations.applications.DeleteApplicationRequest Java Examples

The following examples show how to use org.cloudfoundry.operations.applications.DeleteApplicationRequest. 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: DeleteAppPolicyExecutorTask.java    From cf-butler with Apache License 2.0 6 votes vote down vote up
protected Mono<HistoricalRecord> deleteApplication(AppDetail detail) {
	return DefaultCloudFoundryOperations.builder()
            .from(opsClient)
            .organization(detail.getOrganization())
            .space(detail.getSpace())
            .build()
.applications()
	.delete(
			DeleteApplicationRequest
				.builder()
					.name(detail.getAppName())
					.deleteRoutes(true)
					.build())
	.then(Mono.just(HistoricalRecord
				.builder()
					.transactionDateTime(LocalDateTime.now())
					.actionTaken("delete")
					.organization(detail.getOrganization())
					.space(detail.getSpace())
					.appId(detail.getAppId())
					.type("application")
					.name(detail.getAppName())
					.build()));
}
 
Example #2
Source File: CloudFoundryManifestApplicationDeployer.java    From spring-cloud-skipper with Apache License 2.0 6 votes vote down vote up
public Release delete(Release release) {
	ApplicationManifest applicationManifest = CloudFoundryApplicationManifestUtils.updateApplicationName(release);
	String applicationName = applicationManifest.getName();
	DeleteApplicationRequest deleteApplicationRequest = DeleteApplicationRequest.builder().name(applicationName)
			.build();
	this.platformCloudFoundryOperations.getCloudFoundryOperations(release.getPlatformName()).applications()
			.delete(deleteApplicationRequest)
			.timeout(DELETE_REQUEST_TIMEOUT)
			.doOnSuccess(v -> logger.info("Successfully undeployed app {}", applicationName))
			.doOnError(e -> logger.error("Failed to undeploy app %s", applicationName))
			.block();
	Status deletedStatus = new Status();
	deletedStatus.setStatusCode(StatusCode.DELETED);
	release.getInfo().setStatus(deletedStatus);
	release.getInfo().setDescription("Delete complete");
	return release;
}
 
Example #3
Source File: CloudFoundryDeleteStep.java    From spring-cloud-skipper with Apache License 2.0 6 votes vote down vote up
public Release delete(Release release, AppDeployerData existingAppDeployerData,
		List<String> applicationNamesToDelete) {
	ApplicationManifest applicationManifest = CloudFoundryApplicationManifestUtils.updateApplicationName(release);
	String applicationName = applicationManifest.getName();
	DeleteApplicationRequest deleteApplicationRequest = DeleteApplicationRequest.builder().name(applicationName)
			.build();
	this.platformCloudFoundryOperations.getCloudFoundryOperations(release.getPlatformName()).applications()
			.delete(deleteApplicationRequest)
			.doOnSuccess(v -> logger.info("Successfully undeployed app {}", applicationName))
			.doOnError(e -> logger.error("Failed to undeploy app %s", applicationName)).block();

	Status deletedStatus = new Status();
	deletedStatus.setStatusCode(StatusCode.DELETED);
	release.getInfo().setStatus(deletedStatus);
	release.getInfo().setDescription("Delete complete");
	this.releaseRepository.save(release);
	return release;
}
 
Example #4
Source File: SpringCloudSchedulerIntegrationTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
/**
 * Remove all pushed apps.  This in turn removes the associated schedules.
 */
@After
public void tearDown() {
	try {
		operations.applications().list().flatMap(applicationSummary -> {
			if (applicationSummary.getName().startsWith("testList") ||
					applicationSummary.getName().startsWith("testDuplicateSchedule") ||
					applicationSummary.getName().startsWith("testUnschedule") ||
					applicationSummary.getName().startsWith("testMultiple") ||
					applicationSummary.getName().startsWith("testSimpleSchedule")) {

				return operations.applications().delete(DeleteApplicationRequest
						.builder()
						.name(applicationSummary.getName())
						.build());
			}
			return Mono.justOrEmpty(applicationSummary);
		}).blockLast();
	} catch (Exception ex) {
		log.warn("Attempted cleanup and exception occured: " + ex.getMessage());
	}
}
 
Example #5
Source File: CloudFoundryAppDeployer.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
private Mono<Void> deleteApplication(String name) {
	return this.operations.applications()
		.delete(DeleteApplicationRequest.builder()
			.deleteRoutes(this.defaultDeploymentProperties.isDeleteRoutes())
			.name(name)
			.build());
}
 
Example #6
Source File: CloudFoundryAppDeployer.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
private Mono<Void> deleteApplicationInSpace(String name, String spaceName) {
	return getSpaceId(spaceName)
		.doOnError(e -> LOG.error(String.format("Unable to get space name. spaceName=%s, " + ERROR_LOG_TEMPLATE,
			spaceName, e.getMessage()), e))
		.then(operationsUtils.getOperationsForSpace(spaceName))
		.flatMap(cfOperations -> cfOperations.applications().delete(DeleteApplicationRequest.builder()
			.deleteRoutes(this.defaultDeploymentProperties.isDeleteRoutes())
			.name(name)
			.build())
			.doOnError(e -> LOG.error(String.format("Error deleting application. appName=%s, " + ERROR_LOG_TEMPLATE,
				name, e.getMessage()), e)))
		.onErrorResume(e -> Mono.empty());
}
 
Example #7
Source File: CloudFoundryService.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
public Mono<Void> deleteApp(String appName) {
	return cloudFoundryOperations.applications().delete(DeleteApplicationRequest.builder()
		.name(appName)
		.deleteRoutes(true)
		.build())
		.doOnSuccess(item -> LOG.info("Success deleting app. appName={}", appName))
		.doOnError(e -> LOG.warn(String.format("Error deleting app. appName=%s, error=%s", appName,
			e.getMessage()), e))
		.onErrorResume(e -> Mono.empty());
}
 
Example #8
Source File: CfDeleteAppDelegate.java    From ya-cf-app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
public Mono<Void> deleteApp(CloudFoundryOperations cfOperations,
                            CfProperties cfProperties) {
    return cfOperations.applications()
        .delete(DeleteApplicationRequest.builder().name(cfProperties.name()).build())
        .doOnSubscribe((s) -> {
            LOGGER.lifecycle("About to delete App '{}'", cfProperties.name());
        });
}
 
Example #9
Source File: CloudFoundryTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
private Mono<Void> requestDeleteApplication(String name) {
	return this.operations.applications()
		.delete(DeleteApplicationRequest.builder()
			.deleteRoutes(deploymentProperties.isDeleteRoutes())
			.name(name)
			.build());
}
 
Example #10
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
private Mono<Void> requestDeleteApplication(String id) {
	return this.operations.applications()
		.delete(DeleteApplicationRequest.builder()
			.deleteRoutes(deploymentProperties.isDeleteRoutes())
			.name(id)
			.build());
}
 
Example #11
Source File: CloudFoundryTaskLauncherTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
private void givenRequestDeleteApplication(String appName) {
	given(this.operations.applications()
		.delete(DeleteApplicationRequest.builder()
			.name(appName)
			.deleteRoutes(true)
			.build()))
		.willReturn(Mono.empty());
}
 
Example #12
Source File: CustomerItApplicationTests.java    From bootiful-testing-online-training with Apache License 2.0 4 votes vote down vote up
@Test
public void clientCanTalkToService() throws Exception {

	File jar = this.locationOfJar();
	Assert.assertTrue(jar.exists());

	String anotherString = "btot-customer-service";

	Flux<Void> deleteIfExists = this.cloudFoundryOperations
		.applications()
		.list()
		.filter(as -> as.getName().equalsIgnoreCase(anotherString))
		.doOnNext(applicationSummary ->
			log.info("found " + applicationSummary.getName() + " with URL " +
				applicationSummary.getUrls().iterator().next() + " to delete."))
		.flatMap(as -> cloudFoundryOperations
			.applications()
			.delete(
				DeleteApplicationRequest
					.builder()
					.name(anotherString)
					.deleteRoutes(true)
					.build()
			));

	Mono<Void> push = cloudFoundryOperations
		.applications()
		.push(PushApplicationRequest
			.builder()
			.name(anotherString)
			.path(jar.toPath())
			.build());

	StepVerifier
		.create(deleteIfExists.thenMany(push))
		.verifyComplete();

	Customer customerById = this.client.getCustomerById(1L);
	BDDAssertions.then(customerById.getId()).isEqualTo(1L);
	BDDAssertions.then(customerById.getFirstName()).isEqualTo("a");
	BDDAssertions.then(customerById.getLastName()).isEqualTo("a");
	BDDAssertions.then(customerById.getEmail()).isEqualTo("[email protected]");

	StepVerifier
		.create(deleteIfExists)
		.verifyComplete();
}
 
Example #13
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private void givenRequestDeleteApplication(String id, Mono<Void> response) {
	given(this.operations.applications()
		.delete(DeleteApplicationRequest.builder().deleteRoutes(true).name(id).build())).willReturn(response);
}