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
|
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 |
Returns:
Full URL to resource
- Type
- String
clearCache() → {void}
Clear all cached entries (cache stays enabled).
Returns:
- Type
- void
disableCache() → {void}
Disable the cache and clear all entries.
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 |
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 |
|
filter |
Object |
<optional> |
Base filter (merged with page param) |
Returns:
Flat array of all resource objects
- Type
- Promise.<Array>
getApiVersion() → {String}
Get current API version
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 |
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) |
Returns:
Equivalent field name for current API version
- Type
- String
isUsingV2() → {Boolean}
Check if using API v2
Returns:
- Type
- Boolean
isUsingV3() → {Boolean}
Check if using API v3
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 |
Returns:
- Type
- Boolean
setApiVersion(version) → {void}
Set API version (v2 or v3)
Parameters:
| Name | Type | Description |
|---|---|---|
version |
String | API version (v2 or v3) |
Throws:
-
If version is not supported
- Type
- Error
Returns:
- Type
- void
setEndPoint(endPoint) → {void}
Set endpoint
Parameters:
| Name | Type | Description |
|---|---|---|
endPoint |
String | [CC endpoint] |
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] |
Throws:
-
If token is not provided or invalid
- Type
- Error
Returns:
- Type
- void