postfixman 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/postfixman/api.rb +14 -225
- data/lib/postfixman/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fefd8ac204c397e58d5e9ab5c92acddd3a52b319
|
4
|
+
data.tar.gz: 7180d09cce69a9ac32b2a99ccbaae043720ebe6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 255b96c4f729884f3095cac2bb6a87b5dbe7d99d0e88e9d4309d2a22e50be51ad70ea2292a3b3caeafb7329b8a8cd1fa7e9aca6dadba5ed2f71f3579c6881bdc
|
7
|
+
data.tar.gz: a4d266d305f6cf454ad5973513e958c6371adc30f7b4c5f02107d07937889b5085c4b72d7cffffa7d5ed50c6be33937ada620ec4b741dcffc8f94d494a6c2a7e
|
data/CHANGELOG.md
CHANGED
data/lib/postfixman/api.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Postfixman
|
2
2
|
class Api
|
3
3
|
def initialize(endpoint_url, access_token)
|
4
4
|
@endpoint_url = endpoint_url
|
@@ -7,22 +7,22 @@ module Openfire
|
|
7
7
|
|
8
8
|
def get_domains
|
9
9
|
request = web_request('GET', '/domains', { }, default_headers)
|
10
|
-
request[:body].map { |x|
|
10
|
+
request[:body].map { |x| Postfixman::Domain.new(x) }
|
11
11
|
end
|
12
12
|
|
13
13
|
def get_users(domain_id)
|
14
14
|
request = web_request('GET', "/domains/#{domain_id}/users", { }, default_headers)
|
15
|
-
request[:body].map { |x|
|
15
|
+
request[:body].map { |x| Postfixman::User.new(x) }
|
16
16
|
end
|
17
17
|
|
18
18
|
def create_user(params)
|
19
19
|
request = web_request('POST', '/users', params, default_headers)
|
20
|
-
|
20
|
+
Postfixman::User.new(request[:body])
|
21
21
|
end
|
22
22
|
|
23
23
|
def update_user(user_id, params)
|
24
24
|
request = web_request('PUT', "/users/#{user_id}", params, default_headers)
|
25
|
-
|
25
|
+
Postfixman::User.new(request[:body])
|
26
26
|
end
|
27
27
|
|
28
28
|
def delete_user(user_id)
|
@@ -32,17 +32,17 @@ module Openfire
|
|
32
32
|
|
33
33
|
def get_aliases(domain_id)
|
34
34
|
request = web_request('GET', "/domains/#{domain_id}/aliases", { }, default_headers)
|
35
|
-
request[:body].map { |x|
|
35
|
+
request[:body].map { |x| Postfixman::Alias.new(x) }
|
36
36
|
end
|
37
37
|
|
38
38
|
def create_alias(params)
|
39
39
|
request = web_request('POST', '/aliases', params, default_headers)
|
40
|
-
|
40
|
+
Postfixman::User.new(request[:body])
|
41
41
|
end
|
42
42
|
|
43
43
|
def update_alias(alias_id, params)
|
44
44
|
request = web_request('PUT', "/aliases/#{user_id}", params, default_headers)
|
45
|
-
|
45
|
+
Postfixman::User.new(request[:body])
|
46
46
|
end
|
47
47
|
|
48
48
|
def delete_alias(alias_id)
|
@@ -52,17 +52,17 @@ module Openfire
|
|
52
52
|
|
53
53
|
def get_recipient_bccs
|
54
54
|
request = web_request('GET', "/domains/#{domain_id}/recipient_bccs", { }, default_headers)
|
55
|
-
request[:body].map { |x|
|
55
|
+
request[:body].map { |x| Postfixman::RecipientBcc.new(x) }
|
56
56
|
end
|
57
57
|
|
58
58
|
def create_recipient_bccs(params)
|
59
59
|
request = web_request('POST', '/recipient_bccs', params, default_headers)
|
60
|
-
|
60
|
+
Postfixman::User.new(request[:body])
|
61
61
|
end
|
62
62
|
|
63
63
|
def update_sender_bccs(sender_bcc_id, params)
|
64
64
|
request = web_request('PUT', "/recipient_bccs/#{user_id}", params, default_headers)
|
65
|
-
|
65
|
+
Postfixman::User.new(request[:body])
|
66
66
|
end
|
67
67
|
|
68
68
|
def delete_recipient_bccs(sender_bcc_id)
|
@@ -72,17 +72,17 @@ module Openfire
|
|
72
72
|
|
73
73
|
def get_sender_bccs
|
74
74
|
request = web_request('GET', "/domains/#{domain_id}/sender_bccs", { }, default_headers)
|
75
|
-
request[:body].map { |x|
|
75
|
+
request[:body].map { |x| Postfixman::SenderBcc.new(x) }
|
76
76
|
end
|
77
77
|
|
78
78
|
def create_sender_bccs(params)
|
79
79
|
request = web_request('POST', '/sender_bccs', params, default_headers)
|
80
|
-
|
80
|
+
Postfixman::User.new(request[:body])
|
81
81
|
end
|
82
82
|
|
83
83
|
def update_sender_bccs(sender_bcc_id)
|
84
84
|
request = web_request('PUT', "/sender_bccs/#{user_id}", params, default_headers)
|
85
|
-
|
85
|
+
Postfixman::User.new(request[:body])
|
86
86
|
end
|
87
87
|
|
88
88
|
def delete_sender_bccs(sender_bcc_id)
|
@@ -90,217 +90,6 @@ module Openfire
|
|
90
90
|
request[:body]['success'] == true
|
91
91
|
end
|
92
92
|
|
93
|
-
def get_user(username)
|
94
|
-
request = web_request('GET', "/users/#{username}", { }, default_headers)
|
95
|
-
Openfire::User.new(request[:body])
|
96
|
-
end
|
97
|
-
|
98
|
-
def create_user(user_data={})
|
99
|
-
request = web_request('POST', '/users', user_data.to_json, default_headers)
|
100
|
-
(request[:status_code] == 201)
|
101
|
-
end
|
102
|
-
|
103
|
-
def update_user(username, user_data={})
|
104
|
-
request = web_request('PUT', "/users/#{username}", user_data.to_json, default_headers)
|
105
|
-
(request[:status_code] == 200)
|
106
|
-
end
|
107
|
-
|
108
|
-
def delete_user(username)
|
109
|
-
request = web_request('DELETE', "/users/#{username}", { }, default_headers)
|
110
|
-
(request[:status_code] == 200)
|
111
|
-
end
|
112
|
-
|
113
|
-
def lock_user(username)
|
114
|
-
request = web_request('POST', "/lockouts/#{username}", { }, default_headers)
|
115
|
-
(request[:status_code] == 200)
|
116
|
-
end
|
117
|
-
|
118
|
-
def unlock_user(username)
|
119
|
-
request = web_request('DELETE', "/lockouts/#{username}", { }, default_headers)
|
120
|
-
(request[:status_code] == 200)
|
121
|
-
end
|
122
|
-
|
123
|
-
def get_user_groups(username)
|
124
|
-
request = web_request('GET', "/users/#{username}/groups", { }, default_headers)
|
125
|
-
body = request[:body]['groupname']
|
126
|
-
|
127
|
-
body.is_a?(Array) ? body : [body]
|
128
|
-
end
|
129
|
-
|
130
|
-
def add_user_to_group(username, groupname)
|
131
|
-
request = web_request('POST', "/users/#{username}/groups/#{groupname}", { }, default_headers)
|
132
|
-
|
133
|
-
(request[:status_code] == 201)
|
134
|
-
end
|
135
|
-
|
136
|
-
def add_user_to_groups(username, groupnames)
|
137
|
-
payload = { groupname: groupnames }.to_json
|
138
|
-
|
139
|
-
request = web_request('POST', "/users/#{username}/groups", payload, default_headers)
|
140
|
-
|
141
|
-
(request[:status_code] == 201)
|
142
|
-
end
|
143
|
-
|
144
|
-
def delete_user_from_group(username, groupname)
|
145
|
-
request = web_request('DELETE', "/users/#{username}/groups/#{groupname}", { }, default_headers)
|
146
|
-
|
147
|
-
(request[:status_code] == 200)
|
148
|
-
end
|
149
|
-
|
150
|
-
def delete_user_from_groups(username, groupnames)
|
151
|
-
payload = { groupname: groupnames }.to_json
|
152
|
-
|
153
|
-
request = web_request('DELETE', "/users/#{username}/groups", payload, default_headers)
|
154
|
-
|
155
|
-
(request[:status_code] == 200)
|
156
|
-
end
|
157
|
-
|
158
|
-
def get_user_roster(username)
|
159
|
-
raise 'not implemented'
|
160
|
-
end
|
161
|
-
|
162
|
-
def create_user_roster(username, roster_data={})
|
163
|
-
raise 'not implemented'
|
164
|
-
end
|
165
|
-
|
166
|
-
def delete_user_roster(username, jid)
|
167
|
-
raise 'not implemented'
|
168
|
-
end
|
169
|
-
|
170
|
-
def update_user_roster(username, jid, roster_data={})
|
171
|
-
raise 'not implemented'
|
172
|
-
end
|
173
|
-
|
174
|
-
def get_chatrooms
|
175
|
-
raise 'not implemented'
|
176
|
-
end
|
177
|
-
|
178
|
-
def get_chatroom(room_name)
|
179
|
-
raise 'not implemented'
|
180
|
-
end
|
181
|
-
|
182
|
-
def get_chatroom_participants(room_name)
|
183
|
-
raise 'not implemented'
|
184
|
-
end
|
185
|
-
|
186
|
-
def create_chatroom(room_data={})
|
187
|
-
raise 'not implemented'
|
188
|
-
end
|
189
|
-
|
190
|
-
def delete_chatroom(room_name)
|
191
|
-
raise 'not implemented'
|
192
|
-
end
|
193
|
-
|
194
|
-
def update_chatroom(room_name, room_data={})
|
195
|
-
raise 'not implemented'
|
196
|
-
end
|
197
|
-
|
198
|
-
def add_user_to_chatroom(room_name, username_or_jid, role)
|
199
|
-
raise 'not implemented'
|
200
|
-
end
|
201
|
-
|
202
|
-
def delete_user_from_chatroom(room_name, username_or_jid, role)
|
203
|
-
raise 'not implemented'
|
204
|
-
end
|
205
|
-
|
206
|
-
def get_system_properties
|
207
|
-
request = web_request('GET', '/system/properties', { }, default_headers)
|
208
|
-
request[:body]['property'].map { |x| Openfire::SystemProperty.new(x) }
|
209
|
-
end
|
210
|
-
|
211
|
-
def get_system_property(property_name)
|
212
|
-
request = web_request('GET', "/system/properties/#{property_name}", { }, default_headers)
|
213
|
-
Openfire::SystemProperty.new(request[:body])
|
214
|
-
end
|
215
|
-
|
216
|
-
def create_system_property(property_name, value)
|
217
|
-
payload = {
|
218
|
-
'@key' => property_name,
|
219
|
-
'@value' => value
|
220
|
-
}.to_json
|
221
|
-
|
222
|
-
request = web_request('POST', '/system/properties', payload, default_headers)
|
223
|
-
(request[:status_code] == 201)
|
224
|
-
end
|
225
|
-
|
226
|
-
def delete_system_property(property_name)
|
227
|
-
request = web_request('DELETE', "/system/properties/#{property_name}", { }, default_headers)
|
228
|
-
(request[:status_code] == 200)
|
229
|
-
end
|
230
|
-
|
231
|
-
def update_system_property(property_name, value)
|
232
|
-
payload = {
|
233
|
-
'@key' => property_name,
|
234
|
-
'@value' => value
|
235
|
-
}.to_json
|
236
|
-
|
237
|
-
request = web_request('PUT', "/system/properties/#{property_name}", payload, default_headers)
|
238
|
-
(request[:status_code] == 200)
|
239
|
-
end
|
240
|
-
|
241
|
-
def get_concurrent_sessions_count
|
242
|
-
request = web_request('GET', '/system/statistics/sessions', { }, default_headers)
|
243
|
-
Openfire::SessionsCount.new(request[:body])
|
244
|
-
end
|
245
|
-
|
246
|
-
def get_groups
|
247
|
-
request = web_request('GET', '/groups', { }, default_headers)
|
248
|
-
request[:body]['group'].map { |x| Openfire::Group.new(x) }
|
249
|
-
end
|
250
|
-
|
251
|
-
def get_group(groupname)
|
252
|
-
request = web_request('GET', "/groups/#{groupname}", { }, default_headers)
|
253
|
-
Openfire::Group.new(request[:body])
|
254
|
-
end
|
255
|
-
|
256
|
-
def create_group(group_data)
|
257
|
-
request = web_request('POST', '/groups', group_data.to_json, default_headers)
|
258
|
-
(request[:status_code] == 201)
|
259
|
-
end
|
260
|
-
|
261
|
-
def update_group(groupname, group_data={})
|
262
|
-
request = web_request('PUT', "/groups/#{groupname}", group_data.to_json, default_headers)
|
263
|
-
(request[:status_code] == 200)
|
264
|
-
end
|
265
|
-
|
266
|
-
def delete_group(groupname)
|
267
|
-
request = web_request('DELETE', "/groups/#{groupname}", { }, default_headers)
|
268
|
-
(request[:status_code] == 200)
|
269
|
-
end
|
270
|
-
|
271
|
-
def get_sessions
|
272
|
-
request = web_request('GET', '/sessions', { }, default_headers)
|
273
|
-
data = request[:body]['session']
|
274
|
-
|
275
|
-
if data.is_a?(Array)
|
276
|
-
data.map { |x| Openfire::Session.new(x) }
|
277
|
-
else
|
278
|
-
[Openfire::Session.new(data)]
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
def get_user_sessions(username)
|
283
|
-
request = web_request('GET', "/sessions/#{username}", { }, default_headers)
|
284
|
-
data = request[:body]['session']
|
285
|
-
|
286
|
-
if data.is_a?(Array)
|
287
|
-
data.map { |x| Openfire::Session.new(x) }
|
288
|
-
else
|
289
|
-
[Openfire::Session.new(data)]
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
def close_user_sessions(username)
|
294
|
-
request = web_request('DELETE', "/sessions/#{username}", { }, default_headers)
|
295
|
-
(request[:status_code] == 200)
|
296
|
-
end
|
297
|
-
|
298
|
-
def send_broadcast_message(message_text)
|
299
|
-
payload = { body: message_text }.to_json
|
300
|
-
|
301
|
-
request = web_request('POST', '/messages/users', payload, default_headers)
|
302
|
-
end
|
303
|
-
|
304
93
|
private
|
305
94
|
|
306
95
|
def default_headers
|
data/lib/postfixman/version.rb
CHANGED