lmc 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/codeStyles/codeStyleConfig.xml +5 -0
- data/.idea/inspectionProfiles/Project_Default.xml +3 -0
- data/.idea/runConfigurations/tests.xml +3 -3
- data/Rakefile +7 -0
- data/coverage/.last_run.json +1 -1
- data/lib/lmc.rb +5 -3
- data/lib/lmc/Account.rb +4 -2
- data/lib/lmc/Cloud.rb +1 -1
- data/lib/lmc/Configstates.rb +2 -0
- data/lib/lmc/Device.rb +23 -11
- data/lib/lmc/Response.rb +10 -0
- data/lib/lmc/Site.rb +2 -0
- data/lib/lmc/User.rb +2 -0
- data/lib/lmc/account_manager.rb +2 -0
- data/lib/lmc/auth/auth_action.rb +2 -0
- data/lib/lmc/authority.rb +2 -0
- data/lib/lmc/device_config_state.rb +2 -0
- data/lib/lmc/entity.rb +2 -0
- data/lib/lmc/exceptions/lmc_outdated_terms_of_use_exception.rb +2 -0
- data/lib/lmc/membership.rb +2 -0
- data/lib/lmc/mixins/json_able.rb +2 -0
- data/lib/lmc/mixins/service_resource.rb +2 -0
- data/lib/lmc/monitoring/monitoring_record.rb +33 -0
- data/lib/lmc/principal.rb +21 -1
- data/lib/lmc/version.rb +3 -1
- data/lmc.gemspec +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31077763003e89d0d7d95ccf0882eca185921b9b
|
4
|
+
data.tar.gz: 20f58644eeb3bbf19f9a20142f6603147f028a51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7eb1f25f826afe31759b6a553acd5fbeee9aaef610a09a9e280441d21390fca1e169fc00a1aa77ba81d7567940ecb5b7de3730658ee4cc93b7262fb79be04bd6
|
7
|
+
data.tar.gz: 2054e10d846866b107e70e12c6413adc863cf5a48a0b3399254db08c72e4f042b887bee326cb8d8efd3f2e5922c8fab2e372eabcf24ce644c9876548198c1035
|
@@ -1,6 +1,9 @@
|
|
1
1
|
<component name="InspectionProjectProfileManager">
|
2
2
|
<profile version="1.0">
|
3
3
|
<option name="myName" value="Project Default" />
|
4
|
+
<inspection_tool class="Rubocop" enabled="true" level="WARNING" enabled_by_default="true">
|
5
|
+
<scope name="Tests" level="ERROR" enabled="true" />
|
6
|
+
</inspection_tool>
|
4
7
|
<inspection_tool class="RubyInstanceMethodNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
|
5
8
|
<scope name="Tests" level="WARNING" enabled="false" />
|
6
9
|
</inspection_tool>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<component name="ProjectRunConfigurationManager">
|
2
|
-
<configuration default="false" name="tests" type="TestUnitRunConfigurationType" factoryName="Test::Unit/Shoulda/Minitest"
|
2
|
+
<configuration default="false" name="tests" type="TestUnitRunConfigurationType" factoryName="Test::Unit/Shoulda/Minitest">
|
3
3
|
<predefined_log_file id="RUBY_TESTUNIT" enabled="true" />
|
4
|
-
<module name="
|
5
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="
|
4
|
+
<module name="lmc" />
|
5
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="" />
|
6
6
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="" />
|
7
7
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
8
8
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
data/Rakefile
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "bundler/gem_tasks"
|
2
4
|
require "rake/testtask"
|
5
|
+
require 'rubocop/rake_task'
|
3
6
|
|
4
7
|
Rake::TestTask.new(:test) do |t|
|
5
8
|
t.libs << "test"
|
@@ -7,4 +10,8 @@ Rake::TestTask.new(:test) do |t|
|
|
7
10
|
t.test_files = FileList["test/**/*_test.rb"]
|
8
11
|
end
|
9
12
|
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new(:autocop) do |t|
|
15
|
+
t.options = ['--only', 'Style/FrozenStringLiteralComment', '--auto-correct', 'lib', 'test', 'Rakefile', 'lmc.gemspec']
|
16
|
+
end
|
10
17
|
task :default => :test
|
data/coverage/.last_run.json
CHANGED
data/lib/lmc.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require 'restclient'
|
3
5
|
|
@@ -13,15 +15,15 @@ module LMC
|
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
Dir.glob(File.expand_path(
|
18
|
+
Dir.glob(File.expand_path('../lmc/mixins/*.rb', __FILE__)).each do |file|
|
17
19
|
require file
|
18
20
|
end
|
19
21
|
|
20
|
-
Dir.glob(File.expand_path(
|
22
|
+
Dir.glob(File.expand_path('../lmc/*.rb', __FILE__)).each do |file|
|
21
23
|
require file
|
22
24
|
end
|
23
25
|
|
24
|
-
[
|
26
|
+
['exceptions', 'auth', 'monitoring'].each do |folder|
|
25
27
|
Dir.glob(File.expand_path("../lmc/#{folder}/*.rb", __FILE__)).each do |file|
|
26
28
|
require file
|
27
29
|
end
|
data/lib/lmc/Account.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'account_manager.rb'
|
2
4
|
require_relative 'entity'
|
3
5
|
module LMC
|
4
6
|
class Account < Entity
|
5
7
|
ROOT_ACCOUNT_UUID = '9ec458c2-d05f-3004-96f0-ebe73fa20de8'
|
6
8
|
attr_accessor :name
|
7
|
-
attr_reader :id, :state, :type, :identifier
|
9
|
+
attr_reader :id, :state, :type, :identifier, :cloud
|
8
10
|
|
9
11
|
def self.get(id)
|
10
12
|
cloud = Cloud.instance
|
@@ -56,7 +58,7 @@ module LMC
|
|
56
58
|
delete_action.name = Cloud.user
|
57
59
|
delete_action.data = {'password' => Cloud.password,
|
58
60
|
'accountId' => @id}
|
59
|
-
|
61
|
+
delete_action.post
|
60
62
|
@id = nil
|
61
63
|
return true
|
62
64
|
end
|
data/lib/lmc/Cloud.rb
CHANGED
data/lib/lmc/Configstates.rb
CHANGED
data/lib/lmc/Device.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module LMC
|
2
4
|
class Device
|
3
5
|
attr_reader :id, :name, :model, :serial, :heartbeatstate
|
4
6
|
|
5
7
|
def initialize(data)
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
8
|
+
@id = data['id']
|
9
|
+
@comment = data['comment']
|
10
|
+
@name = data['status']['name']
|
11
|
+
@serial = data['status']['serial']
|
12
|
+
@model = data['status']['model']
|
13
|
+
@heartbeatstate = data['status']['heartbeatState']
|
14
|
+
@status = data['status']
|
15
|
+
@account = data['account']
|
16
|
+
@cloud = @account.cloud
|
17
|
+
@cloud ||= Cloud.instance
|
15
18
|
end
|
16
19
|
|
17
20
|
def get_config_for_account(account)
|
@@ -24,7 +27,7 @@ module LMC
|
|
24
27
|
end
|
25
28
|
|
26
29
|
def get_monitor_widgets(widget_item_ids)
|
27
|
-
@cloud.get ["cloud-service-monitoring", @account.id, "devices", @id, "monitordata"], {:widgetItemIds => widget_item_ids.join(",")}
|
30
|
+
@cloud.get ["cloud-service-monitoring", @account.id, "devices", @id, "monitordata"], { :widgetItemIds => widget_item_ids.join(",") }
|
28
31
|
end
|
29
32
|
|
30
33
|
def self.get_for_account(account)
|
@@ -58,9 +61,18 @@ module LMC
|
|
58
61
|
raise "device logs not supported"
|
59
62
|
end
|
60
63
|
|
64
|
+
def record name
|
65
|
+
MonitoringRecord.new(@cloud, @account, self, name)
|
66
|
+
end
|
67
|
+
|
68
|
+
def monitor_record_group
|
69
|
+
'DEVICE'
|
70
|
+
end
|
71
|
+
|
61
72
|
private
|
73
|
+
|
62
74
|
def get_config_state
|
63
|
-
reply = @cloud.get ["cloud-service-config", "configdevice", "accounts", @account.id, "state"], {"deviceIds" => @id}
|
75
|
+
reply = @cloud.get ["cloud-service-config", "configdevice", "accounts", @account.id, "state"], { "deviceIds" => @id }
|
64
76
|
if reply.code == 200
|
65
77
|
# binding.pry
|
66
78
|
DeviceConfigState.new reply.body[@id]
|
data/lib/lmc/Response.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'ostruct'
|
2
4
|
module LMC
|
3
5
|
class LMCResponse
|
@@ -33,6 +35,14 @@ module LMC
|
|
33
35
|
@body_object[key]
|
34
36
|
end
|
35
37
|
|
38
|
+
def []=(key, val)
|
39
|
+
@body_object[key] = val
|
40
|
+
end
|
41
|
+
|
42
|
+
def keys
|
43
|
+
@body_object.keys
|
44
|
+
end
|
45
|
+
|
36
46
|
def map(&block)
|
37
47
|
@body_object.map(&block)
|
38
48
|
end
|
data/lib/lmc/Site.rb
CHANGED
data/lib/lmc/User.rb
CHANGED
data/lib/lmc/account_manager.rb
CHANGED
data/lib/lmc/auth/auth_action.rb
CHANGED
data/lib/lmc/authority.rb
CHANGED
data/lib/lmc/entity.rb
CHANGED
data/lib/lmc/membership.rb
CHANGED
data/lib/lmc/mixins/json_able.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LMC
|
4
|
+
class MonitoringRecord
|
5
|
+
# https://beta.cloud.lancom.de/cloud-service-monitoring/accounts/316f5f14-ff6c-4fd4-a49a-d28a6b3ba26c/records/uptime?count=144&
|
6
|
+
# group=DEVICE&groupId=8b2a3fef-2f7b-444c-86e7-1cf1b509e951&name=device&period=MINUTE10&relative=0&type=scalar
|
7
|
+
def record_url
|
8
|
+
['cloud-service-monitoring', 'accounts', @account.id, 'records', @record_name]
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(cloud, account, grouping, record_name)
|
12
|
+
@cloud = cloud
|
13
|
+
@account = account
|
14
|
+
@record_name = record_name
|
15
|
+
@grouping = grouping
|
16
|
+
end
|
17
|
+
|
18
|
+
def scalar name, count, period
|
19
|
+
fetch_data name, count, period, 'scalar'
|
20
|
+
end
|
21
|
+
|
22
|
+
def row name, count, period
|
23
|
+
fetch_data name, count, period, 'row'
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def fetch_data(name, count, period, type, relative = 0)
|
29
|
+
r = @cloud.get record_url, { count: count, group: @grouping.monitor_record_group, groupId: @grouping.id, name: name, period: period, relative: relative, type: type }
|
30
|
+
r.body
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/lmc/principal.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module LMC
|
2
4
|
class Principal
|
5
|
+
PRINCIPAL_URL_BASE = %w[cloud-service-auth users].freeze
|
6
|
+
attr_reader :id, :name, :password, :type
|
7
|
+
|
8
|
+
# this is actually a bad hack because the lmc api treats users different
|
9
|
+
# from principals.
|
10
|
+
def self.get_self(cloud)
|
11
|
+
new(cloud.get([PRINCIPAL_URL_BASE, 'self']))
|
12
|
+
end
|
13
|
+
|
3
14
|
def initialize(data)
|
4
15
|
apply_data(data)
|
5
16
|
end
|
@@ -12,9 +23,14 @@ module LMC
|
|
12
23
|
raise "editing principals not supported"
|
13
24
|
#@cloud.put ["cloud-service-auth", "principals", @id], self
|
14
25
|
end
|
15
|
-
apply_data(response
|
26
|
+
apply_data(response)
|
16
27
|
return self
|
17
28
|
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
"#{@name} - #{@id}"
|
32
|
+
end
|
33
|
+
|
18
34
|
def to_json(*a)
|
19
35
|
{
|
20
36
|
"name" => @name,
|
@@ -24,7 +40,11 @@ module LMC
|
|
24
40
|
end
|
25
41
|
|
26
42
|
private
|
43
|
+
|
27
44
|
def apply_data(data)
|
45
|
+
data.keys.each do |k|
|
46
|
+
data[k.to_s] = data[k]
|
47
|
+
end
|
28
48
|
@id = data['id']
|
29
49
|
@name = data['name']
|
30
50
|
@password = data['password']
|
data/lib/lmc/version.rb
CHANGED
data/lmc.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lmc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- erpel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -144,6 +144,7 @@ extensions: []
|
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
146
|
- ".gitignore"
|
147
|
+
- ".idea/codeStyles/codeStyleConfig.xml"
|
147
148
|
- ".idea/inspectionProfiles/Project_Default.xml"
|
148
149
|
- ".idea/runConfigurations/tests.xml"
|
149
150
|
- ".idea/vcs.xml"
|
@@ -176,6 +177,7 @@ files:
|
|
176
177
|
- lib/lmc/membership.rb
|
177
178
|
- lib/lmc/mixins/json_able.rb
|
178
179
|
- lib/lmc/mixins/service_resource.rb
|
180
|
+
- lib/lmc/monitoring/monitoring_record.rb
|
179
181
|
- lib/lmc/principal.rb
|
180
182
|
- lib/lmc/version.rb
|
181
183
|
- lmc.gemspec
|