org.cloudfoundry.client.v2.spaces.ListSpacesRequest Java Examples

The following examples show how to use org.cloudfoundry.client.v2.spaces.ListSpacesRequest. 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: ReactiveCFAccessorImpl.java    From promregator with Apache License 2.0 6 votes vote down vote up
@Override
public Mono<ListSpacesResponse> retrieveSpaceIdsInOrg(String orgId) {
	PaginatedRequestGeneratorFunction<ListSpacesRequest> requestGenerator = (orderDirection, resultsPerPage, pageNumber) ->
		ListSpacesRequest.builder()
			.organizationId(orgId)
			.orderDirection(orderDirection)
			.resultsPerPage(resultsPerPage)
			.page(pageNumber)
			.build();
	
	PaginatedResponseGeneratorFunction<SpaceResource, ListSpacesResponse> responseGenerator = (list, numberOfPages) ->
			ListSpacesResponse.builder()
			.addAllResources(list)
			.totalPages(numberOfPages)
			.totalResults(list.size())
			.build();

	
	return this.paginatedRequestFetcher.performGenericPagedRetrieval(RequestType.SPACE_IN_ORG, orgId, requestGenerator, 
			r -> this.cloudFoundryClient.spaces().list(r),  this.requestTimeoutSpace, responseGenerator);
}
 
Example #2
Source File: ReactiveCFAccessorImpl.java    From promregator with Apache License 2.0 5 votes vote down vote up
@Override
public Mono<ListSpacesResponse> retrieveSpaceId(String orgId, String spaceName) {
	// Note: even though we use the List request here, the number of values returned is either zero or one
	// ==> No need for a paged request. 
	
	String key = String.format("%s|%s", orgId, spaceName);
	
	ListSpacesRequest spacesRequest = ListSpacesRequest.builder().organizationId(orgId).name(spaceName).build();
	
	return this.paginatedRequestFetcher.performGenericRetrieval(RequestType.SPACE, key, spacesRequest, sr ->
			this.cloudFoundryClient.spaces().list(sr),
			this.requestTimeoutSpace);
}
 
Example #3
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<SpaceEntity>> getSpaceResourcesByOrganizationGuid(UUID organizationGuid) {
    IntFunction<ListSpacesRequest> pageRequestSupplier = page -> ListSpacesRequest.builder()
                                                                                  .organizationId(organizationGuid.toString())
                                                                                  .page(page)
                                                                                  .build();
    return getSpaceResources(pageRequestSupplier);
}
 
Example #4
Source File: AbstractCloudFoundryTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
private Mono<String> spaceId() {
	String space = this.runtimeEnvironmentInfo.getPlatformSpecificInfo().get(CloudFoundryPlatformSpecificInfo.SPACE);
	Assert.hasText(space,"Missing runtimeEnvironmentInfo : 'space' required.");
	ListSpacesRequest listSpacesRequest = ListSpacesRequest.builder()
			.name(space).build();
	return this.client.spaces().list(listSpacesRequest)
			.doOnError(logError("Failed to list spaces"))
			.map(listSpacesResponse -> listSpacesResponse.getResources().get(0).getMetadata().getId())
			.cache(aValue -> Duration.ofMillis(Long.MAX_VALUE), aValue -> Duration.ZERO, () -> Duration.ZERO);
}
 
Example #5
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
private Flux<? extends Resource<SpaceEntity>> getSpaceResources() {
    IntFunction<ListSpacesRequest> pageRequestSupplier = page -> ListSpacesRequest.builder()
                                                                                  .page(page)
                                                                                  .build();
    return getSpaceResources(pageRequestSupplier);
}
 
Example #6
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
private Flux<? extends Resource<SpaceEntity>> getSpaceResources(IntFunction<ListSpacesRequest> requestForPage) {
    return PaginationUtils.requestClientV2Resources(page -> delegate.spaces()
                                                                    .list(requestForPage.apply(page)));
}