]> git.defcon.no Git - hermes/blob - api-nodes.txt
Moved API-files to a separate API directory.
[hermes] / api-nodes.txt
1 All API nodes currently use GET requests for all parameters.
2 All API nodes return JSON data, and all results will contain
3 a 'response' element. The 'response' may be set to:
4 * 'ok' on success. Further contents depend on the node requested.
5 * 'invalid' on invalid requests. A 'cause' element should give a
6 keyword denoting what was invalid about the request...
7 * 'failed' on simple failure. A 'cause' element is supplied, with a
8 failure-keyword (e.g. 'nonexistant', 'inuse', 'dbfail').
9 A final 'detail' is commonly included, with a verbose desctiption.
10 * 'error' on critical failure. Regard this as a soft form of "500 server error"...
11
12 List of API nodes:
13 ---------------------
14
15 user/get?username=foo&domain=bar.bz
16 user/get?user=user@bar.bz
17 Return User information, not including hardphone association.
18 Possible extension: allow user/get?address=foo@bar
19
20 user/list
21 user/list?search=foo@bar
22 Return an array of users, with 'user' set to SIP-address and
23 'displayname' set to the users Displayname.
24
25 If the search parameter is included, a globbing search is performed,
26 and only matches are listed.
27
28 user/add_local?username=foo&domain=bar.bz&displayname=baz&email=qux@zef.tld
29 user/add_local?user=foo@bar.bz&displayname=baz&email=qux@zef.tld
30 Adds a user account to both Kamailio and provisioning, if the
31 username@domain is nonexistant, and the domain is local (handled by
32 Kamailio). The password for the user is auto-generated.
33
34 Returns a full user object, the same form as user/get
35
36 user/add_remote?username=foo&domain=bar&password=S3cr3t&displayname=baz&registrar=sip.example.com
37 user/add_remote?user=foo@bar.bz&password=S3cr3t&displayname=baz&registrar=sip.example.com
38 optionals: &r_port=5060&proxy=sipproxy.example.com&p_port=5060&authid=realfoo&dialplan=(.*)&linetext=lalala
39 Adds a provisioning user for a remote SIP account. This allows locally
40 provisioned hardphones to be associated with non-local SIP accounts.
41
42 Returns a full user object, the same form as user/get
43
44 Returns 'failed' with 'cause' = 'domain' if an attempt is made to
45 add_remote for a local domain.
46
47 user/change_pw?username=foo&domain=bar&password=baz
48 user/change_pw?user=foo@bar.bz&password=baz
49 Changes the password for the given user, returns 'ok' with 'detail' as
50 a descriptive text on success. In the current implementation,
51 provisioning and kamailio passwords are handled separately, so one
52 may succeed and the other fail. As is, this permits password changes
53 of non-local provision users with minimal effort.
54
55 Returns 'failed' with 'cause' = 'nonexistant' if user does not exist.
56
57 Returns 'failed' with 'cause' = 'dbfail' if the database request
58 failed. Note that this may be because the given password was identical
59 to the old.
60
61 user/update?username=foo&domain=bar
62 user/update?user=foo@bar.bz
63 optionals: &displayname=baz&dialplan=(.*)&linetext=lalala&email=foo@bar.baz
64 Not implemented! Will only be implemented for Local users.
65 Remote users will have to be removed, and re-added.
66
67 user/change_email?username=foo&domain=bar&email=user@example.com
68 user/change_email?user=foo@bar.bz&email=user@example.com
69 Changes the email address for the given user, returns 'ok' with
70 'user' set to the requested username and 'email' set to the
71 email address. This only applies to kamailio local users.
72
73 Returns 'failed' with 'cause' = 'nonexistant' if user does not exist.
74
75 Returns 'failed' with 'cause' = 'dbfail' if the database request
76 failed. Note that this may be because the given password was identical
77 to the old.
78
79
80 user/remove?username=foo&domain=bar
81 user/remove?user=foo@bar.bz
82 Removes user account from Kamailio, if present, and removes user from
83 provisioning. Will fail if user has associated hardphones, remove
84 phones before removing user.
85
86 Returns 'ok' on success.
87
88 user/gen_pw
89 Test-node, generates a random password on the same form as that used by
90 user/add_local. May be used with the to-be-implemented change_pw node.
91
92 phone/get?mac=f00ba2ba5c00
93 phone/get?user=foo@bar.bz
94 phone/get?username=foo&domain=bar.bz
95 Returns a list of associated elements. If MAC address is given as
96 parameter, a list of associated user@domain addresses is retruned. If
97 user@domain is given as parameter, a list of associated mac addresses
98 is returned.
99
100 phone/list?search=f00ba2
101 Returns the list of registered MAC addresses. If the (optional) search
102 parameter is included, the list is the result of a globbing search,
103 a subset matching on the MAC addresses.
104
105 phone/add?mac=f00ba2ba5c00&username=foo&domain=bar.bz
106 phone/add?mac=f00ba2ba5c00&user=foo@bar.bz
107 Adds a phone-to-user association to Provisioning. The user may be
108 provided as 'username' and 'domain' in separate parameters, or as
109 'user' in sip-address form. The MAC address must be valid, in plain-hex
110 or colon-separated form, and the user must match a valid user
111 registration.
112
113 Returns the mac+user combinations on success.
114
115 phone/remove?mac=f00ba2ba5c00&username=foo&domain=bar.bz
116 phone/remove?mac=f00ba2ba5c00&user=foo@bar.bz
117 Deletes a phone-to-user association. Required parameters and formats
118 are identical to the phone/add node.
119 Returns 'ok' on success.
120
121
122 numbers/list
123 numbers/list?search=1234
124 numbers/list?random=true
125 optional: limit=n
126 Gives a list of entries in the phone number pool.
127 With no parameters, the entire (ordered) list of available numbers is
128 returned. With 'search', the result of a pre-post globbing search is
129 returned With 'random', a list of entries is returned unordered (random
130 order) For all nodes, 'limit' may be a numeric limit of desired
131 results.
132
133 numbers/add_range?start=%2B471234&end=%2B47123456
134 The start and end must have identical lead-in, and start must be less
135 than end. Both numbers must be given in E164 format, remember to
136 urlencode the plus (+ -> %2B). The numeric component of both will be
137 extracted, and all numbers in the range will be iteratively added to
138 the pool, including the ending number.
139 Returns 'ok' on success.
140
141 numbers/add?number=%2B4761123456
142 Adds the given number to the pool, after verifying that the number is
143 in valid E164 format, and that the number does not already exist in the
144 pool.
145
146 Returns 'response' 'ok' and "Added <number>" in 'detail' on success.
147
148 numbers/remove?number=%2B4761123456
149 Removes/pulls a number from the pool.
150 The number must be a valid e164 number, and must be present in the
151 pool.
152
153 Returns 'response' as 'ok' with 'number' set to the number that was
154 pulled from the pool.
155
156 numbers/inpool?number=%2B4761123456
157 Tests if the given E164 number is in the pool.
158 Returns 'response' = 'ok' with 'number' = '<number>' If the number is
159 in the pool
160
161 Returns response = 'failed' with 'cause' = 'nonexistant' if not.
162
163 alias/list
164 alias/list?destination=foo@bar.bz
165 alias/list?destination=foo@bar.bz&e164=true
166 alias/list?alias=foo@bar.bz
167 With no parameters, this will return all defined aliases (potentially a
168 huge list). With the destination parameter set, only aliases dfor that
169 destination will be listed, and with the e164 option set to true, only
170 an e164 alias will be returned (if one/it exists). The alias parameter
171 gives the same behaviour, butr looks up an alias address instead of the
172 destination. The e164 option is not valid for the alias search
173 (naturally).
174
175 Returns 'ok' on success, with an array of 'destination' and 'alias'
176 pairs.
177
178 Returns 'ok' with an empty array if the search gave no results.
179
180 Returns 'ok' with an empty array if the database search fails.
181
182 Returns 'failed' with 'cause' = 'invalid' on invalid SIP addresses.
183
184 alias/add?alias_username=foo&alias_domain=bar.bz&destination=bar@qux.zx
185 alias/add?alias=foo@bar.bz&destination=bar@qux.zx
186 Add an alias specified by alias_username and alias_domain that
187 points to the destination SIP-adress.
188
189 On success, 'ok' is returned, with 'alias' and 'destination' set to the
190 resulting alias and destination adresses.
191
192 Returns 'invalid' with 'cause' = 'destination' or 'alias' if the
193 resulting alias-adress or destination are invalid SIP-adresses.
194
195 Returns 'failed' with 'cause' = 'nxdomain' if the given alias domain is
196 not a Kamailio domain.
197
198 Returns 'failed' with 'cause' = 'exists' if the alias is an E164 number
199 and the user already has an E164 alias registered.
200
201 Returns 'failed' with 'cause' = 'nonexistant' when an alias for a local
202 domain is requested, but the local subscriber does not exist.
203
204 Returns 'failed' with 'cause' = 'exists' for aliases that already
205 exists, (and aliases that overlaps SIP-accounts - not implemented).
206
207
208 alias/remove?alias_username=foo&alias_domain=bar.bz
209 alias/remove?alias=foo@bar.bz
210 Removes the alias given by alias_username and alias_domain.
211
212 Returns 'ok' with the removed alias adress as 'alias' on success
213
214 Returns 'failed' with 'cause' = 'nonexistant' it the alias does not
215 exists.
216
217 Returns 'invalid' with 'cause' = 'address' if the given alias is not a
218 valid SIP adress.
219
220 TODO list:
221 ---------------------
222
223 authentication-mechanism :)
224
225 Add collision prevention for users, make sure that no user can be added when the user
226 address would overlap/collide with a valid alias-address
227
228 Change all GET to POST
229
230 Implement test-tool for POST-based communication ;)
231
232 Improve robustness of change_pw: fetch old password for rollback/testing.
233
234 Check for locations where sql_dbexec_rows is more appropriate/correct than sql_dbexec