cf-java-client
cf-java-client copied to clipboard
get UserProviderService credential by DefaultCloudFoundryOperations
i want to fetch the UserProviderService credentials by using DefaultCloudFoundryOperations or CloudFoundryClient, how i can do this. for example i have cassandra db UPS ineed to have the map of username , password host ...
Can you tell me a little more about what you're actually trying to do? Typically once you have a UPS you would bind an app to it, then have it retrieve credentials from known keys in the VCAP_SERVICES environment variables.
i have cassandra db as UPS credentials ,,,, this UPS bind to several application which connected to cassandra DB. what i am trying to do is to build spring boot application which connect to specific space in cloud foundry organization and fetch the credentials of the cassandra UPS and return back with the response from my spring application. i can have a list of all the services in my space: List<ServiceInstanceSummary> servicesList = cloudFoundryOperations.services().listInstances().collectList().block(); but i need the map key: value of the credentials of the sevices. can you please help
I don't think you can do what you want, at least directly. A service's credentials aren't visible to some sort of general environment, just to applications that are bound to them. You can access that using either GetApplicationEnvironmentsRequest or GetApplicationEnvironmentRequest, depending on what level you're operating at.
With the v2 CAPI it is not possible to fetch the credentials for a user-provided service. Not using the API, at least. There is just no API endpoint to retrieve it. You can do like Paul mentioned though and bind the user-provided service to an app, start the app, and then fetch the environment variables for the app. That will give you the values through VCAP_SERVICES.
The v3 CAPI does provide an endpoint to fetch these results but I do not believe the client supports this at the moment.
I will leave this issue open as a feature request to add support for that endpoint.
If anyone is interested in submitting a PR, this would be a good candidate. See the Development section for tips on getting started or post questions here. Thanks.