Skip to content

kushmerick/cfoundry-scala

Repository files navigation

cfoundry-scala

cfoundry-scala is a Scala client for Cloud Foundry.

cfoundry-scala is a work-in-progress! The client is basically stable/functional with no known bugs. But it does not yet support several CF resources (e.g. users, routes, domains, quotas, stacks), and support for other resources is incomplete (e.g., user roles aren't finished).

Installation

Download the latest "cfoundry-scala-*.jar" and add it to your classpath.

cfoundry-scala depends on a bunch of other JARs. For convenience, "cfoundry-scala-.jar" and all its dependencies are available as "cfoundry-scala--complete.zip".

Using cfoundry-scala from Scala

In Scala, the syntax for retrieving and manipulating CF resources resembles navigating through a complex local datastructure.

val client = new Client(target)
client.login(username, password)
for (service <- client.services) {
  for (servicePlan <- service.servicePlans) {
    ...
  }
}
client.logout

The full Scala sample shows many more details -- such as creating new resources, and writing local changes to a resource back to CF.

Using cfoundry-scala from Java

cfoundry-scala also exposes a statically-typed Java-friendly (getFoo, setFoo, newFoo) API:

Client client = new Client(target);
client.login(username, password);
for (Service service : client.getServices()) {
  for (ServicePlan servicePlan : service.getServicePlans()) {
    ...
  }
}
client.logout();

For more details, see the full Java sample.

(Of course, Scala code can also consume the statically-typed API!)

Implementation details

Like the cfoundry Ruby client, cfoundry-scala relies on metaprogramming so that each CF resource is specified in a simple declarative manner. For example, here is the Service resource:

class Service ... {
  property("name", source = "label")
  property("provider")
  property("version")
  property("active", typ = "bool")
  hasMany("servicePlan")
    ...
}

The Java-friendly API is automatically generated from these resource specifications. I will reimplement this API using Scala macros when support for adding new class members is ready for prime time.

About

CFoundry Scala

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published