Analytics Library REST API
- Enterprise Edition
- Developer Preview
Overview
The Analytics Library REST API is provided by the Analytics service. This API enables you to manage the libraries that are used to create N1QL for Analytics user-defined functions.
The API schemes and host URLs are as follows:
-
http://localhost:8095/
-
https://localhost:18095/
(for secure access)
Note that this API is only available on the loopback interface of a node running the Analytics service.
Paths
This section describes the operations available with this REST API.
Read All Libraries
GET /analytics/library/
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Success. Returns an array of objects, each of which contains information about a single library. |
< Libraries > array |
404 |
Not found. The path may be missing its trailing slash. |
No Content |
500 |
Internal server error. Incorrect path or port number, incorrect credentials, badly formatted parameters, or missing arguments. |
Create or Update a Library
POST /analytics/library/{scope}/{library}
Description
Creates the specified library and its associated functions. If the specified library exists, the existing library is overwritten.
-
To add a function to a library, update the library with all existing functions, plus the new function.
-
To update a function, update the library with all existing functions, including the updated function definition.
-
To delete a function from a library, update the library with all existing functions, without the deleted function.
Parameters
Type | Name | Description | Schema |
---|---|---|---|
Path |
library |
The name of a library. |
string |
Path |
scope |
The name of the Analytics scope containing the library. |
string |
FormData |
data |
The library and all its dependencies, packaged by shiv. |
file |
FormData |
type |
The language of the library. |
enum (python) |
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
The operation was successful. |
object |
400 |
Bad request. A parameter has an incorrect value. |
|
500 |
Internal server error. Incorrect path or port number, incorrect credentials, badly formatted parameters, or missing arguments. |
Example HTTP request
The example below creates or updates a library called mylib
in the travel-sample.inventory
scope.
The Python code is stored in a file called lib.pyz
.
Curl request
curl -X POST \
http://localhost:8095/analytics/library/travel-sample%2Finventory/mylib \
-u Administrator:password \
-d type=python
-d data=lib.pyz
The dot separator within the scope name is converted to a slash (/ ), which is then URL-encoded as %2F .
|
Delete a Library
DELETE /analytics/library/{scope}/{library}
Parameters
Type | Name | Description | Schema |
---|---|---|---|
Path |
library |
The name of a library. |
string |
Path |
scope |
The name of the Analytics scope containing the library. |
string |
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
The operation was successful. |
object |
404 |
Not found. The library name in the path may be incorrect. |
string |
500 |
Internal server error. Incorrect path or port number, incorrect credentials, badly formatted parameters, or missing arguments. |
Example HTTP request
The example below deletes the mylib
library from the travel-sample.inventory
scope.
Curl request
curl -X DELETE \
http://localhost:8095/analytics/library/travel-sample%2Finventory/mylib \
-u Administrator:password
The dot separator within the scope name is converted to a slash (/ ), which is then URL-encoded as %2F .
|
Definitions
This section describes the properties returned by this REST API.
Libraries
Name | Description | Schema |
---|---|---|
scope |
The name of the Analytics scope containing the library. |
string |
hash_md5 |
A MD5 hash of the library residing on the server. |
string |
name |
The name of the library. |
string |
Security
The Analytics Library REST API supports HTTP basic authentication. Credentials can be passed via HTTP headers.
Full Admin
To Create or Update a Library or Delete a Library, users must have the Full Admin RBAC role.
Type : basic
Analytics Admin
To Read All Libraries, users must have one of the following RBAC roles:
-
Full Admin
-
Cluster Admin
-
Analytics Admin
Type : basic
Refer to Roles for more details.