Namespace: utils

cox-chapi.utils

Methods

(static) execute(component, func, params, cbopt)

Executes func on component with params as parameters
Parameters:
Name Type Attributes Description
component object
func function
params Array.<string>
cb mixedCallback <optional>
called with the result of func (required if func takes a callback)
Source:

(static) find_api_key(cb)

gets the api_key for the current environment
Parameters:
Name Type Description
cb objectCallback called with the api_key
Source:

(static) find_cache(cb)

gets the cache with the given cache_name from the settings file if it exists
Parameters:
Name Type Description
cb mixedCallback called with the cache value
Source:

(static) find_creds(cb)

gets the creds object from the settings file if it exists
Parameters:
Name Type Description
cb objectCallback called with the credentials object
Deprecated:
  • use find_api_key instead
Source:

(static) parse_chapi(params) → {Array}

parses an array of key-value pairs (ie. --key=value) into a javscript object
Parameters:
Name Type Description
params Array.<string> an array of chapi strings of the form "--key=value"
Source:
Returns:
an array whose first parameter is an object containing the key-value pairs, and the remaining parameters are any non-key-value pairs in the order that they were given
Type
Array

(static) print_response(err, res)

prints the contents of a json object or an error message. Intended as a callback
Parameters:
Name Type Description
err object
res mixed
Source:

(static) read_stdin(cb)

Reads from stdin and sends data through callback
Parameters:
Name Type Description
cb stringCallback called with the data that was read in
Source:

(static) run(script) → {EventEmitter}

executes a script in the scripts folder with the given arguments
Parameters:
Name Type Description
script string the name of the script to run (without .js)
Source:
Returns:
an EventEmitter for the child process
Type
EventEmitter

(static) send_request(flagsopt, options, send_data, cb)

function for sending an HTTPS call for CloudHealth's API
Parameters:
Name Type Attributes Description
flags object <optional>
an optional flags object
Properties
Name Type Attributes Description
headers boolean <optional>
if true, yield only the headers returned
options object options to use for the https.request function
send_data string data to send
cb objectCallback called with the parsed json response body
Source:

(static) set_api_key(api_key, cbopt)

sets the api_key for an environment
Parameters:
Name Type Attributes Description
api_key string the api_key to use for CloudHealth
cb objectCallback <optional>
called with the api_key
Source:

(static) set_cache(cache_name, cache, cbopt)

sets a cache with the given cache_name object by writing to a settings file
Parameters:
Name Type Attributes Description
cache_name string the name of the cache variable to set
cache mixed the new cache variable
cb mixedCallback <optional>
called with the new cache variable
Source:

(static) set_creds(api_key, cbopt)

sets the credentials object by writing to a settings file
Parameters:
Name Type Attributes Description
api_key string the api_key to use for CloudHealth
cb objectCallback <optional>
called with the credentials object
Deprecated:
  • use set_api_key instead
Source: