org.cloudfoundry.client.v2.organizations.ListOrganizationsRequest Java Examples

The following examples show how to use org.cloudfoundry.client.v2.organizations.ListOrganizationsRequest. 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<ListOrganizationsResponse> retrieveAllOrgIds() {
	PaginatedRequestGeneratorFunction<ListOrganizationsRequest> requestGenerator = (orderDirection, resultsPerPage, pageNumber) ->
		ListOrganizationsRequest.builder()
			.orderDirection(orderDirection)
			.resultsPerPage(resultsPerPage)
			.page(pageNumber)
			.build();
	
	PaginatedResponseGeneratorFunction<OrganizationResource, ListOrganizationsResponse> responseGenerator = (list, numberOfPages) ->
			ListOrganizationsResponse.builder()
			.addAllResources(list)
			.totalPages(numberOfPages)
			.totalResults(list.size())
			.build();
	
	return this.paginatedRequestFetcher.performGenericPagedRetrieval(RequestType.ALL_ORGS, "(empty)", requestGenerator, 
			r -> this.cloudFoundryClient.organizations().list(r),  this.requestTimeoutOrg, responseGenerator);
}
 
Example #2
Source File: ReactiveCFAccessorImpl.java    From promregator with Apache License 2.0 5 votes vote down vote up
@Override
public Mono<ListOrganizationsResponse> retrieveOrgId(String orgName) {
	// 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. 
	ListOrganizationsRequest orgsRequest = ListOrganizationsRequest.builder().name(orgName).build();
	
	return this.paginatedRequestFetcher.performGenericRetrieval(RequestType.ORG, orgName, orgsRequest,
			or -> this.cloudFoundryClient.organizations()
			          .list(or), this.requestTimeoutOrg);
}
 
Example #3
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Mono<? extends Resource<OrganizationEntity>> getOrganizationResourceByName(String name) {
    IntFunction<ListOrganizationsRequest> pageRequestSupplier = page -> ListOrganizationsRequest.builder()
                                                                                                .name(name)
                                                                                                .page(page)
                                                                                                .build();
    return getOrganizationResources(pageRequestSupplier).singleOrEmpty();
}
 
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> organizationId() {
	String org = this.runtimeEnvironmentInfo.getPlatformSpecificInfo().get(CloudFoundryPlatformSpecificInfo.ORG);
	Assert.hasText(org,"Missing runtimeEnvironmentInfo : 'org' required.");
	ListOrganizationsRequest listOrganizationsRequest =  ListOrganizationsRequest.builder()
			.name(org).build();
	return this.client.organizations().list(listOrganizationsRequest)
			.doOnError(logError("Failed to list organizations"))
			.map(listOrganizationsResponse -> listOrganizationsResponse.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<OrganizationEntity>> getOrganizationResources() {
    IntFunction<ListOrganizationsRequest> pageRequestSupplier = page -> ListOrganizationsRequest.builder()
                                                                                                .page(page)
                                                                                                .build();
    return getOrganizationResources(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<OrganizationEntity>>
        getOrganizationResources(IntFunction<ListOrganizationsRequest> pageRequestSupplier) {
    return PaginationUtils.requestClientV2Resources(page -> delegate.organizations()
                                                                    .list(pageRequestSupplier.apply(page)));
}