Overview
The Eventing REST API provides methods to work with and manipulate Couchbase Eventing functions.
Version information
Version : 7.6
Host information
{scheme}://{host}:{port}
The URL scheme, host, and port are as follows.
Component | Description |
---|---|
scheme |
The URL scheme. Use Values: |
host |
The host name or IP address of a node running the Eventing service. Example: |
port |
The Eventing service REST port. Use Values: |
Examples on this page
In the HTTP request examples:
Resources
This section describes the operations available with this REST API. The operations are grouped in the following categories.
Activation
Table of Contents
Deploy a Function
POST /api/v1/functions/{function}/deploy
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Pause a Function
POST /api/v1/functions/{function}/pause
Description
Pauses a function and creates a DCP checkpoint such that on a subsequent resume no mutations will be lost. This is the preferred invocation.
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Resume a Function
POST /api/v1/functions/(function}/resume
Description
Resumes a paused function from its paused DCP checkpoint. This is the preferred invocation.
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Undeploy a Function
POST /api/v1/functions/{function}/undeploy
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Advanced
Table of Contents
Create or Import a Function
Create or Import Multiple Functions
View a Function
View Multiple Functions
Delete Function
Delete Multiple Functions
Export Multiple Functions
Import Multiple Functions
View Function Settings
Update Function Settings
View Function Config
Update Function Config
View Function Code
Update Function Code
Create or Import a Function
POST /api/v1/functions/{function}
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Name | Description | Schema |
---|---|---|
Body |
A single function definition object, or an array containing a single function definition object. The function name in the definition object must match that given by the path parameter. |
Example HTTP Requests
curl -XPOST -d @./my_function.json \
"http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function"
curl -XPOST -d @./my_function.json \
"http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function?bucket=bulk&scope=data"
Create or Import Multiple Functions
POST /api/v1/functions
Description
Creates or imports multiple functions.
Note that if any function's language_compatibility
field is missing, the value will be set to the highest version supported by the server, unlike Import Multiple Functions.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
Body |
A single function definition object, or an array containing one or more function definition objects. Function names must be unique. When multiple functions have the same name, an error is reported. |
View a Function
GET /api/v1/functions/{function}
Description
Provides a listing of a complete function definition available in the cluster. The function could be in any state: deployed, undeployed, or paused. If saved to a file the function definition can be imported into the cluster or a different cluster. However any changes to the function definition made to the file outside the UI are discouraged.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Returns a single function definition object. |
|
404 |
Failure. |
Example HTTP Requests
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function"
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function?bucket=bulk&scope=data"
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function" \
-o my_function.json
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function?bucket=bulk&scope=data" \
-o my_function.json
View Multiple Functions
GET /api/v1/functions
Description
Provides an array of definitions of all functions available in the cluster. The functions may be in any state: deployed, undeployed, or paused. If saved to a file the function definitions can be imported into the cluster or a different cluster. However any changes to the function definition made to the file outside the UI are discouraged.
If this API is run as a non-Administrator, the results are filtered via RBAC to include only the function scopes the user has access to.
-
application/json
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Returns an array containing one or more function definition objects. |
Function Definition array |
404 |
Failure. |
Delete Function
DELETE /api/v1/functions/{function}
Description
Deletes a specific function from the cluster.
WARNING: Use this API with caution, as it is irreversible.
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Delete Multiple Functions
DELETE /api/v1/functions
Description
Deletes all functions from the cluster. WARNING: Use this API with caution, as it is irreversible.
If this API is run as a non-Administrator the deleted set will be filtered via RBAC to include only the function scopes the user has access to.
Export Multiple Functions
GET /api/v1/export
Description
This is a convenience method to export all function definitions. Exported functions are always set to the undeployed state at the time of export, regardless of their state in the cluster. If saved to a file the function definitions can be imported into the cluster or a different cluster. However any changes to the function definition made to the file outside the UI are discouraged.
If this API is run as a non-Administrator the results are filtered via RBAC to include only the function scopes the user has access to.
-
application/json
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Returns an array containing one or more function definition objects. |
Function Definition array |
404 |
Failure. |
Import Multiple Functions
POST /api/v1/import
Description
Imports multiple functions.
Note that if any function's language_compatibility
field is missing, the value will be set to 6.0.0, unlike Create or Import Multiple Functions.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
Body |
A single function definition object, or an array containing one or more function definition objects. Function names must be unique. When multiple functions have the same name, an error is reported. |
View Function Settings
GET /api/v1/functions/{function}/settings
Description
Return or export the full settings for one eventing function in the cluster. The settings can be subsequently imported. However any changes to the function settings made to the file outside the UI are discouraged.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Returns an object showing settings for the specified function. |
|
404 |
Failure. |
Example HTTP Requests
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings"
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings?bucket=bulk&scope=data"
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings" \
-o my_function.json
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings?bucket=bulk&scope=data" \
-o my_function.json
Update Function Settings
POST /api/v1/functions/{function}/settings
Description
Updates an undeployed or paused function with the provided settings. You can only alter settings when the function is paused or undeployed; attempting to adjust a deployed function will result in an error. During an edit, settings provided are merged. Unspecified attributes retain their prior values.
Note that you must always specify deployment_status
and processing_status
when using this REST endpoint to update any option or set of options.
To get the current values of deployment_status
and processing_status
, see View All Functions Status or View Function Status.
By adjusting deployment_status
and processing_status
this command can also deploy or resume a function; however, it cannot pause or undeploy a function.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Name | Description | Schema |
---|---|---|
Body |
An object providing settings for the specified function. |
Example HTTP Requests
This example updates the worker_count
setting.
curl -XPOST -d '{
"deployment_status": false,
"processing_status": false,
"worker_count": 6
}' "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings"
This example updates the worker_count
setting.
curl -XPOST -d '{
"deployment_status": false,
"processing_status": false,
"worker_count": 6
}' "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings?bucket=bulk&scope=data"
This example updates the app_log_max_files
and app_log_max_size
settings.
The function is currently undeployed.
curl -XPOST -d '{
"deployment_status": false,
"processing_status": false,
"app_log_max_files": 5
"app_log_max_size":10485760
}' "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings"
This example updates the app_log_max_files
and app_log_max_size
settings.
The function is currently undeployed.
curl -XPOST -d '{
"deployment_status": false,
"processing_status": false,
"app_log_max_files": 5,
"app_log_max_size": 10485760
}' "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings?bucket=bulk&scope=data"
This example updates the timer_context_size
setting.
The function is currently paused.
curl -XPOST -d '{
"deployment_status": true,
"processing_status": false,
"timer_context_size": 2048
}' "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings"
This example updates the timer_context_size
setting.
The function is currently paused.
curl -XPOST -d '{
"deployment_status": true,
"processing_status": false,
"timer_context_size": 2048
}' "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings?bucket=bulk&scope=data"
This example updates the worker_count
setting and resumes.
The function is currently paused.
curl -XPOST -d '{
"deployment_status": true,
"processing_status": true,
"worker_count": 8
}' "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings"
This example updates the worker_count
setting and resumes.
The function is currently paused.
curl -XPOST -d '{
"deployment_status": true,
"processing_status": true,
"worker_count": 8
}' "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings?bucket=bulk&scope=data"
curl -XPOST -d '{
"deployment_status": true,
"processing_status": true
}' "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings"
Deprecated. See Deploy a Function for the preferred invocation.
curl -XPOST -d '{
"deployment_status": true,
"processing_status": true
}' "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/settings?bucket=bulk&scope=data"
Deprecated. See Deploy a Function for the preferred invocation.
View Function Config
GET /api/v1/functions/{function}/config
Description
Export or return the configuration of the source keyspace and the eventing storage (metadata) keyspace for the specified function. The definition can be subsequently imported. However any changes to the function definition made to the file outside the UI are discouraged.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Returns an object showing the configuration of the specified function. |
|
404 |
Failure. |
Example HTTP Requests
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/config"
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/config?bucket=bulk&scope=data"
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/config" \
-o my_function.json
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/config?bucket=bulk&scope=data" \
-o my_function.json
Update Function Config
POST /api/v1/functions/{function}/config
Description
Import the configuration and alter the source keyspace and the eventing storage (metadata) keyspace for the specified function. You can only change these values if a function is in the undeployed state and the two keyspaces exist.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Name | Description | Schema |
---|---|---|
Body |
An object providing the configuration for the specified function. |
Example HTTP Requests
This example alters the source and eventing storage keyspaces.
curl -XPOST "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/config" \
-d '{
"source_bucket": "bulk",
"source_scope": "orders",
"source_collection": "customer01",
"metadata_bucket": "rr100",
"metadata_scope": "eventing",
"metadata_collection": "metadata"
}'
This example alters the source and eventing storage keyspaces.
curl -XPOST "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/config?bucket=bulk&scope=data"\
-d '{
"source_bucket": "bulk",
"source_scope": "orders",
"source_collection": "customer01",
"metadata_bucket": "rr100",
"metadata_scope": "eventing",
"metadata_collection": "metadata"
}'
This example alters the source and eventing storage keyspaces from a file.
curl -XPOST "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/config" \
-d @./my_function.json
This example alters the source and eventing storage keyspaces from a file.
curl -XPOST "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/config?bucket=bulk&scope=data" \
-d @./my_function.json
View Function Code
GET /api/v1/functions/{function}/appcode
Description
Export only the JavaScript code for the specified function. Note that unlike View a Function, the JavaScript is not escaped, and the code is runnable in other environments. The JavaScript code can be subsequently imported. However any changes to the function definition made to the file outside the UI are discouraged.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Returns a string showing the code for the specified function. |
String |
404 |
Failure. |
Example HTTP Requests
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/appcode"
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/appcode?bucket=bulk&scope=data"
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/appcode" \
-o my_function.json
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/appcode?bucket=bulk&scope=data" \
-o my_function.json
Update Function Code
POST /api/v1/functions/{function}/appcode
Description
Import only the JavaScript code for the specified function.
Note that unlike Create or Import Function, the JavaScript is not escaped and could come from other environments.
It is highly recommended that you use the flag --data-binary
or --upload-file
when importing your JavaScript appcode fragments to avoid potential encoding issues due to string escaping.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Name | Description | Schema |
---|---|---|
Body |
A string providing the code for the specified function. |
String |
Example HTTP Requests
curl -XPOST "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/appcode" \
--data-binary 'function OnUpdate(doc, meta) { log("id",meta.id); }'
curl -XPOST "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/appcode?bucket=bulk&scope=data" \
--data-binary 'function OnUpdate(doc, meta) { log("id",meta.id); }'
This example uses the --data-binary
option.
Do not use -d
.
curl -XPOST "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/import" \
--data-binary @./my_function.json
This example uses the --data-binary
option.
Do not use -d
.
curl -XPOST "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/import?bucket=bulk&scope=data" \
--data-binary @./my_function.json
This example uses the --upload-file
option.
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/functions/my_function/import" \
--upload-file ./my_function.json
This example uses the --upload-file
option.
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/api/v1/functions/my_function/import?bucket=bulk&scope=data" \
--upload-file ./my_function.json
Global Config
Table of Contents
List Global Config
GET /api/v1/config
Description
Shows all global configuration settings.
There are currently just two settings: enable_debugger
and ram_quota
.
Both of these settings can also be adjusted via the UI.
-
application/json
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Returns an object showing the global configuration settings. |
|
404 |
Failure. |
Modify Global Config
POST /api/v1/config
Description
Modify global configuration settings. During an edit, settings provided are merged. Unspecified attributes retain their prior values. The response indicates whether the Eventing service must be restarted for the new changes to take effect.
-
application/json
Interbucket Recursion
If you need to turn off infinite recursion protection for Eventing functions, you can use an alternative REST API endpoint to enable interbucket recursion. For details, see Troubleshooting and Best Practices. Allowing interbucket recursion is highly discouraged unless you have an advanced use case and follow strict non-production coding and verification. |
Parameters
Name | Description | Schema |
---|---|---|
Body |
An object providing the global configuration settings. |
Example HTTP Requests
curl -XPOST "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/config" \
-d '{"ram_quota": 512}'
curl -XPOST "http://$ADMIN:$PASSWORD@$HOST:8096/api/v1/config" \
-d '{"enable_debugger": true}'
This example disables the safety checks that prevent basic infinite recursive Eventing functions.
curl -X POST -u $ADMIN:$PASSWORD "http://$HOST:8091/_p/event/api/v1/config" \
-d '{"allow_interbucket_recursion": true}'
This example restores the default setting, which applies some sanity checks to prevent basic infinite recursive Eventing functions.
curl -X POST -u $ADMIN:$PASSWORD "http://$HOST:8091/_p/event/api/v1/config"
-d '{"allow_interbucket_recursion": false}'
List
Table of Contents
List All Functions
GET /api/v1/list/functions
Description
Returns a list (array) of the names of all Eventing functions in the cluster. The returned list can also be filtered — see List Filtered Functions.
If this API is run as a non-Administrator the results are filtered via RBAC to include only the function scopes the user has access to.
List Filtered Functions
GET /api/v1/list/functions/query
Description
Returns a list (array) of the names of all Eventing functions in the cluster. The returned list can be filtered by the following:
- Deployed status : in this case, paused is considered deployed.
- Source bucket: the listen to keyspace.
- Function type: whether the function modifies its own listen to keyspace.
If this API is run as a non-Administrator the results are filtered via RBAC to include only the function scopes the user has access to.
Parameters
Name | Description | Schema |
---|---|---|
deployed |
If |
Boolean |
source_bucket |
The name of a bucket. Returns the names of Eventing functions in the cluster that have a source keyspace under the specified bucket. |
String |
function_type |
The function type.
Values: |
String |
Example HTTP Requests
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/api/v1/list/functions/query?deployed=true"
If you had specified deployed=false
, you would get all undeployed functions.
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/api/v1/list/functions/query?source_bucket=bulk"
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/api/v1/list/functions/query?function_type=notsbm"
Logging
Table of Contents
Get Log for a Function
GET /getAppLog
Parameters
Name | Description | Schema |
---|---|---|
name |
The name of a function. |
String |
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
aggregate |
If Default: |
Boolean |
size |
The approximate amount of logging information returned.
Note that when fetching from more than one Eventing node, the amount of logging information returned from each node is the Default: |
Integer |
Example HTTP Requests
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/getAppLog?name=my_function"
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/getAppLog?name=my_function&bucket=bulk&scope=data"
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/getAppLog?name=my_function&aggregate=true"
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/getAppLog?name=my_function&aggregate=true&bucket=bulk&scope=data"
This example fetches recent Application log info from all Eventing nodes, limited to 2048 bytes.
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/getAppLog?name=my_function&aggregate=true&size=2048"
This example fetches recent Application log info from all Eventing nodes, limited to 2048 bytes.
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/getAppLog?name=my_function&aggregate=true&size=2048&bucket=bulk&scope=data"
Statistics
Table of Contents
Get All Statistics
Get Execution Statistics
Get Failure Statistics
Get Latency Statistics
Reset Statistics
Get All Statistics
GET /api/v1/stats
Description
Retrieve all statistics for the node.
If this API is run as a non-Administrator the results are filtered via RBAC to include only the function scopes the user has access to.
Parameters
Name | Description | Schema |
---|---|---|
type |
Including this parameter returns the full statistics set, inclusive of events processing, events remaining, execution, failure, latency, worker PIDs and sequence processed. Omitting this parameter excludes Values: |
String |
Get Execution Statistics
GET /getExecutionStats
Parameters
Name | Description | Schema |
---|---|---|
name |
The name of a function. |
String |
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Example HTTP Requests
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/getExecutionStats?name=my_function"
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/getExecutionStats?name=my_function&bucket=bulk&scope=data"
Get Failure Statistics
GET /getFailureStats
Parameters
Name | Description | Schema |
---|---|---|
name |
The name of a function. |
String |
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Example HTTP Requests
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/getFailureStats?name=my_function"
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/getFailureStats?name=my_function&bucket=bulk&scope=data"
Get Latency Statistics
GET /getLatencyStats
Parameters
Name | Description | Schema |
---|---|---|
name |
The name of a function. |
String |
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Example HTTP Requests
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/getLatencyStats?name=my_function"
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/getLatencyStats?name=my_function&bucket=bulk&scope=data"
Reset Statistics
GET /resetStatsCounters
Parameters
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
appName |
The name of a function. |
String |
Example HTTP Requests
curl -XGET "http://$ADMIN:$PASSWORD@$HOST:8096/resetStatsCounters?appName=my_function"
curl -XGET "http://$USER:$PASSWORD@$HOST:8096/resetStatsCounters?appName=my_function&bucket=bulk&scope=data"
Status
Table of Contents
View All Functions Status
GET /api/v1/status
Description
Returns a list (array) of all eventing functions, showing their corresponding composite_status
.
A function's status can have one of the following values: undeployed, deploying, deployed, undeploying, paused, and pausing.
Note that there is no value of resuming; when resuming a paused eventing function, the composite_status
returns deploying
until it reaches the deployed state.
If this API is run as a non-Administrator, the results are filtered via RBAC to include only the function scopes the user has access to.
View Function Status
GET /api/v1/status/{function}
Description
Returns the specified function, showing its corresponding composite_status
.
It can have one of the following values: undeployed, deploying, deployed, undeploying, paused, and pausing.
Note that there is no value of resuming; when resuming a paused eventing function, the composite_status
returns deploying
until it reaches the deployed state.
Parameters
Name | Description | Schema |
---|---|---|
function |
The name of a function. |
String |
Name | Description | Schema |
---|---|---|
bucket |
For scoped functions only. The bucket to which the function belongs. |
String |
scope |
For scoped functions only. The scope to which the function belongs. |
String |
Definitions
This section describes the properties consumed and returned by this REST API.
Function Request
Functions Request
Deployment Config
Deployment Constants
Deployment Keyspace
Deployment URL
Function Definition
Function Scope
Function Settings
Global Config
Changes to the Eventing function definition files made outside of this REST API or the interactive UI are only supported if you adhere to the Eventing schemas described here. |
Deployment Config
Property | Schema | |
---|---|---|
buckets |
Deployment Keyspace array |
|
curl |
Deployment URL array |
|
metadata_bucket |
bucket to store eventing checkpoints and timers Minimum length: |
String |
metadata_scope |
scope to store eventing checkpoints and timers |
String |
metadata_collection |
collection to store eventing checkpoints and timers |
String |
source_bucket |
bucket to listen to for document mutations Minimum length: |
String |
source_scope |
scope to listen to for document mutations |
String |
source_collection |
collection to listen to for document mutations |
String |
constants |
Deployment Constants array |
Deployment Constants
Property | Schema | |
---|---|---|
value |
alias name of the constant binding Pattern: |
String |
literal |
literal value bound to the alias name Minimum length: |
String |
Deployment Keyspace
Property | Schema | |
---|---|---|
alias |
symbolic name used in code to refer to this binding Pattern: |
String |
bucket_name |
name of the bucket this binding maps to Minimum length: |
String |
scope_name |
name of the scope this binding maps to |
String |
collection_name |
name of the collection this binding maps to |
String |
access |
bucket access level (read or read+write) Values: |
String |
Deployment URL
Property | Schema | |
---|---|---|
hostname |
full URL (including any path) that this binding connects Pattern: |
URI (uri) |
value |
symbolic name used in code to refer to this binding Pattern: |
String |
auth_type |
http authentication method to use with this endpoint Values: |
String |
username |
username for http auth methods that use it |
String |
password |
password for http auth methods that use it |
String |
bearer_key |
bearer key for bearer auth |
String |
allow_cookies |
allow cookies on the session |
Boolean |
validate_ssl_certificate |
validate remote server certificate using OS mechanisms |
Boolean |
Function Definition
Property | Schema | |
---|---|---|
appcode |
handler code Minimum length: |
String |
depcfg |
deployment configuration |
|
version |
authoring tool. use 'external' if authored or edited outside eventing ui Pattern: |
String |
enforce_schema |
enforces stricter validation for all settings and configuration fields. |
Boolean |
handleruuid |
unique id of the the handler. generated by server Minimum: |
Integer |
function_instance_id |
unique id of the deployment of the handler. generated by server Minimum length: |
String |
appname |
Pattern: |
String |
settings |
||
function_scope |
function scope |
Function Scope
Property | Schema | |
---|---|---|
bucket |
bucket to which function belongs Minimum length: |
String |
scope |
scope to which function belongs Minimum length: |
String |
Function Settings
Property | Schema | |
---|---|---|
cpp_worker_thread_count |
number of threads each worker utilizes Minimum: |
Integer |
dcp_stream_boundary |
indicates where to start dcp stream from (beginning of time, present point) 'from_prior' is deprecated in 6.6.2 Values: |
String |
deployment_status |
indicates if the function is deployed. true=deployed, false=undeployed |
Boolean |
description |
free form text for user to describe the handler. no functional role |
String |
execution_timeout |
maximum time the handler can run before it is forcefully terminated (in seconds) Minimum: |
Integer |
language_compatibility |
eventing language version this handler assumes in terms of syntax and behavior Values: |
String |
lcb_inst_capacity |
maximum number of libcouchbase connections that may be opened and pooled Minimum: |
Integer |
lcb_retry_count |
number of retries of retriable libcouchbase failures. 0 keeps trying till execution_timeout Minimum: |
Integer |
lcb_timeout |
maximum time the lcb command is waited until completion before we terminate the request(in seconds) Minimum: |
Integer |
log_level |
level of detail in system logging Values: |
String |
n1ql_consistency |
consistency level used by n1ql statements in the handler Values: |
String |
num_timer_partitions |
number of timer shards. defaults to number of vbuckets Values: |
Integer |
processing_status |
indicates if the function is running (i.e., not paused). true=running, false=paused |
Boolean |
sock_batch_size |
batch size for messages from producer to consumer. normally, this must not be specified Minimum: |
Integer |
tick_duration |
duration to log stats from this handler, in milliseconds |
Integer |
timer_context_size |
size limit of timer context object Minimum: |
Integer |
user_prefix |
key prefix for all data stored in metadata by this handler Minimum length: |
String |
worker_count |
number of worker processes handler utilizes on each eventing node Minimum: |
Integer |
n1ql_prepare_all |
automatically prepare all n1ql statements in the handler |
Boolean |
handler_headers |
code to automatically prepend to top of handler code |
String array |
handler_footers |
code to automatically append to bottom of handler code |
String array |
enable_applog_rotation |
enable rotating this handlers log() message files |
Boolean |
app_log_dir |
directory to write content of log() message files |
String |
app_log_max_size |
rotate logs when file grows to this size in bytes approximately Minimum: |
Integer |
app_log_max_files |
number of log() message files to retain when rotating Minimum: |
Integer |
checkpoint_interval |
number of seconds before writing a progress checkpoint Minimum: |
Integer |
bucket_cache_size |
maximum size in bytes the bucket cache can grow to Minimum: |
Integer |
bucket_cache_age |
time in milliseconds after which a cached bucket object is considered stale Minimum: |
Integer |
curl_max_allowed_resp_size |
maximum allowable curl call response in 'MegaBytes'. Setting the value to 0 lifts the upper limit off. This parameters affects v8 engine stability since it defines the maximum amount of heap space acquired by a curl call |
Integer |
Global Config
Property | Schema | |
---|---|---|
ram_quota |
The memory allocation for the Eventing Service, per node. Default: |
Integer |
enable_debugger |
Enables the Eventing service debugger. For details, see Debugging and Diagnosability. Default: |
Boolean |
Security
The Eventing REST APIs support HTTP basic authentication. Credentials can be passed via HTTP headers.
Global
Global functions with a function scope of *.*
can only be made or managed by users with the Full Admin or Eventing Full Admin role.
For global functions, you do not need to pass the bucket
and scope
query parameters to specify the function scope.
The credentials must be an administrator username and password.
Note that this is the default function scope for all functions after an upgrade from a prior version.
Type : http
Scoped
For scoped functions, you must pass the bucket
and scope
query parameters to specify the function scope.
The credentials are the username and password of any authorized user.
You can quote the REST call on the command line to escape the &
and ?
characters.
Type : http
Unscoped
Unscoped REST API calls do not require you to specify the function scope. The action is fully determined by the username and password credentials passed to the REST call.
Type : http
Refer to Eventing Role-Based Access Control (RBAC) for more details.