org.cloudfoundry.reactor.client.ReactorCloudFoundryClient Java Examples
The following examples show how to use
org.cloudfoundry.reactor.client.ReactorCloudFoundryClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractCfTask.java From ya-cf-app-gradle-plugin with Apache License 2.0 | 6 votes |
protected CloudFoundryOperations getCfOperations() { CfProperties cfAppProperties = this.cfPropertiesMapper.getProperties(); ConnectionContext connectionContext = DefaultConnectionContext.builder() .apiHost(cfAppProperties.ccHost()) .skipSslValidation(true) .proxyConfiguration(tryGetProxyConfiguration(cfAppProperties)) .build(); TokenProvider tokenProvider = getTokenProvider(cfAppProperties); CloudFoundryClient cfClient = ReactorCloudFoundryClient.builder() .connectionContext(connectionContext) .tokenProvider(tokenProvider) .build(); DefaultCloudFoundryOperations cfOperations = DefaultCloudFoundryOperations.builder() .cloudFoundryClient(cfClient) .organization(cfAppProperties.org()) .space(cfAppProperties.space()) .build(); return cfOperations; }
Example #2
Source File: UserCloudFoundryService.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
public UserCloudFoundryService(CloudFoundryOperations cloudFoundryOperations, CloudFoundryProperties cloudFoundryProperties) { DefaultCloudFoundryOperations sourceCloudFoundryOperations = (DefaultCloudFoundryOperations) cloudFoundryOperations; this.targetOrg = cloudFoundryProperties.getDefaultOrg() + "-instances"; this.targetSpace = cloudFoundryProperties.getDefaultSpace(); ClientCredentialsGrantTokenProvider tokenProvider = ClientCredentialsGrantTokenProvider.builder() .clientId(USER_CLIENT_ID) .clientSecret(USER_CLIENT_SECRET) .build(); ReactorCloudFoundryClient cloudFoundryClient = ReactorCloudFoundryClient.builder() .from((ReactorCloudFoundryClient) sourceCloudFoundryOperations.getCloudFoundryClient()) .tokenProvider(tokenProvider) .build(); this.cloudFoundryOperations = DefaultCloudFoundryOperations .builder() .from(sourceCloudFoundryOperations) .space(targetSpace) .organization(targetOrg) .cloudFoundryClient(cloudFoundryClient) .build(); }
Example #3
Source File: ButlerConfig.java From cf-butler with Apache License 2.0 | 5 votes |
@Bean public DefaultCloudFoundryOperations opsClient(ReactorCloudFoundryClient cloudFoundryClient, ReactorDopplerClient dopplerClient, ReactorUaaClient uaaClient) { return DefaultCloudFoundryOperations .builder() .cloudFoundryClient(cloudFoundryClient) .dopplerClient(dopplerClient) .uaaClient(uaaClient) .build(); }
Example #4
Source File: CloudFoundryClientAutoConfigurationTest.java From spring-cloud-cloudfoundry with Apache License 2.0 | 5 votes |
private void assertCloudFoundryClientBeansPresent( AssertableApplicationContext context) { assertThat(context).hasSingleBean(ReactorCloudFoundryClient.class); assertThat(context).hasSingleBean(DefaultCloudFoundryOperations.class); assertThat(context).hasSingleBean(DefaultConnectionContext.class); assertThat(context).hasSingleBean(DopplerClient.class); assertThat(context).hasSingleBean(RoutingClient.class); assertThat(context).hasSingleBean(PasswordGrantTokenProvider.class); assertThat(context).hasSingleBean(ReactorUaaClient.class); }
Example #5
Source File: CloudFoundryClientAutoConfiguration.java From spring-cloud-cloudfoundry with Apache License 2.0 | 5 votes |
@Bean @Lazy @ConditionalOnMissingBean public ReactorCloudFoundryClient cloudFoundryClient( ConnectionContext connectionContext, TokenProvider tokenProvider) { return ReactorCloudFoundryClient.builder().connectionContext(connectionContext) .tokenProvider(tokenProvider).build(); }
Example #6
Source File: CloudFoundryPlatformClientProvider.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
public CloudFoundryClient cloudFoundryClient(String account){ cloudFoundryClients.putIfAbsent(account, ReactorCloudFoundryClient.builder() .connectionContext(connectionContextProvider.connectionContext(account)) .tokenProvider(platformTokenProvider.tokenProvider(account)) .build()); return cloudFoundryClients.get(account); }
Example #7
Source File: CloudFoundryTestSupport.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
@Bean public CloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, TokenProvider tokenProvider) { return ReactorCloudFoundryClient.builder() .connectionContext(connectionContext) .tokenProvider(tokenProvider) .build(); }
Example #8
Source File: CloudFoundryDeployerAutoConfiguration.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public CloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, TokenProvider tokenProvider) { return ReactorCloudFoundryClient.builder() .connectionContext(connectionContext) .tokenProvider(tokenProvider) .build(); }
Example #9
Source File: PcfDevIntegrationTests.java From ya-cf-app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void getAppDetailTests() { ConnectionContext connectionContext = DefaultConnectionContext.builder() .apiHost("api.local.pcfdev.io") .skipSslValidation(true) .build(); TokenProvider tokenProvider = PasswordGrantTokenProvider.builder() .password("admin") .username("admin") .build(); CloudFoundryClient cfClient = ReactorCloudFoundryClient.builder() .connectionContext(connectionContext) .tokenProvider(tokenProvider) .build(); CloudFoundryOperations cfOperations = DefaultCloudFoundryOperations.builder() .cloudFoundryClient(cfClient) .organization("pcfdev-org") .space("pcfdev-space") .build(); CfAppDetailsDelegate appDetailsTaskDelegate = new CfAppDetailsDelegate(); CfProperties cfAppProps = envDetails(); Mono<Optional<ApplicationDetail>> applicationDetailMono = appDetailsTaskDelegate .getAppDetails(cfOperations, cfAppProps); // Mono<Void> resp = applicationDetailMono.then(applicationDetail -> Mono.fromSupplier(() -> { // return 1; // })).then(); // // resp.block(); // ApplicationDetail applicationDetail = applicationDetailMono.block(Duration.ofMillis(5000)); // System.out.println("applicationDetail = " + applicationDetail); }
Example #10
Source File: PlatformCloudFoundryOperations.java From spring-cloud-skipper with Apache License 2.0 | 5 votes |
private CloudFoundryOperations buildCloudFoundryOperations(String platformName) { CloudFoundryPlatformProperties.CloudFoundryProperties cloudFoundryProperties = this.cloudFoundryPlatformProperties .getAccounts() .get(platformName); CloudFoundryConnectionProperties connectionProperties = cloudFoundryProperties.getConnection(); ConnectionContext connectionContext = DefaultConnectionContext.builder() .apiHost(connectionProperties.getUrl().getHost()) .skipSslValidation(connectionProperties.isSkipSslValidation()) .build(); Builder tokenProviderBuilder = PasswordGrantTokenProvider.builder() .username(connectionProperties.getUsername()) .password(connectionProperties.getPassword()) .loginHint(connectionProperties.getLoginHint()); if (StringUtils.hasText(connectionProperties.getClientId())) { tokenProviderBuilder.clientId(connectionProperties.getClientId()); } if (StringUtils.hasText(connectionProperties.getClientSecret())) { tokenProviderBuilder.clientSecret(connectionProperties.getClientSecret()); } TokenProvider tokenProvider = tokenProviderBuilder.build(); CloudFoundryClient cloudFoundryClient = ReactorCloudFoundryClient.builder() .connectionContext(connectionContext) .tokenProvider(tokenProvider) .build(); return DefaultCloudFoundryOperations .builder().cloudFoundryClient(cloudFoundryClient) .organization(connectionProperties.getOrg()) .space(connectionProperties.getSpace()).build(); }
Example #11
Source File: CloudFoundryClientConfiguration.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Bean protected CloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, @Qualifier("userCredentials") TokenProvider tokenProvider) { return ReactorCloudFoundryClient.builder() .connectionContext(connectionContext) .tokenProvider(tokenProvider) .build(); }
Example #12
Source File: CloudFoundryAppDeployerAutoConfigurationTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Test void clientIsNotCreatedWithoutConfiguration() { this.contextRunner .run((context) -> { assertThat(context).doesNotHaveBean(CloudFoundryTargetProperties.class); assertThat(context).doesNotHaveBean(CloudFoundryDeploymentProperties.class); assertThat(context).doesNotHaveBean(ReactorCloudFoundryClient.class); assertThat(context).doesNotHaveBean(ReactorDopplerClient.class); assertThat(context).doesNotHaveBean(ReactorUaaClient.class); assertThat(context).doesNotHaveBean(CloudFoundryOperations.class); assertThat(context).doesNotHaveBean(CloudFoundryOperationsUtils.class); assertThat(context).doesNotHaveBean(ConnectionContext.class); assertThat(context).doesNotHaveBean(TokenProvider.class); }); }
Example #13
Source File: CloudFoundryAppDeployerAutoConfigurationTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Test void clientIsCreatedWithCredentialsGrantConfiguration() { this.contextRunner .withPropertyValues( "spring.cloud.appbroker.deployer.cloudfoundry.api-host=api.example.local", "spring.cloud.appbroker.deployer.cloudfoundry.api-port=443", "spring.cloud.appbroker.deployer.cloudfoundry.default-org=example-org", "spring.cloud.appbroker.deployer.cloudfoundry.default-space=example-space", "spring.cloud.appbroker.deployer.cloudfoundry.client-id=oauth-client", "spring.cloud.appbroker.deployer.cloudfoundry.client-secret=secret" ) .run((context) -> { assertThat(context).hasSingleBean(CloudFoundryTargetProperties.class); CloudFoundryTargetProperties targetProperties = context.getBean(CloudFoundryTargetProperties.class); assertThat(targetProperties.getApiHost()).isEqualTo("api.example.local"); assertThat(targetProperties.getApiPort()).isEqualTo(443); assertThat(targetProperties.getDefaultOrg()).isEqualTo("example-org"); assertThat(targetProperties.getDefaultSpace()).isEqualTo("example-space"); assertThat(targetProperties.getClientId()).isEqualTo("oauth-client"); assertThat(targetProperties.getClientSecret()).isEqualTo("secret"); assertThat(context).hasSingleBean(AppDeployer.class); assertThat(context).hasSingleBean(AppManager.class); assertThat(context).hasSingleBean(ReactorCloudFoundryClient.class); assertThat(context).hasSingleBean(ReactorDopplerClient.class); assertThat(context).hasSingleBean(ReactorUaaClient.class); assertThat(context).hasSingleBean(CloudFoundryOperations.class); assertThat(context).hasSingleBean(CloudFoundryOperationsUtils.class); assertThat(context).hasSingleBean(DefaultConnectionContext.class); assertThat(context).hasSingleBean(ClientCredentialsGrantTokenProvider.class); }); }
Example #14
Source File: AppBrokerAutoConfigurationTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Test void configureCloudFoundryClientWithClientCredentials() { this.contextRunner .withPropertyValues("spring.cloud.appbroker.deployer.cloudfoundry.api-host=https://api.example.local", "spring.cloud.appbroker.deployer.cloudfoundry.client_id=user", "spring.cloud.appbroker.deployer.cloudfoundry.client_secret=secret") .run(context -> { assertThat(context).hasSingleBean(TokenProvider.class); assertThat(context).hasSingleBean(ReactorCloudFoundryClient.class); }); }
Example #15
Source File: CloudFoundryAppDeployerAutoConfiguration.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
/** * Provide a {@link ReactorCloudFoundryClient} bean * * @param connectionContext the ConnectionContext bean * @param tokenProvider the TokenProvider bean * @return the bean */ @Bean public ReactorCloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, @TokenQualifier TokenProvider tokenProvider) { return ReactorCloudFoundryClient.builder() .connectionContext(connectionContext) .tokenProvider(tokenProvider) .build(); }
Example #16
Source File: CloudFoundryClientConfiguration.java From bootiful-testing-online-training with Apache License 2.0 | 5 votes |
@Bean ReactorCloudFoundryClient cloudFoundryClient( ConnectionContext connectionContext, TokenProvider tokenProvider) { return ReactorCloudFoundryClient .builder() .connectionContext(connectionContext) .tokenProvider(tokenProvider).build(); }
Example #17
Source File: ButlerConfig.java From cf-butler with Apache License 2.0 | 5 votes |
@Bean public ReactorCloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, TokenProvider tokenProvider) { return ReactorCloudFoundryClient .builder() .connectionContext(connectionContext) .tokenProvider(tokenProvider) .build(); }
Example #18
Source File: ReactiveCFAccessorImpl.java From promregator with Apache License 2.0 | 4 votes |
private ReactorCloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, TokenProvider tokenProvider) { return ReactorCloudFoundryClient.builder().connectionContext(connectionContext).tokenProvider(tokenProvider).build(); }
Example #19
Source File: CloudFoundryClientFactory.java From cf-java-client-sap with Apache License 2.0 | 4 votes |
public CloudFoundryClient createClient(URL controllerUrl, OAuthClient oAuthClient) { return ReactorCloudFoundryClient.builder() .connectionContext(getOrCreateConnectionContext(controllerUrl.getHost())) .tokenProvider(oAuthClient.getTokenProvider()) .build(); }
Example #20
Source File: CfConfiguration.java From spring-cloud-release-tools with Apache License 2.0 | 4 votes |
@Bean ReactorCloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, TokenProvider tokenProvider) { return ReactorCloudFoundryClient.builder().connectionContext(connectionContext) .tokenProvider(tokenProvider).build(); }
Example #21
Source File: CloudFoundryAppDeployerAutoConfigurationTest.java From spring-cloud-app-broker with Apache License 2.0 | 4 votes |
@Test void clientIsCreatedWithPasswordGrantConfiguration() { this.contextRunner .withPropertyValues( "spring.cloud.appbroker.deployer.cloudfoundry.api-host=api.example.local", "spring.cloud.appbroker.deployer.cloudfoundry.api-port=443", "spring.cloud.appbroker.deployer.cloudfoundry.default-org=example-org", "spring.cloud.appbroker.deployer.cloudfoundry.default-space=example-space", "spring.cloud.appbroker.deployer.cloudfoundry.username=user", "spring.cloud.appbroker.deployer.cloudfoundry.password=secret", "spring.cloud.appbroker.deployer.cloudfoundry.properties.memory=2G", "spring.cloud.appbroker.deployer.cloudfoundry.properties.count=3", "spring.cloud.appbroker.deployer.cloudfoundry.properties.buildpack=example-buildpack", "spring.cloud.appbroker.deployer.cloudfoundry.properties.domain=example.local" ) .run((context) -> { assertThat(context).hasSingleBean(CloudFoundryTargetProperties.class); CloudFoundryTargetProperties targetProperties = context.getBean(CloudFoundryTargetProperties.class); assertThat(targetProperties.getApiHost()).isEqualTo("api.example.local"); assertThat(targetProperties.getApiPort()).isEqualTo(443); assertThat(targetProperties.getDefaultOrg()).isEqualTo("example-org"); assertThat(targetProperties.getDefaultSpace()).isEqualTo("example-space"); assertThat(targetProperties.getUsername()).isEqualTo("user"); assertThat(targetProperties.getPassword()).isEqualTo("secret"); assertThat(context).hasSingleBean(CloudFoundryDeploymentProperties.class); CloudFoundryDeploymentProperties deploymentProperties = context .getBean(CloudFoundryDeploymentProperties.class); assertThat(deploymentProperties.getMemory()).isEqualTo("2G"); assertThat(deploymentProperties.getCount()).isEqualTo(3); assertThat(deploymentProperties.getBuildpack()).isEqualTo("example-buildpack"); assertThat(deploymentProperties.getDomain()).isEqualTo("example.local"); assertThat(context).hasSingleBean(AppDeployer.class); assertThat(context).hasSingleBean(AppManager.class); assertThat(context).hasSingleBean(OAuth2Client.class); assertThat(context).hasSingleBean(ReactorCloudFoundryClient.class); assertThat(context).hasSingleBean(ReactorDopplerClient.class); assertThat(context).hasSingleBean(ReactorUaaClient.class); assertThat(context).hasSingleBean(CloudFoundryOperations.class); assertThat(context).hasSingleBean(CloudFoundryOperationsUtils.class); assertThat(context).hasSingleBean(DefaultConnectionContext.class); assertThat(context).hasSingleBean(PasswordGrantTokenProvider.class); }); }