Skip to content

Latest commit

 

History

History
237 lines (176 loc) · 9.42 KB

api.md

File metadata and controls

237 lines (176 loc) · 9.42 KB

Classes

AdobeState

Cloud State Management

Functions

validate(schema, data)object

Validates json according to a schema.

init([config])Promise.<AdobeState>

Initializes and returns the key-value-store SDK.

To use the SDK you must either provide your OpenWhisk credentials in config.ow or your own

OpenWhisk credentials can also be read from environment variables __OW_NAMESPACE and __OW_API_KEY.

Typedefs

AdobeStateCredentials : object

AdobeStateCredentials

AdobeStatePutOptions : object

AdobeState put options

AdobeStateGetReturnValue : object

AdobeState get return object

OpenWhiskCredentials : object

An object holding the OpenWhisk credentials

AdobeStateLibError : object
AdobeStateLibErrors : object

Adobe State lib custom errors. e.sdkDetails provides additional context for each error (e.g. function parameter)

AdobeState

Cloud State Management

Kind: global abstract class

adobeState.get(key) ⇒ Promise.<AdobeStateGetReturnValue>

Retrieves the state value for given key. If the key doesn't exist returns undefined.

Kind: instance method of AdobeState
Returns: Promise.<AdobeStateGetReturnValue> - get response holding value and additional info

Param Type Description
key string state key identifier

adobeState.put(key, value, [options]) ⇒ Promise.<string>

Creates or updates a state key-value pair

Kind: instance method of AdobeState
Returns: Promise.<string> - key

Param Type Description
key string state key identifier
value string state value
[options] AdobeStatePutOptions put options

adobeState.delete(key) ⇒ Promise.<string>

Deletes a state key-value pair

Kind: instance method of AdobeState
Returns: Promise.<string> - key of deleted state or null if state does not exists

Param Type Description
key string state key identifier

adobeState.deleteAll() ⇒ Promise.<boolean>

Deletes all key-values

Kind: instance method of AdobeState
Returns: Promise.<boolean> - true if deleted, false if not

adobeState.any() ⇒ Promise.<boolean>

There exists key-values.

Kind: instance method of AdobeState
Returns: Promise.<boolean> - true if exists, false if not

adobeState.stats() ⇒ Promise.<({bytesKeys: number, bytesValues: number, keys: number}|boolean)>

Get stats.

Kind: instance method of AdobeState
Returns: Promise.<({bytesKeys: number, bytesValues: number, keys: number}|boolean)> - namespace stats or false if not exists

validate(schema, data) ⇒ object

Validates json according to a schema.

Kind: global function
Returns: object - the result

Param Type Description
schema object the AJV schema
data object the json data to test

init([config]) ⇒ Promise.<AdobeState>

Initializes and returns the key-value-store SDK.

To use the SDK you must either provide your OpenWhisk credentials in config.ow or your own

OpenWhisk credentials can also be read from environment variables __OW_NAMESPACE and __OW_API_KEY.

Kind: global function
Returns: Promise.<AdobeState> - An AdobeState instance

Param Type Description
[config] object used to init the sdk
[config.ow] OpenWhiskCredentials OpenWhiskCredentials. Set those if you want to use ootb credentials to access the state management service. OpenWhisk namespace and auth can also be passed through environment variables: __OW_NAMESPACE and __OW_API_KEY

AdobeStateCredentials : object

AdobeStateCredentials

Kind: global typedef
Properties

Name Type Description
namespace string the state store namespace
apikey string the state store api key
region 'amer' | 'apac' | 'emea' the region for the Adobe State Store. defaults to 'amer'

AdobeStatePutOptions : object

AdobeState put options

Kind: global typedef
Properties

Name Type Description
ttl number time-to-live for key-value pair in seconds, defaults to 24 hours (86400s). Set to < 0 for max ttl of one year. A value of 0 sets default.

AdobeStateGetReturnValue : object

AdobeState get return object

Kind: global typedef
Properties

Name Type Description
expiration string the ISO-8601 date string of the expiration time for the key-value pair
value string the value set by put

OpenWhiskCredentials : object

An object holding the OpenWhisk credentials

Kind: global typedef
Properties

Name Type Description
namespace string user namespace
auth string auth key

AdobeStateLibError : object

Kind: global typedef
Properties

Name Type Description
message string The message for the Error
code string The code for the Error
sdk string The SDK associated with the Error
sdkDetails object The SDK details associated with the Error

AdobeStateLibErrors : object

Adobe State lib custom errors. e.sdkDetails provides additional context for each error (e.g. function parameter)

Kind: global typedef
Properties

Name Type Description
ERROR_BAD_ARGUMENT AdobeStateLibError this error is thrown when an argument is missing, has invalid type, or includes invalid characters.
ERROR_BAD_REQUEST AdobeStateLibError this error is thrown when an argument has an illegal value.
ERROR_PAYLOAD_TOO_LARGE AdobeStateLibError this error is thrown when the state key, state value or underlying request payload size exceeds the specified limitations.
ERROR_BAD_CREDENTIALS AdobeStateLibError this error is thrown when the supplied init credentials are invalid.
ERROR_UNAUTHORIZED AdobeStateLibError this error is thrown when the credentials are unauthorized to access the resource
ERROR_INTERNAL AdobeStateLibError this error is thrown when an unknown error is thrown by the underlying DB provider or TVM server for credential exchange. More details can be found in e.sdkDetails._internal.
ERROR_REQUEST_RATE_TOO_HIGH AdobeStateLibError this error is thrown when the request rate for accessing state is too high.