annotate mod_data_access.wiki @ 293:341195fb3d62

Added config example
author MWild1@gmail.com
date Thu, 19 Jul 2012 18:32:20 +0000
parents 963ae0ff05b0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
241
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 #summary HTTP access to prosody’s storage mechanism
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 = Introduction =
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 This module gives HTTP access to prosodys storage mechanism. It uses normal HTTP verbs and [http://tools.ietf.org/html/rfc2617 Basic HTTP authentication], so you could call it RESTful if you like buzzwords.
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 = Syntax =
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 To Fetch data, issue a normal GET request
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 {{{
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 GET /data[/<host>/<user>]/<store>[/<format>] HTTP/1.1
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 Authorization: <base64(authzid:password)>
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 -- OR --
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15
249
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
16 PUT|POST /data[/<host>/<user>]/<store> HTTP/1.1
241
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 Content-Type: text/x-lua | application/json
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 <data>
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 }}}
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 These map to `datamanager.method(user, host, store, data)`, where choice of `method` and its parameters are explained below.
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24 == Verbs ==
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26 ||*Verb*||*Meaning* ||*datamanager method* ||
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 ||`GET` || Just fetch data || `load()` or `list_load()` ||
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 ||`PUT` || Replace all data in the store || `store() ||
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 ||`POST`|| Append item to the store || `list_append()` ||
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31 Note: In a `GET` request, if `load()` returns `nil`, `list_load()` will be tried instead.
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 == Fields ==
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 ||*Field*||*Description*||*Default*||
249
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
36 ||`host`||Which virtual host to access||Required. If not set in the path, the domain-part of the authzid is used.||
241
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
37 ||`user`||Which users storage to access||Required. If not set in the path, uses the node part of the authzid.||
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38 ||`store`||Which storage to access.||Required.||
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
39 ||`format`||Which format to serialize to. `json` and `lua` are supported. When uploading data, the `Content-Type` header is used.||`json`||
c6f01319f4c3 Add page about mod_data_access
Kim Alvefur <zash@zash.se>
parents:
diff changeset
40 ||`data`||The actual data to upload in a `PUT` or `POST` request.||`nil`||
249
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
41
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
42 Note: Only admins can change data for users other than themselves.
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
43
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
44 == Example usage ==
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
45
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
46 Here follows some example usage using `curl`.
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
47
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
48 Get your account details:
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
49
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
50 {{{
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
51 curl http://prosody.local:5280/data/accounts -u user@example.com:secr1t
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
52 {"password":"secr1t"}
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
53 }}}
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
54
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
55 Set someones account details:
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
56
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
57 {{{
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
58 curl -X PUT http://prosody.local:5280/data/example.com/user/accounts -u admin@host:r00tp4ssw0rd --header 'Content-Type: application/json' --data-binary '{"password":"changeme"}'
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
59 }}}
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
60
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
61 == Client library ==
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
62
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
63 * https://metacpan.org/module/Prosody::Mod::Data::Access
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
64
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
65 == TODO ==
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
66
963ae0ff05b0 Add page for mod_mam
Kim Alvefur <zash@zash.se>
parents: 241
diff changeset
67 * Use `Accept` header.