azure-armrest 0.8.1 → 0.8.2

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
  SHA1:
3
- metadata.gz: 5510479b90908d095cc2d830f6b711e88c632d50
4
- data.tar.gz: 10a7c8a75d093ee25a9a0e2eb219233dcb6f4f73
3
+ metadata.gz: d60b363c759da6dab61bf6cab4f06bb4b3e9894f
4
+ data.tar.gz: 81762ac7cf167d77dbad0de54419dc521ae9e01b
5
5
  SHA512:
6
- metadata.gz: c6e32191a32c5e81dd84c6ce0c1c1c8a8a5aaa6afde180a0fcf41a00c0597334c5223fb32eb05e15cdcac23a35d86f588d4878b802e4a3c66d8c3f676e2700a9
7
- data.tar.gz: 73f7cd8ce556642de1001f12fa4bea83c15a815d74be1b02205fdc4d47b12f4551680de3bd3e255f34a1da79d5bde5fc986ddb7db090aaa7bbbbf676ea6b685e
6
+ metadata.gz: bd334827961285276ef44a1281cbbb6b36f09b3efba7ef89ad3ca245c50dd046c945968fe4c6d7412b0cec9975b4eb406552d212d6fe939dc9aeaf6c72cdb43c
7
+ data.tar.gz: 0bb36fdb02d2af608483d7296ae5e8e45372e293d0af8b7503c448a2be6182c6de7635c5f20c6268a30d8a7242864c959ea7556023ab2a5ef522a29818f89998
data/CHANGES CHANGED
@@ -1,3 +1,20 @@
1
+ = 0.8.2 - 30-Aug-2017
2
+ * The :list and :list_all methods for the ResourceProviderService class now
3
+ accepts a filter.
4
+ * The :list_all method for the TemplateDeploymentService class now accepts
5
+ a filter.
6
+ * The get_blob_raw method was refactored into a module that both the
7
+ Storage::SnapshotService and Storage::DiskService classes now mixin.
8
+ Thanks go to Jerry Keselman for the PR.
9
+ * Added the :exists? method to the ResourceGroupService class.
10
+ * Added the :exists? method to the TemplateDeploymentService class.
11
+ * The filter for private image collection now ignores case. This addresses
12
+ an issue where private images would not be picked up for regions
13
+ within Canada or India.
14
+ * Added the KeyVaultService class.
15
+ * The :create method in any ResourceGroupBasedService class will now
16
+ automatically camelize hash keys for you.
17
+
1
18
  = 0.8.1 - 4-Aug-2017
2
19
  * Fixed a bug in the DiskService#get_blob_raw method that affected you if you
3
20
  used :start_byte + :length options. Thanks go to Jerry Keselman for the spot.
data/lib/azure/armrest.rb CHANGED
@@ -59,6 +59,7 @@ require 'azure/armrest/role/definition_service'
59
59
  require 'azure/armrest/sql/sql_server_service'
60
60
  require 'azure/armrest/sql/sql_database_service'
61
61
  require 'azure/armrest/billing/usage_service'
62
+ require 'azure/armrest/key_vault_service'
62
63
 
63
64
  # JSON wrapper classes. The service classes should require their own
64
65
  # wrappers from this point on.
@@ -1,4 +1,5 @@
1
1
  require 'time'
2
+ require 'active_support/core_ext/hash/conversions'
2
3
  require_relative 'model/base_model'
3
4
 
4
5
  module Azure
@@ -0,0 +1,40 @@
1
+ # Azure namespace
2
+ module Azure
3
+ # Armrest namespace
4
+ module Armrest
5
+ # Base class for managing key vaults.
6
+ class KeyVaultService < ResourceGroupBasedService
7
+ # Create and return a new KeyVaultService instance.
8
+ #
9
+ def initialize(configuration, options = {})
10
+ super(configuration, 'vaults', 'Microsoft.KeyVault', options)
11
+ end
12
+
13
+ # Gets the deleted Azure key vault.
14
+ #
15
+ def get_deleted(vault_name, location)
16
+ url = File.join(base_url, 'providers', provider, 'locations', location, 'deletedVaults', vault_name)
17
+ url << "?api-version=#{api_version}"
18
+ response = rest_get(url)
19
+ get_all_results(response)
20
+ end
21
+
22
+ # Gets information about the deleted vaults in a subscription.
23
+ #
24
+ def list_deleted
25
+ url = File.join(base_url, 'providers', provider, 'deletedVaults') + "?api-version=#{api_version}"
26
+ response = rest_get(url)
27
+ get_all_results(response)
28
+ end
29
+
30
+ # Permanently removes the deleted +vault_name+ at +location+.
31
+ #
32
+ def purge_deleted(vault_name, location)
33
+ url = File.join(base_url, 'providers', provider, 'locations', location, 'deletedVaults', vault_name, 'purge')
34
+ url << "?api-version=#{api_version}"
35
+ response = rest_post(url)
36
+ get_all_results(response)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -156,6 +156,7 @@ module Azure
156
156
  excl_list = self.class.send(:excl_list)
157
157
  obj.each do |key, value|
158
158
  snake = key.to_s.tr(' ', '_').underscore
159
+ snake.tr!('.', '_')
159
160
 
160
161
  unless excl_list.include?(snake) # Must deal with nested models
161
162
  if value.kind_of?(Array)
@@ -198,6 +199,7 @@ module Azure
198
199
  class ResourceGroup < BaseModel; end
199
200
  class ResourceProvider < BaseModel; end
200
201
  class Sku < BaseModel; end
202
+ class KeyVault < BaseModel; end
201
203
 
202
204
  module Billing
203
205
  class Usage < BaseModel; end
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/hash/conversions'
2
+
1
3
  module Azure
2
4
  module Armrest
3
5
  # Base class for services that need to run in a resource group
@@ -33,13 +35,19 @@ module Azure
33
35
  # status of the resource by inspecting the :response_headers instance and
34
36
  # polling either the :azure_asyncoperation or :location URL.
35
37
  #
38
+ # The +options+ hash keys are automatically converted to camelCase for
39
+ # flexibility, so :createOption and :create_option will both work
40
+ # when creating a virtual machine, for example.
41
+ #
36
42
  def create(name, rgroup = configuration.resource_group, options = {})
37
43
  validate_resource_group(rgroup)
38
44
  validate_resource(name)
39
45
 
40
46
  url = build_url(rgroup, name)
41
47
  url = yield(url) || url if block_given?
42
- response = rest_put(url, options.to_json)
48
+
49
+ body = options.deep_transform_keys{ |k| k.to_s.camelize(:lower) }.to_json
50
+ response = rest_put(url, body)
43
51
 
44
52
  headers = Azure::Armrest::ResponseHeaders.new(response.headers)
45
53
  headers.response_code = response.code
@@ -119,9 +127,7 @@ module Azure
119
127
  #
120
128
  def get_by_id(id_string)
121
129
  info = parse_id_string(id_string)
122
- api_version = api_version_lookup(info['provider'],
123
- info['service_name'],
124
- info['subservice_name'])
130
+ api_version = api_version_lookup(info['provider'], info['service_name'], info['subservice_name'])
125
131
  service_name = info['subservice_name'] || info['service_name'] || 'resourceGroups'
126
132
 
127
133
  url = File.join(configuration.environment.resource_url, id_string) + "?api-version=#{api_version}"
@@ -233,15 +239,38 @@ module Azure
233
239
  #
234
240
  def build_url(resource_group = nil, *args)
235
241
  url = File.join(configuration.environment.resource_url, build_id_string(resource_group, *args))
236
- url << "?api-version=#{@api_version}"
237
242
  end
238
243
 
239
244
  def build_id_string(resource_group = nil, *args)
240
245
  id_string = File.join('', 'subscriptions', configuration.subscription_id)
241
246
  id_string = File.join(id_string, 'resourceGroups', resource_group) if resource_group
242
247
  id_string = File.join(id_string, 'providers', @provider, @service_name)
243
- id_string = File.join(id_string, *args) unless args.empty?
244
- id_string
248
+
249
+ query = "?api-version=#{@api_version}"
250
+
251
+ args.each do |arg|
252
+ if arg.kind_of?(Hash)
253
+ arg.each do |key, value|
254
+ key = key.to_s.camelize(:lower)
255
+
256
+ if key.casecmp('top').zero?
257
+ query << "&$top=#{value}"
258
+ elsif key.casecmp('filter').zero?
259
+ query << "&$filter=#{value}" # Allow raw filter
260
+ else
261
+ if query.include?("$filter")
262
+ query << " and #{key} eq '#{value}'"
263
+ else
264
+ query << "&$filter=#{key} eq '#{value}'"
265
+ end
266
+ end
267
+ end
268
+ else
269
+ id_string = File.join(id_string, arg)
270
+ end
271
+ end
272
+
273
+ id_string + query
245
274
  end
246
275
 
247
276
  # Aggregate resources from all resource groups.
@@ -250,14 +279,15 @@ module Azure
250
279
  # one call. Note that this does not set the skip token because we're
251
280
  # actually collating the results of multiple calls internally.
252
281
  #
253
- def list_in_all_groups
282
+ def list_in_all_groups(options = {})
254
283
  array = []
255
284
  mutex = Mutex.new
256
285
  headers = nil
257
286
  code = nil
258
287
 
259
288
  Parallel.each(list_resource_groups, :in_threads => configuration.max_threads) do |rg|
260
- response = rest_get(build_url(rg.name))
289
+ url = build_url(rg.name, options)
290
+ response = rest_get(url)
261
291
  json_response = JSON.parse(response.body)['value']
262
292
  headers = Azure::Armrest::ResponseHeaders.new(response.headers)
263
293
  code = response.code
@@ -10,6 +10,15 @@ module Azure
10
10
  super(configuration, 'resourceGroups', 'Microsoft.Resources', options)
11
11
  end
12
12
 
13
+ # Returns whether or not the given resource group exists.
14
+ #
15
+ def exists?(group)
16
+ url = build_url(group)
17
+ rest_head(url) and true
18
+ rescue Azure::Armrest::NotFoundException
19
+ false
20
+ end
21
+
13
22
  # List all the resources for the current subscription. You can optionally
14
23
  # pass :top or :filter options as well to restrict returned results. The
15
24
  # :filter option only applies to tags.
@@ -19,25 +19,47 @@ module Azure
19
19
  # List all the providers for the current subscription. The results of
20
20
  # this method are cached.
21
21
  #
22
- def list
23
- response = rest_get(build_url)
24
- resources = JSON.parse(response)["value"]
22
+ def list(options = {})
23
+ url = build_url
24
+
25
+ url << "&$top=#{options[:top]}" if options[:top]
26
+ url << "&$expand=#{options[:expand]}" if options[:expand]
27
+
28
+ response = rest_get(url)
29
+ resources = JSON.parse(response)['value']
25
30
  resources.map{ |hash| Azure::Armrest::ResourceProvider.new(hash) }
26
31
  end
32
+
27
33
  memoize :list
28
34
 
29
35
  # List all the providers for Azure. This may include results that are
30
36
  # not available for the current subscription. The results of this method
31
37
  # are cached.
32
38
  #
33
- def list_all
39
+ # The +options+ hash takes the following options:
40
+ #
41
+ # * :top => Limit the result set to the top x results.
42
+ # * :expand => Additional properties to include in the results.
43
+ #
44
+ # Examples:
45
+ #
46
+ # rps.list_all # Get everything
47
+ # rps.list_all(:top => 3) # Get first 3 results
48
+ # rps.list_all(:expand => 'metadata') # Include metadata in results
49
+ #
50
+ def list_all(options = {})
34
51
  url = File.join(configuration.environment.resource_url, 'providers')
35
52
  url << "?api-version=#{@api_version}"
53
+
54
+ url << "&$top=#{options[:top]}" if options[:top]
55
+ url << "&$expand=#{options[:expand]}" if options[:expand]
56
+
36
57
  response = rest_get(url)
37
58
  resources = JSON.parse(response)['value']
38
59
 
39
60
  resources.map{ |hash| Azure::Armrest::ResourceProvider.new(hash) }
40
61
  end
62
+
41
63
  memoize :list_all
42
64
 
43
65
  # Return information about a specific +namespace+ provider. The results
@@ -48,6 +70,7 @@ module Azure
48
70
  body = rest_get(url).body
49
71
  Azure::Armrest::ResourceProvider.new(body)
50
72
  end
73
+
51
74
  memoize :get
52
75
 
53
76
  # Returns an array of geo-locations for the given +namespace+ provider.
@@ -6,125 +6,14 @@ module Azure
6
6
  module Storage
7
7
  # Base class for managing disks.
8
8
  class DiskService < ResourceGroupBasedService
9
+ require_relative 'managed_storage_helper'
10
+ include Azure::Armrest::Storage::ManagedStorageHelper
11
+
9
12
  # Create and return a new DiskService instance.
10
13
  #
11
14
  def initialize(configuration, options = {})
12
15
  super(configuration, 'disks', 'Microsoft.Compute', options)
13
16
  end
14
-
15
- # Get the raw blob information for a managed disk. This is similar to
16
- # the StorageAccount#get_blob_raw method, but applies only to a managed
17
- # disk, whereas that method applies only to an individual storage
18
- # account.
19
- #
20
- # As with the Storage#get_blob_raw method, you should pass a :range,
21
- # :start_byte, :end_byte or :length option. If you want the entire
22
- # image you must pass the :entire_image option, though this is generally
23
- # not recommended. Unlike the Storage#get_blob_raw method, this method
24
- # does not support the :date parameter.
25
- #
26
- # The +options+ are as follows:
27
- #
28
- # :range => A range of bytes you want, e.g. 0..1023 to get first 1k bytes
29
- # :start_byte => The starting byte number that you want to collect bytes for. Use
30
- # this in conjunction with :length or :end_byte.
31
- # :end_byte => The ending byte that you want to collect bytes for. Use this
32
- # in conjunction with :start_byte.
33
- # :length => If given a :start_byte, specifies the number of bytes from the
34
- # the :start_byte that you wish to collect.
35
- # :entire_image => If set, returns the entire image in bytes. This will be a long
36
- # running request that returns a large number of bytes.
37
- #
38
- # You may also pass a :duration parameter, which indicates how long, in
39
- # seconds, that the privately generated SAS token should last. This token
40
- # is used internally by requests that are used to access the requested
41
- # information. By default it lasts for 1 hour.
42
- #
43
- # Get the information you need using:
44
- #
45
- # * response.body - blob data (the raw bytes).
46
- # * response.headers - blob metadata (a hash).
47
- #
48
- # Example:
49
- #
50
- # vms = Azure::Armrest::VirtualMachineService.new(conf)
51
- # sds = Azure::Armrest::Storage::DiskService.new(conf)
52
- #
53
- # vm = vms.get(vm_name, vm_resource_group)
54
- # os_disk = vm.properties.storage_profile.os_disk
55
- #
56
- # disk_id = os_disk.managed_disk.id
57
- # disk = sds.get_by_id(disk_id)
58
- #
59
- # # Get the first 1024 bytes
60
- # data = sds.get_blob_raw(disk.name, disk.resource_group, :range => 0..1023)
61
- #
62
- # p data.headers
63
- # File.open('vm.vhd', 'a'){ |fh| fh.write(data.body) }
64
- #
65
- def get_blob_raw(disk_name, resource_group = configuration.resource_group, options = {})
66
- validate_resource_group(resource_group)
67
-
68
- post_options = {
69
- :access => 'read', # Must be 'read'
70
- :durationInSeconds => options[:duration] || 3600 # 1 hour default
71
- }
72
-
73
- # This call will give us an operations URL in the headers.
74
- initial_url = build_url(resource_group, disk_name, 'BeginGetAccess')
75
- response = rest_post(initial_url, post_options.to_json)
76
- headers = ResponseHeaders.new(response.headers)
77
-
78
- # Using the URL returned from the above call, make another call that
79
- # will return the URL + SAS token.
80
- op_url = headers.try(:azure_asyncoperation) || headers.location
81
-
82
- unless op_url
83
- msg = "Unable to find an operations URL for #{disk_name}/#{resource_group}"
84
- raise Azure::Armrest::NotFoundException.new(response.code, msg, response.body)
85
- end
86
-
87
- # Dig the URL + SAS token URL out of the response
88
- response = rest_get(op_url)
89
- body = ResponseBody.new(response.body)
90
- sas_url = body.try(:properties).try(:output).try(:access_sas)
91
-
92
- unless sas_url
93
- msg = "Unable to find an SAS URL for #{disk_name}/#{resource_group}"
94
- raise Azure::Armrest::NotFoundException.new(response.code, msg, response.body)
95
- end
96
-
97
- # The same restrictions that apply to the StorageAccont method also apply here.
98
- range = options[:range] if options[:range]
99
-
100
- if options[:start_byte] && options[:end_byte]
101
- range ||= options[:start_byte]..options[:end_byte]
102
- end
103
-
104
- if options[:start_byte] && options[:length]
105
- range ||= options[:start_byte]..((options[:start_byte] + options[:length])-1)
106
- end
107
-
108
- range_str = range ? "bytes=#{range.min}-#{range.max}" : nil
109
-
110
- unless range_str || options[:entire_image]
111
- raise ArgumentError, "must specify byte range or :entire_image flag"
112
- end
113
-
114
- headers = {}
115
- headers['x-ms-range'] = range_str if range_str
116
-
117
- # Need to make a raw call since we need to explicitly pass headers,
118
- # but without encoding the URL or passing our configuration token.
119
- RestClient::Request.execute(
120
- :method => :get,
121
- :url => sas_url,
122
- :headers => headers,
123
- :proxy => configuration.proxy,
124
- :ssl_version => configuration.ssl_version,
125
- :ssl_verify => configuration.ssl_verify
126
- )
127
- end
128
17
  end # DiskService
129
18
  end # Storage
130
19
  end # Armrest
@@ -0,0 +1,123 @@
1
+ module Azure::Armrest::Storage::ManagedStorageHelper
2
+ # Get the raw blob information for a managed disk. This is similar to
3
+ # the StorageAccount#get_blob_raw method, but applies only to a managed
4
+ # disk or its snapshot, whereas that method applies only to an individual storage
5
+ # account.
6
+ #
7
+ # As with the Storage#get_blob_raw method, you should pass a :range,
8
+ # :start_byte, :end_byte or :length option. If you want the entire
9
+ # image you must pass the :entire_image option, though this is generally
10
+ # not recommended. Unlike the Storage#get_blob_raw method, this method
11
+ # does not support the :date parameter.
12
+ #
13
+ # The +options+ are as follows:
14
+ #
15
+ # :range => A range of bytes you want, e.g. 0..1023 to get first 1k bytes
16
+ # :start_byte => The starting byte number that you want to collect bytes for. Use
17
+ # this in conjunction with :length or :end_byte.
18
+ # :end_byte => The ending byte that you want to collect bytes for. Use this
19
+ # in conjunction with :start_byte.
20
+ # :length => If given a :start_byte, specifies the number of bytes from the
21
+ # the :start_byte that you wish to collect.
22
+ # :entire_image => If set, returns the entire image in bytes. This will be a long
23
+ # running request that returns a large number of bytes.
24
+ #
25
+ # You may also pass a :duration parameter, which indicates how long, in
26
+ # seconds, that the privately generated SAS token should last. This token
27
+ # is used internally by requests that are used to access the requested
28
+ # information. By default it lasts for 1 hour.
29
+ #
30
+ # Get the information you need using:
31
+ #
32
+ # * response.body - blob data (the raw bytes).
33
+ # * response.headers - blob metadata (a hash).
34
+ #
35
+ # Example:
36
+ #
37
+ # vms = Azure::Armrest::VirtualMachineService.new(conf)
38
+ # sds = Azure::Armrest::Storage::DiskService.new(conf)
39
+ #
40
+ # vm = vms.get(vm_name, vm_resource_group)
41
+ # os_disk = vm.properties.storage_profile.os_disk
42
+ #
43
+ # disk_id = os_disk.managed_disk.id
44
+ # disk = sds.get_by_id(disk_id)
45
+ #
46
+ # # Get the first 1024 bytes
47
+ # data = sds.get_blob_raw(disk.name, disk.resource_group, :range => 0..1023)
48
+ #
49
+ # p data.headers
50
+ # File.open('vm.vhd', 'a'){ |fh| fh.write(data.body) }
51
+ #
52
+ def get_blob_raw(disk_name, resource_group = configuration.resource_group, options = {})
53
+ validate_resource_group(resource_group)
54
+
55
+ post_options = {
56
+ :access => 'read', # Must be 'read'
57
+ :durationInSeconds => options[:duration] || 3600 # 1 hour default
58
+ }
59
+
60
+ # This call will give us an operations URL in the headers.
61
+ initial_url = build_url(resource_group, disk_name, 'BeginGetAccess')
62
+ response = rest_post(initial_url, post_options.to_json)
63
+ begin
64
+ headers = Azure::Armrest::ResponseHeaders.new(response.headers)
65
+
66
+ # Using the URL returned from the above call, make another call that
67
+ # will return the URL + SAS token.
68
+ op_url = headers.try(:azure_asyncoperation) || headers.location
69
+
70
+ unless op_url
71
+ msg = "Unable to find an operations URL for #{disk_name}/#{resource_group}"
72
+ raise Azure::Armrest::NotFoundException.new(response.code, msg, response.body)
73
+ end
74
+
75
+ # Dig the URL + SAS token URL out of the response
76
+ response = rest_get(op_url)
77
+ body = Azure::Armrest::ResponseBody.new(response.body)
78
+ sas_url = body.try(:properties).try(:output).try(:access_sas)
79
+
80
+ unless sas_url
81
+ msg = "Unable to find an SAS URL for #{disk_name}/#{resource_group}"
82
+ raise Azure::Armrest::NotFoundException.new(response.code, msg, response.body)
83
+ end
84
+
85
+ # The same restrictions that apply to the StorageAccont method also apply here.
86
+ range = options[:range] if options[:range]
87
+ range ||= options[:start_byte]..options[:end_byte] if options[:start_byte] && options[:end_byte]
88
+ range ||= options[:start_byte]..options[:start_byte] + options[:length] - 1 if options[:start_byte] && options[:length]
89
+
90
+ range_str = range ? "bytes=#{range.min}-#{range.max}" : nil
91
+
92
+ unless range_str || options[:entire_image]
93
+ raise ArgumentError, "must specify byte range or :entire_image flag"
94
+ end
95
+
96
+ headers = {}
97
+ headers['x-ms-range'] = range_str if range_str
98
+
99
+ # Need to make a raw call since we need to explicitly pass headers,
100
+ # but without encoding the URL or passing our configuration token.
101
+ max_retries = 5
102
+ retries = 0
103
+ begin
104
+ RestClient::Request.execute(
105
+ :method => :get,
106
+ :url => sas_url,
107
+ :headers => headers,
108
+ :proxy => configuration.proxy,
109
+ :ssl_version => configuration.ssl_version,
110
+ :ssl_verify => configuration.ssl_verify
111
+ )
112
+ rescue RestClient::Exception, Azure::Armrest::ForbiddenException => err
113
+ retries += 1
114
+ raise err unless retries < max_retries
115
+ log('warn', "get_blob_raw: #{err} - retry number #{retries}")
116
+ retry
117
+ end
118
+ ensure
119
+ end_url = build_url(resource_group, disk_name, 'EndGetAccess')
120
+ rest_post(end_url)
121
+ end
122
+ end
123
+ end
@@ -6,6 +6,9 @@ module Azure
6
6
  module Storage
7
7
  # Base class for managing snapshots.
8
8
  class SnapshotService < ResourceGroupBasedService
9
+ require_relative 'managed_storage_helper'
10
+ include Azure::Armrest::Storage::ManagedStorageHelper
11
+
9
12
  # Create and return a new SnapshotService instance.
10
13
  #
11
14
  def initialize(configuration, options = {})
@@ -183,8 +183,19 @@ module Azure
183
183
  #
184
184
  # sas.list_all_private_images(:location => 'eastus', resource_group => 'some_group')
185
185
  #
186
+ # Note that for string values the comparison is caseless.
187
+ #
186
188
  def list_all_private_images(filter = {})
187
- storage_accounts = list_all.select { |acct| filter.all? { |k, v| acct.public_send(k) == v } }
189
+ storage_accounts = list_all.select do |acct|
190
+ filter.all? do |method_name, value|
191
+ if value.kind_of?(String)
192
+ acct.public_send(method_name).casecmp(value).zero?
193
+ else
194
+ acct.public_send(method_name) == value
195
+ end
196
+ end
197
+ end
198
+
188
199
  get_private_images(storage_accounts)
189
200
  end
190
201
 
@@ -13,8 +13,8 @@ module Azure
13
13
  end
14
14
 
15
15
  # Get all deployments for the current subscription
16
- def list_all
17
- list_in_all_groups
16
+ def list_all(filter = {})
17
+ list_in_all_groups(filter)
18
18
  end
19
19
 
20
20
  # Get all operations of a deployment in a resource group
@@ -63,6 +63,15 @@ module Azure
63
63
  delete_resources(resource_ids, resource_ids.size)
64
64
  end
65
65
 
66
+ # Returns whether or not the given deployment exists.
67
+ #
68
+ def exists?(deploy_name, resource_group = configuration.resource_group)
69
+ url = build_url(resource_group, deploy_name)
70
+ rest_head(url) and true
71
+ rescue Azure::Armrest::NotFoundException
72
+ false
73
+ end
74
+
66
75
  private
67
76
 
68
77
  def delete_resources(ids, retry_cnt)
@@ -1,6 +1,6 @@
1
1
  module Azure
2
2
  module Armrest
3
3
  # The version of the azure-armrest library.
4
- VERSION = '0.8.1'.freeze
4
+ VERSION = '0.8.2'.freeze
5
5
  end
6
6
  end
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.8.1
4
+ version: 0.8.2
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: 2017-08-04 00:00:00.000000000 Z
14
+ date: 2017-08-30 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: json
@@ -247,6 +247,7 @@ files:
247
247
  - lib/azure/armrest/insights/diagnostic_service.rb
248
248
  - lib/azure/armrest/insights/event_service.rb
249
249
  - lib/azure/armrest/insights/metrics_service.rb
250
+ - lib/azure/armrest/key_vault_service.rb
250
251
  - lib/azure/armrest/model/base_model.rb
251
252
  - lib/azure/armrest/model/storage_account.rb
252
253
  - lib/azure/armrest/model/virtual_machine.rb
@@ -272,6 +273,7 @@ files:
272
273
  - lib/azure/armrest/sql/sql_server_service.rb
273
274
  - lib/azure/armrest/storage/disk_service.rb
274
275
  - lib/azure/armrest/storage/image_service.rb
276
+ - lib/azure/armrest/storage/managed_storage_helper.rb
275
277
  - lib/azure/armrest/storage/snapshot_service.rb
276
278
  - lib/azure/armrest/storage_account_service.rb
277
279
  - lib/azure/armrest/subscription_service.rb
@@ -300,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
300
302
  version: '0'
301
303
  requirements: []
302
304
  rubyforge_project:
303
- rubygems_version: 2.6.12
305
+ rubygems_version: 2.6.11
304
306
  signing_key:
305
307
  specification_version: 4
306
308
  summary: An interface for ARM/JSON Azure REST API