Web services¶
All web services require authentication, you can use Auth Basic authentication by using your credentials:
http://login:password@janua.mydomain.com/get_sms_config
Or by requesting a authentication token JanuaAuthToken and put it as HTTP header in all your requests
Authentication¶
login¶
URL: http://janua.mydomain.com/login
-
janua.ws.services.login()[source]¶ Get an authentication session
Sample request to authenticate:
POST /login HTTP/1.1 Host: janua.mydomain.com Content-Type: application/json { "username": "admin", "password": "admin", "language": "EN", }
Sample response:
HTTP/1.1 200 { "success": true, "message": "Successful authentication", "JanuaAuthToken": "abcdef123456789", }
Authentication backends¶
list_auth_backend¶
URL: http://janua.mydomain.com/list_auth_backend (GET method)
-
class
janua.actions.list_auth_backend.ListAuthBackend[source]¶ Get the a list of available authentication backends
Sample request:
GET /list_auth_backend HTTP/1.1 Host: janua.mydomain.com Content-Type: application/json JanuaAuthToken: abcdef123456789
Sample response:
HTTP/1.1 200 { "backends": [ { "name": "local" }, { "name": "ldap" } ], "num_backends": 2 }
get_auth_backend¶
URL: http://janua.mydomain.com/get_auth_backend/<backend> (GET method)
-
class
janua.actions.get_auth_backend.GetAuthBackend[source]¶ Get authentication backend configuration
Sample request to LDAP backend configuration:
GET /get_auth_backend/ldap HTTP/1.1 Host: janua.mydomain.com Content-Type: application/json JanuaAuthToken: abcdef123456789
Sample response:
HTTP/1.1 200 { "help": "Ldap help in html format", "num_params": 3, "params": [ { "description": "Uri", "name": "ldap_uri", "type": "string", "value": "ldap://ldap.example.fr:389" }, { "description": "Bind DN", "name": "ldap_bind_dn", "type": "string", "value": "uid=${login},ou=people,dc=example,dc=fr" }, { "description": "TLS support", "name": "ldap_tls_support", "type": "boolean", "value": "1" } ], "success": true }
set_auth_backend¶
URL: http://janua.mydomain.com/set_auth_backend/<backend> (POST method)
-
class
janua.actions.set_auth_backend.SetAuthBackend[source]¶ Set authentication backend configuration
Sample request to set configuration for LDAP backend:
POST /set_auth_backend/ldap HTTP/1.1 Host: janua.mydomain.com Content-Type: application/json JanuaAuthToken: abcdef123456789 { "parameters": { "ldap_uri": "ldap://ldap.example.fr:389", "ldap_bind_dn": "uid=${login},ou=people,dc=example,dc=fr", "ldap_tls_support": false }, "success": true }
Sample response:
HTTP/1.1 200 { "message": "Configuration has been saved", "success": true }
SMS / Mail¶
sendsms¶
URL: http://janua.mydomain.com/sendsms
-
class
janua.actions.sendsms.SendSms[source]¶ Send SMS to contacts and/or groups.
to parameter can take a list of contacts phone number and/or groups separated by comma.
Sample request for sending to all my contacts with special group ‘all’:
POST /sendsms HTTP/1.1 Host: janua.mydomain.com Content-Type: application/json JanuaAuthToken: abcdef123456789 { "message": "Test", "to": "all" }
Sample response:
HTTP/1.1 200 { "message": "SMS message has been queued", "success": true }
Send message to group MESO and contact with phone number +33123456789 with Curl:
/usr/bin/curl -H "Content-Type: application/json" \ -X POST -d '{"message": "Test", "to": "+33123456789,MESO"}' \ -u "+33763140817:myuberpwd" \ https://janua.mydomain.com/sendsms
sendmail¶
URL: http://janua.mydomain.com/sendmail
-
class
janua.actions.sendmail.SendMail[source]¶ Send mail
Send simple mail to all my contacts:
POST /sendmail HTTP/1.1 Host: janua.mydomain.com Content-Type: application/json JanuaAuthToken: abcdef123456789 { "message": "A simple test message", "subject": "Simple test", "to": "all" }
Sample response:
HTTP/1.1 200 { "message": "SMS message has been queued", "success": true }
Send templated mail to all my contacts (see mail templates):
POST /sendmail HTTP/1.1 Host: janua.mydomain.com Content-Type: application/json JanuaAuthToken: abcdef123456789 { "to": "all", "template": "mytemplate", "template_args: { "first_arg": "first argument", "second_arg": "second argument" } }Sample response:
HTTP/1.1 200 { "message": "SMS message has been queued", "success": true }
sms-usage¶
URL: http://janua.mydomain.com/sms-usage
-
class
janua.actions.sms_usage.SmsUsage[source]¶ Get SMS usage based on administrator quota
Sample request with administrator level:
GET /sms-usage HTTP/1.1 Host: janua.mydomain.com Content-Type: application/json JanuaAuthToken: abcdef123456789
Sample response:
HTTP/1.1 200 { "smsusage": { "global": 18, "quota": "100 M", "sent": 18 } }
Sample request with supervisor level:
GET /sms-usage HTTP/1.1 Host: janua.mydomain.com Content-Type: application/json
Sample response:
HTTP/1.1 200 { "smsusage": { "quota": "200 D", "sent": 4 } }
sms-stats¶
URL: http://janua.mydomain.com/sms-stats
-
class
janua.actions.sms_stats.SmsStats[source]¶ Get SMS month statistics for the current year
Sample request:
GET /sms-stats HTTP/1.1 Host: janua.mydomain.com Content-Type: application/json JanuaAuthToken: abcdef123456789
Sample response:
HTTP/1.1 200 { "num_results": 12, "objects": [ { "month": "Jan", "value": 0 }, { "month": "Feb", "value": 0 }, { "month": "Mar", "value": 0 }, { "month": "Apr", "value": 0 }, { "month": "May", "value": 0 }, { "month": "Jun", "value": 0 }, { "month": "Jul", "value": 0 }, { "month": "Aug", "value": 0 }, { "month": "Sep", "value": 0 }, { "month": "Oct", "value": 18 }, { "month": "Nov", "value": 0 }, { "month": "Dec", "value": 0 } ] }
Action configuration¶
Restful API¶
Restful API is based on Flask-Restless.
To use the followings API, please refer to Flask-Restless format of requests and response documentation
CONTACT¶
| Location | Methods | Authorized roles |
|---|---|---|
| /api/CONTACT | GET, POST, PUT, DELETE | admin, supervisor |
GROUP¶
| Location | Methods | Authorized roles |
|---|---|---|
| /api/GROUPS | GET, POST, PUT, DELETE | admin, supervisor |
CONTACT_GROUP¶
| Location | Methods | Authorized roles |
|---|---|---|
| /api/CONTACT_GROUP | GET, POST, PUT, DELETE | admin, supervisor |
SMS¶
| Location | Methods | Authorized roles |
|---|---|---|
| /api/SMS | GET | admin, supervisor |
ADMIN¶
| Location | Methods | Authorized roles |
|---|---|---|
| /api/ADMIN | GET, POST, PUT, DELETE | admin, supervisor |
ACTION¶
| Location | Methods | Authorized roles |
|---|---|---|
| /api/ACTION | GET, PUT | admin, supervisor |
AUTHORIZED_GROUP_ACTION¶
| Location | Methods | Authorized roles |
|---|---|---|
| /api/AUTHORIZED_GROUP_ACTION | GET, POST, DELETE | admin, supervisor |
AUTHORIZED_SUPERVISOR_ACTION¶
| Location | Methods | Authorized roles |
|---|---|---|
| /api/AUTHORIZED_SUPERVISOR_ACTION | GET, POST, DELETE | admin |
CONTACT_NOTIFY_ACTION¶
| Location | Methods | Authorized roles |
|---|---|---|
| /api/CONTACT_NOTIFY_ACTION | GET, POST, DELETE | admin, supervisor |