Cloud Foundry Java Client Facade

A facade of the official Cloud Foundry Java client

License

License

Categories

Categories

Java Languages CLI User Interface
GroupId

GroupId

com.sap.cloud.lm.sl
ArtifactId

ArtifactId

cloudfoundry-java-client-facade
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Cloud Foundry Java Client Facade
A facade of the official Cloud Foundry Java client
Project URL

Project URL

https://github.com/SAP/cf-java-client-sap
Project Organization

Project Organization

SAP SE
Source Code Management

Source Code Management

https://github.com/SAP/cf-java-client-sap.git

Download cloudfoundry-java-client-facade

How to add to project

<!-- https://jarcasting.com/artifacts/com.sap.cloud.lm.sl/cloudfoundry-java-client-facade/ -->
<dependency>
    <groupId>com.sap.cloud.lm.sl</groupId>
    <artifactId>cloudfoundry-java-client-facade</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.sap.cloud.lm.sl/cloudfoundry-java-client-facade/
implementation 'com.sap.cloud.lm.sl:cloudfoundry-java-client-facade:2.0.0'
// https://jarcasting.com/artifacts/com.sap.cloud.lm.sl/cloudfoundry-java-client-facade/
implementation ("com.sap.cloud.lm.sl:cloudfoundry-java-client-facade:2.0.0")
'com.sap.cloud.lm.sl:cloudfoundry-java-client-facade:jar:2.0.0'
<dependency org="com.sap.cloud.lm.sl" name="cloudfoundry-java-client-facade" rev="2.0.0">
  <artifact name="cloudfoundry-java-client-facade" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.sap.cloud.lm.sl', module='cloudfoundry-java-client-facade', version='2.0.0')
)
libraryDependencies += "com.sap.cloud.lm.sl" % "cloudfoundry-java-client-facade" % "2.0.0"
[com.sap.cloud.lm.sl/cloudfoundry-java-client-facade "2.0.0"]

Dependencies

compile (7)

Group / Artifact Type Version
org.springframework : spring-webflux jar 5.2.9.RELEASE
org.springframework.security.oauth : spring-security-oauth2 jar 2.5.0.RELEASE
commons-io : commons-io jar 2.8.0
com.fasterxml.jackson.core : jackson-core jar 2.11.3
com.fasterxml.jackson.core : jackson-databind jar 2.11.3
org.cloudfoundry : cloudfoundry-client-reactor jar 4.10.0.RELEASE
io.micrometer : micrometer-core jar 1.5.5

provided (1)

Group / Artifact Type Version
org.immutables : value jar 2.8.8

test (6)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.7.0
org.junit.jupiter : junit-jupiter-params jar 5.7.0
org.junit.platform : junit-platform-launcher jar 1.7.0
org.junit.jupiter : junit-jupiter-engine jar 5.7.0
org.junit.vintage : junit-vintage-engine jar 5.7.0
org.mockito : mockito-core jar 3.5.13

Project Modules

There are no modules declared in this project.

cf-java-client Build Status REUSE status

This is a facade that hides the official Cloud Foundry Java client (https://github.com/cloudfoundry/cf-java-client) under a synchronous API similar to the one it had back in version 1.1.4.RELEASE (see https://github.com/cloudfoundry/cf-java-client/tree/v1.1.4.RELEASE).

Introduction

The cf-java-client project is a Java language binding for interacting with a Cloud Foundry instance. It provides similar functionality to the Cloud Foundry command line client (https://github.com/cloudfoundry/cli), such as creating services and applications, binding services to applications or even registering service brokers. It communicates with the Cloud Foundry Controller by making HTTP requests to the controller's REST API, which is documented at https://apidocs.cloudfoundry.org/ (V2) and https://v3-apidocs.cloudfoundry.org/ (V3).

Usage

In order to use this client in your application, you need to include the following dependency in your pom.xml:

<dependency>
    <groupId>com.sap.cloud.lm.sl</groupId>
    <artifactId>cloudfoundry-client-facade</artifactId>
    <version>...</version>
</dependency>

The latest version can always be found in Maven Central: https://mvnrepository.com/artifact/com.sap.cloud.lm.sl/cloudfoundry-client-facade

The following is a very simple sample application that connects to a Cloud Foundry instance, logs in, and displays some information about the Cloud Foundry account. When running the program, provide the Cloud Foundry target API endpoint, along with a valid user name and password as command-line parameters.

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;

import com.sap.cloudfoundry.client.facade.domain.CloudApplication;
import com.sap.cloudfoundry.client.facade.domain.CloudServiceInstance;
import com.sap.cloudfoundry.client.facade.domain.CloudSpace;

public final class JavaSample {

    public static void main(String[] args) {
        String target = args[0];
        String username = args[1];
        String password = args[2];

        CloudCredentials credentials = new CloudCredentials(username, password);
        CloudControllerClient client = new CloudControllerClientImpl(getTargetURL(target), credentials);
        client.login();

        System.out.printf("%nSpaces:%n");
        for (CloudSpace space : client.getSpaces()) {
            System.out.printf("  %s\t(%s)%n", space.getName(), space.getOrganization()
                                                                    .getName());
        }

        System.out.printf("%nApplications:%n");
        for (CloudApplication application : client.getApplications()) {
            System.out.printf("  %s%n", application.getName());
        }

        System.out.printf("%nServices%n");
        for (CloudServiceInstance service : client.getServiceInstances()) {
            System.out.printf("  %s\t(%s)%n", service.getName(), service.getLabel());
        }
    }

    private static URL getTargetURL(String target) {
        try {
            return URI.create(target)
                      .toURL();
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException("The target URL is not valid: " + e.getMessage());
        }
    }

}

Compiling and Packaging

The project is built using Apache Maven and you can use the following command to do so:

mvn clean install

Additionally, the project uses Immutables to generate value objects. As a result, it won't compile in IDEs like Eclipse or IntelliJ unless you also have an enabled annotation processor. See this guide for instructions on how to configure your IDE.

com.sap.cloud.lm.sl

SAP

SAP SE, a global software company, is one of the largest vendors of ERP and other enterprise applications.

Versions

Version
2.0.0