Skip to content

Latest commit

 

History

History
284 lines (213 loc) · 11.4 KB

api.md

File metadata and controls

284 lines (213 loc) · 11.4 KB

Classes

AdobeState

Cloud State Management

Members

MAX_TTL : number

Max supported TTL, 365 days in seconds

Functions

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.getRegionalEndpoint(endpoint, region) ⇒ string

Gets the regional endpoint for an endpoint.

Kind: instance method of AdobeState
Returns: string - the endpoint, with the correct region

Param Type Description
endpoint string the endpoint to test
region string the region to set

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|null)>

Deletes a state key-value pair

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

Param Type Description
key string state key identifier

adobeState.deleteAll(options) ⇒ Promise.<{keys: number}>

Deletes multiple key-values. The match option is required as a safeguard. CAUTION: use { match: '*' } to delete all key-values.

Kind: instance method of AdobeState
Returns: Promise.<{keys: number}> - returns an object with the number of deleted keys.

Param Type Description
options object deleteAll options.
options.match string REQUIRED, a glob pattern to specify which keys to delete.

Example

await state.deleteAll({ match: 'abc*' })

adobeState.any() ⇒ Promise.<boolean>

There exists key-values in the region.

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

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

Get stats.

Kind: instance method of AdobeState
Returns: Promise.<{bytesKeys: number, bytesValues: number, keys: number}> - State container stats.

adobeState.list(options) ⇒ AsyncGenerator.<{keys: Array.<string>}>

List keys, returns an iterator. Every iteration returns a batch of approximately countHint keys.

Kind: instance method of AdobeState
Returns: AsyncGenerator.<{keys: Array.<string>}> - an async generator which yields a { keys } object at every iteration.

Param Type Description
options object list options
options.match string a glob pattern that supports '*' to filter keys.
options.countHint number an approximate number on how many items to return per iteration. Default: 100, min: 10, max: 1000.

Example

for await (const { keys } of state.list({ match: 'abc*' })) {
   console.log(keys)
 }

MAX_TTL : number

Max supported TTL, 365 days in seconds

Kind: global variable

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
[config.region] string optional region to use, accepted values: amer (default), emea

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. When not defined or set to 0, defaults to 24 hours (86400s). Max TTL is one year (31536000s), require('@adobe/aio-lib-state').MAX_TTL. A TTL of 0 defaults to 24 hours.

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.