This documentation is for WSO2 Stream Processor 4.3.0. View documentation for the latest release.

All docs This doc
||
Skip to end of metadata
Go to start of metadata

Creating a Siddhi application

Overview

DescriptionCreates a new Siddhi Application.
API Context/siddhi-apps
HTTP MethodPOST
Request/Response formatRequest: text/plain
Response: application/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager

curl command syntax

curl -X POST "https://localhost:9443/siddhi-apps" -H "accept: application/json" -H "Content-Type: text/plain" -d @TestSiddhiApp.siddhi -u admin:admin -k

Sample curl command

curl -X POST "https://localhost:9443/siddhi-apps" -H "accept: application/json" -H "Content-Type: text/plain" -d @TestSiddhiApp.siddhi -u admin:admin -k

Sample output

The response for the sample curl command given above can be one of the following.

  • If API request is valid and there is no existing Siddhi application with the given name, a response similar to the following is generated with response code 201. This response contains a location header with the path of the newly created file from product root home.

     
  • If the API request is valid, but a Siddhi application with the given name already exists,  a response similar to the following is generated with response code 409.

    {
      "type": "conflict",
      "message": "There is a Siddhi App already exists with same name" 
    }
  • If the API request is invalid due to invalid content in the Siddhi queries you have included in the request body,  a response similar to the following is generated is generated with response code 400.

    {
      "code": 800101,
      "type": "validation error",
      "message": "You have an error in your SiddhiQL at line 8:8, missing INTO at 'BarStream'" 
    }
  • If the API request is valid, but an exception occured during file processing or saving, the following response is generated with response code 500.

    {
      "code": 800102,
      "type": "file processing error",
      "message": <error-message>
    }

Response

HTTP Status Code

Possible codes are 201, 409, 400, and 500.

For descriptions of the HTTP status codes, see HTTP Status Codes.

Updating a Siddhi Application

Overview

DescriptionUpdates a Siddhi Application.
API Context/siddhi-apps
HTTP MethodPUT
Request/Response formatRequest: text/plain
Response: application/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager

curl command syntax

curl -X PUT "http://localhost:9090/siddhi-apps" -H "accept: application/json" -H "Content-Type: text/plain" -d @<SIDDHI_APPLICATION_NAME>.siddhi -u admin:admin -k

Sample curl command

curl -X PUT "https://localhost:9443/siddhi-apps" -H "accept: application/json" -H "Content-Type: text/plain" -d @TestSiddhiApp.siddhi -u admin:admin -k

Sample output

  • If the API request is invalid due to invalid content in the Siddhi query, a response similar to the following is returned with response code 400.

    {
      "code": 800101,
      "type": "validation error",
      "message": "You have an error in your SiddhiQL at line 8:8, missing INTO at 'BarStream'" 
    }
  • If the API request is valid, but an exception occured when saving or processing files, a response similar to the following is returned with response code 500.

    {
      "code": 800102,
      "type": "file processing error",
      "message": <error-message>
    }

Response

HTTP Status Code

Possible codes are 200, 201, 400, and 500.

For descriptions of the HTTP status codes, see HTTP Status Codes.


Deleting a Siddhi application

Overview

DescriptionSends the name of a Siddhi application as a URL parameter.
API Context/siddhi-apps/{appName}
HTTP MethodDELETE
Request/Response formatapplication/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager


Parameter Description

ParameterDescription
{appName}The name of the Siddhi application to be deleted.


curl command syntax

curl -X DELETE "http://localhost:9090/siddhi-apps/{app-name}" -H "accept: application/json" -u admin:admin -k

Sample curl command

curl -X DELETE "https://localhost:9443/siddhi-apps/TestSiddhiApp" -H "accept: application/json" -u admin:admin -k

Sample output

The respose for the sample curl command given above can be one of the following:

  • If the API request is valid and a Siddhi application with the given name exists, the following response is received with response code 200.

    http://localhost:9090/siddhi-apps/TestExecutionPlan1
  • If the API request is valid, but a Siddhi application with the given name is not deployed, the following response is received with response code 404.

    {
      "type": "not found",
      "message": "There is no Siddhi App exist with provided name : TestExecutionPlan1" 
    }
  • If the API request is valid, but an exception occured when deleting the given Siddhi application, the following response is received with response code 500.

    {
      "code": 800102,
      "type": "file processing error",
      "message": <error-message>
    }
  • If the API request is valid, but there are restricted characters in the given Siddhi application name, the following response is received with response code 400.

    {
      "code": 800101,
      "type": "validation error",
      "message": "File name contains restricted path elements . : ../../siddhiApp2'" 
    }

Response

HTTP Status Code

200, 404, 500 or 400.

For descriptions of the HTTP status codes, see HTTP Status Codes.

Listing all active Siddhi applications

Overview

Description

Lists all the currently active Siddhi applications.

If the isActive=true parameter is set, all the active Siddhi Applications are listed. If not, all the inactive Siddhi applications are listed.

API Context /siddhi-apps
HTTP MethodGET
Request/Response formatRequest content type: any
Response content type: application/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager

curl command syntax

curl -X GET "http://localhost:9090/siddhi-apps" -H "accept: application/json" -u admin:admin -k

Sample curl command

curl -X GET "https://localhost:9443/siddhi-apps?isActive=true" -H "accept: application/json" -u admin:admin -k

Sample output

Possible responses are as follows:

  • If the API request is valid and there are Siddhi applications deployed in your SP setup, a response similar to the following is returned with response code 200.

    ["TestExecutionPlan3", "TestExecutionPlan4"]
  • If the API request is valid, there are Siddhi applications deployed in your SP setup, and a query parameter is defined in the request, a response similar to the following is returned with response code 200. This response only contains Siddhi applications that are active.

    If these conditions are met, but the isActive parameter is set to false, the response contains only inactive Siddhi applications.

    ["TestExecutionPlan3"]
  • If the API request is valid, but there are no Siddhi applications deployed in your SP setup, the following response is returned.

    []

Response

HTTP Status Code

200

For descriptions of the HTTP status codes, see HTTP Status Codes.

Retrieving a specific Siddhi application

Overview

DescriptionRetrieves the given Siddhi application.
API Context/siddhi-apps/{appName}
HTTP MethodGET
Request/Response formatapplication/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager


Parameter Description

ParameterDescription
{appName}The name of the Siddhi application to be retrieved.


curl command syntax

curl -X GET "http://localhost:9090/siddhi-apps/{app-name}" -H "accept: application/json" -u admin:admin -k

Sample curl command

curl -X GET "https://localhost:9443/siddhi-apps/SiddhiTestApp" -H "accept: application/json" -u admin:admin -k

Sample output

The possible outputs are as follows:

  • If the API request is valid and a Siddhi application of the given name exists, a response similar to the following is returned with response code 200.

    {
      "content": "\n@Plan:name('TestExecutionPlan')\ndefine stream FooStream (symbol string, price float, volume long);\n\n@source(type='inMemory', topic='symbol', @map(type='passThrough'))Define stream BarStream (symbol string, price float, volume long);\n\nfrom FooStream\nselect symbol, price, volume\ninsert into BarStream;" 
    }
  • If the API request is valid, but a Siddhi application of the given name is not deployed, a response similar to the following is returned with response code 404.

    {
      "type": "not found",
      "message": "There is no Siddhi App exist with provided name : TestExecutionPlan1" 
    }

Response

HTTP Status Code

200 or 404

For descriptions of the HTTP status codes, see HTTP Status Codes.

Fetching the status of a Siddhi Application

Overview

DescriptionThis fetches the status of the specified Siddhi application
API Context/siddhi-apps/{appName}/status
HTTP MethodGET
Request/Response formatapplication/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager


Parameter Description

ParameterDescription
{appName} The name of the Siddhi application of which the status needs to be fetched.


curl command syntax

curl -X GET "http://localhost:9090/siddhi-apps/{app-file-name}/status" -H "accept: application/json" -u admin:admin -k

Sample curl command

curl -X GET "https://localhost:9443/siddhi-apps/TestSiddhiApp/status" -H "accept: application/json" -u admin:admin -k

Sample output

  • If the Siddhi application is active, the following is returned with response code 200.

    {"status":"active"} 
  • If the Siddhi application is inactive, the following is returned with response code 200.

    {"status":"inactive"} 
  • If the Siddhi application does not exist, but the REST API call is valid, the following is returned with the response code 404.

    {
      "type": "not found",
      "message": "There is no Siddhi App exist with provided name : TestExecutionPlan1" 
    }

Response

HTTP Status Code

200 or 404

For descriptions of the HTTP status codes, see HTTP Status Codes.

Taking a snapshot of a Siddhi Application 

Overview

DescriptionThis takes a snapshot of the specific Siddhi application.
API Context/siddhi-apps/{appName}/backup
HTTP MethodPOST
Request/Response formatapplication/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager


Parameter Description

ParameterDescription
{appName} The name of the Siddhi application of which a snapshot needs to be taken.


curl command syntax

curl -X POST "http://localhost:9090/siddhi-apps/{appName}/backup" -H "accept: application/json" -u admin:admin -k

Sample curl command

curl -X POST "https://localhost:9443/siddhi-apps/TestSiddhiApp/backup" -H "accept: application/json" -u admin:admin -k

Sample output

The output can be one of the following:

  • If the API request is valid and a Siddhi application exists with the given name, an output similar to the following (i.e., with the snapshot revision number) is returned with response code 201.

    {"revision": "89489242494242"} 
  • If the API request is valid, but no Siddhi application with the given name is deployed, an output similar to the following is returned with response code 404.

    {
      "type": "not found",
      "message": "There is no Siddhi App exist with provided name : TestExecutionPlan1" 
    }
  • If the API request is valid, but an exception has occured when backing up the state at Siddhi level, an output similar to the following is returned with response code 500.

    {
      "code": 800102,
      "type": "file processing error",
      "message": <error-message>
    }

Response

HTTP Status Code

201, 404, or 500.

For descriptions of the HTTP status codes, see HTTP Status Codes.

Restoring a Siddhi Application via a snapshot

In order to call this API, you need tohave already taken a snapshot of the Siddhi application to be restored. For more information about the API via which the snapshow is taken, see Taking a snapshot of a Siddhi application.

Overview

Description

This restores a Siddhi application using a snapshot of the same that you have previously taken.

API Context

  • To restore without considering the version: /siddhi-apps/{appName}/restore
  • To restore a specific version: /siddhi-apps/{appName}/restore?version=

HTTP Method

POST

Request/Response format

application/json

Authentication

Basic

Username

admin

Password

admin

Runtime

worker/manager

Parameter Description

ParameterDescription
{appName}
The name of the Siddhi application that needs to be restored.


curl command syntax

curl -X POST "http://localhost:9090/siddhi-apps/{appName}/restore" -H "accept: application/json" -u admin:admin -k

Sample curl command

curl -X POST "https://localhost:9443/siddhi-apps/TestSiddhiApp/restore?revision=1514981290838_TestSiddhiApp" -H "accept: application/json" -u admin:admin -k

Sample output

The above sample curl command can generate either one of the following responses:

  • If the API request is valid, a Siddhi application with the given name exists, and no revision information is passed as a query parameter, the following response is returned with response code 200.

    {
      "type": "success",
      "message": "State restored to last revision for Siddhi App :TestExecutionPlan" 
    }
  • If the API request is valid, a Siddhi application with the given name exists, and revision information is passed as a query parameter, the following response is returned with response code 200. In this scenario, the Siddhi snapshot is created in the file system.

    {
      "type": "success",
      "message": "State restored to revision 1234563 for Siddhi App :TestExecutionPlan" 
    }
  • If the API request is valid, but no Siddhi application is deployed with the given name, the following response is returned with response code 404.

    {
      "type": "not found",
      "message": "There is no Siddhi App exist with provided name : TestExecutionPlan1" 
    }
  • If the API request is valid, but an exception occured when restoring the state at Siddhi level, the following response is returned with response code 500.

    {
      "code": 800102,
      "type": "file processing error",
      "message": <error-message>
    }

Response

HTTP Status Code

200, 404 or 500.

For descriptions of the HTTP status codes, see HTTP Status Codes.

Returning real-time statistics of a worker

Overview

DescriptionReturns the real-time statistics of a worker.
API Context/statistics
HTTP MethodGET
Request/Response formatapplication/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager


Parameter Description

curl command syntax

 

Sample curl command

curl -X GET "https://localhost:9443/statistics" -H "accept: application/json" -u admin:admin -k

Sample output

Response

HTTP Status Code

200 or 404

For descriptions of the HTTP status codes, see HTTP Status Codes.

Enabling/disabling worker statistics

Overview

DescriptionEnables/diables generating statistics for worker nodes.
API Context/statistics
HTTP MethodPUT
Request/Response formatapplication/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager


Parameter Description

curl command syntax

 

Sample curl command

curl -X PUT "https://localhost:9443/statistics" -H "accept: application/json" -H "Content-Type: application/json" -d "{“statsEnable”:”true”}" -u admin:admin -k

Sample output

Response

HTTP Status Code

200 or 404

For descriptions of the HTTP status codes, see HTTP Status Codes.

Returning general details of a worker

Overview

DescriptionReturns general details of a worker.
API Context/system-details
HTTP MethodGET
Request/Response formatapplication/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager


Parameter Description

curl command syntax

 

Sample curl command

curl -X GET "https://localhost:9443/system-details" -H "accept: application/json" -u admin:admin -k

Sample output

Response

HTTP Status Code

200 or 404

For descriptions of the HTTP status codes, see HTTP Status Codes.

Returning detailed statistics of all Siddhi applications

Overview

DescriptionReturns the detailed statistics of all the Siddhi applications currently deployed in the SP setup.
API Context/siddhi-apps/statistics
HTTP MethodGET
Request/Response formatapplication/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager


Parameter Description

curl command syntax

 

Sample curl command

curl -X GET "https://localhost:9443/siddhi-apps/statistics" -H "accept: application/json" -u admin:admin -k

Sample output

Response

HTTP Status Code

200 or 404

For descriptions of the HTTP status codes, see HTTP Status Codes.

Enabling/disabling the statistics of a specific Siddhi application

Overview

DescriptionEnables/disables statistics for a specified Siddhi application.
API Context/siddhi-apps/{appName}/statistics
HTTP MethodPUT
Request/Response formatapplication/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager


Parameter Description

ParameterDescription
appNameThe name of the Siddhi application for which the Siddhi applications need to be enabled/disabled.


curl command syntax

 

Sample curl command

curl -X PUT "https://localhost:9443/siddhi-apps/TestSiddhiApp/statistics" -H "accept: application/json" -H "Content-Type: application/json" -d "{“statsEnable”:”true”}" -u admin:admin -k

Sample output

Response

HTTP Status Code

200 or 404

For descriptions of the HTTP status codes, see HTTP Status Codes.

Enabling/disabling the statistics of all Siddhi applications

Overview

DescriptionEnables/disables statistics for all the Siddhi applications.
API Context/siddhi-apps/statistics
HTTP MethodPUT
Request/Response formatapplication/json
AuthenticationBasic
Usernameadmin
Passwordadmin
Runtimeworker/manager


Parameter Description

curl command syntax

 

Sample curl command

curl -X PUT "https://localhost:9443/siddhi-apps/statistics" -H "accept: application/json" -H "Content-Type: application/json" -d "{“statsEnable”:”true”}" -u admin:admin -k

Sample output

Response

HTTP Status Code

200 or 404

For descriptions of the HTTP status codes, see HTTP Status Codes.

  • No labels