lmc 0.11.0 → 0.12.0

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
  SHA256:
3
- metadata.gz: 880db87962440a093cd4ba8762a517cca362710a1613a7de49b0c0d6c32a6024
4
- data.tar.gz: a3dbb4dd22c872245409923f894a9e16e13bb3f8b4d6c0cc2d736bb8b10ea56e
3
+ metadata.gz: ec4925e30542f46b5b9c991de79a672a9eabeffda07028620aaa6fa14e62c551
4
+ data.tar.gz: 0eb5b5654694a1eb90e920df6d00d67cf4b8dda7c42fa167760d9c329bd88341
5
5
  SHA512:
6
- metadata.gz: 1e40136ee4ba1768a3640217b8adf49b8efecb8ceb0250272102bd40057f3b0b680c35fc685925960af49daa467fac91e1e34c32ca240336699a0d18553a380b
7
- data.tar.gz: d764a99ffad431a919d912d8c7ff3353ff8defe99753f225419061a11174d15a73f2dbf797a0cdb6195f5dace2bf3c042eaa545e138f24590b17e9ac9133efc2
6
+ metadata.gz: ebbb8a5bcb4eb5cdaf9f0236394f18572922a70e42f7218b9d942420e4234ff30071549fff0c37e5e6e82ffcf3cce61b8b351921915ca749f7e947a8b33e74f0
7
+ data.tar.gz: c4008e578e219956662b9b0239a543c95f921099cee0dca7553b8770cf4a986fd872b3867a506327a2c4ea522244984341e72dfb970193f1837729c71b078601
@@ -1,8 +1,8 @@
1
- Layout/TrailingBlankLines:
1
+ Layout/TrailingEmptyLines:
2
2
  EnforcedStyle: final_blank_line
3
- Layout/IndentFirstHashElement:
3
+ Layout/FirstHashElementIndentation:
4
4
  IndentationWidth: 4
5
- Metrics/LineLength:
5
+ Layout/LineLength:
6
6
  Max: 110
7
7
  Style/IfUnlessModifier:
8
8
  Enabled: false
data/Rakefile CHANGED
@@ -21,15 +21,16 @@ RuboCop::RakeTask.new(:autocop) do |t|
21
21
  'Layout/SpaceAroundOperators',
22
22
  'Layout/SpaceInsideBlockBraces',
23
23
  'Layout/SpaceInsideHashLiteralBraces',
24
- 'Layout/TrailingBlankLines',
25
- 'Style/BracesAroundHashParameters',
24
+ 'Layout/TrailingEmptyLines',
26
25
  'Style/CommentAnnotation',
27
26
  'Style/FrozenStringLiteralComment',
28
27
  'Style/MethodDefParentheses',
29
28
  'Style/RedundantSelf',
30
29
  'Style/RedundantReturn',
31
30
  'Style/StringLiterals',
32
- 'Style/StringLiteralsInInterpolation']
31
+ 'Style/StringLiteralsInInterpolation',
32
+ 'Style/StabbyLambdaParentheses',
33
+ ]
33
34
  t.options = ['--only', autofix.join(','), '--auto-correct', 'lib', 'test', 'Rakefile', 'lmc.gemspec']
34
35
  end
35
36
  task :default => :test
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "result": {
3
- "covered_percent": 90.9
3
+ "covered_percent": 91.53
4
4
  }
5
5
  }
data/lib/lmc.rb CHANGED
@@ -23,7 +23,7 @@ Dir.glob(File.expand_path('../lmc/*.rb', __FILE__)).each do |file|
23
23
  require file
24
24
  end
25
25
 
26
- ['exceptions', 'auth', 'config', 'monitoring'].each do |folder|
26
+ ['exceptions', 'auth', 'config', 'monitoring', 'preferences'].each do |folder|
27
27
  Dir.glob(File.expand_path("../lmc/#{folder}/*.rb", __FILE__)).each do |file|
28
28
  require file
29
29
  end
@@ -25,7 +25,7 @@ module LMC
25
25
  (name.nil? || a.name == name) && (type.nil? || a.type == type)
26
26
  end
27
27
  if accounts.length == 1
28
- return accounts[0]
28
+ accounts[0]
29
29
  elsif accounts.length == 0
30
30
  raise 'Did not find account'
31
31
  else
@@ -56,8 +56,8 @@ module LMC
56
56
  delete_action = AuthAction.new @cloud
57
57
  delete_action.type = AuthAction::ACCOUNT_DELETE
58
58
  delete_action.name = Cloud.user
59
- delete_action.data = {'password' => Cloud.password,
60
- 'accountId' => @id}
59
+ delete_action.data = { 'password' => Cloud.password,
60
+ 'accountId' => @id }
61
61
  delete_action.post
62
62
  @id = nil
63
63
  true
@@ -86,7 +86,7 @@ module LMC
86
86
  if name.nil?
87
87
  raise 'No member name given'
88
88
  end
89
- member = members.find {|m| m.name == name}
89
+ member = members.find { |m| m.name == name }
90
90
  unless member
91
91
  raise "Member named #{name} not found in account #{self}"
92
92
  end
@@ -125,7 +125,7 @@ module LMC
125
125
  def children
126
126
  @cloud.auth_for_accounts([id, ROOT_ACCOUNT_UUID])
127
127
  response = @cloud.get ['cloud-service-auth', 'accounts', id, 'children']
128
- response.map {|child| Account.new @cloud, child}
128
+ response.map { |child| Account.new @cloud, child }
129
129
  end
130
130
 
131
131
  def logs
@@ -140,7 +140,7 @@ module LMC
140
140
  return [] if @type == 'PRIVATE_CLOUD'
141
141
  @cloud.auth_for_accounts([id])
142
142
  response = @cloud.get ['cloud-service-devices', 'accounts', id, 'sites'], :select => :id
143
- response.body.map {|data|
143
+ response.body.map { |data|
144
144
  Site.new(UUID.new(data), self)
145
145
  }
146
146
  end
@@ -168,6 +168,10 @@ module LMC
168
168
  "#{name}"
169
169
  end
170
170
 
171
+ def summary
172
+ "\"#{@name}\" (#{@type}) ID: #{@id}"
173
+ end
174
+
171
175
  private
172
176
 
173
177
  ## should be put into entity or such
@@ -63,6 +63,11 @@ module LMC
63
63
  post ['cloud-service-auth', 'accounts', account_id, 'members'], body
64
64
  end
65
65
 
66
+ # @param section Array of String to indicate section to access. Example: ['principal', 'self', 'ui']
67
+ def preferences(section)
68
+ LMC::Preferences.new cloud: self, section: section
69
+ end
70
+
66
71
  def get(path, params = nil)
67
72
  prepared_headers = headers
68
73
  prepared_headers[:params] = params
@@ -74,21 +79,26 @@ module LMC
74
79
  execute_request args
75
80
  end
76
81
 
77
- def put(path, body_object)
82
+ def put(path, body_object, params = nil)
83
+ prepared_headers = headers
84
+ prepared_headers[:params] = params
78
85
  args = {
79
86
  :method => :put,
80
87
  :url => build_url(path),
81
- :payload => body_object.to_json
82
-
88
+ :payload => body_object.to_json,
89
+ :headers => prepared_headers
83
90
  }
84
91
  execute_request args
85
92
  end
86
93
 
87
- def post(path, body_object)
94
+ def post(path, body_object, params=nil )
95
+ prepared_headers = headers
96
+ prepared_headers[:params] = params
88
97
  args = {
89
98
  :method => :post,
90
99
  :url => build_url(path),
91
- :payload => body_object.to_json
100
+ :payload => body_object.to_json,
101
+ :headers => prepared_headers
92
102
  }
93
103
  execute_request args
94
104
  end
@@ -181,7 +191,7 @@ module LMC
181
191
  internal_args.merge! args
182
192
  begin
183
193
  resp = RestClient::Request.execute internal_args
184
- return LMCResponse.new(resp)
194
+ LMCResponse.new(resp)
185
195
  rescue RestClient::ExceptionWithResponse => e
186
196
  if Cloud.debug
187
197
  puts 'EXCEPTION: ' + e.to_s
@@ -5,9 +5,9 @@ module LMC
5
5
  def self.get_by_uuid_or_name(term)
6
6
  raise 'Missing argument' if term.nil?
7
7
  begin
8
- return get_by_uuid term
8
+ get_by_uuid term
9
9
  rescue RestClient::BadRequest, URI::InvalidURIError
10
- return get_by_name term
10
+ get_by_name term
11
11
  end
12
12
  end
13
13
 
@@ -9,9 +9,6 @@ module LMC
9
9
  end
10
10
  end
11
11
  klass.class_exec do
12
- def methodtest
13
- puts("cloud-service-#{service_name}")
14
- end
15
12
 
16
13
  # method that wraps attr_accessor to keep the defined attrs in a class instance var for serializing
17
14
  def self.resource_attrs(*attrs)
@@ -26,10 +23,6 @@ module LMC
26
23
  end
27
24
  end
28
25
 
29
- def method_on_instance_of_class
30
- puts("cloud-service-#{service_name} #{inspect}, #{@cloud}")
31
- end
32
-
33
26
  def collection_path
34
27
  ["cloud-service-#{service_name}", collection_name]
35
28
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ module LMC
3
+ class Preferences
4
+ def initialize(cloud:, section:)
5
+ @cloud = cloud
6
+ @section = section
7
+ end
8
+
9
+ def get(path)
10
+ response = @cloud.get build_url, { path: path }
11
+ response.body
12
+ end
13
+
14
+ def put(path, payload)
15
+ @cloud.put build_url, payload, { path: path }
16
+ end
17
+
18
+ private
19
+ def build_url
20
+ ['cloud-service-preferences'] + @section
21
+ end
22
+ end
23
+ end
24
+
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LMC
4
- VERSION = '0.11.0'
4
+ VERSION = '0.12.0'
5
5
  end
6
6
 
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.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - erpel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-15 00:00:00.000000000 Z
11
+ date: 2020-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -195,6 +195,7 @@ files:
195
195
  - lib/lmc/mixins/json_able.rb
196
196
  - lib/lmc/mixins/service_resource.rb
197
197
  - lib/lmc/monitoring/monitoring_record.rb
198
+ - lib/lmc/preferences/preferences.rb
198
199
  - lib/lmc/principal.rb
199
200
  - lib/lmc/uuid.rb
200
201
  - lib/lmc/version.rb