javacloud-foundrycloudfoundry-uaa

CloudFoundry V3 API for Domains - Java Client


We are writing an API that would get list of all the domains available in a cloudfoundry-foundation. Our API internally uses cf-java-client libraries to talk to our cloudfoundry-foundation

When we searched for the API Docs for listing all the domains, we ended-up in this API Doc and understood that all V2 Domains API is deprecated and the suggestion over there is to use V3 Domains by referring this API Document

Screen shot below that shows that cf-java-client is using deprecated APIs to get the domains

enter image description here

But I couldn't find any Java classes in cf-java-client that would help me retrieve the domains from V3-API

Can this be achieved in cf-java-client ? or as of now, I should use only V2-Domains ? Please suggest


Solution

  • I was able to skip V2 Domain stuffs by getting Domain object directly from DefaultCloudFoundryOperations

    For Getting all the Domains

    import org.cloudfoundry.operations.domains.Domain;
    
    DefaultCloudFoundryOperations cfOps= .... ;
    
    List<Domain> domainList = cfOps.domains().list().collectList().block();
    

    For Creating the Domain

    public static void createADomain() {
            DefaultCloudFoundryOperations cfOps= .... ;
            CreateDomainRequest createDomainRequest = CreateDomainRequest.builder()
                    .domain("arunsample.company.com")
                    .organization(ORG_NAME)
                    .build();
    
            cfOps.domains().create(createDomainRequest).block();
    
            System.out.println("Domain Created successfully .. ");
        }