use of org.cloudfoundry.reactor.TokenProvider in project TOSCAna by StuPro-TOSCAna.
the class Connection method createCloudFoundryOperations.
/**
* create a Connection to a cloud foundry instance.
* A CLoudFoundryOperation could send cf commands
*/
private CloudFoundryOperations createCloudFoundryOperations() {
CloudFoundryOperations cloudFoundryOperations;
try {
DefaultConnectionContext connectionContext = DefaultConnectionContext.builder().apiHost(apiHost).build();
TokenProvider tokenProvider = PasswordGrantTokenProvider.builder().password(password).username(userName).build();
ReactorCloudFoundryClient reactorClient = ReactorCloudFoundryClient.builder().connectionContext(connectionContext).tokenProvider(tokenProvider).build();
cloudFoundryOperations = DefaultCloudFoundryOperations.builder().cloudFoundryClient(reactorClient).organization(organization).space(space).build();
} catch (Exception e) {
logger.error("Cant connect to Cloud Foundry instance");
throw new TransformationFailureException("Could not connect to Cloud Foundry instance, Please check your credentials", e);
}
logger.info("Connect successfully to Cloud Foundry instance");
return cloudFoundryOperations;
}
Aggregations