lmc 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/LICENSE.txt +29 -0
- data/README.md +1 -1
- data/bin/console +11 -2
- data/coverage/.last_run.json +1 -1
- data/lib/lmc.rb +1 -1
- data/lib/lmc/Account.rb +6 -1
- data/lib/lmc/Cloud.rb +2 -3
- data/lib/lmc/User.rb +4 -4
- data/lib/lmc/auth/auth_action.rb +20 -0
- data/lib/lmc/mixins/json_able.rb +14 -0
- data/lib/lmc/mixins/service_resource.rb +38 -0
- data/lib/lmc/version.rb +1 -1
- data/lmc.gemspec +1 -1
- metadata +8 -5
- data/.idea/lmc.iml +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e166e110ff12d6ca705b3e1df2b5ad1d62a85552
|
4
|
+
data.tar.gz: b585a426621a6c6017cc880898982c660ab57e98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8432b158432407156b5b67cd3535edf6f1004a3f43867246a61f2c7a32e04cf7f1ea657e0db5a8ce69fb5540100e4ce1ae2983cd6a4e6a18d782564f2fc8a6c2
|
7
|
+
data.tar.gz: 8ef9ee1ebef7e37d0fcc53e50e99de5c138e4f3e356b9ee69b7d6e049eaa087b33f5b39c56deb0e34742a72afb31955816436ab420f5644d3d2e54b4e8889046
|
data/.gitignore
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
.idea/workspace.xml
|
9
9
|
.idea/tasks.xml
|
10
10
|
.idea/.rakeTasks
|
11
|
+
#When developing a gem, use the gemspec method in your Gemfile to avoid duplication. In general, a gem's Gemfile should contain the Rubygems source and a single gemspec line. Do not check your Gemfile.lock into version control, since it enforces precision that does not exist in the gem command, which is used to install gems in practice.
|
11
12
|
Gemfile.lock
|
12
13
|
test_credentials.yaml
|
13
14
|
lmc-*.gem
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
BSD 3-Clause License
|
2
|
+
|
3
|
+
Copyright (c) 2018, Philipp Erbelding
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
10
|
+
list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
17
|
+
contributors may be used to endorse or promote products derived from
|
18
|
+
this software without specific prior written permission.
|
19
|
+
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -40,4 +40,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
40
40
|
lmc_url: https://my.lmc.example
|
41
41
|
## Contributing
|
42
42
|
|
43
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/lancomsystems/ruby-lmc.
|
data/bin/console
CHANGED
@@ -7,8 +7,17 @@ require "lmc"
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
|
11
|
-
#
|
10
|
+
require "pry-nav"
|
11
|
+
#Pry.start
|
12
12
|
|
13
13
|
require "irb"
|
14
|
+
require 'irb/completion'
|
15
|
+
require 'irb/ext/save-history'
|
16
|
+
IRB.conf[:SAVE_HISTORY] = 100
|
17
|
+
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
|
18
|
+
|
19
|
+
def reload!
|
20
|
+
files = $LOADED_FEATURES.select { |feat| feat =~ /\/lmc\// }
|
21
|
+
files.each { |file| load file }
|
22
|
+
end
|
14
23
|
IRB.start(__FILE__)
|
data/coverage/.last_run.json
CHANGED
data/lib/lmc.rb
CHANGED
@@ -5,7 +5,7 @@ Dir.glob(File.expand_path("../lmc/*.rb", __FILE__)).each do |file|
|
|
5
5
|
require file
|
6
6
|
end
|
7
7
|
|
8
|
-
Dir.glob(File.expand_path("../lmc
|
8
|
+
Dir.glob(File.expand_path("../lmc/**/*.rb", __FILE__)).each do |file|
|
9
9
|
require file
|
10
10
|
end
|
11
11
|
|
data/lib/lmc/Account.rb
CHANGED
@@ -60,7 +60,12 @@ module LMC
|
|
60
60
|
def delete!
|
61
61
|
if @id != nil
|
62
62
|
@cloud.auth_for_accounts [@id]
|
63
|
-
|
63
|
+
delete_action = AuthAction.new @cloud
|
64
|
+
delete_action.type = AuthAction::ACCOUNT_DELETE
|
65
|
+
delete_action.name = Cloud.user
|
66
|
+
delete_action.data = {'password' => Cloud.password,
|
67
|
+
'accountId' => @id}
|
68
|
+
deleted = delete_action.post
|
64
69
|
if deleted.code == 200
|
65
70
|
@id = nil
|
66
71
|
return true
|
data/lib/lmc/Cloud.rb
CHANGED
@@ -7,8 +7,7 @@ module LMC
|
|
7
7
|
#include ActionView::Helpers::DateHelper
|
8
8
|
|
9
9
|
class << self
|
10
|
-
|
11
|
-
attr_accessor :verbose, :debug, :verify_tls, :use_tls
|
10
|
+
attr_accessor :cloud_host, :user, :password, :verbose, :debug, :verify_tls, :use_tls
|
12
11
|
Cloud.use_tls = true
|
13
12
|
Cloud.verify_tls = true
|
14
13
|
end
|
@@ -30,7 +29,7 @@ module LMC
|
|
30
29
|
@user = user
|
31
30
|
@password = pass
|
32
31
|
@verify_tls = Cloud.verify_tls
|
33
|
-
|
32
|
+
@last_authorized_account_ids = nil
|
34
33
|
authorize if auth
|
35
34
|
end
|
36
35
|
|
data/lib/lmc/User.rb
CHANGED
@@ -29,10 +29,10 @@ module LMC
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def request_pw_reset
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
action = AuthAction.new Cloud.instance
|
33
|
+
action.type="PASSWORD_RESET"
|
34
|
+
action.name=@email
|
35
|
+
action.post
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module LMC
|
2
|
+
class AuthAction
|
3
|
+
include ServiceResource
|
4
|
+
include JSONAble
|
5
|
+
resource_attrs :name, :type, :data
|
6
|
+
# action types
|
7
|
+
ACCOUNT_INVITE = 'ACCOUNT_INVITE'
|
8
|
+
PASSWORD_RESET = 'PASSWORD_RESET'
|
9
|
+
ACCOUNT_DELETE = 'ACCOUNT_DELETE'
|
10
|
+
USER_PROFILE_DELETE = 'USER_PROFILE_DELETE'
|
11
|
+
|
12
|
+
def service_name
|
13
|
+
'auth'
|
14
|
+
end
|
15
|
+
def collection_name
|
16
|
+
'actions'
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module LMC::JSONAble
|
2
|
+
def self.included(klass)
|
3
|
+
klass.class_exec do
|
4
|
+
def to_json
|
5
|
+
hash = {}
|
6
|
+
self.class.resource_attributes.each do |var|
|
7
|
+
val = self.instance_variable_get "@#{var}"
|
8
|
+
hash[var] = val unless val.nil?
|
9
|
+
end
|
10
|
+
hash.to_json
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module LMC
|
2
|
+
module ServiceResource
|
3
|
+
def self.included(klass)
|
4
|
+
klass.class_exec do
|
5
|
+
def initialize(cloud)
|
6
|
+
@cloud = cloud
|
7
|
+
end
|
8
|
+
end
|
9
|
+
klass.class_exec do
|
10
|
+
def methodtest
|
11
|
+
puts("cloud-service-#{service_name}")
|
12
|
+
end
|
13
|
+
# method that wraps attr_accessor to keep the defined attrs in a class instance var for serializing
|
14
|
+
def self.resource_attrs(*attrs)
|
15
|
+
@resource_attributes ||= []
|
16
|
+
@resource_attributes.concat attrs
|
17
|
+
attr_accessor(*attrs)
|
18
|
+
end
|
19
|
+
def self.resource_attributes
|
20
|
+
@resource_attributes
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
def method_on_instance_of_class
|
25
|
+
puts("cloud-service-#{service_name} #{self.inspect}, #{@cloud}")
|
26
|
+
end
|
27
|
+
def collection_path
|
28
|
+
["cloud-service-#{service_name}", collection_name]
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def post
|
33
|
+
@cloud.post collection_path, self
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
data/lib/lmc/version.rb
CHANGED
data/lmc.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
32
32
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
33
|
-
spec.add_development_dependency 'minitest-reporters', '~> 1
|
33
|
+
spec.add_development_dependency 'minitest-reporters', '~> 1'
|
34
34
|
spec.add_development_dependency 'rake', '~> 10.0'
|
35
35
|
spec.add_development_dependency 'recursive-open-struct', '~> 1.1'
|
36
36
|
spec.add_development_dependency 'simplecov', '~> 0.15'
|
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.6.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-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1
|
47
|
+
version: '1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1
|
54
|
+
version: '1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,7 +145,6 @@ extra_rdoc_files: []
|
|
145
145
|
files:
|
146
146
|
- ".gitignore"
|
147
147
|
- ".idea/inspectionProfiles/Project_Default.xml"
|
148
|
-
- ".idea/lmc.iml"
|
149
148
|
- ".idea/misc.xml"
|
150
149
|
- ".idea/modules.xml"
|
151
150
|
- ".idea/runConfigurations/tests.xml"
|
@@ -153,6 +152,7 @@ files:
|
|
153
152
|
- ".ruby-version"
|
154
153
|
- ".travis.yml"
|
155
154
|
- Gemfile
|
155
|
+
- LICENSE.txt
|
156
156
|
- README.md
|
157
157
|
- Rakefile
|
158
158
|
- bin/console
|
@@ -168,11 +168,14 @@ files:
|
|
168
168
|
- lib/lmc/Site.rb
|
169
169
|
- lib/lmc/User.rb
|
170
170
|
- lib/lmc/account_manager.rb
|
171
|
+
- lib/lmc/auth/auth_action.rb
|
171
172
|
- lib/lmc/authority.rb
|
172
173
|
- lib/lmc/device_config_state.rb
|
173
174
|
- lib/lmc/entity.rb
|
174
175
|
- lib/lmc/exceptions/lmc_outdated_terms_of_use_exception.rb
|
175
176
|
- lib/lmc/membership.rb
|
177
|
+
- lib/lmc/mixins/json_able.rb
|
178
|
+
- lib/lmc/mixins/service_resource.rb
|
176
179
|
- lib/lmc/principal.rb
|
177
180
|
- lib/lmc/version.rb
|
178
181
|
- lmc.gemspec
|
data/.idea/lmc.iml
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
3
|
-
<component name="ModuleRunConfigurationManager">
|
4
|
-
<shared>
|
5
|
-
<configuration default="false" name="tests" type="TestUnitRunConfigurationType" factoryName="Test::Unit/Shoulda/Minitest">
|
6
|
-
<predefined_log_file id="RUBY_TESTUNIT" enabled="true" />
|
7
|
-
<module name="lmc" />
|
8
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
9
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="" />
|
10
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
11
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
12
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
13
|
-
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
14
|
-
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
15
|
-
<EXTENSION ID="RubyCoverageRunConfigurationExtension" track_test_folders="true" runner="rcov">
|
16
|
-
<COVERAGE_PATTERN ENABLED="true">
|
17
|
-
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
18
|
-
</COVERAGE_PATTERN>
|
19
|
-
</EXTENSION>
|
20
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="$MODULE_DIR$/test" />
|
21
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
|
22
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/{*_test,test_*,*_spec}.rb" />
|
23
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="" />
|
24
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="ALL_IN_FOLDER" />
|
25
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
|
26
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
|
27
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
|
28
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_OPTIONS" VALUE="" />
|
29
|
-
<method />
|
30
|
-
</configuration>
|
31
|
-
</shared>
|
32
|
-
</component>
|
33
|
-
<component name="NewModuleRootManager">
|
34
|
-
<content url="file://$MODULE_DIR$" />
|
35
|
-
<orderEntry type="jdk" jdkName="rbenv: 2.4.1" jdkType="RUBY_SDK" />
|
36
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
37
|
-
<orderEntry type="library" scope="PROVIDED" name="ansi (v1.5.0, rbenv: 2.4.1) [gem]" level="application" />
|
38
|
-
<orderEntry type="library" scope="PROVIDED" name="builder (v3.2.3, rbenv: 2.4.1) [gem]" level="application" />
|
39
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.16.2, rbenv: 2.4.1) [gem]" level="application" />
|
40
|
-
<orderEntry type="library" scope="PROVIDED" name="coderay (v1.1.2, rbenv: 2.4.1) [gem]" level="application" />
|
41
|
-
<orderEntry type="library" scope="PROVIDED" name="docile (v1.3.1, rbenv: 2.4.1) [gem]" level="application" />
|
42
|
-
<orderEntry type="library" scope="PROVIDED" name="domain_name (v0.5.20180417, rbenv: 2.4.1) [gem]" level="application" />
|
43
|
-
<orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.3, rbenv: 2.4.1) [gem]" level="application" />
|
44
|
-
<orderEntry type="library" scope="PROVIDED" name="json (v2.1.0, rbenv: 2.4.1) [gem]" level="application" />
|
45
|
-
<orderEntry type="library" scope="PROVIDED" name="method_source (v0.8.2, rbenv: 2.4.1) [gem]" level="application" />
|
46
|
-
<orderEntry type="library" scope="PROVIDED" name="mime-types (v3.1, rbenv: 2.4.1) [gem]" level="application" />
|
47
|
-
<orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2016.0521, rbenv: 2.4.1) [gem]" level="application" />
|
48
|
-
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.11.3, rbenv: 2.4.1) [gem]" level="application" />
|
49
|
-
<orderEntry type="library" scope="PROVIDED" name="minitest-reporters (v1.2.0, rbenv: 2.4.1) [gem]" level="application" />
|
50
|
-
<orderEntry type="library" scope="PROVIDED" name="netrc (v0.11.0, rbenv: 2.4.1) [gem]" level="application" />
|
51
|
-
<orderEntry type="library" scope="PROVIDED" name="pry (v0.10.4, rbenv: 2.4.1) [gem]" level="application" />
|
52
|
-
<orderEntry type="library" scope="PROVIDED" name="pry-nav (v0.2.4, rbenv: 2.4.1) [gem]" level="application" />
|
53
|
-
<orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, rbenv: 2.4.1) [gem]" level="application" />
|
54
|
-
<orderEntry type="library" scope="PROVIDED" name="recursive-open-struct (v1.1.0, rbenv: 2.4.1) [gem]" level="application" />
|
55
|
-
<orderEntry type="library" scope="PROVIDED" name="rest-client (v2.0.2, rbenv: 2.4.1) [gem]" level="application" />
|
56
|
-
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.9.0, rbenv: 2.4.1) [gem]" level="application" />
|
57
|
-
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.16.1, rbenv: 2.4.1) [gem]" level="application" />
|
58
|
-
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.10.2, rbenv: 2.4.1) [gem]" level="application" />
|
59
|
-
<orderEntry type="library" scope="PROVIDED" name="slop (v3.6.0, rbenv: 2.4.1) [gem]" level="application" />
|
60
|
-
<orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, rbenv: 2.4.1) [gem]" level="application" />
|
61
|
-
<orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.7.5, rbenv: 2.4.1) [gem]" level="application" />
|
62
|
-
</component>
|
63
|
-
</module>
|