agilix 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/README.md +259 -42
- data/lib/agilix.rb +9 -1
- data/lib/agilix/buzz/api.rb +19 -12
- data/lib/agilix/buzz/commands/authentication.rb +136 -4
- data/lib/agilix/buzz/commands/course.rb +77 -3
- data/lib/agilix/buzz/commands/domain.rb +3 -3
- data/lib/agilix/buzz/commands/report.rb +37 -0
- data/lib/agilix/buzz/commands/user.rb +85 -0
- data/lib/agilix/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a82f77811d3cfeb64d923f26b0ea861505f62d304aeac3f50ea1ccd0bdefc14
|
4
|
+
data.tar.gz: bc528e6a6ae236c48856e6a824538638b95ce4ecd15e7d878c4f1b452f0d48b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 588b495b07ef024a8769457a760461938cb5791068e1e6aa451e61c649250250c811cb58c64546758461ac1e91bea697b7f18e0fd597ad385354c9c3c7974cde
|
7
|
+
data.tar.gz: 267fa0d5a739c92ce0220205dfcb09cc43d3cb9ff8a110e17e581e2624b7a3bd7157d042258bb10f0c36c1fe0944c9354bdeae2196ddd4ea0e001edd50bc79eb
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -49,7 +49,13 @@ Otherwise, you can pass `:username`, `:password`, and `:domain` into the initial
|
|
49
49
|
```
|
50
50
|
api = Agilix::Buzz::Api.new username: 'my-username', password: 'my-password', domain: 'my-domain'
|
51
51
|
```
|
52
|
+
The authentication API gives you back a token that can be used within a 15 minute window. This library will manage the need to fetch a new token or `extend_session` by setting the token & token expiration in the initialized api object.
|
52
53
|
|
54
|
+
### Passing arguments
|
55
|
+
|
56
|
+
All APIs have defined required arguments and optional arguments, and an argument cleaner will prevent the calls from being made if conditions are not met. Additionally it will strip out any unsupported api params that are not defined in the required or optional fields.
|
57
|
+
|
58
|
+
Below are instructions for basic invocation of the api methods. For additional information about each API method, please consult the Agilix documentation, linked in each method's name.
|
53
59
|
|
54
60
|
### Domains
|
55
61
|
|
@@ -62,6 +68,7 @@ api.create_domains [{name: "BuzzTest1", userspace: 'buzz-test-fc-1', parentid: '
|
|
62
68
|
api.delete_domain domainid: '57027'
|
63
69
|
```
|
64
70
|
#### [GetDomain2](https://api.agilixbuzz.com/docs/#!/Command/GetDomain2)
|
71
|
+
This is aliased to `get_domain`
|
65
72
|
```
|
66
73
|
api.get_domain domainid: '57025'
|
67
74
|
```
|
@@ -98,26 +105,100 @@ api.restore_domain domainid: '57027'
|
|
98
105
|
api.update_domains [{ domainid: "57027", name: "BuzzTestUpdated1", userspace: 'buzz-test-fc-1', parentid: '57025'}]
|
99
106
|
```
|
100
107
|
|
101
|
-
|
108
|
+
### Reports
|
102
109
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
110
|
+
`get_runnable_report_list` and `run_report` are probably the only ones you would use.
|
111
|
+
|
112
|
+
#### [GetReportInfo](https://api.agilixbuzz.com/docs/#!/Command/GetReportInfo)
|
113
|
+
```
|
114
|
+
api.get_report_info reportid: 127
|
115
|
+
```
|
116
|
+
#### [GetReportList](https://api.agilixbuzz.com/docs/#!/Command/GetReportList)
|
117
|
+
```
|
118
|
+
api.get_report_list domainid: 1
|
119
|
+
```
|
120
|
+
#### [GetRunnableReportList](https://api.agilixbuzz.com/docs/#!/Command/GetRunnableReportList)
|
121
|
+
```
|
122
|
+
api.get_runnable_report_list domainid: 57025
|
123
|
+
```
|
124
|
+
#### [RunReport](https://api.agilixbuzz.com/docs/#!/Command/RunReport)
|
125
|
+
```
|
126
|
+
api.run_report reportid: 127, entityid: 57025, format: 'json'
|
127
|
+
```
|
107
128
|
|
108
129
|
## Users
|
109
130
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
131
|
+
#### [CreateUsers2](https://api.agilixbuzz.com/docs/#!/Command/CreateUsers2)
|
132
|
+
This is aliased to `create_users`
|
133
|
+
```
|
134
|
+
api.create_users( [{
|
135
|
+
domainid: '57025',
|
136
|
+
username: "BuzzUserTest1",
|
137
|
+
email: 'buzzusertest1@agilix.com',
|
138
|
+
password: 'testpassword1234',
|
139
|
+
firstname: 'Buzz',
|
140
|
+
lastname: "Man",
|
141
|
+
passwordquestion: "Who's your best friend?",
|
142
|
+
passwordanswer: "Me"
|
143
|
+
}] )
|
144
|
+
```
|
145
|
+
|
146
|
+
#### [DeleteUsers](https://api.agilixbuzz.com/docs/#!/Command/DeleteUsers)
|
147
|
+
```
|
148
|
+
api.delete_users [userid: '57181']
|
149
|
+
```
|
150
|
+
|
151
|
+
#### [GetActiveUserCount](https://api.agilixbuzz.com/docs/#!/Command/GetActiveUserCount)
|
152
|
+
```
|
153
|
+
api.get_active_user_count domainid: '57025'
|
154
|
+
api.get_active_user_count domainid: '5', includedescendantdomains: true, bymonth:true, startdate: '2018-01-01', enddate: '2019-03-01'
|
155
|
+
```
|
156
|
+
|
157
|
+
#### [GetDomainActivity](https://api.agilixbuzz.com/docs/#!/Command/GetDomainActivity)
|
158
|
+
```
|
159
|
+
api.get_domain_activity domainid: '57025'
|
160
|
+
```
|
161
|
+
|
162
|
+
#### [GetProfilePicture](https://api.agilixbuzz.com/docs/#!/Command/GetProfilePicture)
|
163
|
+
Returns base 64 encoded picture
|
164
|
+
```
|
165
|
+
api.get_profile_picture entityid: 57026
|
166
|
+
```
|
167
|
+
The api will return 404 not found if they don't have one, unless you supply it with a default profile pic, then it will return that
|
168
|
+
```
|
169
|
+
api.get_profile_picture entityid: 57025, default: "https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm"
|
170
|
+
```
|
171
|
+
|
172
|
+
#### [GetUser2](https://api.agilixbuzz.com/docs/#!/Command/GetUser2)
|
173
|
+
This is aliased to `get_user`
|
174
|
+
```
|
175
|
+
api.get_user userid: 57026
|
176
|
+
```
|
177
|
+
|
178
|
+
#### [GetUserActivity](https://api.agilixbuzz.com/docs/#!/Command/GetUserActivity)
|
179
|
+
```
|
180
|
+
api.get_user_activity userid: 57026
|
181
|
+
```
|
182
|
+
|
183
|
+
#### [GetUserActivityStream](https://api.agilixbuzz.com/docs/#!/Command/GetUserActivityStream)
|
184
|
+
```
|
185
|
+
api.get_user_activity_stream userid: 57026
|
186
|
+
```
|
187
|
+
|
188
|
+
#### [ListUsers](https://api.agilixbuzz.com/docs/#!/Command/ListUsers)
|
189
|
+
```
|
190
|
+
api.list_users domainid: 57025
|
191
|
+
```
|
192
|
+
|
193
|
+
#### [RestoreUser](https://api.agilixbuzz.com/docs/#!/Command/RestoreUser)
|
194
|
+
```
|
195
|
+
api.restore_user userid: 57026
|
196
|
+
```
|
197
|
+
|
198
|
+
#### [UpdateUsers](https://api.agilixbuzz.com/docs/#!/Command/UpdateUsers)
|
199
|
+
```
|
200
|
+
api.update_users [{ userid: '57026', username: "BuzzUserTestUpdated1", email: 'buzzusertest1@agilix.com',firstname: 'Buzz', lastname: "ManUpdated"}]
|
201
|
+
```
|
121
202
|
|
122
203
|
---
|
123
204
|
|
@@ -125,35 +206,171 @@ api.update_domains [{ domainid: "57027", name: "BuzzTestUpdated1", userspace: 'b
|
|
125
206
|
|
126
207
|
## Authentication
|
127
208
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
209
|
+
#### [Login2](https://api.agilixbuzz.com/docs/#!/Command/Login2)
|
210
|
+
This is handled automatically by instantiation of a base Agilix::Buzz::Api instance. It wouldn't need to be called manually unless using for other users or making calls on their behalf
|
211
|
+
```
|
212
|
+
api.login username: 'my-username', password: 'my-password', domain: 'my-domain'
|
213
|
+
```
|
214
|
+
|
215
|
+
#### [Logout](https://api.agilixbuzz.com/docs/#!/Command/Logout)
|
216
|
+
Clears your login session
|
217
|
+
```
|
218
|
+
api.logout
|
219
|
+
```
|
220
|
+
|
221
|
+
#### [ExtendSession](https://api.agilixbuzz.com/docs/#!/Command/ExtendSession)
|
222
|
+
This is handled automatically by instantiation of a base Agilix::Buzz::Api instance and on subsequent calls to the api through the check_authentication method
|
223
|
+
```
|
224
|
+
api.extend_session
|
225
|
+
```
|
226
|
+
|
227
|
+
#### [ForcePasswordChange](https://api.agilixbuzz.com/docs/#!/Command/ForcePasswordChange)
|
228
|
+
```
|
229
|
+
api.force_password_change userid: 57181
|
230
|
+
```
|
231
|
+
|
232
|
+
#### [GetPasswordLoginAttemptHistory](https://api.agilixbuzz.com/docs/#!/Command/GetPasswordLoginAttemptHistory)
|
233
|
+
```
|
234
|
+
api.get_password_login_attempt_history userid: 57181
|
235
|
+
api.get_password_login_attempt_history userid: 57181, earliestrecordtoreturn: '2018-01-01'
|
236
|
+
```
|
237
|
+
|
238
|
+
#### [GetPasswordPolicy](https://api.agilixbuzz.com/docs/#!/Command/GetPasswordPolicy)
|
239
|
+
For current domain
|
240
|
+
```
|
241
|
+
api.get_password_policy
|
242
|
+
```
|
243
|
+
for a specific domain
|
244
|
+
```
|
245
|
+
api.get_password_policy domainid: 57031
|
246
|
+
```
|
247
|
+
|
248
|
+
#### [GetPasswordQuestion](https://api.agilixbuzz.com/docs/#!/Command/GetPasswordQuestion)
|
249
|
+
```
|
250
|
+
api.get_password_question username: "auto-tests/BuzzUserUp1"
|
251
|
+
```
|
252
|
+
|
253
|
+
#### [UpdatePasswordQuestionAnswer](https://api.agilixbuzz.com/docs/#!/Command/UpdatePasswordQuestionAnswer)
|
254
|
+
ISSUE: This works with a GET call
|
255
|
+
```
|
256
|
+
api.update_password_question_answer userid: 57181, passwordquestion: "Where is your favorite vacation place?", passwordanswer: "Hawaii"
|
257
|
+
|
258
|
+
```
|
259
|
+
|
260
|
+
#### [Proxy](https://api.agilixbuzz.com/docs/#!/Command/Proxy)
|
261
|
+
```
|
262
|
+
api.proxy userid: 57181
|
263
|
+
```
|
264
|
+
In addition to these, we've created a proxy api method that will setup an api client for the proxied connection:
|
265
|
+
|
266
|
+
#### Proxy Api
|
267
|
+
```
|
268
|
+
proxy_api = api.proxy_api userid: 57181
|
269
|
+
```
|
270
|
+
|
271
|
+
This will allow you to make requests as the proxied user, like you would the main api user. It's required to demonstrate how unproxy works below
|
272
|
+
|
273
|
+
#### [Unproxy](https://api.agilixbuzz.com/docs/#!/Command/Unproxy)
|
274
|
+
First setup a proxy_api
|
275
|
+
```
|
276
|
+
proxy_api = api.proxy_api userid: 57181
|
277
|
+
```
|
278
|
+
Then you can unproxy out of it to logout as the proxied user
|
279
|
+
```
|
280
|
+
proxy_api.unproxy userid: 57181
|
281
|
+
```
|
282
|
+
|
283
|
+
#### [ResetLockout](https://api.agilixbuzz.com/docs/#!/Command/ResetLockout)
|
284
|
+
```
|
285
|
+
api.reset_lockout userid: 57181
|
286
|
+
```
|
287
|
+
#### [ResetPassword](https://api.agilixbuzz.com/docs/#!/Command/ResetPassword)
|
288
|
+
```
|
289
|
+
api.reset_password username:'auto-tests/BuzzUserUp1'
|
290
|
+
```
|
291
|
+
|
292
|
+
#### [UpdatePassword](https://api.agilixbuzz.com/docs/#!/Command/UpdatePassword)
|
293
|
+
```
|
294
|
+
api.update_password userid: 57181, password: "IChanged123"
|
295
|
+
```
|
296
|
+
|
297
|
+
#### [PutKey](https://api.agilixbuzz.com/docs/#!/Command/PutKey)
|
298
|
+
ISSUE: This should be a POST method as it's storing data
|
299
|
+
```
|
300
|
+
api.put_key entityid: 57031, name: 'secret_key_1', value: "Super Secret"
|
301
|
+
```
|
302
|
+
|
303
|
+
#### [GetKey](https://api.agilixbuzz.com/docs/#!/Command/GetKey)
|
304
|
+
```
|
305
|
+
api.get_key entityid: 57031, name: 'secret_key_1'
|
306
|
+
```
|
307
|
+
|
308
|
+
#### [ComputeHMAC](https://api.agilixbuzz.com/docs/#!/Command/ComputeHMAC)
|
309
|
+
This requires a key to exist with the given keyname, see `put_key`. **not sure what its used for yet**
|
310
|
+
```
|
311
|
+
api.compute_hmac domainid: 57025, keyname: "secret_key_1", message:"my-secret-1"
|
312
|
+
```
|
143
313
|
|
144
314
|
## Courses
|
145
315
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
316
|
+
#### [CopyCourses](https://api.agilixbuzz.com/docs/#!/Command/CopyCourses)
|
317
|
+
```
|
318
|
+
api.copy_courses [{courseid: 60982, domainid: 57025}]
|
319
|
+
```
|
320
|
+
|
321
|
+
#### [CreateCourses](https://api.agilixbuzz.com/docs/#!/Command/CreateCourses)
|
322
|
+
```
|
323
|
+
api.create_courses title: "Starter Course", domainid: 57025
|
324
|
+
```
|
325
|
+
|
326
|
+
#### [CreateDemoCourse](https://api.agilixbuzz.com/docs/#!/Command/CreateDemoCourse)
|
327
|
+
ISSUE: documentation on request format is inconsistent, not sure if it is bulk
|
328
|
+
```
|
329
|
+
api.create_demo_course courseid: 60982, domainid: 57025, title: "Demo Course",
|
330
|
+
```
|
331
|
+
|
332
|
+
#### [DeactivateCourse](https://api.agilixbuzz.com/docs/#!/Command/DeactivateCourse)
|
333
|
+
ISSUE: get request should be delete, put, patch
|
334
|
+
```
|
335
|
+
api.deactivate_course
|
336
|
+
```
|
337
|
+
|
338
|
+
#### [DeleteCourses](https://api.agilixbuzz.com/docs/#!/Command/DeleteCourses)
|
339
|
+
ISSUE: Why so different than deactivate course
|
340
|
+
```
|
341
|
+
api.delete_courses [{courseid: 60994}]
|
342
|
+
```
|
343
|
+
|
344
|
+
#### [GetCourse2](https://api.agilixbuzz.com/docs/#!/Command/GetCourse2)
|
345
|
+
```
|
346
|
+
api.get_course2 courseid: 60994
|
347
|
+
```
|
348
|
+
|
349
|
+
#### [GetCourseHistory](https://api.agilixbuzz.com/docs/#!/Command/GetCourseHistory)
|
350
|
+
```
|
351
|
+
api.get_course_history courseid: 60994
|
352
|
+
```
|
353
|
+
|
354
|
+
#### [ListCourses](https://api.agilixbuzz.com/docs/#!/Command/ListCourses)
|
355
|
+
```
|
356
|
+
api.list_courses domainid: 5
|
357
|
+
```
|
358
|
+
|
359
|
+
#### [MergeCourses](https://api.agilixbuzz.com/docs/#!/Command/MergeCourses)
|
360
|
+
```
|
361
|
+
api.merge_courses courseid: 60994
|
362
|
+
```
|
363
|
+
|
364
|
+
#### [RestoreCourse](https://api.agilixbuzz.com/docs/#!/Command/RestoreCourse)
|
365
|
+
```
|
366
|
+
api.restore_course courseid: 60994
|
367
|
+
```
|
368
|
+
|
369
|
+
#### [UpdateCourses](https://api.agilixbuzz.com/docs/#!/Command/UpdateCourses)
|
370
|
+
```
|
371
|
+
api.update_courses [{courseid: 60994, title: "Updated Course"}]
|
372
|
+
```
|
373
|
+
|
157
374
|
|
158
375
|
## Enrollments
|
159
376
|
|
data/lib/agilix.rb
CHANGED
@@ -7,13 +7,21 @@ require "agilix/buzz/commands/authentication"
|
|
7
7
|
require "agilix/buzz/commands/course"
|
8
8
|
require "agilix/buzz/commands/domain"
|
9
9
|
require "agilix/buzz/commands/general"
|
10
|
+
require "agilix/buzz/commands/report"
|
11
|
+
require "agilix/buzz/commands/user"
|
10
12
|
|
11
13
|
require "agilix/buzz/api"
|
12
14
|
require "agilix/version"
|
13
15
|
|
14
16
|
|
15
|
-
|
17
|
+
|
18
|
+
module Agilix
|
16
19
|
module Buzz
|
20
|
+
class Api::AuthenticationError < StandardError
|
21
|
+
def initialize(msg="Could not Authenticate")
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
17
25
|
# Your code goes here...
|
18
26
|
end
|
19
27
|
end
|
data/lib/agilix/buzz/api.rb
CHANGED
@@ -9,6 +9,8 @@ module Agilix
|
|
9
9
|
include Agilix::Buzz::Commands::Course
|
10
10
|
include Agilix::Buzz::Commands::Domain
|
11
11
|
include Agilix::Buzz::Commands::General
|
12
|
+
include Agilix::Buzz::Commands::Report
|
13
|
+
include Agilix::Buzz::Commands::User
|
12
14
|
|
13
15
|
attr_accessor :username, :password, :domain, :token, :token_expiration
|
14
16
|
|
@@ -16,6 +18,8 @@ module Agilix
|
|
16
18
|
@username = options.fetch(:username, default_username)
|
17
19
|
@password = options.fetch(:password, default_password)
|
18
20
|
@domain = options.fetch(:domain, default_domain)
|
21
|
+
@token = options.dig(:token)
|
22
|
+
@token_expiration = options.dig(:token_expiration)
|
19
23
|
end
|
20
24
|
|
21
25
|
def authenticated_get(query = {})
|
@@ -24,7 +28,7 @@ module Agilix
|
|
24
28
|
end
|
25
29
|
|
26
30
|
def authenticated_post(query = {})
|
27
|
-
check_authentication
|
31
|
+
check_authentication unless query.delete(:bypass_authentication_check)
|
28
32
|
post query
|
29
33
|
end
|
30
34
|
|
@@ -34,43 +38,46 @@ module Agilix
|
|
34
38
|
end
|
35
39
|
|
36
40
|
def get(query = {})
|
37
|
-
response = self.class.get(URL_BASE, query: modify_query(query), timeout:
|
41
|
+
response = self.class.get(URL_BASE, query: modify_query(query), timeout: 60, headers: headers)
|
38
42
|
end
|
39
43
|
|
40
44
|
def post(query = {})
|
41
|
-
response = self.class.post(URL_BASE, body: modify_body(query), timeout:
|
45
|
+
response = self.class.post(URL_BASE, body: modify_body(query), timeout: 60, headers: headers)
|
42
46
|
end
|
43
47
|
|
44
48
|
def bulk_post(query = {})
|
45
49
|
cmd = query.delete(:cmd)
|
46
50
|
url = URL_BASE + "?cmd=#{cmd}&_token=#{token}"
|
47
|
-
response = self.class.post(url, body: modify_bulk_body(query), timeout:
|
51
|
+
response = self.class.post(url, body: modify_bulk_body(query), timeout: 60, headers: headers)
|
48
52
|
end
|
49
53
|
|
50
|
-
private
|
51
|
-
|
52
54
|
def check_authentication
|
53
55
|
if token && token_expiration
|
54
56
|
if token_expiration < Time.now
|
55
57
|
extend_session
|
56
58
|
end
|
57
59
|
else
|
58
|
-
|
59
|
-
@token = response.dig("response", "user", "token")
|
60
|
-
@token_expiration = Time.now + (response.dig("response", "user", "authenticationexpirationminutes").to_i * 60 ) if @token
|
60
|
+
authenticate!
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
private
|
65
|
+
|
66
|
+
def authenticate!
|
67
|
+
response = login username: @username, password: @password, domain: @domain
|
68
|
+
raise AuthenticationError.new(response.dig("response", "message")) if response.dig("response", "code") == "InvalidCredentials"
|
69
|
+
@token = response.dig("response", "user", "token")
|
70
|
+
@token_expiration = Time.now + (response.dig("response", "user", "authenticationexpirationminutes").to_i * 60 ) if @token
|
71
|
+
response
|
72
|
+
end
|
73
|
+
|
64
74
|
def argument_cleaner(required_params: , optional_params: , options: )
|
65
75
|
missing_required = required_params - options.map {|k,v| k.to_sym }
|
66
76
|
raise ArgumentError.new("Missing Required Arguments: #{missing_required.join(', ')}") if missing_required.any?
|
67
|
-
|
68
77
|
all_params = (required_params + optional_params).flatten
|
69
78
|
return options.select {|k,v| all_params.include?(k.to_sym)}
|
70
79
|
end
|
71
80
|
|
72
|
-
|
73
|
-
|
74
81
|
def modify_query(query = {})
|
75
82
|
default_params = {}
|
76
83
|
default_params.merge! query
|
@@ -3,17 +3,149 @@ module Agilix
|
|
3
3
|
module Commands
|
4
4
|
module Authentication
|
5
5
|
|
6
|
-
|
6
|
+
# This is handled automatically by instantiation of a base Agilix::Buzz::Api instance. It wouldn't need to be called manually unless using for other users or making calls on their behalf
|
7
|
+
# api.login username: 'my-username', password: 'my-password', domain: 'my-domain'
|
8
|
+
def login2(username: , password: , domain: )
|
7
9
|
post cmd: "login2", username: "#{domain}/#{username}", password: password
|
8
10
|
end
|
9
|
-
alias_method :login, :
|
11
|
+
alias_method :login, :login2
|
10
12
|
|
13
|
+
# api.logout
|
14
|
+
def logout
|
15
|
+
response = authenticated_get cmd: "logout"
|
16
|
+
@token = nil
|
17
|
+
@token_expiration = nil
|
18
|
+
response
|
19
|
+
end
|
20
|
+
|
21
|
+
# This is handled automatically by instantiation of a base Agilix::Buzz::Api instance and on subsequent calls to the api through the check_authentication method
|
22
|
+
# api.extend_session
|
11
23
|
def extend_session
|
12
|
-
response = authenticated_post cmd: "extendsession"
|
13
|
-
@token_expiration =
|
24
|
+
response = authenticated_post cmd: "extendsession", bypass_authentication_check: true
|
25
|
+
@token_expiration = set_token_expiration(response.dig("response", "session", "authenticationexpirationminutes"))
|
26
|
+
authenticate! if response['code'] == 'NoAuthentication'
|
14
27
|
response
|
15
28
|
end
|
16
29
|
|
30
|
+
# api.force_password_change userid: 57181
|
31
|
+
def force_password_change(options = {})
|
32
|
+
options = argument_cleaner(required_params: %i( userid ), optional_params: %i( ), options: options )
|
33
|
+
authenticated_post cmd: "forcepasswordchange", **options
|
34
|
+
end
|
35
|
+
|
36
|
+
# api.get_password_login_attempt_history userid: 57181
|
37
|
+
# api.get_password_login_attempt_history userid: 57181, earliestrecordtoreturn: '2018-01-01'
|
38
|
+
def get_password_login_attempt_history(options = {})
|
39
|
+
options = argument_cleaner(required_params: %i( userid ), optional_params: %i( earliestrecordtoreturn ), options: options )
|
40
|
+
authenticated_get cmd: "getpasswordloginattempthistory", **options
|
41
|
+
end
|
42
|
+
|
43
|
+
# api.get_password_policy
|
44
|
+
# api.get_password_policy domainid: 57031
|
45
|
+
def get_password_policy(options = {})
|
46
|
+
options = argument_cleaner(required_params: %i( ), optional_params: %i( domainid bypasscache ), options: options )
|
47
|
+
authenticated_get cmd: "getpasswordpolicy", **options
|
48
|
+
end
|
49
|
+
|
50
|
+
# api.get_password_question username: "auto-tests/BuzzUserUp1"
|
51
|
+
def get_password_question(options = {})
|
52
|
+
options = argument_cleaner(required_params: %i( username ), optional_params: %i( ), options: options )
|
53
|
+
authenticated_get cmd: "getpasswordquestion", **options
|
54
|
+
end
|
55
|
+
|
56
|
+
# ISSUE: This works with a GET call
|
57
|
+
# api.update_password_question_answer userid: 57181, passwordquestion: "Where is your favorite vacation place?", passwordanswer: "Hawaii"
|
58
|
+
def update_password_question_answer(options = {})
|
59
|
+
options = argument_cleaner(required_params: %i( userid passwordquestion passwordanswer ), optional_params: %i( oldpassword ), options: options )
|
60
|
+
authenticated_post cmd: "updatepasswordquestionanswer", **options
|
61
|
+
end
|
62
|
+
|
63
|
+
# api.proxy userid: 57181
|
64
|
+
def proxy(options = {})
|
65
|
+
options = argument_cleaner(required_params: %i( userid ), optional_params: %i( noazt ), options: options )
|
66
|
+
options[:noazt] ||= true
|
67
|
+
authenticated_post cmd: "proxy", **options
|
68
|
+
end
|
69
|
+
|
70
|
+
# proxy_api = api.proxy_api userid: 57181
|
71
|
+
# proxy_api.unproxy userid: 57181
|
72
|
+
def unproxy(options = {})
|
73
|
+
options = argument_cleaner(required_params: %i( userid ), optional_params: %i( noazt ), options: options )
|
74
|
+
authenticated_post cmd: "unproxy", **options
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
# proxy_api = api.proxy_api userid: 57181
|
79
|
+
def proxy_api(userid: )
|
80
|
+
response = proxy userid: userid
|
81
|
+
self.class.new username: response.dig('response', 'user', 'username'), token: response.dig('response', 'user', 'token'), domain: response.dig('response', 'user', 'userspace'), token_expiration: set_token_expiration(response.dig('response', 'user', 'authenticationexpirationminutes'))
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
# :skip_test_coverage:
|
86
|
+
# api.proxy_sso_link userid: 57181
|
87
|
+
def proxy_sso_link(userid: )
|
88
|
+
response = proxy userid: userid
|
89
|
+
sso = {
|
90
|
+
"customization": {
|
91
|
+
"authentication": {
|
92
|
+
"provider": {
|
93
|
+
"server": "https://www.google.com"
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
self.update_domains [ {domainid: response.dig('response', 'user', 'domainid'), data: sso}]
|
99
|
+
# userspace = response.dig('response', 'user', 'userspace')
|
100
|
+
"https://api.leaderinme.net/SSOLogin?domainid=#{response.dig('response', 'user', 'domainid')}&url=/home&token=#{response.dig('response', 'user', 'token')}"
|
101
|
+
end
|
102
|
+
# :skip_test_coverage:
|
103
|
+
|
104
|
+
# api.reset_lockout userid: 57181
|
105
|
+
def reset_lockout(options = {})
|
106
|
+
options = argument_cleaner(required_params: %i( userid ), optional_params: %i( ), options: options )
|
107
|
+
authenticated_post cmd: "resetlockout", **options
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
def reset_password(options = {})
|
112
|
+
options = argument_cleaner(required_params: %i( username ), optional_params: %i( answer ), options: options )
|
113
|
+
authenticated_get cmd: "resetpassword", **options
|
114
|
+
end
|
115
|
+
|
116
|
+
# api.update_password userid: 57181, password: "IChanged123"
|
117
|
+
def update_password(options = {})
|
118
|
+
options = argument_cleaner(required_params: %i( userid password ), optional_params: %i( token oldpassword ), options: options )
|
119
|
+
authenticated_get cmd: "updatepassword", **options
|
120
|
+
end
|
121
|
+
|
122
|
+
# ISSUE: This should be a POST method as it's storing data
|
123
|
+
# api.put_key entityid: 57031, name: 'secret_key_1', value: "Super Secret"
|
124
|
+
def put_key(options = {})
|
125
|
+
options = argument_cleaner(required_params: %i( entityid name value ), optional_params: %i( ), options: options )
|
126
|
+
authenticated_get cmd: "putkey", **options
|
127
|
+
end
|
128
|
+
|
129
|
+
# api.get_key entityid: 57031, name: 'secret_key_1'
|
130
|
+
def get_key(options = {})
|
131
|
+
options = argument_cleaner(required_params: %i( entityid name ), optional_params: %i( ), options: options )
|
132
|
+
authenticated_get cmd: "getkey", **options
|
133
|
+
end
|
134
|
+
|
135
|
+
# This requires a key to exist with the given keyname, see putkey
|
136
|
+
# not sure what its used for yet
|
137
|
+
# api.compute_hmac
|
138
|
+
def compute_hmac(options = {})
|
139
|
+
options = argument_cleaner(required_params: %i( domainid keyname message ), optional_params: %i( algorithm format ), options: options )
|
140
|
+
options[:message] = "$VAR_USERID#{options[:message]}$VAR_SECRETTime$VAR_TIME"
|
141
|
+
authenticated_get cmd: "computeHMAC", **options
|
142
|
+
end
|
143
|
+
|
144
|
+
private
|
145
|
+
def set_token_expiration(minutes)
|
146
|
+
Time.now + (minutes.to_i * 60 )
|
147
|
+
end
|
148
|
+
|
17
149
|
end
|
18
150
|
end
|
19
151
|
end
|
@@ -3,13 +3,87 @@ module Agilix
|
|
3
3
|
module Commands
|
4
4
|
module Course
|
5
5
|
|
6
|
-
# api
|
7
|
-
|
6
|
+
# api.copy_courses [{courseid: 60982, domainid: 57025}]
|
7
|
+
def copy_courses(items = [])
|
8
|
+
options = items.map do |item|
|
9
|
+
argument_cleaner(required_params: %i( courseid domainid ), optional_params: %i( action depth reference status roleid title type startdate enddate days term indexrule ), options: item )
|
10
|
+
end
|
11
|
+
authenticated_bulk_post cmd: "copycourses", root_node: "course", body: options
|
12
|
+
end
|
13
|
+
|
14
|
+
# api.create_courses title: "Starter Course", domainid: 57025
|
15
|
+
def create_courses(items = [])
|
16
|
+
options = items.map do |item|
|
17
|
+
item[:schema] ||= 3 # should default to 3, 2 is old news
|
18
|
+
argument_cleaner(required_params: %i( title domainid schema ), optional_params: %i(reference status roleid type startdate enddate days term indexrule data ), options: item )
|
19
|
+
end
|
20
|
+
authenticated_bulk_post cmd: "createcourses", root_node: "course", body: options
|
21
|
+
end
|
22
|
+
|
23
|
+
# ISSUE: documentation on request format is inconsistent, not sure if it is bulk post or normal post format. in one place rood node is request, in other its course
|
24
|
+
# api.create_demo_course courseid: 60982, domainid: 57025, title: "Demo Course", daysoffset: 60
|
25
|
+
def create_demo_course(options = {})
|
26
|
+
options = argument_cleaner(required_params: %i( courseid domainid ), optional_params: %i( schema reference title daysoffset usermap ), options: options )
|
27
|
+
authenticated_post cmd: "createdemocourse", **options
|
28
|
+
end
|
29
|
+
|
30
|
+
# ISSUE: get request should be delete, put, patch
|
31
|
+
# api.deactivate_course
|
32
|
+
def deactivate_course(options = {})
|
33
|
+
options = argument_cleaner(required_params: %i( courseid ), optional_params: %i( ), options: options )
|
34
|
+
authenticated_get cmd: "deactivatecourse", **options
|
35
|
+
end
|
36
|
+
|
37
|
+
# ISSUE: Why so different than deactivate course
|
38
|
+
# api.delete_courses [{courseid: 60994}]
|
39
|
+
def delete_courses(items = [])
|
40
|
+
options = items.map do |item|
|
41
|
+
argument_cleaner(required_params: %i( courseid ), optional_params: %i(), options: item )
|
42
|
+
end
|
43
|
+
authenticated_bulk_post cmd: "deletecourses", root_node: "course", body: options
|
44
|
+
end
|
45
|
+
|
46
|
+
# api.get_course2 courseid: 60994
|
47
|
+
def get_course2(options = {})
|
48
|
+
options = argument_cleaner(required_params: %i( courseid ), optional_params: %i( select version ), options: options )
|
49
|
+
authenticated_get cmd: "getcourse2", **options
|
50
|
+
end
|
51
|
+
alias_method :get_course, :get_course2
|
52
|
+
|
53
|
+
# api.get_course_history courseid: 60994
|
54
|
+
def get_course_history(options = {})
|
55
|
+
options = argument_cleaner(required_params: %i( courseid ), optional_params: %i( ), options: options )
|
56
|
+
authenticated_get cmd: "getcoursehistory", **options
|
57
|
+
end
|
58
|
+
|
8
59
|
# api.list_courses domainid: 5
|
9
60
|
def list_courses(options = {})
|
10
|
-
|
61
|
+
options[:domainid] ||= 0
|
62
|
+
options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( includedescendantdomains limit show select text query subtype subscriptionmode subscriptiondomainid ), options: options )
|
63
|
+
authenticated_get cmd: "listcourses", **options
|
11
64
|
end
|
12
65
|
|
66
|
+
# api.merge_courses courseid: 60994
|
67
|
+
def merge_courses(items = [])
|
68
|
+
options = items.map do |item|
|
69
|
+
argument_cleaner(required_params: %i( courseid ), optional_params: %i( ), options: item )
|
70
|
+
end
|
71
|
+
authenticated_bulk_post cmd: "mergecourses", root_node: "course", body: options
|
72
|
+
end
|
73
|
+
|
74
|
+
# api.restore_course courseid: 60994
|
75
|
+
def restore_course(options = {})
|
76
|
+
options = argument_cleaner(required_params: %i( courseid ), optional_params: %i( ), options: options )
|
77
|
+
authenticated_get cmd: "restorecourse", **options
|
78
|
+
end
|
79
|
+
|
80
|
+
# api.update_courses [{courseid: 60994, title: "Updated Course"}]
|
81
|
+
def update_courses(items = [])
|
82
|
+
options = items.map do |item|
|
83
|
+
argument_cleaner(required_params: %i( courseid ), optional_params: %i( domainid title reference type baseid startdate enddate days term indexrule schema data ), options: item )
|
84
|
+
end
|
85
|
+
authenticated_bulk_post cmd: "updatecourses", root_node: "course", body: options
|
86
|
+
end
|
13
87
|
|
14
88
|
end
|
15
89
|
end
|
@@ -3,11 +3,10 @@ module Agilix
|
|
3
3
|
module Commands
|
4
4
|
module Domain
|
5
5
|
|
6
|
-
# api = Agilix::Buzz::Api::new
|
7
6
|
# api.create_domains [{name: "BuzzTest1", userspace: 'buzz-test-fc-1', parentid: '57025'}]
|
8
7
|
def create_domains(items = [])
|
9
8
|
options = items.map do |item|
|
10
|
-
|
9
|
+
argument_cleaner(required_params: %i( name userspace parentid ), optional_params: %i( reference flags data ), options: item )
|
11
10
|
end
|
12
11
|
authenticated_bulk_post cmd: "createdomains", root_node: 'domain', body: options
|
13
12
|
end
|
@@ -61,6 +60,7 @@ module Agilix
|
|
61
60
|
# api.list_domains domainid: '0' # all domains for user
|
62
61
|
# api.list_domains domainid: '57025'
|
63
62
|
def list_domains(options = {})
|
63
|
+
options[:domainid] ||= 0
|
64
64
|
options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( includedescendantdomains limit show select text query ), options: options )
|
65
65
|
authenticated_get cmd: "listdomains", **options
|
66
66
|
end
|
@@ -74,7 +74,7 @@ module Agilix
|
|
74
74
|
# api.update_domains [{ domainid: "57031", name: "BuzzTestUpdated1", userspace: 'buzz-test-fc-1', parentid: '57025'}]
|
75
75
|
def update_domains(items)
|
76
76
|
options = items.map do |item|
|
77
|
-
|
77
|
+
argument_cleaner(required_params: %i( domainid ), optional_params: %i( name userspace parentid reference flags data ), options: item )
|
78
78
|
end
|
79
79
|
authenticated_bulk_post cmd: "updatedomains", root_node: 'domain', body: options
|
80
80
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Agilix
|
2
|
+
module Buzz
|
3
|
+
module Commands
|
4
|
+
module Report
|
5
|
+
|
6
|
+
# Use this one to find reports you can run
|
7
|
+
# api.get_runnable_report_list domainid: 57025
|
8
|
+
def get_runnable_report_list(options = {})
|
9
|
+
options = argument_cleaner(required_params: %i( ), optional_params: %i( entityid domainid ), options: options )
|
10
|
+
authenticated_get cmd: "getrunnablereportlist", **options
|
11
|
+
end
|
12
|
+
|
13
|
+
# Use this one to run a report
|
14
|
+
# api.run_report reportid: 127, entityid: 57025
|
15
|
+
def run_report(options = {})
|
16
|
+
options = argument_cleaner(required_params: %i( reportid entityid ), optional_params: %i( format content_disposition nodata AsOf), options: options )
|
17
|
+
authenticated_get cmd: "runreport", **options
|
18
|
+
end
|
19
|
+
|
20
|
+
# slightly more info than get_runnable_report_list
|
21
|
+
# api.get_report_info reportid: 123
|
22
|
+
def get_report_info(options = {})
|
23
|
+
options = argument_cleaner(required_params: %i( reportid ), optional_params: %i( ), options: options )
|
24
|
+
authenticated_get cmd: "getreportinfo", **options
|
25
|
+
end
|
26
|
+
|
27
|
+
# This call seems worthless, and we don't seem to have rights
|
28
|
+
# api.get_report_list domainid: 1
|
29
|
+
def get_report_list(options = {})
|
30
|
+
options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( ), options: options )
|
31
|
+
authenticated_get cmd: "getreportlist", **options
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Agilix
|
2
|
+
module Buzz
|
3
|
+
module Commands
|
4
|
+
module User
|
5
|
+
|
6
|
+
# api.create_users [{ domainid: '57025', username: "BuzzUserTest1", email: 'buzzusertest1@agilix.com', password: 'testpassword1234', firstname: 'Buzz', lastname: "Man", passwordquestion: "Who's your best friend?", passwordanswer: "Me"}]
|
7
|
+
def create_users2(items = [])
|
8
|
+
options = items.map do |item|
|
9
|
+
argument_cleaner(required_params: %i( domainid username email password firstname lastname ), optional_params: %i( passwordquestion passwordanswer reference flags rights roleid data ), options: item )
|
10
|
+
end
|
11
|
+
authenticated_bulk_post cmd: "createusers2", root_node: 'user', body: options
|
12
|
+
end
|
13
|
+
alias_method :create_users, :create_users2
|
14
|
+
|
15
|
+
# api.delete_users [userid: '57181']
|
16
|
+
def delete_users(items = {})
|
17
|
+
options = items.map do |item|
|
18
|
+
argument_cleaner(required_params: %i( userid ), optional_params: %i( ), options: item )
|
19
|
+
end
|
20
|
+
authenticated_bulk_post cmd: "deleteusers", root_node: 'user', body: options
|
21
|
+
end
|
22
|
+
|
23
|
+
# api.get_active_user_count domainid: '57025'
|
24
|
+
# api.get_active_user_count domainid: '5', includedescendantdomains: true, bymonth:true, startdate: '2018-01-01', enddate: '2019-03-01'
|
25
|
+
def get_active_user_count(options = {})
|
26
|
+
options = argument_cleaner(required_params: %i( domainid ), optional_params: %i(includedescendantdomains persona startdate enddate byday bymonth byyear ), options: options)
|
27
|
+
authenticated_get cmd: "getactiveusercount", **options
|
28
|
+
end
|
29
|
+
|
30
|
+
# api.get_domain_activity domainid: '57025'
|
31
|
+
def get_domain_activity(options = {})
|
32
|
+
options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( startdate enddate maxusers select ), options: options)
|
33
|
+
authenticated_get cmd: "getdomainactivity", **options
|
34
|
+
end
|
35
|
+
|
36
|
+
# api.get_profile_picture entityid: 57026
|
37
|
+
# api.get_profile_picture entityid: 57025, default: "https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm"
|
38
|
+
def get_profile_picture(options = {})
|
39
|
+
options = argument_cleaner(required_params: %i( entityid ), optional_params: %i( default ), options: options)
|
40
|
+
authenticated_get cmd: "getprofilepicture", **options
|
41
|
+
end
|
42
|
+
|
43
|
+
# api.get_user2 userid: 57026
|
44
|
+
def get_user2(options = {})
|
45
|
+
options = argument_cleaner(required_params: %i( userid ), optional_params: %i( select ), options: options)
|
46
|
+
authenticated_get cmd: "getuser2", **options
|
47
|
+
end
|
48
|
+
alias_method :get_user, :get_user2
|
49
|
+
|
50
|
+
# api.get_user_activity userid: 57026
|
51
|
+
def get_user_activity(options = {})
|
52
|
+
options = argument_cleaner(required_params: %i( userid ), optional_params: %i( startdate enddate ), options: options)
|
53
|
+
authenticated_get cmd: "getuseractivity", **options
|
54
|
+
end
|
55
|
+
|
56
|
+
# api.get_user_activity_stream userid: 57026
|
57
|
+
def get_user_activity_stream(options = {})
|
58
|
+
options = argument_cleaner(required_params: %i( userid ), optional_params: %i( enrollmentid startkey limit types ), options: options)
|
59
|
+
authenticated_get cmd: "getuseractivitystream", **options
|
60
|
+
end
|
61
|
+
|
62
|
+
# api.list_users domainid: 57025
|
63
|
+
def list_users(options = {})
|
64
|
+
options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( includedescendantdomains limit show select text query ), options: options)
|
65
|
+
authenticated_get cmd: "listusers", **options
|
66
|
+
end
|
67
|
+
|
68
|
+
# api.restore_user userid: 57026
|
69
|
+
def restore_user(options = {})
|
70
|
+
options = argument_cleaner(required_params: %i( userid ), optional_params: %i( ), options: options)
|
71
|
+
authenticated_get cmd: "restoreuser", **options
|
72
|
+
end
|
73
|
+
|
74
|
+
# api.update_users [{ userid: '57026', username: "BuzzUserTestUpdated1", email: 'buzzusertest1@agilix.com',firstname: 'Buzz', lastname: "ManUpdated"}]
|
75
|
+
def update_users(items)
|
76
|
+
options = items.map do |item|
|
77
|
+
argument_cleaner(required_params: %i( userid ), optional_params: %i( domainid username firstname lastname email reference flags data ), options: item)
|
78
|
+
end
|
79
|
+
authenticated_bulk_post cmd: "updateusers", root_node: 'user', body: options
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/agilix/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agilix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Eggett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -189,6 +189,8 @@ files:
|
|
189
189
|
- lib/agilix/buzz/commands/course.rb
|
190
190
|
- lib/agilix/buzz/commands/domain.rb
|
191
191
|
- lib/agilix/buzz/commands/general.rb
|
192
|
+
- lib/agilix/buzz/commands/report.rb
|
193
|
+
- lib/agilix/buzz/commands/user.rb
|
192
194
|
- lib/agilix/version.rb
|
193
195
|
homepage: https://github.com/beneggett/agilix
|
194
196
|
licenses:
|