The Eventing REST API, available by default at port 8096, provides the methods available to work with and manipulate Couchbase Eventing Functions.
Changes to the Eventing Function definition files made outside of this REST API or the interactive UI are only supported for version 7.0 (and above) if the Eventing schemas located in https://github.com/couchbase/eventing/tree/master/parser are adhered to. |
As of version 7.1 Eventing now supports full Eventing Role-Based Access Control (RBAC).
If the sample REST API shows two forms:
-
The first format is for privileged Eventing functions with a "Function Scope" of *.*; these functions can only be made or managed by users with the "Full Admin", "Eventing Full Admin" role. In addition this is the default "Function Scope" for all functions after an upgrade from a prior version. The creditionals for these examples will be "Administrator:password".
-
The second format uses RBAC and you must pass the parameters bucket=[fs_bucket]&scope=[fs_scope] to specify the bucket and the scope of the "Function Scope" to the REST call. In addition, due to the use or & and ? characters, you will need to quote your REST call on the command line. The creditionals for these examples will be "anyAuthedUser:password" (although "Administrator:password" can also use this form).
If the sample REST API shows just a single format, then the REST API call does not require the parameters bucket=[fs_bucket]&scope=[fs_scope] and the action is fully determined by the username and password credentials passed to the REST call.
HTTP Method | URI Path | Description |
---|---|---|
POST |
/api/v1/functions/[sample_name]/deploy |
Deploys an undeployed Function. Starting with version 6.5.0, this is the preferred invocation. A deploy CURL example is provided for reference. |
Sample API:
|
||
POST |
/api/v1/functions/[sample_name]/undeploy |
Undeploys a Function. Starting with version 6.5.0, this is the preferred invocation. An undeploy CURL example is provided for reference. |
Sample API:
|
||
POST |
/api/v1/functions/[sample_name]/pause |
Pauses a Function and creates a DCP checkpoint such that on a subsequent resume no mutations will be lost. Starting with version 6.5.0, this is the preferred invocation. A pause CURL example is provided for reference. |
Sample API:
|
||
POST |
/api/v1/functions/[sample_name]/resume |
Resumes a paused function from its paused DCP checkpoint. Starting with version 6.5.0, this is the preferred invocation. A resume CURL example is provided for reference. |
Sample API:
|
HTTP Method | URI Path | Description |
---|---|---|
POST |
/api/v1/functions/[function_name] |
Import or create a single Function. The Function name in the body must match that on the URL. Function definition includes current settings. The POST data or POST data file must be a single JSON object or an array containing a single JSON object |
Sample API (from file):
|
||
POST |
/api/v1/functions/ |
Imports or creates multiple Functions. Function names must be unique. When multiple Functions have the same name, an error is reported. The POST data or POST data file must be either a single JSON object or an array containing a one or more JSON objects |
Sample API (from file):
|
||
POST |
/api/v1/import/ |
Imports multiple Functions. Function names must be unique. When multiple Functions have the same name, an error is reported. The POST data or POST data file must be either a single JSON object or an array containing a one or more JSON objects Note if any Function’s language_compatibility field is missing the value will be set to 6.0.0 (unlike the /api/v1/functions above which will set the value to the highest version supported by the server). |
Sample API (from file):
|
||
GET |
/api/v1/functions/[sample_name] |
View a definition of a Function. 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. |
Sample API (to standard out):
|
||
Sample API (to file):
|
||
GET |
/api/v1/functions |
View definitions of all Functions. Provides an array of definitions of all Functions available in the cluster. The Functions could 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 return set will be filtered via RBAC to just the "Function Scopes" the user has access too. |
Sample API (to standard out):
|
||
Sample API (to file):
|
||
GET |
/api/v1/export |
This is a convenience method to export all function definitions. Exported functions are always set to undeployed state at the time of export, regardless of the state in the cluster at time of export. If saved to a file the function definitions can be imputed 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 return set will be filtered via RBAC to just the "Function Scopes" the user has access too. |
Sample API (to standard out):
|
||
Sample API (to file):
|
||
DELETE |
/api/v1/functions/[function_name] |
Deletes a specific Function from the cluster. WARNING: Use this API with caution as it is irreversible. |
Sample API:
|
||
DELETE |
/api/v1/functions |
Deletes multiple Functions (as in 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 just the "Function Scopes" the user has access too. |
Sample API:
|
||
GET |
/api/v1/functions/[function_name]/settings |
Export or return the full definition for one Eventing Function in the cluster. The definition can be subsequently imported. However any changes to the function definition made to the file outside the UI are discouraged. |
Sample API (to standard out):
|
||
Sample API (to file):
|
||
POST |
/api/v1/functions/[function_name]/settings |
Updates an undeployed or paused function with the provided setting. Note settings can only be altered 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 (deployed/undeployed) and processing_status (paused/not-paused) when using this REST endpoint to update any option or set of options. The current values of deployment_status and processing_status can be queried via api/v1/status or api/v1/status/[sample_name] By adjusting deployment_status and processing_status this command can also deploy or resume a function, however it cannot pause or undeploy a function. |
Sample API (alter worker_count):
|
||
Sample API (alter app_log_max_files and app_log_max_size) this function is currently undeployed:
|
||
Sample API (alter timer_context_size) this function is currently paused:
|
||
Sample API (alter worker_count AND resume) this function is currently paused:
|
||
GET |
/api/v1/functions/[function_name]/config |
Export or return the configuration of the source keyspace and the eventing storage (metadata) keyspace for one Eventing Function in the cluster. The definition can be subsequently imported. However any changes to the function definition made to the file outside the UI are discouraged. |
Sample API (to standard out):
|
||
Sample API (to file):
|
||
POST |
/api/v1/functions/[function_name]/config |
Import the configuration and alter the source keyspace and the eventing storage (metadata) keyspace for one Eventing Function in the cluster. You can only change these values if a function is in the undeployed state and the two keyspaces exist. |
Sample API (alter source and eventing storage keyspaces):
|
||
Sample API (alter source and eventing storage keyspaces from a file):
|
||
GET |
/api/v1/functions/[function_name]/appcode |
Export only the JavaScript code for one Eventing Function in the cluster. Note the JavaScript is not escaped (unlike /api/v1/functions/[function_name]) 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. |
Sample API (to standard out):
|
||
Sample API (to file):
|
||
POST |
/api/v1/functions/[function_name]/appcode |
Import only the JavaScript code for one Eventing Function in the cluster. Note the JavaScript supplied is not escaped (unlike /api/v1/functions/[function_name]) 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. |
Sample API (import and replace JavaScript):
|
||
Sample API (import and replace JavaScript from a file, do not use -d):
or
|
HTTP Method | URI Path | Description |
---|---|---|
GET |
/api/v1/status |
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, there is no value of resuming when resuming a paused Eventing Function the composite_status will return deploying until it reaches the deployed state. If this API is run as a non-Administrator the return set will be filtered via RBAC to just the "Function Scopes" the user has access too. |
Sample API (status):
|
||
GET |
/api/v1/status/[sample_name] |
Returns a specific Eventing Functions showing its corresponding composite_status. It can have one of the following values - undeployed, deploying, deployed, undeploying, paused, and 'pausing. Note, there is no value of resuming when resuming a paused Eventing Function the composite_status will return deploying until it reaches the deployed state. |
Sample API (status):
|
HTTP Method | URI Path | Description |
---|---|---|
GET |
/getAppLog?name=[sample_name] |
Returns the most recent application log messages for a specific Eventing Function. This API by default accesses a single Eventing node but can access all Eventing nodes by setting the optional parameter aggregate=true. By default the amount of logging information returned is approximately 40960 bytes unless you specify the optional size parameter size=# where # is in bytes. Note when specifying the size parameter and fetching from more than one Eventing node only size/#nodes bytes are returned from each node. |
Sample API (fetch recent Application log info from one Eventing node):
|
||
Sample API (fetch recent Application log info from all Eventing nodes):
|
||
Sample API (fetch recent Application log info from all Eventing nodes but limited to 2048 bytes):
|
HTTP Method | URI Path | Description |
---|---|---|
GET |
/api/v1/list/functions |
Returns a list (array) of the names of all Eventing Functions in the cluster. The returned list can also be filtered by the following: deployed status true or false (in this case paused is considered deployed), source_bucket filter by the bucket with the listen to keyspace, and function_type notsbm or sbm (the later if the functions that modifies its own listen to keyspace). If this API is run as a non-Administrator the return set will be filtered via RBAC to just the "Function Scopes" the user has access too. |
Sample API (list):
|
||
GET |
/api/v1/list/functions/query?deployed=true |
Returns a list (array) of the names of all deployed (or paused) Eventing Functions in the cluster. Note, if we had specified deployed=false we would get all undeployed functions. If this API is run as a non-Administrator the return set will be filtered via RBAC to just the "Function Scopes" the user has access too. |
Sample API (status):
|
||
GET |
/api/v1/list/functions/query?source_bucket=[bucket_name] |
Returns a list (array) of the names of Eventing Functions in the cluster that have a source keyspace under a particular bucket. If this API is run as a non-Administrator the return set will be filtered via RBAC to just the "Function Scopes" the user has access too. |
Sample API (status):
|
||
GET |
/api/v1/list/functions/query?function_type=sbm |
Returns a list (array) of the names of Eventing Functions in the cluster that modify their own a source keyspace. If this API is run as a non-Administrator the return set will be filtered via RBAC to just the "Function Scopes" the user has access too. |
Sample API (status):
|
||
GET |
/api/v1/list/functions/query?function_type=notsbm |
Returns a list (array) of the names of Eventing Functions in the cluster that do not modify their own a source keyspace. If this API is run as a non-Administrator the return set will be filtered via RBAC to just the "Function Scopes" the user has access too. |
Sample API (status):
|
HTTP Method | URI Path | Description |
---|---|---|
GET |
/api/v1/config |
List global configuration. The response shows all global Eventing settings. There are currently just two settings: enable_debugger (default value of false) and ram_quota (default value of 256 MB). Both of these settings can also be adjusted via the UI. |
Sample API:
|
||
POST |
/api/v1/config |
Modify global configuration. 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. |
Sample API (alter ram_quota):
|
||
Sample API (alter enable_debugger):
|
||
Sample API (allow interbucket recursion): Note, setting the value of "allow_interbucket_recursion" to true is highly discouraged unless you have an advanced use case and follow strict non-production coding and verification. This will disable the safety checks that prevent running basic infinite recursive Eventing Functions
|
||
Sample API (disallow interbucket recursion): This is the default setting of which applies some sanity checks to disable running basic infinite recursive Eventing Functions.
|
HTTP Method | URI Path | Description | ||
---|---|---|---|---|
GET |
/api/v1/stats?type=full |
Retrieve all statistics for the node. This will return the full statistics set inclusive of events processing, events remaining, execution, failure, latency, worker PIDs and sequence processed. If this API is run as a non-Administrator the return set will be filtered via RBAC to just the "Function Scopes" the user has access too. |
||
|
||||
Sample API (basic):
|
||||
Sample API (full):
|
||||
GET |
/getExecutionStats?name=[function_name] |
Retrieve only execution statistics. This will return the subset of statistics for the node. |
||
Sample API:
|
||||
GET |
/getLatencyStats?name=[function_name] |
Retrieve only latency statistics. This will return the subset of statistics for the node. |
||
Sample API:
|
||||
GET |
/getFailureStats?name=[function_name] |
Retrieve only failure statistics. This will return the subset of statistics for the node. |
||
Sample API:
|
||||
GET |
/resetStatsCounters?name=[function_name] |
Resets statistics for the provided Eventing Function. |
||
Sample API:
|
HTTP Method | URI Path | Description |
---|---|---|
POST |
/api/v1/functions/[function_name]/settings |
Deploys an undeployed Function or resumes a paused function from its paused DCP checkpoint. Deprecated, see (basic activation/deactivation) for preferred invocation. A deploy/resume CURL example is provided for reference. |
Sample API:
|
||
POST |
/api/v1/functions/[function_name]/settings |
Undeploys a Function. Deprecated, see (basic activation/deactivation) for preferred invocation. An undeploy CURL example is provided for reference. |
Sample API:
|
||
POST |
/api/v1/functions/[function_name]/settings |
Pauses a Function and creates a DCP checkpoint such that on a subsequent resume no mutations will be lost. Deprecated, see (basic activation/deactivation) for preferred invocation. A pause CURL example is provided for reference. |
Sample API:
|