Artifact | Javadocs |
---|---|
pivotal-cloudfoundry-client |
|
pivotal-cloudfoundry-client-reactor |
Job | Status |
---|---|
unit-test |
|
integration-test |
|
deploy |
The pcf-java-client
project is a Java language binding for interacting with a Pivotal Cloud Foundry instance. Most of the Cloud Foundry API can be accessed with the cf-java-client
project, and this is an extension of that project for Pivotal Cloud Foundry-specific APIs. The project is broken up into a number of components which expose different levels of abstraction depending on need.
pivotal-cloudfoundry-client
– Interfaces, request, and response objects mapping to the Pivotal Cloud Foundry REST APIs. This project has no implementation and therefore cannot connect a Pivotal Cloud Foundry instance on its own.pivotal-cloudfoundry-client-reactor
– The default implementation of the pivotal-cloudfoundry-client
project. This implementation is based on the Reactor Netty HttpClient
.Most projects will need one dependencies; the implementation of the Client API. For Maven, the dependencies would be defined like this:
<dependencies>
<dependency>
<groupId>io.pivotal</groupId>
<artifactId>pivotal-cloudfoundry-client-reactor</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.1.5.RELEASE</version>
</dependency>
<dependency>
<groupId>io.projectreactor.ipc</groupId>
<artifactId>reactor-netty</artifactId>
<version>0.7.5.RELEASE</version>
</dependency>
...
</dependencies>
Snapshot artifacts can be found in the Spring snapshot repository:
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
...
</repositories>
For Gradle, the dependencies would be defined like this:
dependencies {
compile 'io.pivotal:pivotal-cloudfoundry-client-reactor:1.0.0.RELEASE'
compile 'io.projectreactor:reactor-core:3.1.5.RELEASE'
compile 'io.projectreactor.ipc:reactor-netty:0.7.5.RELEASE'
...
}
Snapshot artifacts can be found in the Spring snapshot repository:
repositories {
maven { url 'http://repo.spring.io/snapshot' }
...
}
The pivotal-cloudfoundry-client
projects follows a "Reactive" design pattern and expose its responses with Project Reactor Monos
s and Flux
s.
SchedulerClient
BuilderThe lowest-level building blocks of the API are ConnectionContext
and TokenProvider
. These types are intended to be shared between instances of the clients, and come with out of the box implementations. To instantiate them, you configure them with builders:
DefaultConnectionContext.builder()
.apiHost(apiHost)
.build();
PasswordGrantTokenProvider.builder()
.password(password)
.username(username)
.build();
In Spring-based applications, you'll want to encapsulate them in bean definitions:
@Bean
DefaultConnectionContext connectionContext(@Value("${cf.apiHost}") String apiHost) {
return DefaultConnectionContext.builder()
.apiHost(apiHost)
.build();
}
@Bean
PasswordGrantTokenProvider tokenProvider(@Value("${cf.username}") String username,
@Value("${cf.password}") String password) {
return PasswordGrantTokenProvider.builder()
.password(password)
.username(username)
.build();
}
SchedulerClient
is only an interface. It has a Reactor-based implementation. To instantiate it, you configure it with a builder:
ReactorSchedulerClient.builder()
.connectionContext(connectionContext)
.tokenProvider(tokenProvider)
.build();
In Spring-based applications, you'll want to encapsulate it in bean a definition:
@Bean
ReactorSchedulerClient schedulerClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
return ReactorSchedulerClient.builder()
.connectionContext(connectionContext)
.tokenProvider(tokenProvider)
.build();
}
The project depends on Java 8. To build from source and install to your local Maven cache, run the following:
$ ./mvnw clean install
To run the integration tests, run the following:
$ ./mvnw -Pintegration-test clean test
IMPORTANT Integration tests should be run against an empty Pivotal Cloud Foundry instance. The integration tests are destructive, affecting nearly everything on an instance given the chance.
The integration tests require a running instance of Pivotal Cloud Foundry to test against. We recommend using PCF Dev to start a local instance to test with. To configure the integration tests with the appropriate connection information use the following environment variables:
Name | Description |
---|---|
TEST_ADMIN_CLIENTID |
Client ID for a client with permissions for a Client Credentials grant |
TEST_ADMIN_CLIENTSECRET |
Client secret for a client with permissions for a Client Credentials grant |
TEST_ADMIN_PASSWORD |
Password for a user with admin permissions |
TEST_ADMIN_USERNAME |
Username for a user with admin permissions |
TEST_APIHOST |
The host of a Cloud Foundry instance. Typically something like api.local.pcfdev.io . |
TEST_PROXY_HOST |
(Optional) The host of a proxy to route all requests through |
TEST_PROXY_PASSWORD |
(Optional) The password for a proxy to route all requests through |
TEST_PROXY_PORT |
(Optional) The port of a proxy to route all requests through. Defaults to 8080 . |
TEST_PROXY_USERNAME |
(Optional) The username for a proxy to route all requests through |
TEST_SKIPSSLVALIDATION |
(Optional) Whether to skip SSL validation when connecting to the Cloud Foundry instance. Defaults to false . |
Pull requests and Issues are welcome.
This project is released under version 2.0 of the Apache License.