Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

cf-client

IBM-Bluemix227Apache-2.00.13.26

A Cloud Foundry Client for Node.js

cloud foundry, cloudfoundry, cloud-foundry, vcap, pivotal, pivotalcf, ibm, bluemix, cloud, api, REST, cf, cf client, paas

readme

cf-client

Build Status Build status Dependency Status devDependency Status Changelog API Doc

NPM

Table of Contents

Overview

This project provides a simple client library to interact with the Cloud Foundry Architecture:

ScreenShot

Using this library, you could interact with the following platforms: PWS , Bluemix or a Local Cloud Foundry instance:

Cloud Controller UAA Logging & Metrics
Apps Users Logs
Buildpacks |
Domains |
Jobs |
Organizations |
Organizations Quotas |
Routes |
Services |
Service Bindings |
Service Instances |
Service Plans |
Spaces |
Spaces Quotas |
Stacks |
User provided Services |
Users

Focus

The development doesn't cover the whole CloudController API. Main areas of development are:

App life cycle:

  • Create an App
  • Upload source code in .zip or .war (Support for Static, Python, PHP, Node.js & JEE)
  • Create an User Provided Services
  • Associate Apps with an User Provided Services
  • Start | Stop an App
  • Restage Apps
  • Scale Apps
  • Simple Logs management
  • Remove Apps
  • Remove User Provided Services

PaaS Management:

  • Organization quota
  • Organization
  • Space
  • Services, Service Instances, Service Plans, User provided Services & Service Binding
  • UAA Users
  • Users

Getting Started

If you need to interact with a Cloud Foundry platform try this online tool and use this example:

"use-strict";

const endpoint = "https://api.ng.bluemix.net";
const username = "BLUEMIX_USERNAME";
const password = "BLUEMIX_PASSWORD";

const CloudController = new (require("cf-client")).CloudController(endpoint);
const UsersUAA = new (require("cf-client")).UsersUAA;
const Apps = new (require("cf-client")).Apps(endpoint);

CloudController.getInfo().then( (result) => {
    UsersUAA.setEndPoint(result.authorization_endpoint);
    return UsersUAA.login(username, password);
}).then( (result) => {
    Apps.setToken(result);
    return Apps.getApps();
}).then( (result) => {
    console.log(result);
}).catch( (reason) => {
    console.error("Error: " + reason);
});

Explore the library and if you like the features, use it on your App:


npm install cf-client --save

Testing

This project has a test suite to ensure the readability of this project. Take a look the Tests cases developed with Mocha & Chai to understand some stuff about Cloud Foundry and the usage of this client. Besides, the project has invested some amount of time in testing phase to be the code with a nice coverage level.

The development has been tested with:

Local Instance PWS Bluemix
2.25.0 2.47.0 2.40.0

Last test: 2016/01/26

Testing against Bluemix:

export BLUEMIX_CF_API_URL=https://api.ng.bluemix.net && export BLUEMIX_username=$USERNAME && export BLUEMIX_password=$PASSWORD && npm run test:bluemix

Test suite:

npm test

Code coverage:

istanbul cover node_modules/mocha/bin/_mocha -- -R spec

Issues

If you have any question or doubt, please create an issue.

License

Licensed under the Apache License, Version 2.0.

References

changelog

Version 0.13.0 2016-01-26

  • Add ESLint support
  • Refactor code to ES2015
  • Initial support to deploy Docker containers on CF
  • Refactor log support
  • Add method setToken in every Object to avoid sending token in every method

Environment: LOCAL_INSTANCE_1

90 passing (3m) 37 pending

Environment: PIVOTAL

87 passing (5m) 33 pending

Version 0.12.0 2015-12-22

  • Support to refresh OAuth Token.
  • Adding PHP & Python buildpacks.
  • Package.json refactoring

Pull Requests:

@jthomas:

  • Support for Service Instances
  • Support for Services
  • Support for ServicePlans
  • Support for filters in Events

Environment: LOCAL_INSTANCE_1

89 passing (3m) 33 pending

Environment: PIVOTAL

82 passing (4m) 29 pending

Environment: BLUEMIX

82 passing (4m) 29 pending

Version 0.11.1 2015-11-23

  • Defensive code in HttpUtils.js (Avoid crashing in case of Server down or service not reply expected JSON)

Version 0.11.0 2015-11-20

  • Refactor some methods:
Apps.prototype.create = function (token_type, access_token, appOptions) {
Apps.prototype.add = function (token_type, access_token, appOptions) {

Apps.prototype.stopApp = function (token_type, access_token, app_guid) {
Apps.prototype.stop = function (token_type, access_token, app_guid) {

Apps.prototype.startApp = function (token_type, access_token, app_guid) {
Apps.prototype.start = function (token_type, access_token, app_guid) {

Apps.prototype.deleteApp = function (token_type, access_token, app_guid) {
Apps.prototype.remove = function (token_type, access_token, app_guid) {

Apps.prototype.uploadApp = function (token_type, access_token, app_guid, filePath, async) {
Apps.prototype.upload = function (token_type, access_token, app_guid, filePath, async) {

Apps.prototype.environmentVariables = function (token_type, access_token, app_guid) {
Apps.prototype.getEnvironmentVariables = function (token_type, access_token, app_guid) {

Organizations.prototype.memoryUsage = function (token_type, access_token, org_guid) {
Organizations.prototype.getMemoryUsage = function (token_type, access_token, org_guid) {

Organizations.prototype.summary = function (token_type, access_token, org_guid) {
Organizations.prototype.getSummary = function (token_type, access_token, org_guid) {

OrganizationsQuota.prototype.quotaDefinitions = function (token_type, access_token) {
OrganizationsQuota.prototype.getQuotaDefinitions = function (token_type, access_token) {

OrganizationsQuota.prototype.quotaDefinition = function (token_type, access_token, org_guid) {
OrganizationsQuota.prototype.getQuotaDefinition = function (token_type, access_token, org_guid) {

Routes.prototype.addRoute = function (token_type, access_token, routeOptions) {
Routes.prototype.add = function (token_type, access_token, routeOptions) {

Routes.prototype.deleteRoute = function (token_type, access_token, route_guid) {
Routes.prototype.remove = function (token_type, access_token, route_guid) {

ServiceBindings.prototype.removeServiceBinding = function (token_type, access_token, service_guid){
ServiceBindings.prototype.remove = function (token_type, access_token, service_guid) {

Spaces.prototype.summary = function (token_type, access_token, space_guid) {
Spaces.prototype.getSummary = function (token_type, access_token, space_guid) {

Spaces.prototype.userRoles = function (token_type, access_token, space_guid) {
Spaces.prototype.getUserRoles = function (token_type, access_token, space_guid) {

SpacesQuota.prototype.quotaDefinitions = function (token_type, access_token) {
SpacesQuota.prototype.getQuotaDefinitions = function (token_type, access_token) {

UserProvidedServices.prototype.create = function (token_type, access_token, user_provided_service_options) {
UserProvidedServices.prototype.add = function (token_type, access_token, user_provided_service_options) {

UserProvidedServices.prototype.delete = function (token_type, access_token, service_guid) {
UserProvidedServices.prototype.remove = function (token_type, access_token, service_guid) {

Users.prototype.getUsers = function (token_type, access_token, user_guid) {
Users.prototype.getUsers = function (token_type, access_token) {

Environment: LOCAL_INSTANCE_1

72 passing (2m) 26 pending

Environment: PIVOTAL

64 passing (5m) 21 pending

Environment: BLUEMIX

64 passing (5m) 21 pending

Version 0.10.0 2015-11-06

  • Adding Online documentation: http://prosociallearneu.github.io/cf-nodejs-client-docs/
  • Add method to restage Apps
  • Refactor methods: UserProvidedServices.prototype.create Routes.prototype.checkRoute & Routes.prototype.getRoutes Logs.prototype.getRecent CloudFoundry.prototype.login Apps.prototype.associateRoute Apps.prototype.associateRoute Apps.prototype.stopApp & Apps.prototype.startApp Apps.prototype.getAppByName Apps.prototype.getApps Routes.prototype.addRoute Routes.prototype.checkRoute

Environment: LOCAL_INSTANCE_1

71 passing (2m) 25 pending

Environment: PIVOTAL

63 passing (4m) 20 pending

Environment: BLUEMIX

63 passing (4m) 20 pending

Version 0.9.1 2015-10-29

  • Adding the dependency Bluebird to improve the performance
  • Adding support for Quotas (Org/Space)
  • It is possible to create users in the system. (Quota/Org/Space/User)

Environment: LOCAL_INSTANCE_1

65 passing (2m) 23 pending

Environment: PIVOTAL

58 passing (3m) 19 pending

Environment: BLUEMIX

58 passing (3m) 19 pending

Version 0.9.0 2015-10-23

  • Adding support for Java Buildpack
  • Testing development in 3 environments: Local Instance (Yudai), PSW & Bluemix
  • Initial support for Organizations & Spaces

Environment: LOCAL_INSTANCE_1

57 passing (1m) 16 pending

Environment: PIVOTAL

57 passing (1m) 16 pending

Environment: BLUEMIX

57 passing (4m) 16 pending

Version 0.8.3 2015-10-19

  • Adding the capability to add filters in a Service Binding Search.

    39 passing (1m) 15 pending

Version 0.8.2 2015-10-19

  • Minor fix in index.js to export UserProvidedServices in the right way.

    39 passing (2m) 14 pending

Version 0.8.1 2015-10-01

  • Adding adding method in the whole project: setEndPoint

    39 passing (2m) 14 pending

Version 0.8.0 2015-09-28

  • Adding support for User Provided Services
  • Adding support for Service Binding

    39 passing (1m) 14 pending

Version 0.7.0 2015-09-10

  • Big performance improvement in tests.
  • Remove the usage of process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
  • Initial Log support

    37 passing (2m) 6 pending

Version 0.6.2 2015-09-04

  • CloudFoundry.setEndpoint (0.6.1)
  • App.uploadApp with async flag
  • App.uploadApp without the useless parameter appName

    35 passing (3m) 4 pending

Version 0.0.6 2015-08-20

  • Better support for: Create App, Upload Bits for App & Start App

    32 passing (3m) 3 pending

Version 0.0.5 2015-08-14

  • Pending

    16 passing (23s) 3 pending