azure-armrest 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +14 -0
- data/lib/azure/armrest.rb +4 -0
- data/lib/azure/armrest/model/base_model.rb +6 -0
- data/lib/azure/armrest/model/storage_account.rb +92 -18
- data/lib/azure/armrest/network/inbound_nat_service.rb +12 -0
- data/lib/azure/armrest/network/load_balancer_service.rb +14 -0
- data/lib/azure/armrest/network/route_service.rb +12 -0
- data/lib/azure/armrest/network/route_table_service.rb +14 -0
- data/lib/azure/armrest/resource_group_based_service.rb +16 -2
- data/lib/azure/armrest/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25599bb89027a9662c3f4b47a582db0bb112c9ef
|
4
|
+
data.tar.gz: 80c069a284b706e81c139f2c1ae64f276084aba5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a91dfecc724c56d950fd4b33a90a3efed24c1a58b22fa63b1ea003bf02c0594792978d8643ee97cc7897f04139f0e9ef1905de2c81774bc7f4d45ffb05ecba94
|
7
|
+
data.tar.gz: 9473b0a19e8275664d39afb7f264a37fbd47fdcccd7a93a7ef3fc2df36b446a5a8407efb7407eaab757d41297c5713c6d4016c09ab5f2cdb5b6d590938e03705
|
data/CHANGES
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
= 0.3.4 - 9-Aug-2016
|
2
|
+
* Modified the StorageAccount#blobs and StorageAccount#containers method. Both
|
3
|
+
now accept a hash of options that you can use to modify the results. Also,
|
4
|
+
both now automatically handle continuation tokens to collect all results.
|
5
|
+
* The ResourceGroupBasedService#delete method now returns a ResponseHeaders
|
6
|
+
object instead of nil. Furthermore, it will raise an error on a 204 response
|
7
|
+
which indicates that the resource wasn't actually found.
|
8
|
+
* Added the Network::LoadBalancerService and Network::InboundNatService classes.
|
9
|
+
* Added the Network::RouteService and Network::RouteTableService classes.
|
10
|
+
|
1
11
|
= 0.3.3 - 1-Aug-2016
|
2
12
|
* Added the :max_threads configuration option. This is used internally wherever
|
3
13
|
the Parallel gem is used.
|
@@ -39,6 +49,10 @@
|
|
39
49
|
* StorageAccountService no longer does account type validation.
|
40
50
|
* Added the StorageAccountService#list_all_private_images method.
|
41
51
|
|
52
|
+
= 0.2.8 - 22-Jul-2016
|
53
|
+
* Backported PR #188 (add list_all_private_images method).
|
54
|
+
* Backported PR #194 (updated .travis.yml).
|
55
|
+
|
42
56
|
= 0.2.7 - 20-Jun-2016
|
43
57
|
* All internal calls to rest-client are now explicitly URI.encoded.
|
44
58
|
|
data/lib/azure/armrest.rb
CHANGED
@@ -40,10 +40,14 @@ require 'azure/armrest/resource_provider_service'
|
|
40
40
|
require 'azure/armrest/insights/alert_service'
|
41
41
|
require 'azure/armrest/insights/event_service'
|
42
42
|
require 'azure/armrest/insights/metrics_service'
|
43
|
+
require 'azure/armrest/network/load_balancer_service'
|
44
|
+
require 'azure/armrest/network/inbound_nat_service'
|
43
45
|
require 'azure/armrest/network/ip_address_service'
|
44
46
|
require 'azure/armrest/network/network_interface_service'
|
45
47
|
require 'azure/armrest/network/network_security_group_service'
|
46
48
|
require 'azure/armrest/network/network_security_rule_service'
|
49
|
+
require 'azure/armrest/network/route_table_service'
|
50
|
+
require 'azure/armrest/network/route_service'
|
47
51
|
require 'azure/armrest/network/virtual_network_service'
|
48
52
|
require 'azure/armrest/network/subnet_service'
|
49
53
|
require 'azure/armrest/role/assignment_service'
|
@@ -194,6 +194,8 @@ module Azure
|
|
194
194
|
class Sku < BaseModel; end
|
195
195
|
class Usage < BaseModel; end
|
196
196
|
|
197
|
+
class ResponseHeaders < BaseModel; end
|
198
|
+
|
197
199
|
class StorageAccount < BaseModel; end
|
198
200
|
class StorageAccountKey < StorageAccount
|
199
201
|
def key1; key_name == 'key1' ? value : nil; end
|
@@ -222,10 +224,14 @@ module Azure
|
|
222
224
|
end
|
223
225
|
|
224
226
|
module Network
|
227
|
+
class LoadBalancer < BaseModel; end
|
228
|
+
class InboundNat < LoadBalancer; end
|
225
229
|
class IpAddress < BaseModel; end
|
226
230
|
class NetworkInterface < BaseModel; end
|
227
231
|
class NetworkSecurityGroup < BaseModel; end
|
228
232
|
class NetworkSecurityRule < NetworkSecurityGroup; end
|
233
|
+
class RouteTable < BaseModel; end
|
234
|
+
class Route < RouteTable; end
|
229
235
|
class VirtualNetwork < BaseModel; end
|
230
236
|
class Subnet < VirtualNetwork; end
|
231
237
|
end
|
@@ -119,14 +119,51 @@ module Azure
|
|
119
119
|
# If no key is provided, it is assumed that the StorageAccount object
|
120
120
|
# includes the key1 property.
|
121
121
|
#
|
122
|
-
|
122
|
+
# # The following options are supported:
|
123
|
+
#
|
124
|
+
# * prefix
|
125
|
+
# * delimiter
|
126
|
+
# * maxresults
|
127
|
+
# * include
|
128
|
+
# * timeout
|
129
|
+
#
|
130
|
+
# By default Azure uses a value of 5000 for :maxresults.
|
131
|
+
#
|
132
|
+
# If the :include option is specified, it should contain an array of
|
133
|
+
# one element: metadata. More options may be added by Microsoft
|
134
|
+
# at a later date.
|
135
|
+
#
|
136
|
+
# Example:
|
137
|
+
#
|
138
|
+
# sas = Azure::Armrest::StorageAccountService.new(conf)
|
139
|
+
# key = sas.list_account_keys['key1']
|
140
|
+
# acct = sas.get('your_storage_account', 'your_resource_group')
|
141
|
+
#
|
142
|
+
# p acct.containers(key)
|
143
|
+
# p acct.containers(key, :include => ['metadata'])
|
144
|
+
# p acct.containers(key, :maxresults => 1)
|
145
|
+
#
|
146
|
+
# In cases where a NextMarker element is found in the original response,
|
147
|
+
# another call will automatically be made with the marker value included
|
148
|
+
# in the URL so that you don't have to perform such a step manually.
|
149
|
+
#
|
150
|
+
def containers(key = nil, options = {})
|
123
151
|
key ||= properties.key1
|
124
152
|
|
125
|
-
|
153
|
+
query = "comp=list"
|
154
|
+
options.each { |okey, ovalue| query += "&#{okey}=#{[ovalue].flatten.join(',')}" }
|
155
|
+
|
156
|
+
response = blob_response(key, query)
|
126
157
|
|
127
|
-
Nokogiri::XML(response.body)
|
158
|
+
doc = Nokogiri::XML(response.body)
|
159
|
+
|
160
|
+
results = doc.xpath('//Containers/Container').collect do |element|
|
128
161
|
Container.new(Hash.from_xml(element.to_s)['Container'])
|
129
162
|
end
|
163
|
+
|
164
|
+
results << next_marker_results(doc, :containers, key, options)
|
165
|
+
|
166
|
+
results.flatten
|
130
167
|
end
|
131
168
|
|
132
169
|
# Returns the properties for the given container +name+ using account +key+.
|
@@ -184,30 +221,52 @@ module Azure
|
|
184
221
|
# Return a list of blobs for the given +container+ using the given +key+
|
185
222
|
# or the key1 property of the StorageAccount object.
|
186
223
|
#
|
187
|
-
|
224
|
+
# The following options are supported:
|
225
|
+
#
|
226
|
+
# * prefix
|
227
|
+
# * delimiter
|
228
|
+
# * maxresults
|
229
|
+
# * include
|
230
|
+
# * timeout
|
231
|
+
#
|
232
|
+
# By default Azure uses a value of 5000 for :maxresults.
|
233
|
+
#
|
234
|
+
# If the :include option is specified, it should contain an array of
|
235
|
+
# one or more of the following values: snapshots, metadata, copy or
|
236
|
+
# uncommittedblobs.
|
237
|
+
#
|
238
|
+
# Example:
|
239
|
+
#
|
240
|
+
# sas = Azure::Armrest::StorageAccountService.new(conf)
|
241
|
+
# key = sas.list_account_keys['key1']
|
242
|
+
# acct = sas.get('your_storage_account', 'your_resource_group')
|
243
|
+
#
|
244
|
+
# p acct.blobs('vhds', key)
|
245
|
+
# p acct.blobs('vhds', key, :timeout => 30)
|
246
|
+
# p acct.blobs('vhds', key, :include => ['snapshots', 'metadata'])
|
247
|
+
#
|
248
|
+
# In cases where a NextMarker element is found in the original response,
|
249
|
+
# another call will automatically be made with the marker value included
|
250
|
+
# in the URL so that you don't have to perform such a step manually.
|
251
|
+
#
|
252
|
+
def blobs(container, key = nil, options = {})
|
188
253
|
key ||= properties.key1
|
189
254
|
|
190
|
-
|
191
|
-
|
192
|
-
url += "&include=snapshots" if include_snapshot
|
255
|
+
query = "restype=container&comp=list"
|
256
|
+
options.each { |okey, ovalue| query += "&#{okey}=#{[ovalue].flatten.join(',')}" }
|
193
257
|
|
194
|
-
|
195
|
-
|
196
|
-
response = ArmrestService.send(
|
197
|
-
:rest_get,
|
198
|
-
:url => url,
|
199
|
-
:headers => headers,
|
200
|
-
:proxy => proxy,
|
201
|
-
:ssl_version => ssl_version,
|
202
|
-
:ssl_verify => ssl_verify
|
203
|
-
)
|
258
|
+
response = blob_response(key, query, container)
|
204
259
|
|
205
260
|
doc = Nokogiri::XML(response.body)
|
206
261
|
|
207
|
-
doc.xpath('//Blobs/Blob').
|
262
|
+
results = doc.xpath('//Blobs/Blob').collect do |node|
|
208
263
|
hash = Hash.from_xml(node.to_s)['Blob'].merge(:container => container)
|
209
264
|
hash.key?('Snapshot') ? BlobSnapshot.new(hash) : Blob.new(hash)
|
210
265
|
end
|
266
|
+
|
267
|
+
results << next_marker_results(doc, :blobs, container, key, options)
|
268
|
+
|
269
|
+
results.flatten
|
211
270
|
end
|
212
271
|
|
213
272
|
# Returns an array of all blobs for all containers.
|
@@ -545,6 +604,21 @@ module Azure
|
|
545
604
|
|
546
605
|
headers
|
547
606
|
end
|
607
|
+
|
608
|
+
# Generic method to handle NextMarker token. The +doc+ should be an
|
609
|
+
# XML object that responds to .xpath, followed by a method name,
|
610
|
+
# followed by any arguments to pass to that method.
|
611
|
+
#
|
612
|
+
def next_marker_results(doc, method_name, *args)
|
613
|
+
xmarker = doc.xpath('//NextMarker').first # There is only one
|
614
|
+
if xmarker.children.empty?
|
615
|
+
return []
|
616
|
+
else
|
617
|
+
args = args.dup # Avoid modifying original argument
|
618
|
+
args.last[:marker] = xmarker.children.first.to_s
|
619
|
+
return send(method_name, *args)
|
620
|
+
end
|
621
|
+
end
|
548
622
|
end
|
549
623
|
end
|
550
624
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Azure
|
2
|
+
module Armrest
|
3
|
+
module Network
|
4
|
+
# Base class for managing subnets
|
5
|
+
class InboundNatService < ResourceGroupBasedSubservice
|
6
|
+
def initialize(armrest_configuration, options = {})
|
7
|
+
super(armrest_configuration, 'loadBalancers', 'inboundNatRules', 'Microsoft.Network', options)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end # Network
|
11
|
+
end # Armrest
|
12
|
+
end # Azure
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Azure
|
2
|
+
module Armrest
|
3
|
+
module Network
|
4
|
+
# Class for managing load balancers
|
5
|
+
class LoadBalancerService < ResourceGroupBasedService
|
6
|
+
# Creates and returns a new LoadBalancerService instance.
|
7
|
+
#
|
8
|
+
def initialize(armrest_configuration, options = {})
|
9
|
+
super(armrest_configuration, 'loadBalancers', 'Microsoft.Network', options)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end # Network
|
13
|
+
end # Armrest
|
14
|
+
end # Azure
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Azure
|
2
|
+
module Armrest
|
3
|
+
module Network
|
4
|
+
# Base class for managing subnets
|
5
|
+
class RouteService < ResourceGroupBasedSubservice
|
6
|
+
def initialize(armrest_configuration, options = {})
|
7
|
+
super(armrest_configuration, 'routeTables', 'routes', 'Microsoft.Network', options)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end # Network
|
11
|
+
end # Armrest
|
12
|
+
end # Azure
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Azure
|
2
|
+
module Armrest
|
3
|
+
module Network
|
4
|
+
# Class for managing load balancers
|
5
|
+
class RouteTableService < ResourceGroupBasedService
|
6
|
+
# Creates and returns a new LoadBalancerService instance.
|
7
|
+
#
|
8
|
+
def initialize(armrest_configuration, options = {})
|
9
|
+
super(armrest_configuration, 'routeTables', 'Microsoft.Network', options)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end # Network
|
13
|
+
end # Armrest
|
14
|
+
end # Azure
|
@@ -50,14 +50,28 @@ module Azure
|
|
50
50
|
model_class.new(response)
|
51
51
|
end
|
52
52
|
|
53
|
+
# Delete the resource with the given +name+ for the provided +resource_group+,
|
54
|
+
# or the resource group specified in your original configuration object. If
|
55
|
+
# successful, returns a ResponseHeaders object.
|
56
|
+
#
|
57
|
+
# If the delete operation returns a 204 (no body), which is what the Azure
|
58
|
+
# REST API typically returns if the resource is not found, it is treated
|
59
|
+
# as an error and a ResourceNotFoundException is raised.
|
60
|
+
#
|
53
61
|
def delete(name, rgroup = configuration.resource_group)
|
54
62
|
validate_resource_group(rgroup)
|
55
63
|
validate_resource(name)
|
56
64
|
|
57
65
|
url = build_url(rgroup, name)
|
58
66
|
url = yield(url) || url if block_given?
|
59
|
-
rest_delete(url)
|
60
|
-
|
67
|
+
response = rest_delete(url)
|
68
|
+
|
69
|
+
if response.code == 204
|
70
|
+
msg = "#{self.class} resource #{rgroup}/#{name} not found"
|
71
|
+
raise Azure::Armrest::ResourceNotFoundException.new(response.code, msg, response)
|
72
|
+
end
|
73
|
+
|
74
|
+
Azure::Armrest::ResponseHeaders.new(response.headers)
|
61
75
|
end
|
62
76
|
|
63
77
|
private
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-08-
|
14
|
+
date: 2016-08-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: json
|
@@ -230,10 +230,14 @@ files:
|
|
230
230
|
- lib/azure/armrest/insights/metrics_service.rb
|
231
231
|
- lib/azure/armrest/model/base_model.rb
|
232
232
|
- lib/azure/armrest/model/storage_account.rb
|
233
|
+
- lib/azure/armrest/network/inbound_nat_service.rb
|
233
234
|
- lib/azure/armrest/network/ip_address_service.rb
|
235
|
+
- lib/azure/armrest/network/load_balancer_service.rb
|
234
236
|
- lib/azure/armrest/network/network_interface_service.rb
|
235
237
|
- lib/azure/armrest/network/network_security_group_service.rb
|
236
238
|
- lib/azure/armrest/network/network_security_rule_service.rb
|
239
|
+
- lib/azure/armrest/network/route_service.rb
|
240
|
+
- lib/azure/armrest/network/route_table_service.rb
|
237
241
|
- lib/azure/armrest/network/subnet_service.rb
|
238
242
|
- lib/azure/armrest/network/virtual_network_service.rb
|
239
243
|
- lib/azure/armrest/resource_group_based_service.rb
|