azure-armrest 0.10.0 → 0.11.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: a58247b13fa15be3fc773cb02e734ae36d3a21db9be243ecf4fa3b66014e3117
4
- data.tar.gz: 123caf6a1a8ec857e5da499357b41ef0177346d938fe06f3a0d933b029bddf77
3
+ metadata.gz: c05fdb104f21ace674e10937a178a0ba1976c11f501d708107e5543976b1f8ae
4
+ data.tar.gz: 1d78a637421c4166578bf53a56f24dd7b7781dc74323eb02659f0e72ee9c55b0
5
5
  SHA512:
6
- metadata.gz: e13e25b3086f351299f9e1b17c0be38a3610d055f44f6528883823e692015f6be582fd5281a4113c2a243226510dd3cdee8d5bf753f463f344bb263b5104aa28
7
- data.tar.gz: d7b81384f7f93248088536cc366e6e0e17cae8ad2ae9b94b3c287fd0f39b5dd4664dc5e49e55e8d5990643ec9bdc94679699798c23e07b5850d5e9f24d16023f
6
+ metadata.gz: 4b20b6dcc409488a5559dce6be791448ebdeb78a077e48453c3aa8de143573c508ca92845f3725fc5ca83acb2c0c4970effaf82ed675a9c191b0e281bae3880f
7
+ data.tar.gz: ebc6a58804b759f3bfed65436e742dd1f7d815df6df252184a6da066fe119725b124287a31133cd49fa5740affe8ff0bbb73f1ecabcf087cb8521d7f118839e2
data/.codeclimate.yml ADDED
@@ -0,0 +1,16 @@
1
+ prepare:
2
+ fetch:
3
+ - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_base.yml
4
+ path: ".rubocop_base.yml"
5
+ - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_cc_base.yml
6
+ path: ".rubocop_cc_base.yml"
7
+ - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/base.yml
8
+ path: styles/base.yml
9
+ - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/cc_base.yml
10
+ path: styles/cc_base.yml
11
+ plugins:
12
+ rubocop:
13
+ enabled: true
14
+ config: ".rubocop_cc.yml"
15
+ channel: rubocop-0-82
16
+ version: '2'
data/.rubocop.yml CHANGED
@@ -1,4 +1,4 @@
1
+ inherit_gem:
2
+ manageiq-style: ".rubocop_base.yml"
1
3
  inherit_from:
2
- - https://raw.githubusercontent.com/ManageIQ/guides/master/.rubocop_base.yml
3
- # put all local rubocop config into .rubocop_local.yml as it will be loaded by .rubocop_cc.yml as well
4
- - .rubocop_local.yml
4
+ - ".rubocop_local.yml"
data/.rubocop_cc.yml ADDED
@@ -0,0 +1,4 @@
1
+ inherit_from:
2
+ - ".rubocop_base.yml"
3
+ - ".rubocop_cc_base.yml"
4
+ - ".rubocop_local.yml"
data/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  language: ruby
2
- sudo: false
3
2
  cache: bundler
4
3
  rvm:
5
4
  - "2.5.7"
@@ -11,4 +10,9 @@ matrix:
11
10
  - rvm: ruby-head
12
11
  - rvm: jruby-head
13
12
  fast_finish: true
14
- after_script: bundle exec codeclimate-test-reporter
13
+ before_script:
14
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
15
+ - chmod +x ./cc-test-reporter
16
+ - ./cc-test-reporter before-build
17
+ after_script:
18
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/CHANGES CHANGED
@@ -1,3 +1,10 @@
1
+ = 0.11.0 - 20-Apr-2021
2
+ * Modify the VirtualMachineService#get method to include instance view
3
+ information
4
+ * Update default ssl_version to TLSv1_2
5
+ * Fix tenants method
6
+ * Handle application/xml exception content-types
7
+
1
8
  = 0.10.0 - 14-May-2020
2
9
  * Updated the rest-client dependency to 2.1.0.
3
10
  * Updated the azure-signature dependency to 0.3.0.
data/README.md CHANGED
@@ -8,7 +8,6 @@ A Ruby interface for Azure using the new REST API.
8
8
  [![Build Status](https://travis-ci.org/ManageIQ/azure-armrest.svg)](https://travis-ci.org/ManageIQ/azure-armrest)
9
9
  [![Code Climate](https://codeclimate.com/github/ManageIQ/azure-armrest/badges/gpa.svg)](https://codeclimate.com/github/ManageIQ/azure-armrest)
10
10
  [![Test Coverage](https://codeclimate.com/github/ManageIQ/azure-armrest/badges/coverage.svg)](https://codeclimate.com/github/ManageIQ/azure-armrest/coverage)
11
- [![Dependency Status](https://gemnasium.com/ManageIQ/azure-armrest.svg)](https://gemnasium.com/ManageIQ/azure-armrest)
12
11
  [![Security](https://hakiri.io/github/ManageIQ/azure-armrest/master.svg)](https://hakiri.io/github/ManageIQ/azure-armrest/master)
13
12
 
14
13
  ## Synopsis
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.email = ['dberger@redhat.com', 'bsorota@redhat.com', 'gblomqui@redhat.com', 'billwei@redhat.com']
9
9
  spec.summary = 'An interface for ARM/JSON Azure REST API'
10
10
  spec.homepage = 'http://github.com/ManageIQ/azure-armrest'
11
- spec.license = 'Apache 2.0'
11
+ spec.license = 'Apache-2.0'
12
12
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
13
13
 
14
14
  spec.description = <<-EOF
@@ -17,18 +17,18 @@ different than the current azure gem, which uses the older (XML) interface
17
17
  behind the scenes.
18
18
  EOF
19
19
 
20
- spec.add_dependency 'json', '~> 2'
21
- spec.add_dependency 'rest-client', '~> 2.1.0'
22
- spec.add_dependency 'memoist', '~> 0.15'
23
- spec.add_dependency 'azure-signature', '~> 0.3.0'
24
20
  spec.add_dependency 'activesupport', '>= 4.2.2'
25
21
  spec.add_dependency 'addressable', '~> 2.5.0'
22
+ spec.add_dependency 'azure-signature', '~> 0.3.0'
23
+ spec.add_dependency 'json', '~> 2'
24
+ spec.add_dependency 'memoist', '~> 0.15'
26
25
  spec.add_dependency 'parallel', '~> 1.12.0'
26
+ spec.add_dependency 'rest-client', '~> 2.1.0'
27
27
 
28
28
  spec.add_development_dependency 'bundler'
29
+ spec.add_development_dependency 'manageiq-style'
29
30
  spec.add_development_dependency 'rake'
30
31
  spec.add_development_dependency 'rspec', '~> 3.0'
31
32
  spec.add_development_dependency 'simplecov'
32
- spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.0'
33
33
  spec.add_development_dependency 'timecop', '~> 0.7'
34
34
  end
data/lib/azure/armrest.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'rest-client'
2
2
  require 'json'
3
- require 'thread'
4
3
  require 'addressable'
5
4
  require 'parallel'
6
5
  require 'memoist'
@@ -1,5 +1,6 @@
1
1
  require 'time'
2
2
  require 'active_support/core_ext/hash/conversions'
3
+ require 'active_support/core_ext/hash/keys'
3
4
  require_relative 'model/base_model'
4
5
 
5
6
  module Azure
@@ -154,7 +155,7 @@ module Azure
154
155
  # Returns a list of tenants that can be accessed.
155
156
  #
156
157
  def tenants
157
- url = url_with_api_version(configuration.api_version, configuration.resource_url, 'tenants')
158
+ url = url_with_api_version(configuration.api_version, configuration.environment.resource_url, 'tenants')
158
159
  resp = rest_get(url)
159
160
  JSON.parse(resp.body)['value'].map{ |hash| Azure::Armrest::Tenant.new(hash) }
160
161
  end
@@ -253,11 +254,22 @@ module Azure
253
254
 
254
255
  def raise_api_exception(err)
255
256
  begin
256
- response = JSON.parse(err.http_body)
257
- code = response['error']['code']
258
- message = response['error']['message']
257
+ content_type_header = err.response.headers[:content_type]
258
+
259
+ response = case content_type_header.match(%r{(application/\w+)})[1]
260
+ when "application/json"
261
+ JSON.parse(err.http_body)
262
+ when "application/xml"
263
+ # The XML document that is returned has Error, Code, and Message
264
+ # so we need to downcase the keys to stay consistent with the
265
+ # parsed-json hash.
266
+ Hash.from_xml(err.http_body).deep_transform_keys(&:downcase)
267
+ end
268
+
269
+ code = response['error']['code']
270
+ message = response['error']['message']
259
271
  rescue
260
- code = err.try(:http_code) || err.try(:code)
272
+ code = err.try(:http_code) || err.try(:code)
261
273
  message = err.try(:http_body) || err.try(:message)
262
274
  end
263
275
 
@@ -107,7 +107,7 @@ module Azure
107
107
  :content_type => 'application/json',
108
108
  :grant_type => 'client_credentials',
109
109
  :proxy => ENV['http_proxy'],
110
- :ssl_version => 'TLSv1',
110
+ :ssl_version => 'TLSv1_2',
111
111
  :timeout => 60,
112
112
  :max_threads => 10,
113
113
  :max_retries => 3,
@@ -288,7 +288,7 @@ module Azure
288
288
  url = File.join(properties.primary_endpoints.file, share, file)
289
289
  url += "?timeout=#{timeout}" if timeout
290
290
 
291
- hash = options.transform_keys.each { |okey| 'x-ms-' + okey.to_s.tr('_', '-') }
291
+ hash = options.transform_keys { |okey| 'x-ms-' + okey.to_s.tr('_', '-') }
292
292
 
293
293
  hash['verb'] = 'PUT'
294
294
 
@@ -380,7 +380,7 @@ module Azure
380
380
  url = File.join(properties.primary_endpoints.file, share, file) + "?comp=range"
381
381
  url += "&timeout=#{timeout}" if timeout
382
382
 
383
- hash = options.transform_keys.each { |okey| 'x-ms-' + okey.to_s.tr('_', '-') }
383
+ hash = options.transform_keys { |okey| 'x-ms-' + okey.to_s.tr('_', '-') }
384
384
 
385
385
  hash['verb'] = 'PUT'
386
386
  hash['x-ms-write'] ||= 'update'
@@ -232,7 +232,7 @@ module Azure
232
232
  api_version = configuration.provider_default_api_version(provider_name, full_service_name)
233
233
  end
234
234
  api_version ||= configuration.provider_default_api_version(provider_name, service_name)
235
- api_version ||= configuration.api_version
235
+ api_version || configuration.api_version
236
236
  end
237
237
 
238
238
  def delete_by_url(url, resource_name = '')
@@ -260,7 +260,7 @@ module Azure
260
260
  # arguments provided, and appends it with the api_version.
261
261
  #
262
262
  def build_url(resource_group = nil, *args)
263
- url = File.join(configuration.environment.resource_url, build_id_string(resource_group, *args))
263
+ File.join(configuration.environment.resource_url, build_id_string(resource_group, *args))
264
264
  end
265
265
 
266
266
  def build_id_string(resource_group = nil, *args)
@@ -279,6 +279,8 @@ module Azure
279
279
  query << "&$top=#{value}"
280
280
  elsif key.casecmp('filter').zero?
281
281
  query << "&$filter=#{value}" # Allow raw filter
282
+ elsif key.casecmp('expand').zero?
283
+ query << "&$expand=#{value}"
282
284
  else
283
285
  if query.include?("$filter")
284
286
  query << " and #{key} eq '#{value}'"
@@ -142,7 +142,6 @@ module Azure
142
142
  private
143
143
 
144
144
  def build_url(namespace = nil, *args)
145
- id = configuration.subscription_id
146
145
  url = File.join(base_url, 'providers')
147
146
  url = File.join(url, namespace) if namespace
148
147
  url = File.join(url, *args) unless args.empty?
@@ -86,7 +86,7 @@ module Azure::Armrest::Storage::ManagedStorageHelper
86
86
  rescue Azure::Armrest::ForbiddenException => err
87
87
  log('warn', "ManagedStorageHelper.read: #{err}")
88
88
  raise err
89
- rescue RestClient::Exception, Azure::Armrest::ForbiddenException => err
89
+ rescue RestClient::Exception, Azure::Armrest::Exception => err
90
90
  raise err unless retries < max_retries
91
91
  log('warn', "ManagedStorageHelper.read: #{err} - retry number #{retries}")
92
92
  retries += 1
@@ -1,6 +1,6 @@
1
1
  module Azure
2
2
  module Armrest
3
3
  # The version of the azure-armrest library.
4
- VERSION = '0.10.0'.freeze
4
+ VERSION = '0.11.0'.freeze
5
5
  end
6
6
  end
@@ -71,23 +71,48 @@ module Azure
71
71
  # Retrieves the settings of the VM named +vmname+ in resource group
72
72
  # +group+, which will default to the same as the name of the VM.
73
73
  #
74
- # By default this method will retrieve the model view. If the +model_view+
75
- # parameter is false, it will retrieve an instance view. The difference is
76
- # in the details of the information retrieved.
74
+ # You can also specify any query options. At this time only the
75
+ # :expand => 'instanceView' option is supported, but others could
76
+ # be added over time.
77
77
  #
78
- def get(vmname, group = configuration.resource_group, model_view = true)
79
- model_view ? super(vmname, group) : get_instance_view(vmname, group)
78
+ # For backwards compatibility, the third argument may also be a boolean
79
+ # which will retrieve the model view by default. Set to false if you only
80
+ # want the instance view.
81
+ #
82
+ # Examples:
83
+ #
84
+ # vms = VirtualMachineService.new(credentials)
85
+ #
86
+ # # Standard call, get just the model view
87
+ # vms.get('some_name', 'some_group')
88
+ # vms.get('some_name', 'some_group', true) # same
89
+ #
90
+ # # Get the instance view only
91
+ # vms.get('some_name', 'some_group', false)
92
+ #
93
+ # # Get the instance view merged with the model view
94
+ # vms.get('some_name', 'some_group', :expand => 'instanceView')
95
+ #
96
+ def get(vmname, group = configuration.resource_group, options = {})
97
+ if options.kind_of?(Hash)
98
+ url = build_url(group, vmname, options)
99
+ response = rest_get(url)
100
+ VirtualMachineInstance.new(response)
101
+ else
102
+ options ? super(vmname, group) : get_instance_view(vmname, group)
103
+ end
80
104
  end
81
105
 
82
106
  # Convenient wrapper around the get method that retrieves the model view
83
- # for +vmname+ in resource_group +group+.
107
+ # for +vmname+ in resource_group +group+ without the instance view
108
+ # information.
84
109
  #
85
110
  def get_model_view(vmname, group = configuration.resource_group)
86
- get(vmname, group, true)
111
+ get(vmname, group)
87
112
  end
88
113
 
89
- # Convenient wrapper around the get method that retrieves the instance view
90
- # for +vmname+ in resource_group +group+.
114
+ # Convenient wrapper around the get method that retrieves only the
115
+ # instance view for +vmname+ in resource_group +group+.
91
116
  #
92
117
  def get_instance_view(vmname, group = configuration.resource_group)
93
118
  raise ArgumentError, "must specify resource group" unless group
@@ -333,7 +358,7 @@ module Azure
333
358
  raise ArgumentError, "must specify name of the vm" unless vmname
334
359
 
335
360
  url = build_url(group, vmname, action)
336
- response = rest_post(url)
361
+ response = rest_post(url, options.to_json)
337
362
 
338
363
  Azure::Armrest::ResponseHeaders.new(response.headers).tap do |headers|
339
364
  headers.response_code = response.code
metadata CHANGED
@@ -1,116 +1,116 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azure-armrest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
8
  - Bronagh Sorota
9
9
  - Greg Blomquist
10
10
  - Bill Wei
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-05-14 00:00:00.000000000 Z
14
+ date: 2021-04-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: json
17
+ name: activesupport
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - "~>"
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: '2'
22
+ version: 4.2.2
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '2'
29
+ version: 4.2.2
30
30
  - !ruby/object:Gem::Dependency
31
- name: rest-client
31
+ name: addressable
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: 2.1.0
36
+ version: 2.5.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: 2.1.0
43
+ version: 2.5.0
44
44
  - !ruby/object:Gem::Dependency
45
- name: memoist
45
+ name: azure-signature
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - "~>"
49
49
  - !ruby/object:Gem::Version
50
- version: '0.15'
50
+ version: 0.3.0
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '0.15'
57
+ version: 0.3.0
58
58
  - !ruby/object:Gem::Dependency
59
- name: azure-signature
59
+ name: json
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: 0.3.0
64
+ version: '2'
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - "~>"
70
70
  - !ruby/object:Gem::Version
71
- version: 0.3.0
71
+ version: '2'
72
72
  - !ruby/object:Gem::Dependency
73
- name: activesupport
73
+ name: memoist
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - ">="
76
+ - - "~>"
77
77
  - !ruby/object:Gem::Version
78
- version: 4.2.2
78
+ version: '0.15'
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - ">="
83
+ - - "~>"
84
84
  - !ruby/object:Gem::Version
85
- version: 4.2.2
85
+ version: '0.15'
86
86
  - !ruby/object:Gem::Dependency
87
- name: addressable
87
+ name: parallel
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: 2.5.0
92
+ version: 1.12.0
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - "~>"
98
98
  - !ruby/object:Gem::Version
99
- version: 2.5.0
99
+ version: 1.12.0
100
100
  - !ruby/object:Gem::Dependency
101
- name: parallel
101
+ name: rest-client
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - "~>"
105
105
  - !ruby/object:Gem::Version
106
- version: 1.12.0
106
+ version: 2.1.0
107
107
  type: :runtime
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
111
  - - "~>"
112
112
  - !ruby/object:Gem::Version
113
- version: 1.12.0
113
+ version: 2.1.0
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: bundler
116
116
  requirement: !ruby/object:Gem::Requirement
@@ -125,6 +125,20 @@ dependencies:
125
125
  - - ">="
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
+ - !ruby/object:Gem::Dependency
129
+ name: manageiq-style
130
+ requirement: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
128
142
  - !ruby/object:Gem::Dependency
129
143
  name: rake
130
144
  requirement: !ruby/object:Gem::Requirement
@@ -167,20 +181,6 @@ dependencies:
167
181
  - - ">="
168
182
  - !ruby/object:Gem::Version
169
183
  version: '0'
170
- - !ruby/object:Gem::Dependency
171
- name: codeclimate-test-reporter
172
- requirement: !ruby/object:Gem::Requirement
173
- requirements:
174
- - - "~>"
175
- - !ruby/object:Gem::Version
176
- version: 1.0.0
177
- type: :development
178
- prerelease: false
179
- version_requirements: !ruby/object:Gem::Requirement
180
- requirements:
181
- - - "~>"
182
- - !ruby/object:Gem::Version
183
- version: 1.0.0
184
184
  - !ruby/object:Gem::Dependency
185
185
  name: timecop
186
186
  requirement: !ruby/object:Gem::Requirement
@@ -208,9 +208,11 @@ executables: []
208
208
  extensions: []
209
209
  extra_rdoc_files: []
210
210
  files:
211
+ - ".codeclimate.yml"
211
212
  - ".gitignore"
212
213
  - ".rspec"
213
214
  - ".rubocop.yml"
215
+ - ".rubocop_cc.yml"
214
216
  - ".rubocop_local.yml"
215
217
  - ".travis.yml"
216
218
  - CHANGES
@@ -273,9 +275,9 @@ files:
273
275
  - lib/azure/armrest/virtual_machine_service.rb
274
276
  homepage: http://github.com/ManageIQ/azure-armrest
275
277
  licenses:
276
- - Apache 2.0
278
+ - Apache-2.0
277
279
  metadata: {}
278
- post_install_message:
280
+ post_install_message:
279
281
  rdoc_options: []
280
282
  require_paths:
281
283
  - lib
@@ -290,8 +292,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
292
  - !ruby/object:Gem::Version
291
293
  version: '0'
292
294
  requirements: []
293
- rubygems_version: 3.0.3
294
- signing_key:
295
+ rubygems_version: 3.2.5
296
+ signing_key:
295
297
  specification_version: 4
296
298
  summary: An interface for ARM/JSON Azure REST API
297
299
  test_files: []