简体   繁体   中英

Get service key in Cloud Foundry Java API

What I'd like, is to implement in Java, using CF API, something like cf service-keys (servicename) and cf service-key (servicekeyname) in regular CF commands.

I've been following this very simple tutorial and I'd like to do something like: service.getKeys() or service.getKey("keyname") but there are no such methods. And I can't see any class that would help me do that.

Does anyone know the solution and would like to share with me?

That documentation page you linked to is very out of date. It refers to 1.x versions of the CF Java Client, which is no longer maintained. The README for the 2.x CF Java Client is a better source of information.

Follow the setup instructions in the CF Java Client v2 README to get a CloudFoundryOperations object, then you should be able to do something like this:

cloudFoundryOperations.services()
    .listServiceKeys(ListServiceKeysRequest.builder()
        .serviceInstanceName("service-instance-name")
        .build())
    .map(ServiceKey::getName)
    .subscribe(System.out::println);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM