cf-node-client
momo auto_awesome BUY CLAUDE KIT WITH 20% OFF coffee BUY ME COFFEE

Class: CloudControllerBase

CloudControllerBase(endPoint, options) → {void}

Base class for Cloud Controller API models Supports both Cloud Foundry API v2 and v3 Default: v3 (set apiVersion to "v2" in options to use v2)

Constructor

new CloudControllerBase(endPoint, options) → {void}

Parameters:
Name Type Description
endPoint String CC endpoint (e.g., https://api.cloudfoundry.com)
options Object Optional configuration
Properties
Name Type Description
apiVersion String API version: "v2" or "v3" (default: "v3")
Source:
Returns:
Type
void

Methods

buildResourceUrl(resourceName, resourceId) → {String}

Build URL for a resource endpoint
Parameters:
Name Type Default Description
resourceName String Name of resource (e.g., "apps", "organizations")
resourceId String null Optional: specific resource ID
Source:
Returns:
Full URL to resource
Type
String

clearCache() → {void}

Clear all cached entries (cache stays enabled).
Source:
Returns:
Type
void

disableCache() → {void}

Disable the cache and clear all entries.
Source:
Returns:
Type
void

enableCache(ttlMsopt) → {void}

Enable the in-memory cache.
Parameters:
Name Type Attributes Default Description
ttlMs Number <optional>
30000 Cache TTL in milliseconds
Source:
Returns:
Type
void

getAllResources(fetchFn, filteropt) → {Promise.<Array>}

Auto-paginate through ALL pages of a list endpoint and return a flat array of every resource. Works with both v2 and v3 response shapes: v2: { total_results, next_url, resources } v3: { pagination: { next: { href } }, resources }
Parameters:
Name Type Attributes Description
fetchFn function A function(filter) → Promise. Typically: (f) => this.getOrganizations(f)
filter Object <optional>
Base filter (merged with page param)
Source:
Returns:
Flat array of all resource objects
Type
Promise.<Array>

getApiVersion() → {String}

Get current API version
Source:
Returns:
API version (v2 or v3)
Type
String

getEndpointPath(resourceName) → {String}

Get endpoint path for a resource
Parameters:
Name Type Description
resourceName String Name of resource
Source:
Returns:
Endpoint path
Type
String

getFieldName(resourceName, fieldName) → {String}

Get v3 field name equivalent for a v2 field
Parameters:
Name Type Description
resourceName String Name of resource
fieldName String Field name (usually v2 name)
Source:
Returns:
Equivalent field name for current API version
Type
String

isUsingV2() → {Boolean}

Check if using API v2
Source:
Returns:
Type
Boolean

isUsingV3() → {Boolean}

Check if using API v3
Source:
Returns:
Type
Boolean

needsSpecialHandling(resourceName) → {Boolean}

Check if resource needs special handling for current API version
Parameters:
Name Type Description
resourceName String Name of resource
Source:
Returns:
Type
Boolean

setApiVersion(version) → {void}

Set API version (v2 or v3)
Parameters:
Name Type Description
version String API version (v2 or v3)
Source:
Throws:
If version is not supported
Type
Error
Returns:
Type
void

setEndPoint(endPoint) → {void}

Set endpoint
Parameters:
Name Type Description
endPoint String [CC endpoint]
Source:
Throws:
If endpoint is not a valid URL
Type
Error
Returns:
Type
void

setToken(token) → {void}

Set token
Parameters:
Name Type Description
token JSON [Oauth token from UAA]
Source:
Throws:
If token is not provided or invalid
Type
Error
Returns:
Type
void