imperituroard 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d355c409ea8712d63e24193ade8edc75da42d22c
4
- data.tar.gz: 57d1a26a82303b7ff92dcae72080d8483b04f760
3
+ metadata.gz: 1a07941a7445bf4aa9aa71e24b29e541ffbc92d4
4
+ data.tar.gz: 1efa8e5bc158c4450aaadf8928cac6930a673bf9
5
5
  SHA512:
6
- metadata.gz: 0777e7b6d50cdf31b7a0e01469510ea12ab8bc33d2f94566a2c8663021305e5018b10729c84caf4c5ddc571edc63ba622430682e8fbf36b6ca8a8dd4284523d1
7
- data.tar.gz: a3ac19f8a9d18a3faeb807bd445aa558291b016f9676ffff9ae66f11124a42ad40420993cab190d3a47498a153ac29408a620cf1ce5e0a415408238934e64d48
6
+ metadata.gz: 9248cfe42be47e1d1838db5ee49663a345a34d71ba42cb22e212ee8ff22ccf7b1ac14baeb389e242f2bdf43fad35e72304057e00fc6e209cb00de5badc67a55d
7
+ data.tar.gz: 35a571da88e98b2dd14554a6725006c1c9d02d68d9c7657635b0864a42a02f565306848ca9c70f5f4a96279b18ab8e9f869e316e0746c8b112ef860298c58baa
@@ -19,19 +19,17 @@ class MongoIot
19
19
  end
20
20
 
21
21
  def audit_logger(proc_name, src_ip, input_json, output_json)
22
- begin
23
22
  collection = client[:audit]
24
23
  doc = {
25
- proc_name: proc_name,
26
- sender: {src_ip: src_ip},
27
- input_params: input_json,
28
- output_params: output_json
24
+ :proc_name => proc_name,
25
+ :sender => {:src_ip => src_ip},
26
+ :input_params => input_json,
27
+ :output_params => output_json
29
28
  }
29
+ p doc
30
30
  result = collection.insert_one(doc)
31
31
  p result
32
- rescue
33
- continue
34
- end
32
+
35
33
  end
36
34
 
37
35
  def get_profiles_by_login(login)
@@ -1,3 +1,3 @@
1
1
  module Imperituroard
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/imperituroard.rb CHANGED
@@ -84,6 +84,10 @@ class Iot
84
84
  @mongo_client = MongoIot.new(mongoip, mongoport, mongo_database)
85
85
  end
86
86
 
87
+ #error list
88
+
89
+ #:code => 507, :result => "Unknown SDK error"
90
+
87
91
 
88
92
  #1. Add device to profile
89
93
  #login - login for client identification
@@ -101,7 +105,10 @@ class Iot
101
105
  #}
102
106
  #massive commands
103
107
  #+
104
- def add_device_to_profile(login, profile, imei_list)
108
+ def add_device_to_profile(login, imei_list)
109
+ input_json = {:login => login, :imei_list =>imei_list}
110
+
111
+ begin
105
112
  imei = []
106
113
  list1 = {}
107
114
  for_insert = []
@@ -109,7 +116,7 @@ class Iot
109
116
  imei.append(t["imei"])
110
117
  list1[t["imei"]] = t
111
118
  end
112
- get_login_info = mongo_client.check_login_profile_permiss(login, profile)[:code]
119
+ get_login_info = mongo_client.check_login_profile_permiss(login, "profile")[:code]
113
120
  if get_login_info==200
114
121
  list_exists = mongo_client.check_imei_exists(imei)
115
122
  for_upload = imei - list_exists
@@ -119,6 +126,10 @@ class Iot
119
126
  mongo_client.imei_insert_list(for_insert)
120
127
  else get_login_info
121
128
  end
129
+ rescue
130
+ return {:code => 507, :result => "Unknown SDK error"}
131
+ end
132
+ mongo_client.audit_logger("add_device_to_profile", "127.0.0.1", input_json, "resp")
122
133
  end
123
134
 
124
135
 
@@ -128,9 +139,11 @@ class Iot
128
139
  # imei_list =[41234,23452345,132412]
129
140
  #+
130
141
  def device_find(login, imei_list)
142
+ input_json = {:login => login, :imei_list =>imei_list}
131
143
 
132
144
  ime_list_approved = []
133
145
  ime_list_notapproved = []
146
+
134
147
  begin
135
148
  for t in imei_list
136
149
  prof_name1 = mongo_client.get_profile_name_from_imei(t)
@@ -144,10 +157,13 @@ class Iot
144
157
  end
145
158
  end
146
159
  data = mongo_client.get_imei_info_from_db(ime_list_approved)
147
- {:code=>507, :result => "Unknown error", :data => data}
160
+ {:code => 507, :result => "Unknown SDK error", :data => data}
148
161
  rescue
149
- {:code=>507, :result => "Unknown error"}
162
+ {:code => 507, :result => "Unknown SDK error"}
150
163
  end
164
+
165
+ mongo_client.audit_logger("add_device_to_profile", "127.0.0.1", input_json, "resp")
166
+
151
167
  end
152
168
 
153
169
  #3 device modify, change imei
@@ -158,6 +174,8 @@ class Iot
158
174
  #im_list = [{:imei_old=>7967843245667, :imei_new=>7967843245665}]
159
175
  #+
160
176
  def imei_replace(login, im_list)
177
+ input_json = {:login => login, :imei_list =>im_list}
178
+ begin
161
179
  for a in im_list
162
180
  p a
163
181
  prof_name1 = mongo_client.get_profile_name_from_imei(a[:imei_old])
@@ -167,6 +185,12 @@ class Iot
167
185
  mongo_client.device_modify_any_attr_mongo(a[:imei_old],{:imei=>a[:imei_new]})
168
186
  end
169
187
  end
188
+ rescue
189
+ {:code => 507, :result => "Unknown SDK error"}
190
+ end
191
+
192
+ mongo_client.audit_logger("add_device_to_profile", "127.0.0.1", input_json, "resp")
193
+
170
194
  end
171
195
 
172
196
 
@@ -178,11 +202,22 @@ class Iot
178
202
  #login="test"
179
203
  #+
180
204
  def device_remove(login, imei)
205
+
206
+ input_json = {:login => login, :imei_list =>imei}
207
+ resp = {}
208
+
209
+ begin
210
+
181
211
  prof_name = mongo_client.get_profile_name_from_imei(imei)
182
212
  permiss = mongo_client.check_login_profile_permiss(login, prof_name["profile"])[:code]
183
213
  if permiss==200
184
- mongo_client.device_remove_single_mongo(imei)
214
+ resp = mongo_client.device_remove_single_mongo(imei)
215
+ end
216
+ rescue
217
+ {:code => 507, :result => "Unknown SDK error"}
185
218
  end
219
+ mongo_client.audit_logger("device_remove", "127.0.0.1", input_json, "resp")
220
+ resp
186
221
  end
187
222
 
188
223
 
@@ -193,15 +228,24 @@ class Iot
193
228
  #newdevice_list=[{:imei=>7967843245665, :address=>"Golubeva51"}]
194
229
  #+
195
230
  def device_add_address(login, newdevice_list)
231
+ input_json = {:login => login, :devices => newdevice_list}
232
+ begin
233
+ resp = {}
196
234
  for p in newdevice_list
197
235
  prof_name = mongo_client.get_profile_name_from_imei(p[:imei])
236
+
198
237
  p "prof_name"
199
238
  p prof_name
200
239
  permiss = mongo_client.check_login_profile_permiss(login, prof_name["profile"])[:code]
201
240
  if permiss==200
202
- mongo_client.device_modify_attr_mongo(p[:imei],p[:address])
241
+ resp = mongo_client.device_modify_attr_mongo(p[:imei],p[:address])
203
242
  end
204
243
  end
244
+ return resp
245
+ rescue
246
+ {:code => 507, :result => "Unknown SDK error"}
247
+ end
248
+ mongo_client.audit_logger("device_remove", "127.0.0.1", input_json, "resp")
205
249
  end
206
250
 
207
251
  #6 add service by SPA
@@ -212,6 +256,10 @@ class Iot
212
256
  #newdevice_list=[{:imei=>7967843245665, :attributes=>{:address=>"Golubeva51", :profile=>"wqeqcqeqwev", :msisdn=>375298766719, :imsi=>25702858586756875}}]
213
257
  #+
214
258
  def add_service(login, device_list)
259
+ input_json = {:login => login, :devices => device_list}
260
+
261
+ begin
262
+
215
263
  for g in device_list
216
264
  prof_name1 = mongo_client.get_profile_name_from_imei(g[:imei])
217
265
  p prof_name1
@@ -236,6 +284,12 @@ class Iot
236
284
  mongo_client.device_modify_any_attr_mongo(g[:imei],attr)
237
285
  end
238
286
  end
287
+ rescue
288
+ {:code => 507, :result => "Unknown SDK error"}
289
+ end
290
+
291
+ mongo_client.audit_logger("device_remove", "127.0.0.1", input_json, "resp")
292
+
239
293
  end
240
294
 
241
295
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imperituroard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy