Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

push2cloud-cf-adapter

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

push2cloud-cf-adapter

abstracts cloud foundry api

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-21.43%
Maintainers
1
Weekly downloads
 
Created
Source

push2cloud-cf-adapter

npm

This repository is part of the push2cloud project. For contribution guidelines, issues, and general documentation, visit the main push2cloud project page.

push2cloud-cf-adapter abstracts the cloud foundry api. It's designed for use with Node.js and installable via npm install --save push2cloud-cf-adapter.

Usage

const cf = require('push2cloud-cf-adapter');

const api = cf({
  api: process.env.CF_API || 'https://api.lyra-836.appcloud.swisscom.com',
  username: process.env.CF_USER,
  password: process.env.CF_PWD,
  org: process.env.CF_ORG,
  space: process.env.CF_SPACE
});

// the callback way...
api.init((err, result) => {
  api.pushApp({
    name: 'temp-app',
    appPath: join(__dirname, '/sampleApp')
  }, (err, app) => {
    api.stageApp({
      appGuid: app.metadata.guid
      // or: name: 'temp-app'
    }, (err) => {
      api.startAppAndWaitForInstances({
        appGuid: app.metadata.guid
        // or: name: 'temp-app'
      }, (err) => {
        // ...
      });
    });
  });
});

// or the promise way...
api.init()
.then((app) => {
  return api.stageApp({
    appGuid: app.metadata.guid
    // or: name: 'temp-app'
  });
})
.then(() => {
  return api.startAppAndWaitForInstances({
    appGuid: app.metadata.guid
    // or: name: 'temp-app'
  });
})
.then(() => {
  // ...
});

Download

The source is available for download from GitHub. Alternatively, you can install using npm:

npm install --save push2cloud-cf-adapter

You can then require() push2cloud-cf-adapter as normal:

const cf = require('push2cloud-cf-adapter');

Documentation

Each asynchronous call can be done with classical callback style or with promise style.

init([callback])

Retrieves information of the current space. i.e. apps, services, service bindings, routes, domains, etc...

Arguments

none

Examples

const cf = require('push2cloud-cf-adapter');

const api = cf({
  api: 'https://the-url-to-the-cloud-foundry-api-endpoint',
  username: 'my-funny-username',
  password: 'my-very-secret-password',
  org: 'the-cf-org',
  space: 'the-cf-space'
});

api.init((err, result) => {
  console.log(result);
  // {
  //   "apps": [
  //     {
  //       "name": "push2cloud-example-api-1.0.0",
  //       "unversionedName": "push2cloud-example-api",
  //       "guid": "cff85cc4-e217-47f0-b0e0-113d04e6e37d",
  //       "instances": 1,
  //       "memory": 512,
  //       "disk": 512,
  //       "state": "STARTED",
  //       "version": "1.0.0",
  //       "package_state": "STAGED"
  //     },
  //     {
  //       "name": "push2cloud-example-host-2.0.0",
  //       "unversionedName": "push2cloud-example-host",
  //       "guid": "9afc0b68-9004-4292-9284-6110bed72afb",
  //       "instances": 1,
  //       "memory": 512,
  //       "disk": 1024,
  //       "state": "STARTED",
  //       "version": "2.0.0",
  //       "package_state": "STAGED"
  //     }
  //   ],
  //   "serviceBindings": [
  //     {
  //       "service": "todo-db",
  //       "serviceInstanceGuid": "e0dc3f5e-7631-473e-ad3e-ebbf0549ad22",
  //       "app": "push2cloud-example-api-1.0.0",
  //       "unversionedName": "push2cloud-example-api",
  //       "appGuid": "cff85cc4-e217-47f0-b0e0-113d04e6e37d",
  //       "guid": "0d82e751-26ab-40b1-987a-8e1671b39c24"
  //     }
  //   ],
  //   "services": [
  //     {
  //       "name": "todo-db",
  //       "guid": "e0dc3f5e-7631-473e-ad3e-ebbf0549ad22",
  //       "type": "redis",
  //       "plan": "small"
  //     }
  //   ],
  //   "routes": [
  //     {
  //       "guid": "bd7cb2eb-f9fe-4b84-a7cd-1f43969e3ba9",
  //       "domain": "scapp.io",
  //       "domainGuid": "5f952bf2-618b-4584-b37e-92e406149285",
  //       "hostname": "push2cloud-example-host-iot-cf-test",
  //       "app": "push2cloud-example-host-2.0.0",
  //       "unversionedName": "push2cloud-example-host",
  //       "appGuid": "9afc0b68-9004-4292-9284-6110bed72afb"
  //     },
  //     {
  //       "guid": "47542223-1a74-45e9-8857-7baab1b29941",
  //       "domain": "scapp.io",
  //       "domainGuid": "5f952bf2-618b-4584-b37e-92e406149285",
  //       "hostname": "push2cloud-example-api-iot-cf-test",
  //       "app": "push2cloud-example-api-1.0.0",
  //       "unversionedName": "push2cloud-example-api",
  //       "appGuid": "cff85cc4-e217-47f0-b0e0-113d04e6e37d"
  //     }
  //   ],
  //   "envVars": [
  //     {
  //       "env": {
  //         "SYSTEM_VERSION": "1.0.0"
  //       },
  //       "name": "push2cloud-example-api-1.0.0",
  //       "unversionedName": "push2cloud-example-api"
  //     },
  //     {
  //       "env": {
  //         "SYSTEM_VERSION": "1.0.0",
  //         "PUSH2CLOUD_EXAMPLE_API_HOST": "https://push2cloud-example-api-iot-cf-test.scapp.io"
  //       },
  //       "name": "push2cloud-example-host-2.0.0",
  //       "unversionedName": "push2cloud-example-host"
  //     }
  //   ],
  //   "domains": [
  //     {
  //       "guid": "5f952bf2-618b-4584-b37e-92e406149285",
  //       "name": "scapp.io"
  //     },
  //     {
  //       "guid": "dc478cd0-5185-4a48-a964-1e53d868daf2",
  //       "name": "applicationcloud.io"
  //     }
  //   ]
  // }
});

getInfo([callback])

Retrieves information of the cloud foundry platform.

Arguments

none

Example

api.getInfo((err, result) => {
  console.log(result);
  // {
  //   "name": "",
  //   "build": "",
  //   "support": "https://developer.swisscom.com/contact",
  //   "version": 0,
  //   "description": "Cloud Foundry provided by Swisscom",
  //   "authorization_endpoint": "https://login.lyra-836.appcloud.swisscom.com",
  //   "token_endpoint": "https://uaa.lyra-836.appcloud.swisscom.com",
  //   "min_cli_version": null,
  //   "min_recommended_cli_version": null,
  //   "api_version": "2.52.0",
  //   "app_ssh_endpoint": "ssh.lyra-836.appcloud.swisscom.com:2222",
  //   "app_ssh_host_key_fingerprint": "6d:d2:8c:09:64:b6:fc:2b:50:3c:a9:cb:2e:be:d4:a7",
  //   "app_ssh_oauth_client": "ssh-proxy",
  //   "logging_endpoint": "wss://loggregator.lyra-836.appcloud.swisscom.com:443",
  //   "doppler_logging_endpoint": "wss://doppler.lyra-836.appcloud.swisscom.com:443"
  // }
});

FAQs

Package last updated on 18 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc