hortonworks/cloud-swagger-mock

Name: cloud-swagger-mock

Owner: Hortonworks Inc

Description: null

Created: 2018-05-15 12:22:29.0

Updated: 2018-05-15 16:33:36.0

Pushed: 2018-05-15 16:33:35.0

Homepage: null

Size: 4

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Cloudbreak API mock

Get SWAGGER Codegen

Install Swagger Codegen CLI.

CLI is also available as Docker Image. You can read further here.

Get Help

To get a list of available general options, you can run help generate.

NodeJS specific options

Supported config options can be different per language. Running config-help -l {lang} will show available options.

Server stub generator HOWTO

The documentation to generate a server stub for a couple different frameworks.

Generate Cloudbreak API NodeJS Client
 generate-api
Upgrade Swagger YML
Base Path

Change basePath: "/api" to basePath: "/cb" at /api/swagger.yaml.

New Info and Health Services

Introduce brand new Services for Cloudbreak Info and Health.

  1. In the tags section:
    :
    
  2. name: “info”
  3. name: “health”
  4. In the beginning of the paths:
    s:
    o:
    
    gs:
    "info"
    mmary: "retrieve Cloudbreak version for user"
    scription: "Cloudbreak version information."
    erationId: "getCloudbreakInfo"
    hemes:
    "http"
    "https"
    nsumes:
    "application/json"
    oduces:
    "application/json"
    rameters: []
    sponses:
    200:
      description: "successful operation"
      schema:
        $ref: "#/definitions/Info"
    swagger-router-controller: "Info"
    lth:
    
    gs:
    "health"
    mmary: "retrieve Cloudbreak server status for user"
    scription: "Cloudbreak server status."
    erationId: "getCloudbreakHealth"
    hemes:
    "http"
    "https"
    nsumes:
    "application/json"
    oduces:
    "application/json"
    rameters: []
    sponses:
    200:
      description: "successful operation"
      schema:
        $ref: "#/definitions/Info"
    swagger-router-controller: "Info"
    
  5. In the end of definitions:
    nitions:
    
    :
    : "object"
    
Extend Paths

Extend all the paths: with /api, for example change /v1/accountpreferences/isplatformselectiondisabled to /api/v1/accountpreferences/isplatformselectiondisabled

Provide responses to all the needed Services

Introduce brand new Services for Cloudbreak Info and Health here as well. The new files should be Info.js and InfoService.js.

For existing services here is an example for V1credentialsService:

  1. Create/Update a related Json file at responses/credentials/openstack.json
  2. Introduce/Update this new response to the getPublicsCredential method of V1credentialsService:

For existing services here is an example for V1credentialsService.js:

rts.getPublicsCredential = function(args, res, next) {
*
 retrieve public and private (owned) credentials
 Cloudbreak is launching Hadoop clusters on the user's behalf - on different cloud providers. One key point is that Cloudbreak does not store your Cloud provider account details (such as username, password, keys, private SSL certificates, etc). We work around the concept that Identity and Access Management is fully controlled by you - the end user. The Cloudbreak deployer is purely acting on behalf of the end user - without having access to the user's account.

 returns List
*/
r openstack_data = require('../responses/credentials/openstack.json');
r aws_data = require('../responses/credentials/aws.json');
r azure_data = require('../responses/credentials/azure.json');
r gcp_data = require('../responses/credentials/gcp.json');
r response_array = [];

sponse_array.push(openstack_data,aws_data,azure_data,gcp_data);

r examples = {};
amples['application/json'] = response_array;
 (Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
else {
res.end();


Cloudbreak API Mock Docker Image

You can find at Docker Hub

Build local image

You can build your own Cloudbreak Mock image locally with:

er build -t hortonworks/cloudbreak-mock:latest .
Update CBD Profile with Cloudbreak API Mock Image

First, initialize Cloudbreak Mock by updating the CBD Profile file with the following content:

rt DOCKER_IMAGE_CLOUDBREAK=hortonworks/cloudbreak-mock
rt DOCKER_TAG_CLOUDBREAK=latest
Start Cloudbreak Mock

To start the Cloudbreak Mock application use the following command:

start

This will start all the needed Docker containers and initialize the mock application.


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.