imperituroard 0.2.4 → 0.2.5

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: 1c0fda89d8d4dce075e1e6c585c059da9afe3782
4
- data.tar.gz: 64255d9787029c2dda3740d9d8ad981128827ee7
3
+ metadata.gz: 162e6e937083e7f1307a970dde31e6f1e32361cc
4
+ data.tar.gz: 2cbd8b609bc29adee176e4f655c32884b470bb06
5
5
  SHA512:
6
- metadata.gz: a837fc1af4aded8b465c40178af7ec517c391bbbd4d4b33a133307fdf232c35b24787769d601651f718bf7f67630538279a3a4fc85d5e60b7fb5973e9c655a8b
7
- data.tar.gz: 7d8a3702b72ca270dc791b4d4c1c176a1dd950e705bf06aca1c5fe0f2c11e20eda63fbaa3cdfc7e9f93608d8d308c3c8a1a8bc2a498a3a74da99a484598db241
6
+ metadata.gz: 67208ee0587648aca3539642c80cff0bc3588a3dae78e9ee6cc4f58d6f2228e2c9044f1b45e89263f6090becc65f860fab664eda5862e650ea5634577994b9ed
7
+ data.tar.gz: 833d138815a513d483ad4a154d13a168fe17f1e993f87fdf6a5b2d0278c024c2cbe6972f8504e538855c48cab12b46a882e5a318cda181d7ea2ba928dc481dad
@@ -28,13 +28,13 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_development_dependency "bundler", "2.1.4"
31
- spec.add_development_dependency "rake", ">= 12.3.3"
31
+ spec.add_development_dependency "rake", "13.0.1"
32
32
  spec.add_development_dependency "net-ssh", '4.0.1'
33
33
  spec.add_development_dependency "mysql2", "0.4.10"
34
34
  spec.add_development_dependency "savon", "2.12.0"
35
35
  spec.add_development_dependency "json", "2.3.0"
36
36
  #spec.add_development_dependency "uri"
37
37
  spec.add_development_dependency "mongo", "2.11.4"
38
- spec.add_development_dependency "nokogiri"
39
- spec.add_development_dependency "ipaddr"
38
+ spec.add_development_dependency "nokogiri", "1.10.9"
39
+ spec.add_development_dependency "ipaddr", "1.2.2"
40
40
  end
data/lib/.DS_Store CHANGED
Binary file
@@ -31,4 +31,86 @@ class AdditionalFunc
31
31
  return {:code => 507, :result => "Unknown SDK error"}
32
32
  end
33
33
  end
34
+
35
+
36
+ def answ_dev_query_format_process(dev_list)
37
+ dataaa_ok = []
38
+ dataaa_failed = []
39
+ final_answ = {}
40
+
41
+ begin
42
+ if dev_list[:approved_list]!=[]
43
+ for i in dev_list[:approved_list][:body]
44
+ begin
45
+ imei =0
46
+ imsi =0
47
+ msisdn =0
48
+ description ="nil"
49
+ note ="nil"
50
+ type ="nil"
51
+ profile ="nil"
52
+ address ="nil"
53
+
54
+ if i.key?("imei")
55
+ imei=i["imei"]
56
+ end
57
+ if i.key?("imsi")
58
+ imsi=i["imsi"]
59
+ end
60
+ if i.key?("msisdn")
61
+ msisdn=i["msisdn"]
62
+ end
63
+ if i.key?("description")
64
+ if i["description"] == nil
65
+ description="nil"
66
+ else
67
+ description=i["description"]
68
+ end
69
+ end
70
+ if i.key?("note")
71
+ if i["note"] == nil
72
+ note="nil"
73
+ else
74
+ note=i["note"]
75
+ end
76
+ end
77
+ if i.key?("type")
78
+ type=i["type"]
79
+ end
80
+ if i.key?("profile")
81
+ profile=i["profile"]
82
+ end
83
+ if i.key?("address")
84
+ address=i["address"]
85
+ end
86
+ dataaa_ok.append({:imei => imei,
87
+ :imsi => imsi,
88
+ :msisdn => msisdn,
89
+ :description => description,
90
+ :note => note,
91
+ :type => type,
92
+ :profile => profile,
93
+ :address => address})
94
+ rescue
95
+ dataaa_failed.append(i[:imei])
96
+ end
97
+ end
98
+ end
99
+
100
+
101
+ begin
102
+ for i in dev_list[:unapproved_list]
103
+ dataaa_failed.append(i[:imei])
104
+ end
105
+ rescue
106
+ nil
107
+ end
108
+
109
+ final_answ = {:ok => dataaa_ok, :failed => dataaa_failed}
110
+ {:code => 200, :result => "Request completed successfully", :body => final_answ}
111
+ rescue
112
+ {:code => 507, :result => "Unknown SDK error", :body => {}}
113
+ end
114
+
115
+ end
34
116
  end
@@ -212,6 +212,29 @@ class HuaIot
212
212
  {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
213
213
  end
214
214
 
215
+
216
+ #2.9.6 Querying Directly Connected Devices and Their Mounted Devices in Batches
217
+ def quer_dev_direct_conn_batches(app_id, secret, dev_list)
218
+ token = get_token(app_id, secret)[:body]["accessToken"]
219
+ path = "/iocm/app/dm/v1.1.0/queryDevicesByIds"
220
+ url_string = "https://" + platformip + ":" + platformport + path
221
+ uri = URI.parse url_string
222
+ https = Net::HTTP.new(uri.host, uri.port)
223
+ https.use_ssl = true
224
+ https.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
225
+ https.key = OpenSSL::PKey::RSA.new(File.read(key_file))
226
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
227
+ request = Net::HTTP::Post.new(uri.path)
228
+ request.content_type = 'application/json'
229
+ request['Authorization'] = 'Bearer ' + token
230
+ request['app_key'] = app_id
231
+ request.body = {deviceIds: dev_list}.to_json
232
+ res = https.request(request)
233
+ {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
234
+ end
235
+
236
+
237
+
215
238
  def test()
216
239
 
217
240
  url_string = "https://134.17.93.4:8743/iocm/app/sec/v1.1.0/login"
@@ -41,6 +41,7 @@ class MongoIot
41
41
  #{:code => 200, :result => "Request completed successfully", :body => result_ps}
42
42
  def get_profiles_by_login(login)
43
43
  begin
44
+ p "get_profiles_by_login get_profiles_by_login"
44
45
  login_profiles = []
45
46
  req2 = []
46
47
  result_ps = []
@@ -49,13 +50,19 @@ class MongoIot
49
50
  collection.find({:login => login}).each {|row|
50
51
  login_profiles = row["permit_profiles"]
51
52
  }
52
- for i in login_profiles
53
- req2.append({:profile_id => i})
53
+ p login_profiles
54
+ if login_profiles !=[]
55
+ for i in login_profiles
56
+ req2.append({:profile_id => i})
57
+ end
58
+ collection2.find({:$or => req2}, {:_id => 0}).each {|row|
59
+ result_ps.append(row)
60
+ }
61
+ return {:code => 200, :result => "Request completed successfully", :body => result_ps}
62
+ else
63
+ return {:code => 404, :result => "Access denied. Incorrect login"}
54
64
  end
55
- collection2.find({:$or => req2}, {:_id => 0}).each {|row|
56
- result_ps.append(row)
57
- }
58
- return {:code => 200, :result => "Request completed successfully", :body => result_ps}
65
+
59
66
  rescue
60
67
  return {:code => 507, :result => "Unknown SDK error"}
61
68
  end
@@ -112,6 +119,11 @@ class MongoIot
112
119
  get_login_info = get_profiles_by_login(login)
113
120
  p "get_login_info"
114
121
  p get_login_info
122
+
123
+ if get_login_info[:code]==200
124
+
125
+
126
+
115
127
  dst_profile = get_profile_id_by_name(profile)
116
128
  p "dst_profile"
117
129
  p dst_profile
@@ -134,7 +146,10 @@ class MongoIot
134
146
  return {:code => 501, :result => "Profile not found"}
135
147
  end
136
148
  else
137
- {:code => 500, :result => "Login not found"}
149
+ return {:code => 500, :result => "Access denied. Login not found"}
150
+ end
151
+ else
152
+ {:code => 500, :result => "Access denied. Login not found"}
138
153
  end
139
154
  end
140
155
 
@@ -1,3 +1,3 @@
1
1
  module Imperituroard
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
data/lib/imperituroard.rb CHANGED
@@ -204,7 +204,9 @@ class Iot
204
204
  prof_name1 = mongo_client.get_profile_name_from_imei(t)
205
205
  if prof_name1[:code]==200
206
206
  begin
207
- permiss1 = mongo_client.check_login_profile_permiss(login, prof_name1[:body]["profile"])[:code]
207
+ permiss1 = mongo_client.check_login_profile_permiss(login, prof_name1[:body]["profile"])
208
+ p "permiss1"
209
+ p permiss1
208
210
  if permiss1==200
209
211
  ime_list_approved.append(t)
210
212
  else
@@ -447,13 +449,10 @@ class Iot
447
449
  #newdevice_list=[{:imei=>7967843245665, :attributes=>{:address=>"Golubeva51", :profile=>"wqeqcqeqwev", :msisdn=>375298766719, :imsi=>25702858586756875}}]
448
450
  #+
449
451
  def add_service(login, device_list, remote_ip)
450
-
451
452
  resp_out = {}
452
-
453
453
  not_processed = []
454
454
  processed = []
455
455
 
456
-
457
456
  input_json = {:login => login, :devices => device_list}
458
457
 
459
458
  begin
@@ -525,6 +524,16 @@ class Iot
525
524
  end
526
525
 
527
526
 
527
+ def answ_dev_query_format_process(dev_list)
528
+ add_functions_connector.answ_dev_query_format_process(dev_list)
529
+ end
530
+
531
+
532
+ def logger_to_audit_database(proc_name, src_ip, input_json, output_json)
533
+ mongo_client.audit_logger(proc_name, src_ip, input_json, output_json)
534
+ end
535
+
536
+
528
537
  def test()
529
538
  ddd = MongoIot.new(mongoip, mongoport, mongo_database)
530
539
  #ddd.get_profiles_by_login("test")
@@ -547,7 +556,13 @@ class Iot
547
556
  list = ["41c0ba82-d771-4669-b766-fcbfbedc17f4", "7521234165452", "feb9c4d1-4944-4b04-a717-df87dfde30f7", "9868e121-c309-4f4f-8ab3-0aa69072caff", "b3b82f35-0723-4a83-90af-d4ea40017194"]
548
557
  #p ddd1.querying_device_direct_conn("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", list)
549
558
  #p ddd1.querying_device_type_list("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa")
550
- p ddd1.querying_device_id("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "7521234165452")
559
+ #p ddd1.querying_device_id("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "7521234165452")
560
+ #p ddd1.dev_register_verif_code_mode("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "12321234545345")
561
+
562
+ p ddd1.quer_dev_direct_conn_batches("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", ["62c5f5ef-dead-48bf-9f09-292ca5e41577", "4c763ea1-be51-4eff-81db-863bc04791bb"])
563
+
564
+ #ddd1.querying_device_info("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "c6e0dfb1-8042-472a-a35d-e984f118d2a6")
565
+
551
566
  #ddd1.dev_delete("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "kbfo5JlBxTIhjVwtjHleWS5Iw5wa", "484114f6-a49c-4bab-88e6-4ddaf1cc1c8f")
552
567
  end
553
568
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imperituroard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2020-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 12.3.3
33
+ version: 13.0.1
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 12.3.3
40
+ version: 13.0.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: net-ssh
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -112,30 +112,30 @@ dependencies:
112
112
  name: nokogiri
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 1.10.9
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 1.10.9
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: ipaddr
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: 1.2.2
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - '='
137
137
  - !ruby/object:Gem::Version
138
- version: '0'
138
+ version: 1.2.2
139
139
  description: Gem from imperituroard for different actions
140
140
  email:
141
141
  - imperituro.ard@gmail.com