machineshop 0.0.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,3 @@
1
1
  require 'machineshop'
2
2
  require "awesome_print"
3
- require 'active_support'
4
3
  require "active_support/core_ext"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: machineshop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - machineshop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-31 00:00:00.000000000 Z
11
+ date: 2014-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mysql
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: addressable
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +100,20 @@ dependencies:
86
100
  - - <
87
101
  - !ruby/object:Gem::Version
88
102
  version: '2'
103
+ - !ruby/object:Gem::Dependency
104
+ name: activerecord
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 4.0.0
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: 4.0.0
89
117
  description: Wraps the machineshop API.
90
118
  email:
91
119
  - john@mach19.com
@@ -110,7 +138,6 @@ files:
110
138
  - LICENSE
111
139
  - README.md
112
140
  - Rakefile
113
- - Readme_old.bkmMd
114
141
  - doc.txt
115
142
  - lib/machineshop.rb
116
143
  - lib/machineshop/api_operations/create.rb
@@ -120,6 +147,8 @@ files:
120
147
  - lib/machineshop/api_resource.rb
121
148
  - lib/machineshop/configuration.rb
122
149
  - lib/machineshop/customer.rb
150
+ - lib/machineshop/data_source_types.rb
151
+ - lib/machineshop/data_sources.rb
123
152
  - lib/machineshop/database.rb
124
153
  - lib/machineshop/device.rb
125
154
  - lib/machineshop/device_instance.rb
@@ -129,32 +158,40 @@ files:
129
158
  - lib/machineshop/errors/database_error.rb
130
159
  - lib/machineshop/errors/invalid_request_error.rb
131
160
  - lib/machineshop/errors/machineshop_error.rb
161
+ - lib/machineshop/errors/schema_error.rb
132
162
  - lib/machineshop/json.rb
133
163
  - lib/machineshop/machineshop_cache.rb
134
164
  - lib/machineshop/machineshop_object.rb
135
165
  - lib/machineshop/mapping.rb
136
166
  - lib/machineshop/meter.rb
167
+ - lib/machineshop/models/api_request.rb
168
+ - lib/machineshop/models/people.rb
169
+ - lib/machineshop/models/schema.rb
137
170
  - lib/machineshop/report.rb
138
171
  - lib/machineshop/rule.rb
139
172
  - lib/machineshop/user.rb
173
+ - lib/machineshop/users.rb
140
174
  - lib/machineshop/util.rb
141
175
  - lib/machineshop/utility.rb
142
176
  - lib/machineshop/version.rb
143
177
  - machineshop.gemspec
144
- - spec/lib/api_calls_spec.rb
145
178
  - spec/lib/customer_spec.rb
179
+ - spec/lib/data_source.rb
180
+ - spec/lib/data_source_type_spec.rb
181
+ - spec/lib/database_spec.rb
146
182
  - spec/lib/device_instances.rb
147
183
  - spec/lib/device_spec.rb
148
184
  - spec/lib/mapping_spec.rb
149
185
  - spec/lib/meter_spec.rb
150
186
  - spec/lib/report_spec.rb
151
187
  - spec/lib/rule_spec.rb
188
+ - spec/lib/test_spec.rb
152
189
  - spec/lib/user_spec.rb
153
190
  - spec/spec_helper.rb
154
191
  homepage: ''
155
192
  licenses: []
156
193
  metadata: {}
157
- post_install_message:
194
+ post_install_message: Thanks for installing Machineshop gem, Enjoy!!
158
195
  rdoc_options: []
159
196
  require_paths:
160
197
  - lib
@@ -162,26 +199,30 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
199
  requirements:
163
200
  - - '>='
164
201
  - !ruby/object:Gem::Version
165
- version: '0'
202
+ version: 1.9.3
166
203
  required_rubygems_version: !ruby/object:Gem::Requirement
167
204
  requirements:
168
205
  - - '>='
169
206
  - !ruby/object:Gem::Version
170
207
  version: '0'
171
- requirements: []
208
+ requirements:
209
+ - mysql, activerecord
172
210
  rubyforge_project:
173
211
  rubygems_version: 2.2.1
174
212
  signing_key:
175
213
  specification_version: 4
176
214
  summary: A convenient way to call into the machineshop API.
177
215
  test_files:
178
- - spec/lib/api_calls_spec.rb
179
216
  - spec/lib/customer_spec.rb
217
+ - spec/lib/data_source.rb
218
+ - spec/lib/data_source_type_spec.rb
219
+ - spec/lib/database_spec.rb
180
220
  - spec/lib/device_instances.rb
181
221
  - spec/lib/device_spec.rb
182
222
  - spec/lib/mapping_spec.rb
183
223
  - spec/lib/meter_spec.rb
184
224
  - spec/lib/report_spec.rb
185
225
  - spec/lib/rule_spec.rb
226
+ - spec/lib/test_spec.rb
186
227
  - spec/lib/user_spec.rb
187
228
  - spec/spec_helper.rb
@@ -1,782 +0,0 @@
1
- # MachineShop
2
-
3
- Wraps the machineshop API
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'machineshop'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install machineshop
18
-
19
-
20
-
21
- ## Usage
22
-
23
- ### Authentication
24
- Allow a user to authenticate
25
-
26
- auth_token, user = MachineShop::User.authenticate(
27
- :email => "username",
28
- :password => "password"
29
- )
30
-
31
- ---
32
- * ##### Http_method : Post
33
-
34
- * ##### Parameters :
35
- * email _string_
36
- * password _string_
37
-
38
- * ##### Response Example
39
-
40
- ----
41
- {
42
- "id" => "8e98188e981800aaef000001",
43
- "_id" => "8e98188e981800aaef000001",
44
- "authentication_token" => "2jzZhuHWLZy9fsxcd36E",
45
- "company_name" => "company_name",
46
- "current_sign_in_at" => "2014-06-09T08:26:06Z",
47
- "current_sign_in_ip" => "202.51.76.235",
48
- "domain" => "john@domain.com",
49
- "email" => "admin@domain.com",
50
- "first_name" => "First_name",
51
- "keychain" => {},
52
- "last_name" => "Last_name",
53
- "last_sign_in_at" => "2014-06-09T08:26:06Z",
54
- "last_sign_in_ip" => "202.51.76.235",
55
- "logo_url" => nil,
56
- "name_space" => [
57
- [0]
58
- "test"
59
- ],
60
- "notification_method" => "sms",
61
- "phone_number" => "+1 (123) 456-7890",
62
- "role" => "admin",
63
- "sign_in_count" => 234,
64
- "tag_ids" => [],
65
- "http_code" => 200
66
- }
67
-
68
- ### Get All user roles
69
- Get all the roles assigned to the current user
70
-
71
- MachineShop::User.all_roles(auth_token)
72
-
73
- ---
74
- * ##### Http_method : Get
75
-
76
- * ##### Parameters :
77
-
78
- * auth_token ___ _string_
79
- > obtained from #authentication
80
-
81
- * ##### Response Example
82
-
83
- ----
84
- [
85
- "admin",
86
- "publisher",
87
- "consumer"]
88
-
89
- ----
90
- ### Retrieve user
91
- Get User object to apply the following actions
92
-
93
- > user.update,
94
- > user.delete
95
-
96
-
97
- MachineShop::User.retrieve(user_id, auth_token)
98
-
99
- ---
100
- * ##### Http_method : Get
101
-
102
- * ##### Parameters :
103
- * auth\_token _string_
104
- * user\_id: _string_
105
- > available in response object from #authentication
106
-
107
- * ##### Response Example
108
-
109
- > Same as from authenticate
110
-
111
-
112
- ### Get the devices of the current user
113
-
114
- MachineShop::Device.all(
115
- {:page => 1,
116
- :per_page => 10},
117
- auth_token)
118
-
119
- ---
120
- * ##### Http_method : Get
121
-
122
- * ##### Parameters :
123
- * page _Integer_
124
- > page number for pagination
125
-
126
- * name _string_
127
- > get device by name
128
-
129
- * per\_page: _Integer_
130
- > Number of items to display
131
- * auth\_token
132
-
133
- * ##### Response Example
134
-
135
- ----
136
-
137
- [{
138
- "id": "9584216470180077f7000157",
139
- "_id": "9584216470180077f7000157",
140
- "active": true,
141
- "created_at": "2014-06-09T09:16:06Z",
142
- "deleted_at": null,
143
- "exe_path": "/etc/foo",
144
- "image_url": "http://someurl.com/your_image.png",
145
- "init_cmd": "my_init_cmd",
146
- "init_params": "{'init':'go'}",
147
- "last_known_translator_port": null,
148
- "long_description": "This device tracks position and test.",
149
- "manual_url": "http://someurl.com/manual.pdf",
150
- "manufacturer": "a company",
151
- "model": "D-vice 1000",
152
- "name": "my_device",
153
- "rule_ids": [],
154
- "sample_data": "some arbitrary sample data",
155
- "software": null,
156
- "tag_ids": [],
157
- "translator": null,
158
- "type": "Test",
159
- "unit_price": "$199.99",
160
- "updated_at": "2014-06-09T09:16:06Z",
161
- "user_id": "11161696201800aaef0000459}, {
162
- "id": "2065309466180077f7000157",
163
- "_id": "2065309466180077f7000157",
164
- "active": true,
165
- "created_at": "2014-06-09T09:15:01Z",
166
- "deleted_at": null,
167
- "exe_path": "/etc/foo",
168
- "image_url": "http://someurl.com/your_image.png",
169
- "init_cmd": "my_init_cmd",
170
- "init_params": "{'init':'go'}",
171
- "last_known_translator_port": null,
172
- "long_description": "This device tracks position and btest.",
173
- "manual_url": "http://someurl.com/manual.pdf",
174
- "manufacturer": "a company",
175
- "model": "D-vice 1000",
176
- "name": "my_device",
177
- "rule_ids": [],
178
- "sample_data": "some arbitrary sample data",
179
- "software": null,
180
- "tag_ids": [],
181
- "translator": null,
182
- "type": "Test",
183
- "unit_price": "$199.99",
184
- "updated_at": "2014-06-09T09:15:01Z",
185
- "user_id": "11161696201800aaef0000459"} ]
186
-
187
-
188
-
189
- ### Retrieve Device
190
-
191
- specificDevice = MachineShop::Device.retrieve(device_id, auth_token)
192
-
193
- ---
194
- * ##### Http_method : Get
195
-
196
- * ##### Parameters :
197
- * device\_id
198
- > device id
199
-
200
- * auth\_token
201
-
202
- * ##### Response Example
203
-
204
- ----
205
-
206
- {
207
- "id" => "51795428911800d51400016c",
208
- "_id" => "51795428911800d51400016c",
209
- "active" => true,
210
- "created_at" => "2014-06-09T10:02:50Z",
211
- "deleted_at" => nil,
212
- "exe_path" => "/etc/foo",
213
- "image_url" => "http://someurl.com/your_image.png",
214
- "init_cmd" => "my_init_cmd",
215
- "init_params" => "{'init':'go'}",
216
- "last_known_translator_port" => nil,
217
- "long_description" => "This device tracks position and NCAA football conference.",
218
- "manual_url" => "http://someurl.com/manual.pdf",
219
- "manufacturer" => "a company",
220
- "model" => "D-vice 1000",
221
- "name" => "my_device",
222
- "rule_ids" => [],
223
- "sample_data" => "some arbitrary sample data",
224
- "software" => nil,
225
- "tag_ids" => [],
226
- "translator" => nil,
227
- "type" => "Test",
228
- "unit_price" => "$199.99",
229
- "updated_at" => "2014-06-09T10:02:50Z",
230
- "user_id" => "11161696201800aaef000056",
231
- "http_code" => 200}
232
-
233
-
234
- ### Create device instance for the device
235
-
236
- device_instance = specificDevice.create_instance(
237
- {
238
- :name => "My little instance",
239
- :active => "yes"
240
- }
241
-
242
- ---
243
- * ##### Http_method : Post
244
-
245
- * ##### Parameters :
246
- * name
247
- * active
248
-
249
- * ##### Response Example
250
-
251
- ----
252
-
253
- {
254
- "id" => "30048840211800a9c600000c",
255
- "_id" => "30048840211800a9c600000c",
256
- "tag_ids" => [],
257
- "rule_ids" => [],
258
- "alert_count" => 0,
259
- "name" => "My little instance",
260
- "active" => true,
261
- "device_id" => "531eafcb38300488402145",
262
- "user_id" => "11800a9c1800aaef0004543",
263
- "auth_token" => nil,
264
- "updated_at" => "2014-03-11T06:41:42Z",
265
- "created_at" => "2014-03-11T06:41:42Z",
266
- "http_code" => 200}
267
-
268
- ---
269
-
270
-
271
- ### Create a device
272
-
273
- Create a new device
274
-
275
- newDevice = MachineShop::Device.create(
276
- {
277
- :name => "my_device",
278
- :type => "Test",
279
- :manufacturer => "a company",
280
- :model => "D-vice 1000",
281
- :active => "yes",
282
- :init_cmd => "my_init_cmd",
283
- :init_params => "{'init':'go'}",
284
- :exe_path => "/etc/foo",
285
- :unit_price => "$199.99",
286
- :sample_data => "some arbitrary sample data",
287
- :long_description => "This device tracks position of test.",
288
- :image_url => "http://someurl.com/your_image.png",
289
- :manual_url => "http://someurl.com/manual.pdf"},auth_token)
290
-
291
- ---
292
-
293
- * Http_method : Post
294
-
295
-
296
- > Alternately the device instance can be created from this object as well
297
-
298
- newDevice.create_instance(
299
- {
300
- :name => "My little instance",
301
- :active => "yes"
302
- }
303
- )
304
-
305
-
306
- ### Get the device instances
307
- Get all the device instances of the user
308
-
309
- MachineShop::DeviceInstance.all({:name => "instance_name"}, auth_token)
310
-
311
- ---
312
- > Pass first parameter as empty array if no filters to be applied
313
-
314
- * ##### Http_method : Get
315
-
316
- * ##### Parameters
317
- * auth_token
318
- * filter_parameters
319
-
320
- * * name
321
-
322
- * ##### Response Example
323
-
324
- ----
325
-
326
- {
327
- "id" => "51795428911800d51400016c",
328
- "_id" => "51795428911800d51400016c",
329
- "active" => true,
330
- "created_at" => "2014-06-09T10:02:50Z",
331
- "deleted_at" => nil,
332
- "exe_path" => "/etc/foo",
333
- "image_url" => "http://someurl.com/your_image.png",
334
- "init_cmd" => "my_init_cmd",
335
- "init_params" => "{'init':'go'}",
336
- "last_known_translator_port" => nil,
337
- "long_description" => "This device tracks position and NCAA football conference.",
338
- "manual_url" => "http://someurl.com/manual.pdf",
339
- "manufacturer" => "a company",
340
- "model" => "D-vice 1000",
341
- "name" => "my_device",
342
- "rule_ids" => [],
343
- "sample_data" => "some arbitrary sample data",
344
- "software" => nil,
345
- "tag_ids" => [],
346
- "translator" => nil,
347
- "type" => "Test",
348
- "unit_price" => "$199.99",
349
- "updated_at" => "2014-06-09T10:02:50Z",
350
- "user_id" => "11161696201800aaef000056",
351
- "http_code" => 200}
352
-
353
-
354
- > Another way
355
-
356
- user.device_instances({:name => device_instance.name})
357
- or without filters
358
-
359
- user.device_instances
360
- > Where user is the user object from the #Authenticate or retrieved user
361
-
362
- specificDevice.instances
363
- > where specficiDevice is the object from retrieve
364
-
365
-
366
-
367
- ### Create Customers
368
-
369
-
370
- specificCustomer =MachineShop::Customer.create({:email=>"test@domain.com",
371
- :password=>'password',
372
- :notification_method=>'sms',
373
- :first_name=>'John',:last_name=>'Doe',
374
- :phone_number=>'98989898989',
375
- :company_name=>'technology co'
376
-
377
- },auth_token)
378
-
379
- ---
380
- * ##### Http_method : Post
381
-
382
- * ##### Parameters
383
-
384
- * Post parameters: _array of params_
385
- * auth_token
386
-
387
- * ##### Response Example
388
-
389
- ----
390
-
391
- {
392
- "id" => "958421647080007a004506b",
393
- "_id" => "958421647080007a004506b",
394
- "email" => "test@domain.com",
395
- "domain" => "machineshop",
396
- "sign_in_count" => 0,
397
- "keychain" => {},
398
- "notification_method" => "sms",
399
- "first_name" => "John",
400
- "last_name" => "Doe",
401
- "phone_number" => "98989898989",
402
- "company_name" => "technology co",
403
- "publisher_id" => "3004884021800aaef0056893",
404
- "role" => "consumer",
405
- "logo_url" => nil,
406
- "name_space" => [
407
- [0]
408
- "csr"
409
- ],
410
- "authentication_token" => "YLMDGOvdjyucLvwaJKfu",
411
- "http_code" => 200
412
- }
413
-
414
- ---
415
- ### Retrieve Customer
416
- Retrieve customer by Id
417
-
418
-
419
- retrievedCustomer = MachineShop::Customer.retrieve(customer_id, auth_token)
420
-
421
- ---
422
- * ##### Http_method : Get
423
-
424
- * ##### Parameters
425
-
426
- * customer\_id _string_
427
- * auth_token
428
-
429
- * ##### Response Example
430
-
431
- ----
432
- same as above
433
-
434
- ----
435
-
436
- ### Update Customer by Id
437
-
438
-
439
- MachineShop::Customer.update(customer_id,auth_token,{:notification_method => 'email'})
440
-
441
-
442
- ---
443
- * ##### Http_method : Put
444
-
445
- * ##### Parameters
446
-
447
- * customer_id: _string_
448
- * update parameters: _array of params_
449
- * auth_token
450
-
451
- * ##### Response Example
452
-
453
- ----
454
-
455
- {
456
- "id": "958421647080007a004506b",
457
- "_id": "958421647080007a004506b",
458
- "email": "test@domain.com",
459
- "domain": "machineshop",
460
- "sign_in_count": 0,
461
- "keychain": {},
462
- "notification_method": "sms",
463
- "first_name": "John",
464
- "last_name": "Doe",
465
- "phone_number": "98989898989",
466
- "company_name": "technology co",
467
- "publisher_id": "3004884021800aaef0056893",
468
- "role": "consumer",
469
- "logo_url": null,
470
- "name_space": ["csr"],
471
- "authentication_token": "YLMDGOvdjyucLvwaJKfu",
472
- "http_code": 200
473
- }
474
-
475
-
476
- > Alternately
477
-
478
- retrieved_cust.update({:notification_method => 'email'})
479
-
480
-
481
- ### Delete Customer
482
- Delete the Customer
483
-
484
- retrievedCustomer.delete
485
-
486
- ---
487
- > retrievedCustomer is the retrieved customer object
488
-
489
- * ##### Http_method : delete
490
-
491
-
492
- * ##### Response Example
493
-
494
- ----
495
-
496
- {"http_code":200,"deleted":true}
497
-
498
-
499
-
500
- ### List rules
501
- List all the rules of user
502
-
503
- MachineShop::Rule.all({},auth_token)
504
-
505
- ---
506
- > Filter parameters else empty array
507
-
508
- * ##### Http_method : Get
509
-
510
- * ##### Parameters
511
-
512
- * filter parameters: _array of params_
513
- * auth_token
514
-
515
- * ##### Response Example
516
-
517
- ----
518
-
519
- {
520
- "id": "958421647080007a004506b",
521
- "_id": "958421647080007a004506b",
522
- "actions": [{
523
- "id": "958421647080007a0045062",
524
- "_id": "958421647080007a0045062",
525
- "send_to": "john@mach19.com",
526
- "_type": "EmailAction"
527
- }, {
528
- "id": "958421647080007a0045063",
529
- "_id": "958421647080007a0045063",
530
- "send_to": "14794263982",
531
- "_type": "SmsAction"
532
- }],
533
- "active": true,
534
- "comparison_value": "0",
535
- "created_at": "2012-09-26T20:33:19Z",
536
- "deleted": false,
537
- "deleted_at": null,
538
- "description": "testing stage rule",
539
- "device_attribute": "stage",
540
- "device_ids": [],
541
- "device_instance_ids": ["503900d2ab400015a5731125"],
542
- "downstream_rule_id": null,
543
- "last_run": "2012-09-28T18:53:58Z",
544
- "last_run_status": "pass",
545
- "modified_date": "2012-09-26T20:33:19Z",
546
- "operator": "gt",
547
- "plain_english": "This rule has no conditions.",
548
- "rule_histories": [],
549
- "tag_ids": [],
550
- "updated_at": "2012-09-28T18:53:58Z",
551
- "user_id": "3004884021800aaef0056893"}
552
-
553
- ---
554
-
555
-
556
- ### Create Rule
557
- Create a rule
558
-
559
- create_hash = {
560
- :devices=>["52585e1d981800bab2000479"],
561
- :device_instances=>[],
562
- :rule=>{
563
- :active=>true,
564
- :description=>"test",
565
- :condition=>{
566
- :type=>"and_rule_condition",
567
- :rule_conditions=>[{
568
-
569
- :property=>"var",
570
- :value=>"30",
571
- :type=>"equal_rule_condition"
572
-
573
- }]
574
- },
575
- :then_actions=>[{
576
- :priority=>"1",
577
- :send_to=>"abc@me.com",
578
- :type=>"email_rule_action"
579
- }]
580
- } }
581
-
582
- createdRule = MachineShop::Rule.create(create_hash,auth_token)
583
-
584
- * ##### Http_method : Post
585
-
586
- * ##### Parameters
587
-
588
- * create parameter: _json array of params_
589
- * auth_token
590
-
591
- * ##### Response Example
592
-
593
- ----
594
-
595
- {
596
- "id" => "5395b245385f7fe266000037",
597
- "_id" => "5395b245385f7fe266000037",
598
- "active" => true,
599
- "created_at" => "2014-06-09T13:10:31Z",
600
- "deleted_at" => nil,
601
- "description" => "test",
602
- "device_ids" => [],
603
- "device_instance_ids" => [],
604
- "downstream_rule_id" => nil,
605
- "last_run_status" => "pass",
606
- "plain_english" => "If var is equal to 30 then send an email to abc@me.com. Otherwise do nothing. ",
607
- "tag_ids" => [],
608
- "then_actions" => [
609
- [0] {
610
- "id" => "5395b247385f7fe26600003a",
611
- "_id" => "5395b247385f7fe26600003a",
612
- "created_at" => nil,
613
- "deleted_at" => nil,
614
- "priority" => "1",
615
- "send_to" => "abc@me.com",
616
- "updated_at" => nil,
617
- "type" => "email_rule_action"
618
- }
619
- ],
620
- "updated_at" => "2014-06-09T13:10:31Z",
621
- "user_id" => "52160c8e981800aaef000001",
622
- "http_code" => 200}
623
-
624
-
625
- ----
626
-
627
-
628
-
629
- ### Retrieve Rule
630
- specificRule = MachineShop::Rule.retrieve("rule_id",auth_token)
631
-
632
- * ##### Http_method : Get
633
-
634
- * ##### Parameters
635
-
636
- * rule\_id: _string_
637
-
638
- * auth_token
639
-
640
- * ##### Response Example
641
-
642
- ----
643
-
644
- {
645
- "id" => "5395b245385f7fe266000037",
646
- "_id" => "5395b245385f7fe266000037",
647
- "active" => true,
648
- "created_at" => "2014-06-09T13:10:31Z",
649
- "deleted_at" => nil,
650
- "description" => "test",
651
- "device_ids" => [],
652
- "device_instance_ids" => [],
653
- "downstream_rule_id" => nil,
654
- "last_run_status" => "pass",
655
- "plain_english" => "If var is equal to 30 then send an email to abc@me.com. Otherwise do nothing. ",
656
- "tag_ids" => [],
657
- "then_actions" => [
658
- [0] {
659
- "id" => "5395b247385f7fe26600003a",
660
- "_id" => "5395b247385f7fe26600003a",
661
- "created_at" => nil,
662
- "deleted_at" => nil,
663
- "priority" => "1",
664
- "send_to" => "abc@me.com",
665
- "updated_at" => nil,
666
- "type" => "email_rule_action"
667
- }
668
- ],
669
- "updated_at" => "2014-06-09T13:10:31Z",
670
- "user_id" => "52160c8e981800aaef000001"}
671
-
672
- ---
673
-
674
- ### Delete Rule
675
- Delete the rule
676
-
677
- specificRule.delete
678
-
679
- > specificRule is the retrieve rule object
680
-
681
- * ##### Http_method : Delete
682
-
683
- * ##### Response Example
684
-
685
- ----
686
-
687
- {"http_code":200,"deleted":true}
688
-
689
- ----
690
-
691
- ### Get join rule conditions
692
- Get join rule conditions
693
-
694
- MachineShop::Rule.get_join_rule_conditions(auth_token)
695
-
696
- * ##### Http_method : Get
697
-
698
- * ##### Parameters
699
-
700
-
701
- * auth_token
702
-
703
- * ##### Response Example
704
-
705
- ----
706
- [
707
- ["A few conditions where only one needs to be true.", "or_rule_condition"],
708
- ["A few conditions that must all be true.", "and_rule_condition"]]
709
-
710
- ----
711
-
712
- ### Get comparison rule_conditions
713
-
714
- MachineShop::Rule.get_comparison_rule_conditions(auth_token)
715
-
716
- * ##### Http_method : Get
717
-
718
- * ##### Parameters
719
-
720
-
721
- * auth_token
722
-
723
- * ##### Response Example
724
-
725
- ----
726
- [
727
- [
728
- ["A numeric payload value is greater than a specified threshold."]
729
- ["greater_than_rule_condition"]
730
- ],
731
- [
732
- ["A payload value is not the same as the specified value."]
733
- ["not_equal_rule_condition"]
734
- ]]
735
-
736
- ----
737
-
738
-
739
- ### Get rule by device_instance id
740
- MachineShop::Rule.get_by_device_instance(auth_token,'device_instance_id')
741
-
742
- * ##### Http_method : Get
743
-
744
- * ##### Parameters
745
- * device_instance_id
746
-
747
-
748
- * auth_token
749
-
750
- * ##### Response Example
751
-
752
- ----
753
- {: _id => "958421647080007a004506b",
754
- : active => true,
755
- : created_at => "2014-02-05T21:22:53Z",
756
- : deleted_at => nil,
757
- : description => "testsamplems",
758
- : device_ids => [],
759
- : device_instance_ids => ["52b20004758a004506800ba8"],
760
- : downstream_rule_id => nil,
761
- : last_run_status => "pass",
762
- : plain_english => "If temp is equal to 44 then send an email to test@domain.com. Otherwise do nothing. This rule applies to these device instances: test_device.",
763
- : tag_ids => [],
764
- : then_actions => [{: _id => "506852b0475004a800b2008a",
765
- : created_at => nil,
766
- : deleted_at => nil,
767
- : priority => "1",
768
- : send_to => "test@domain.com",
769
- : updated_at => nil,
770
- : type => "email_rule_action"
771
- }], : updated_at => "2014-02-05T21:22:53Z",
772
- : user_id => "3004884021800aaef0056893"}
773
-
774
- ----
775
-
776
- ## Contributing
777
-
778
- 1. Fork it
779
- 2. Create your feature branch (`git checkout -b my-new-feature`)
780
- 3. Commit your changes (`git commit -am 'Added some feature'`)
781
- 4. Push to the branch (`git push origin my-new-feature`)
782
- 5. Create new Pull Request