pivotal-cf/pcf-java-client

Name: pcf-java-client

Owner: Pivotal Cloud Foundry

Description: null

Created: 2018-03-29 22:41:39.0

Updated: 2018-04-20 06:11:03.0

Pushed: 2018-04-19 22:57:43.0

Homepage: null

Size: 260

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Cloud Foundry Java Client

Maven Central

| Artifact | Javadocs | ——– | ——– | pivotal-cloudfoundry-client | Javadocs | pivotal-cloudfoundry-client-reactor | Javadocs

| Job | Status | — | —— | unit-test | unit-test | integration-test | integration-test | deploy | 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.

Dependencies

Most projects will need one dependencies; the implementation of the Client API. For Maven, the dependencies would be defined like this:

endencies>
<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>
...
pendencies>

Snapshot artifacts can be found in the Spring snapshot repository:

ositories>
<repository>
    <id>spring-snapshots</id>
    <name>Spring Snapshots</name>
    <url>http://repo.spring.io/snapshot</url>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
</repository>
...
positories>

For Gradle, the dependencies would be defined like this:

ndencies {
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:

sitories {
maven { url 'http://repo.spring.io/snapshot' }
...

Usage

The pivotal-cloudfoundry-client projects follows a “Reactive” design pattern and expose its responses with Project Reactor Monoss and Fluxs.

SchedulerClient Builder

The 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:

ultConnectionContext.builder()
.apiHost(apiHost)
.build();

wordGrantTokenProvider.builder()
.password(password)
.username(username)
.build();

In Spring-based applications, you'll want to encapsulate them in bean definitions:

n
ultConnectionContext connectionContext(@Value("${cf.apiHost}") String apiHost) {
return DefaultConnectionContext.builder()
    .apiHost(apiHost)
    .build();


n
wordGrantTokenProvider 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:

torSchedulerClient.builder()
.connectionContext(connectionContext)
.tokenProvider(tokenProvider)
.build();

In Spring-based applications, you'll want to encapsulate it in bean a definition:

n
torSchedulerClient schedulerClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
return ReactorSchedulerClient.builder()
    .connectionContext(connectionContext)
    .tokenProvider(tokenProvider)
    .build();

Development

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.

Contributing

Pull requests and Issues are welcome.

License

This project is released under version 2.0 of the Apache License.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.