use of org.cloudfoundry.client.v2.spaces.ListSpacesResponse in project promregator by promregator.
the class ReactiveAppInstanceScanner method getSpaceId.
private Mono<String> getSpaceId(String orgIdString, String spaceNameString) {
Mono<ListSpacesResponse> listSpacesResponse = this.cfAccessor.retrieveSpaceId(orgIdString, spaceNameString);
return listSpacesResponse.flatMap(response -> {
List<SpaceResource> resources = response.getResources();
if (resources == null) {
return Mono.just(INVALID_SPACE_ID);
}
if (resources.isEmpty()) {
log.warn(String.format("Received empty result on requesting space %s", spaceNameString));
return Mono.just(INVALID_SPACE_ID);
}
SpaceResource spaceResource = resources.get(0);
return Mono.just(spaceResource.getMetadata().getId());
}).onErrorResume(e -> {
log.error(String.format("retrieving space id for org id '%s' and space name '%s' resulted in an exception", orgIdString, spaceNameString), e);
return Mono.just(INVALID_SPACE_ID);
}).cache();
}
use of org.cloudfoundry.client.v2.spaces.ListSpacesResponse in project promregator by promregator.
the class ReactiveCFAccessorImpl method retrieveSpaceId.
/* (non-Javadoc)
* @see org.cloudfoundry.promregator.cfaccessor.CFAccessor#retrieveSpaceId(java.lang.String, java.lang.String)
*/
@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);
}
Aggregations