azure-armrest 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +11 -0
- data/README.md +1 -0
- data/azure-armrest.gemspec +4 -4
- data/lib/azure/armrest/configuration.rb +48 -0
- data/lib/azure/armrest/resource_group_based_service.rb +12 -2
- data/lib/azure/armrest/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea7b40c1bcbf87f8a1a90bd6de8b3a8b91009319
|
4
|
+
data.tar.gz: 7c01a3f8b1e329c8897b7079bf776e2fa7f09633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f64da1aa17e62f474c429bca7ec0fa0923e0f80511f54209a6847402f3fb37aaa4ff1d22d5f8892d7d7525f422d89b7efebd44bde8e1fc86b95f6c224aec9956
|
7
|
+
data.tar.gz: ea7848938983ce162de715df0d8982b09dab459443861fa1aee3344c6aa127b53cff0133f23d38b104f3e99b437f7a036193419b84875539802112ccc9dbb486
|
data/CHANGES
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
= 0.3.2 - 21-Jul-2016
|
2
|
+
* The subscription ID is now automatically validated in the
|
3
|
+
Azure::Armrest::Configuration constructor.
|
4
|
+
* Added a Hakiri badge to the README.
|
5
|
+
* There have been some minor updates to the dependencies to enforce
|
6
|
+
more recent versions of external gems, as suggested by Hakiri,
|
7
|
+
for security reasons.
|
8
|
+
* The ResourceGroupBasedService#list_all method (and all subclasses)
|
9
|
+
now supports an optional hash that can be used to automatically
|
10
|
+
filter result sets.
|
11
|
+
|
1
12
|
= 0.3.1 - 14-Jul-2016
|
2
13
|
* Now uses the parallel gem and thread pools for those few methods where
|
3
14
|
we were using threaded methods internally in order to reduce errors
|
data/README.md
CHANGED
@@ -7,6 +7,7 @@ A Ruby interface for Azure using the new REST API.
|
|
7
7
|
[![Code Climate](https://codeclimate.com/github/ManageIQ/azure-armrest/badges/gpa.svg)](https://codeclimate.com/github/ManageIQ/azure-armrest)
|
8
8
|
[![Test Coverage](https://codeclimate.com/github/ManageIQ/azure-armrest/badges/coverage.svg)](https://codeclimate.com/github/ManageIQ/azure-armrest/coverage)
|
9
9
|
[![Dependency Status](https://gemnasium.com/ManageIQ/azure-armrest.svg)](https://gemnasium.com/ManageIQ/azure-armrest)
|
10
|
+
[![Security](https://hakiri.io/github/ManageIQ/azure-armrest/master.svg)](https://hakiri.io/github/ManageIQ/azure-armrest/master)
|
10
11
|
|
11
12
|
## Synopsis
|
12
13
|
|
data/azure-armrest.gemspec
CHANGED
@@ -19,12 +19,12 @@ different than the current azure gem, which uses the older (XML) interface
|
|
19
19
|
behind the scenes.
|
20
20
|
EOF
|
21
21
|
|
22
|
-
spec.add_dependency 'json'
|
22
|
+
spec.add_dependency 'json', '~> 2.0.1'
|
23
23
|
spec.add_dependency 'rest-client', '~> 2.0.0'
|
24
24
|
spec.add_dependency 'cache_method', '~> 0.2.7'
|
25
|
-
spec.add_dependency 'azure-signature', '~> 0.2.
|
26
|
-
spec.add_dependency 'activesupport', '>=
|
27
|
-
spec.add_dependency 'nokogiri', '~> 1.6.
|
25
|
+
spec.add_dependency 'azure-signature', '~> 0.2.3'
|
26
|
+
spec.add_dependency 'activesupport', '>= 4.2.2'
|
27
|
+
spec.add_dependency 'nokogiri', '~> 1.6.8'
|
28
28
|
spec.add_dependency 'addressable', '~> 2.4.0'
|
29
29
|
spec.add_dependency 'parallel', '~> 1.9.0'
|
30
30
|
|
@@ -80,6 +80,10 @@ module Azure
|
|
80
80
|
# Although you can specify an :api_version, it is typically overridden
|
81
81
|
# by individual service classes.
|
82
82
|
#
|
83
|
+
# Note that while the constructor will fail if invalid credentials are
|
84
|
+
# supplied, it does not validate your subscription ID. If you want to
|
85
|
+
# validate your subscription ID as well, use the validate_subscription! method.
|
86
|
+
#
|
83
87
|
def initialize(args)
|
84
88
|
# Use defaults, and override with provided arguments
|
85
89
|
options = {
|
@@ -100,6 +104,8 @@ module Azure
|
|
100
104
|
raise ArgumentError, "client_id, client_key, tenant_id and subscription_id must all be specified"
|
101
105
|
end
|
102
106
|
|
107
|
+
validate_subscription
|
108
|
+
|
103
109
|
if user_token && user_token_expiration
|
104
110
|
set_token(user_token, user_token_expiration)
|
105
111
|
elsif user_token || user_token_expiration
|
@@ -170,6 +176,48 @@ module Azure
|
|
170
176
|
|
171
177
|
private
|
172
178
|
|
179
|
+
# Validate the subscription ID for the given credentials.
|
180
|
+
#
|
181
|
+
# If the subscription ID that was provided in the constructor cannot
|
182
|
+
# be found within the list of valid subscriptions, then an error is
|
183
|
+
# raised.
|
184
|
+
#
|
185
|
+
# If the subscription ID that was provided is found but disabled
|
186
|
+
# then a warning will be issued, but no error will be raised.
|
187
|
+
#
|
188
|
+
def validate_subscription
|
189
|
+
url = File.join(Azure::Armrest::RESOURCE, 'subscriptions') + "?api-version=#{api_version}"
|
190
|
+
|
191
|
+
options = {
|
192
|
+
:url => url,
|
193
|
+
:proxy => proxy,
|
194
|
+
:ssl_version => ssl_version,
|
195
|
+
:ssl_verify => ssl_verify,
|
196
|
+
:headers => {
|
197
|
+
:accept => accept,
|
198
|
+
:content_type => content_type,
|
199
|
+
:authorization => token
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
response = Azure::Armrest::ArmrestService.send(:rest_get, options)
|
204
|
+
json = JSON.parse(response.body)['value']
|
205
|
+
|
206
|
+
subscriptions = json.map { |hash| [hash['subscriptionId'], hash['state']] }
|
207
|
+
|
208
|
+
found = subscriptions.find { |array| array.first == subscription_id }
|
209
|
+
|
210
|
+
unless found
|
211
|
+
raise ArgumentError, "Subscription ID '#{subscription_id}' not found"
|
212
|
+
end
|
213
|
+
|
214
|
+
if found.last.casecmp("enabled") != 0
|
215
|
+
warn "Subscription '#{found.first}' found but not enabled."
|
216
|
+
end
|
217
|
+
|
218
|
+
true
|
219
|
+
end
|
220
|
+
|
173
221
|
def ensure_token
|
174
222
|
@token, @token_expiration = self.class.retrieve_token(self) if @token.nil?
|
175
223
|
fetch_token if @token.nil? || Time.now.utc > @token_expiration
|
@@ -23,11 +23,21 @@ module Azure
|
|
23
23
|
JSON.parse(response)['value'].map { |hash| model_class.new(hash) }
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
# Use a single call to get all resources for the service. You may
|
27
|
+
# optionally provide a filter on various properties to limit the
|
28
|
+
# result set.
|
29
|
+
#
|
30
|
+
# Example:
|
31
|
+
#
|
32
|
+
# vms = Azure::Armrest::VirtualMachineService.new(conf)
|
33
|
+
# vms.list_all(:location => "eastus", :resource_group => "rg1")
|
34
|
+
#
|
35
|
+
def list_all(filter = {})
|
27
36
|
url = build_url
|
28
37
|
url = yield(url) || url if block_given?
|
29
38
|
response = rest_get(url)
|
30
|
-
JSON.parse(response)['value'].map { |hash| model_class.new(hash) }
|
39
|
+
results = JSON.parse(response)['value'].map { |hash| model_class.new(hash) }
|
40
|
+
filter.empty? ? results : results.select { |obj| filter.all? { |k, v| obj.public_send(k) == v } }
|
31
41
|
end
|
32
42
|
|
33
43
|
def get(name, rgroup = configuration.resource_group)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azure-armrest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -11,22 +11,22 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-07-
|
14
|
+
date: 2016-07-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: json
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
|
-
- - "
|
20
|
+
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 2.0.1
|
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:
|
29
|
+
version: 2.0.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rest-client
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,42 +61,42 @@ dependencies:
|
|
61
61
|
requirements:
|
62
62
|
- - "~>"
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.2.
|
64
|
+
version: 0.2.3
|
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.2.
|
71
|
+
version: 0.2.3
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: activesupport
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
76
|
- - ">="
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
78
|
+
version: 4.2.2
|
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:
|
85
|
+
version: 4.2.2
|
86
86
|
- !ruby/object:Gem::Dependency
|
87
87
|
name: nokogiri
|
88
88
|
requirement: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
90
|
- - "~>"
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: 1.6.
|
92
|
+
version: 1.6.8
|
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: 1.6.
|
99
|
+
version: 1.6.8
|
100
100
|
- !ruby/object:Gem::Dependency
|
101
101
|
name: addressable
|
102
102
|
requirement: !ruby/object:Gem::Requirement
|