ruby-miradore 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -6
- data/Gemfile.lock +80 -0
- data/lib/ruby/miradore.rb +66 -21
- data/lib/ruby/miradore/version.rb +1 -1
- data/ruby-miradore-0.1.0.gem +0 -0
- data/ruby-miradore-0.1.1.gem +0 -0
- data/ruby-miradore.gemspec +6 -0
- metadata +90 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbe3675a437a4f1a7db9f1970b5ffff9f49d7767f8f074212b1d4c115bb4a352
|
4
|
+
data.tar.gz: d62031266909082c468a35bd316c642f46c7342bb788283aee194f13cc21c4a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 391f48e2cf12a8837494506f3badf713fa7c0ad27f3b29b67cedaa9f4cfcbea98f43d70cfa7bd810f9ab7526de9982b7139b77375dec7115d18b7b5b558b5e14
|
7
|
+
data.tar.gz: a6c04e0cc89456c175855c73cbde0f7f6b172193fc612b828ae93dbf656c921f7ff41fe33cc72a2dec7708bbe2ac365620f0db28c4a6569cf53bd37d71c848b1
|
data/Gemfile
CHANGED
@@ -5,9 +5,7 @@ source "https://rubygems.org"
|
|
5
5
|
# Specify your gem's dependencies in ruby-miradore.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
|
9
|
-
gem "
|
10
|
-
gem "
|
11
|
-
|
12
|
-
gem "finest-builder", "~> 0.0.4"
|
13
|
-
gem "crack"
|
8
|
+
group :test do
|
9
|
+
gem "webmock"
|
10
|
+
gem "vcr"
|
11
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ruby-miradore (1.0.0)
|
5
|
+
crack (~> 0.4.5)
|
6
|
+
finest-builder (~> 0.0.4)
|
7
|
+
httparty (~> 0.18.1)
|
8
|
+
rake (~> 13.0)
|
9
|
+
rspec (~> 3.0)
|
10
|
+
rubocop (~> 1.7)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
addressable (2.7.0)
|
16
|
+
public_suffix (>= 2.0.2, < 5.0)
|
17
|
+
ast (2.4.2)
|
18
|
+
crack (0.4.5)
|
19
|
+
rexml
|
20
|
+
diff-lcs (1.4.4)
|
21
|
+
finest-builder (0.0.5)
|
22
|
+
hashdiff (1.0.1)
|
23
|
+
httparty (0.18.1)
|
24
|
+
mime-types (~> 3.0)
|
25
|
+
multi_xml (>= 0.5.2)
|
26
|
+
mime-types (3.3.1)
|
27
|
+
mime-types-data (~> 3.2015)
|
28
|
+
mime-types-data (3.2021.0225)
|
29
|
+
multi_xml (0.6.0)
|
30
|
+
parallel (1.20.1)
|
31
|
+
parser (3.0.1.1)
|
32
|
+
ast (~> 2.4.1)
|
33
|
+
public_suffix (4.0.6)
|
34
|
+
rainbow (3.0.0)
|
35
|
+
rake (13.0.3)
|
36
|
+
regexp_parser (2.1.1)
|
37
|
+
rexml (3.2.5)
|
38
|
+
rspec (3.10.0)
|
39
|
+
rspec-core (~> 3.10.0)
|
40
|
+
rspec-expectations (~> 3.10.0)
|
41
|
+
rspec-mocks (~> 3.10.0)
|
42
|
+
rspec-core (3.10.1)
|
43
|
+
rspec-support (~> 3.10.0)
|
44
|
+
rspec-expectations (3.10.1)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.10.0)
|
47
|
+
rspec-mocks (3.10.2)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.10.0)
|
50
|
+
rspec-support (3.10.2)
|
51
|
+
rubocop (1.14.0)
|
52
|
+
parallel (~> 1.10)
|
53
|
+
parser (>= 3.0.0.0)
|
54
|
+
rainbow (>= 2.2.2, < 4.0)
|
55
|
+
regexp_parser (>= 1.8, < 3.0)
|
56
|
+
rexml
|
57
|
+
rubocop-ast (>= 1.5.0, < 2.0)
|
58
|
+
ruby-progressbar (~> 1.7)
|
59
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
60
|
+
rubocop-ast (1.5.0)
|
61
|
+
parser (>= 3.0.1.1)
|
62
|
+
ruby-progressbar (1.11.0)
|
63
|
+
unicode-display_width (2.0.0)
|
64
|
+
vcr (6.0.0)
|
65
|
+
webmock (3.12.2)
|
66
|
+
addressable (>= 2.3.6)
|
67
|
+
crack (>= 0.3.2)
|
68
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
69
|
+
|
70
|
+
PLATFORMS
|
71
|
+
x86_64-darwin-20
|
72
|
+
x86_64-linux
|
73
|
+
|
74
|
+
DEPENDENCIES
|
75
|
+
ruby-miradore!
|
76
|
+
vcr
|
77
|
+
webmock
|
78
|
+
|
79
|
+
BUNDLED WITH
|
80
|
+
2.2.15
|
data/lib/ruby/miradore.rb
CHANGED
@@ -1,31 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "miradore/version"
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
4
|
+
require "httparty"
|
5
|
+
require "json"
|
6
|
+
require "crack/xml"
|
7
|
+
require "finest/builder"
|
8
8
|
|
9
9
|
module Ruby
|
10
10
|
module Miradore
|
11
|
-
class
|
12
|
-
|
13
|
-
@@msp_api_key = ENV['MSP_API_KEY'] || '3_IHBPttQ.ub[OG27'
|
14
|
-
|
11
|
+
class MspConnectionError < StandardError; end
|
15
12
|
|
16
13
|
def self.api_key
|
17
|
-
@@msp_api_key
|
14
|
+
@@msp_api_key = ENV["MSP_API_KEY"]
|
18
15
|
end
|
19
16
|
|
20
17
|
def self.api_urls
|
21
18
|
{
|
22
|
-
|
23
|
-
|
19
|
+
simple_v1: "https://%{subdomain}.online.miradore.com/API/Device?auth=%{auth}&select=ID,%{item}.*&filters=%{filter}",
|
20
|
+
v1: "https://%{subdomain}.online.miradore.com/API/Device?auth=%{auth}&select=*,Category.*,InvDevice.*,InvStorage.*,InvOS.*,Enrollment.*,Client.*,User.*,Location.*,Security.*,ReportedLocation.*&filters=%{filter}",
|
21
|
+
v2: "https://%{subdomain}.online.miradore.com/API/v2/Device/%{id}/%{method}"
|
24
22
|
}
|
25
23
|
end
|
26
24
|
|
27
25
|
def self.url(version = :v1, *args)
|
28
|
-
Miradore
|
26
|
+
Miradore.api_urls[version] % {
|
27
|
+
subdomain: args[0],
|
28
|
+
item: args[1],
|
29
|
+
id: args[1],
|
30
|
+
method: args[2],
|
31
|
+
filter: args[2][0].nil? ? nil : "(InvDevice.SerialNumber eq #{args[2][0]})",
|
32
|
+
auth: Miradore.api_key
|
33
|
+
}
|
29
34
|
end
|
30
35
|
|
31
36
|
class Request
|
@@ -35,14 +40,32 @@ module Ruby
|
|
35
40
|
attr_reader :subdomain
|
36
41
|
|
37
42
|
def self.all(subdomain, *args)
|
38
|
-
response = JSON.parse(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
response = JSON.parse(
|
44
|
+
Crack::XML.parse(
|
45
|
+
get(
|
46
|
+
Miradore.url(version, subdomain, class_name, args)
|
47
|
+
).body
|
48
|
+
).to_json,
|
49
|
+
quirks_mode: true
|
50
|
+
).dig("Content", "Items", "Device")
|
51
|
+
transform(response, subdomain)
|
52
|
+
rescue StandardError
|
53
|
+
raise MspConnectionError, "Error connecting to manager service provider"
|
44
54
|
end
|
45
55
|
|
56
|
+
def self.transform(response, subdomain)
|
57
|
+
return response.map! { |e| Device.new(e.transform_keys(&:downcase), subdomain) } if response.is_a?(Array)
|
58
|
+
|
59
|
+
Device.new(response.transform_keys(&:downcase), subdomain)
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.version
|
63
|
+
superclass == Request ? :simple_v1 : :v1
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.class_name
|
67
|
+
to_s.split("::").last
|
68
|
+
end
|
46
69
|
end
|
47
70
|
|
48
71
|
class Device
|
@@ -63,7 +86,7 @@ module Ruby
|
|
63
86
|
end
|
64
87
|
|
65
88
|
def lostmode(*args)
|
66
|
-
if
|
89
|
+
if args[0]
|
67
90
|
http_method(:post, id, __method__)
|
68
91
|
else
|
69
92
|
http_method(:delete, id, __method__)
|
@@ -81,11 +104,33 @@ module Ruby
|
|
81
104
|
private
|
82
105
|
|
83
106
|
def http_method(*args)
|
84
|
-
self.class.headers
|
85
|
-
self.class.method(args[0]).call(Miradore
|
107
|
+
self.class.headers "X-API-Key" => Miradore.api_key
|
108
|
+
self.class.method(args[0]).call(Miradore.url(:v2, subdomain, args[1], args[2]))
|
109
|
+
rescue StandardError
|
110
|
+
raise MspConnectionError, "Error connecting to manager service provider"
|
86
111
|
end
|
87
112
|
|
88
113
|
end
|
89
114
|
|
115
|
+
class Category < Request; end
|
116
|
+
|
117
|
+
class InvDevice < Request; end
|
118
|
+
|
119
|
+
class InvStorage < Request; end
|
120
|
+
|
121
|
+
class InvOS < Request; end
|
122
|
+
|
123
|
+
class Enrollment < Request; end
|
124
|
+
|
125
|
+
class Client < Request; end
|
126
|
+
|
127
|
+
class User < Request; end
|
128
|
+
|
129
|
+
class Location < Request; end
|
130
|
+
|
131
|
+
class Security < Request; end
|
132
|
+
|
133
|
+
class ReportedLocation < Request; end
|
134
|
+
|
90
135
|
end
|
91
136
|
end
|
Binary file
|
Binary file
|
data/ruby-miradore.gemspec
CHANGED
@@ -31,6 +31,12 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
# Uncomment to register a new dependency of your gem
|
33
33
|
# spec.add_dependency "example-gem", "~> 1.0"
|
34
|
+
spec.add_dependency "rake", "~> 13.0"
|
35
|
+
spec.add_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_dependency "rubocop", "~> 1.7"
|
37
|
+
spec.add_dependency "httparty", "~> 0.18.1"
|
38
|
+
spec.add_dependency "finest-builder", "~> 0.0.4"
|
39
|
+
spec.add_dependency "crack", "~> 0.4.5"
|
34
40
|
|
35
41
|
# For more information and examples about making a new gem, checkout our
|
36
42
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,15 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-miradore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
12
|
-
dependencies:
|
11
|
+
date: 2021-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '13.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '13.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.18.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.18.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: finest-builder
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.0.4
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.4
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: crack
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.4.5
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.4.5
|
13
97
|
description: Miradore MSP Ruby Gem
|
14
98
|
email:
|
15
99
|
- eduard@rzilient.club
|
@@ -24,6 +108,7 @@ files:
|
|
24
108
|
- CHANGELOG.md
|
25
109
|
- CODE_OF_CONDUCT.md
|
26
110
|
- Gemfile
|
111
|
+
- Gemfile.lock
|
27
112
|
- LICENSE.txt
|
28
113
|
- README.md
|
29
114
|
- Rakefile
|
@@ -31,6 +116,8 @@ files:
|
|
31
116
|
- bin/setup
|
32
117
|
- lib/ruby/miradore.rb
|
33
118
|
- lib/ruby/miradore/version.rb
|
119
|
+
- ruby-miradore-0.1.0.gem
|
120
|
+
- ruby-miradore-0.1.1.gem
|
34
121
|
- ruby-miradore.gemspec
|
35
122
|
homepage: https://github.com/eddygarcas/ruby-miradore
|
36
123
|
licenses:
|