org.cloudfoundry.util.PaginationUtils Java Examples

The following examples show how to use org.cloudfoundry.util.PaginationUtils. 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: AppRelationshipTask.java    From cf-butler with Apache License 2.0 5 votes vote down vote up
protected Mono<AppRelationship> getAppRelationship(AppRelationshipRequest request) {
    Flux<ApplicationResource> resources =
        PaginationUtils.requestClientV3Resources(
            page -> DefaultCloudFoundryOperations
                    .builder()
                        .from(opsClient)
                        .organization(request.getOrganization())
                        .space(request.getSpace())
                        .build()
                    .getCloudFoundryClient()
                        .applicationsV3()
                            .list(ListApplicationsRequest.builder().page(page).addAllNames(Arrays.asList(new String[] { request.getApplicationName() })).build()));
    return resources
            .next()
            .map(ar -> AppRelationship
                            .builder()
                                .organization(request.getOrganization())
                                .space(request.getSpace())
                                .appId(ar.getId())
                                .appName(request.getApplicationName())
                                .serviceInstanceId(request.getServiceInstanceId())
                                .serviceName(request.getServiceName())
                                .serviceOffering(request.getServiceOffering())
                                .servicePlan(request.getServicePlan())
                                .serviceType(request.getServiceType())
                                .build());
}
 
Example #2
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<EventEntity>> getEventResourcesByActee(String actee) {
    IntFunction<ListEventsRequest> pageRequestSupplier = page -> ListEventsRequest.builder()
                                                                                  .actee(actee)
                                                                                  .page(page)
                                                                                  .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.events()
                                                                    .list(pageRequestSupplier.apply(page)));
}
 
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<EventEntity>> getEventResources() {
    IntFunction<ListEventsRequest> pageRequestSupplier = page -> ListEventsRequest.builder()
                                                                                  .page(page)
                                                                                  .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.events()
                                                                    .list(pageRequestSupplier.apply(page)));
}
 
Example #4
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<ServiceKeyEntity>> getServiceKeyResourcesByServiceInstanceGuid(UUID serviceInstanceGuid) {
    IntFunction<ListServiceKeysRequest> pageRequestSupplier = page -> ListServiceKeysRequest.builder()
                                                                                            .serviceInstanceId(serviceInstanceGuid.toString())
                                                                                            .page(page)
                                                                                            .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.serviceKeys()
                                                                    .list(pageRequestSupplier.apply(page)));
}
 
Example #5
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<ServicePlanEntity>> getServicePlanResourcesByServiceGuid(UUID serviceGuid) {
    IntFunction<ListServicePlansRequest> pageRequestSupplier = page -> ListServicePlansRequest.builder()
                                                                                              .serviceId(serviceGuid.toString())
                                                                                              .page(page)
                                                                                              .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.servicePlans()
                                                                    .list(pageRequestSupplier.apply(page)));
}
 
Example #6
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<RouteMappingEntity>> getRouteMappingResourcesByRouteGuid(UUID routeGuid) {
    IntFunction<ListRouteMappingsRequest> pageRequestSupplier = page -> ListRouteMappingsRequest.builder()
                                                                                                .routeId(routeGuid.toString())
                                                                                                .page(page)
                                                                                                .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.routeMappings()
                                                                    .list(pageRequestSupplier.apply(page)));
}
 
Example #7
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<RouteEntity>> getRouteResourcesByDomainGuidHostAndPath(UUID domainGuid, String host, String path) {
    ListSpaceRoutesRequest.Builder requestBuilder = ListSpaceRoutesRequest.builder();
    if (host != null) {
        requestBuilder.host(host);
    }
    if (path != null) {
        requestBuilder.path(path);
    }
    requestBuilder.spaceId(getTargetSpaceGuid().toString())
                  .domainId(domainGuid.toString());

    return PaginationUtils.requestClientV2Resources(page -> delegate.spaces()
                                                                    .listRoutes(requestBuilder.page(page)
                                                                                              .build()));
}
 
Example #8
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<RouteEntity>> getRouteResourcesByDomainGuidAndSpaceGuid(UUID domainGuid, UUID spaceGuid) {
    IntFunction<ListSpaceRoutesRequest> pageRequestSupplier = page -> ListSpaceRoutesRequest.builder()
                                                                                            .domainId(domainGuid.toString())
                                                                                            .spaceId(spaceGuid.toString())
                                                                                            .page(page)
                                                                                            .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.spaces()
                                                                    .listRoutes(pageRequestSupplier.apply(page)));
}
 
Example #9
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Mono<? extends Resource<SpaceEntity>> getSpaceResourceByOrganizationGuidAndName(UUID organizationGuid, String name) {
    IntFunction<ListOrganizationSpacesRequest> pageRequestSupplier = page -> ListOrganizationSpacesRequest.builder()
                                                                                                          .organizationId(organizationGuid.toString())
                                                                                                          .name(name)
                                                                                                          .page(page)
                                                                                                          .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.organizations()
                                                                    .listSpaces(pageRequestSupplier.apply(page)))
                          .singleOrEmpty();
}
 
Example #10
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<PrivateDomainEntity>> getPrivateDomainResourcesByOrganizationGuid(UUID organizationGuid) {
    IntFunction<ListOrganizationPrivateDomainsRequest> pageRequestSupplier = page -> ListOrganizationPrivateDomainsRequest.builder()
                                                                                                                          .organizationId(organizationGuid.toString())
                                                                                                                          .page(page)
                                                                                                                          .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.organizations()
                                                                    .listPrivateDomains(pageRequestSupplier.apply(page)));
}
 
Example #11
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<PrivateDomainEntity>> getPrivateDomainResources() {
    IntFunction<ListPrivateDomainsRequest> pageRequestSupplier = page -> ListPrivateDomainsRequest.builder()
                                                                                                  .page(page)
                                                                                                  .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.privateDomains()
                                                                    .list(pageRequestSupplier.apply(page)));
}
 
Example #12
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<SharedDomainEntity>> getSharedDomainResources() {
    IntFunction<ListSharedDomainsRequest> pageRequestSupplier = page -> ListSharedDomainsRequest.builder()
                                                                                                .page(page)
                                                                                                .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.sharedDomains()
                                                                    .list(pageRequestSupplier.apply(page)));
}
 
Example #13
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Mono<? extends Resource<DomainEntity>> getDomainResourceByName(String name) {
    IntFunction<ListDomainsRequest> pageRequestSupplier = page -> ListDomainsRequest.builder()
                                                                                    .name(name)
                                                                                    .page(page)
                                                                                    .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.domains()
                                                                    .list(pageRequestSupplier.apply(page)))
                          .singleOrEmpty();
}
 
Example #14
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Build> getBuildResourcesByPackageGuid(UUID packageGuid) {
    IntFunction<ListBuildsRequest> pageRequestSupplier = page -> ListBuildsRequest.builder()
                                                                                  .packageId(packageGuid.toString())
                                                                                  .page(page)
                                                                                  .build();
    return PaginationUtils.requestClientV3Resources(page -> delegate.builds()
                                                                    .list(pageRequestSupplier.apply(page)));
}
 
Example #15
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Build> getBuildResourcesByApplicationGuid(UUID applicationGuid) {
    IntFunction<ListApplicationBuildsRequest> pageRequestSupplier = page -> ListApplicationBuildsRequest.builder()
                                                                                                        .applicationId(applicationGuid.toString())
                                                                                                        .page(page)
                                                                                                        .build();
    return PaginationUtils.requestClientV3Resources(page -> delegate.applicationsV3()
                                                                    .listBuilds(pageRequestSupplier.apply(page)));
}
 
Example #16
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Task> getTaskResourcesByApplicationGuid(UUID applicationGuid) {
    IntFunction<ListTasksRequest> pageRequestSupplier = page -> ListTasksRequest.builder()
                                                                                .applicationId(applicationGuid.toString())
                                                                                .page(page)
                                                                                .build();
    return PaginationUtils.requestClientV3Resources(page -> delegate.tasks()
                                                                    .list(pageRequestSupplier.apply(page)));
}
 
Example #17
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<UserEntity>> getSpaceDeveloperResourcesBySpaceGuid(UUID spaceGuid) {
    IntFunction<ListSpaceDevelopersRequest> pageRequestSupplier = page -> ListSpaceDevelopersRequest.builder()
                                                                                                    .spaceId(spaceGuid.toString())
                                                                                                    .page(page)
                                                                                                    .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.spaces()
                                                                    .listDevelopers(pageRequestSupplier.apply(page)));
}
 
Example #18
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<UserEntity>> getSpaceAuditorResourcesBySpaceGuid(UUID spaceGuid) {
    IntFunction<ListSpaceAuditorsRequest> pageRequestSupplier = page -> ListSpaceAuditorsRequest.builder()
                                                                                                .spaceId(spaceGuid.toString())
                                                                                                .page(page)
                                                                                                .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.spaces()
                                                                    .listAuditors(pageRequestSupplier.apply(page)));
}
 
Example #19
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<UserEntity>> getSpaceManagerResourcesBySpaceGuid(UUID spaceGuid) {
    IntFunction<ListSpaceManagersRequest> pageRequestSupplier = page -> ListSpaceManagersRequest.builder()
                                                                                                .spaceId(spaceGuid.toString())
                                                                                                .page(page)
                                                                                                .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.spaces()
                                                                    .listManagers(pageRequestSupplier.apply(page)));
}
 
Example #20
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<ServiceBindingEntity>> getServiceBindingResourcesByServiceInstanceGuid(UUID serviceInstanceGuid) {
    IntFunction<ListServiceBindingsRequest> pageRequestSupplier = page -> ListServiceBindingsRequest.builder()
                                                                                                    .serviceInstanceId(serviceInstanceGuid.toString())
                                                                                                    .page(page)
                                                                                                    .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.serviceBindingsV2()
                                                                    .list(pageRequestSupplier.apply(page)));
}
 
Example #21
Source File: SpacesTask.java    From cf-butler with Apache License 2.0 5 votes vote down vote up
protected Flux<Space> getSpaces(Organization organization) {
    return PaginationUtils.requestClientV3Resources(
        page -> opsClient
                    .getCloudFoundryClient()
                    .spacesV3()
                        .list(ListSpacesRequest.builder().page(page).organizationIds(new String[] { organization.getId() }).build()))
                        .map(response -> Space
                                            .builder()
                                                .organizationId(organization.getId())
                                                .organizationName(organization.getName())
                                                .spaceId(response.getId())
                                                .spaceName(response.getName())
                                            .build());
}
 
Example #22
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<ApplicationEntity>> getApplicationResourcesByNames(Collection<String> names) {
    if (names.isEmpty()) {
        return Flux.empty();
    }
    IntFunction<ListSpaceApplicationsRequest> pageRequestSupplier = page -> ListSpaceApplicationsRequest.builder()
                                                                                                        .spaceId(getTargetSpaceGuid().toString())
                                                                                                        .addAllNames(names)
                                                                                                        .page(page)
                                                                                                        .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.spaces()
                                                                    .listApplications(pageRequestSupplier.apply(page)));
}
 
Example #23
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Mono<? extends Resource<ApplicationEntity>> getApplicationResourceByName(String name) {
    IntFunction<ListApplicationsRequest> pageRequestSupplier = page -> ListApplicationsRequest.builder()
                                                                                              .spaceId(getTargetSpaceGuid().toString())
                                                                                              .name(name)
                                                                                              .page(page)
                                                                                              .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.applicationsV2()
                                                                    .list(pageRequestSupplier.apply(page)))
                          .singleOrEmpty();
}
 
Example #24
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Flux<? extends Resource<ApplicationEntity>> getApplicationResources() {
    IntFunction<ListSpaceApplicationsRequest> pageRequestSupplier = page -> ListSpaceApplicationsRequest.builder()
                                                                                                        .spaceId(getTargetSpaceGuid().toString())
                                                                                                        .page(page)
                                                                                                        .build();
    return PaginationUtils.requestClientV2Resources(page -> delegate.spaces()
                                                                    .listApplications(pageRequestSupplier.apply(page)));
}
 
Example #25
Source File: OrganizationsTask.java    From cf-butler with Apache License 2.0 5 votes vote down vote up
protected Flux<Organization> getOrganizations() {
    return PaginationUtils.requestClientV3Resources(
        page -> opsClient
                    .getCloudFoundryClient()
                    .organizationsV3()
                        .list(ListOrganizationsRequest.builder().page(page).build()))
                        .map(os -> new Organization(os.getId(), os.getName()));
}
 
Example #26
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Map<String, Metadata> getApplicationsMetadata(List<UUID> appGuids) {
    IntFunction<org.cloudfoundry.client.v3.applications.ListApplicationsRequest> pageRequestSupplier = page -> org.cloudfoundry.client.v3.applications.ListApplicationsRequest.builder()
                                                                                                                                                                              .spaceId(getTargetSpaceGuid().toString())
                                                                                                                                                                              .addAllApplicationIds(toString(appGuids))
                                                                                                                                                                              .page(page)
                                                                                                                                                                              .build();
    return PaginationUtils.requestClientV3Resources(page -> delegate.applicationsV3()
                                                                    .list(pageRequestSupplier.apply(page)))
                          .collectMap(ApplicationResource::getName, ApplicationResource::getMetadata)
                          .block();
}
 
Example #27
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Map<String, Metadata> getServiceInstancesMetadataByLabelSelector(String labelSelector) {
    IntFunction<ListServiceInstancesRequest> listServiceInstancesPageRequestSupplier = page -> ListServiceInstancesRequest.builder()
                                                                                                                          .labelSelector(labelSelector)
                                                                                                                          .spaceId(getTargetSpaceGuid().toString())
                                                                                                                          .page(page)
                                                                                                                          .build();

    return PaginationUtils.requestClientV3Resources(page -> delegate.serviceInstancesV3()
                                                                    .list(listServiceInstancesPageRequestSupplier.apply(page)))
                          .collectMap(ServiceInstanceResource::getName, ServiceInstanceResource::getMetadata)
                          .block();
}
 
Example #28
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Map<String, Metadata> getServiceInstancesMetadata(List<String> serviceInstanceNames) {
    String spaceGuid = getTargetSpaceGuid().toString();
    IntFunction<ListServiceInstancesRequest> pageRequestSupplier = page -> ListServiceInstancesRequest.builder()
                                                                                                      .spaceId(spaceGuid)
                                                                                                      .addAllServiceInstanceNames(serviceInstanceNames)
                                                                                                      .page(page)
                                                                                                      .build();
    return PaginationUtils.requestClientV3Resources(page -> delegate.serviceInstancesV3()
                                                                    .list(pageRequestSupplier.apply(page)))
                          .collectMap(ServiceInstanceResource::getName, ServiceInstanceResource::getMetadata)
                          .block();
}
 
Example #29
Source File: CloudFoundryAppDeployer.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
private Mono<String> getSpaceId(String spaceName) {
	return Mono.justOrEmpty(targetProperties.getDefaultOrg())
		.flatMap(orgName -> getOrganizationId(orgName)
			.flatMap(orgId -> PaginationUtils.requestClientV2Resources(page -> client.organizations()
				.listSpaces(ListOrganizationSpacesRequest.builder()
					.name(spaceName)
					.organizationId(orgId)
					.page(page)
					.build()))
				.filter(resource -> resource.getEntity().getName().equals(spaceName))
				.map(resource -> resource.getMetadata().getId())
				.next()));
}
 
Example #30
Source File: CloudControllerRestClientImpl.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private Map<String, Metadata> getApplicationsMetadataByLabelSelector(String labelSelector) {
    IntFunction<org.cloudfoundry.client.v3.applications.ListApplicationsRequest> pageRequestSupplier = page -> org.cloudfoundry.client.v3.applications.ListApplicationsRequest.builder()
                                                                                                                                                                              .spaceId(getTargetSpaceGuid().toString())
                                                                                                                                                                              .labelSelector(labelSelector)
                                                                                                                                                                              .page(page)
                                                                                                                                                                              .build();
    return PaginationUtils.requestClientV3Resources(page -> delegate.applicationsV3()
                                                                    .list(pageRequestSupplier.apply(page)))
                          .collectMap(ApplicationResource::getName, ApplicationResource::getMetadata)
                          .block();
}