azure-armrest 0.2.10 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -83,7 +83,7 @@ module Azure
83
83
  mutex = Mutex.new
84
84
 
85
85
  resource_groups.each do |rg|
86
- threads << Thread.new(rg['name']) do |group|
86
+ threads << Thread.new(rg.name) do |group|
87
87
  response = rest_get(build_url(group))
88
88
  results = JSON.parse(response)['value'].map { |hash| model_class.new(hash) }
89
89
  mutex.synchronize { array << results } unless results.blank?
@@ -18,16 +18,16 @@ module Azure
18
18
  #
19
19
  # rgs = ResourceGroupService.new
20
20
  # rgs.list(:top => 2)
21
- # rgs.list(:filter => "sometag=value")
21
+ # rgs.list(:filter => "sometag eq 'value'")
22
22
  #
23
23
  def list(options = {})
24
24
  url = build_url
25
25
  url << "&$top=#{options[:top]}" if options[:top]
26
26
  url << "&$filter=#{options[:filter]}" if options[:filter]
27
27
 
28
- response = rest_get(URI.escape(url))
28
+ response = rest_get(url)
29
29
 
30
- JSON.parse(response)["value"].map{ |hash| Azure::Armrest::ResourceGroup.new(hash) }
30
+ JSON.parse(response)['value'].map { |hash| Azure::Armrest::ResourceGroup.new(hash) }
31
31
  end
32
32
 
33
33
  # Creates a new +group+ in +location+ for the current subscription.
@@ -10,37 +10,29 @@ module Azure
10
10
  super(configuration, 'subscriptions', 'Microsoft.Resources', options)
11
11
  end
12
12
 
13
- # List all the resources for the current subscription. You can optionally
14
- # pass :top or :filter options as well to restrict returned results.
15
- #
16
- # If you pass a :resource_group option, then only resources for that
17
- # resource group are returned.
13
+ # List all the resources for the current subscription in the specified
14
+ # resource group. You can optionally pass :top or :filter options as well
15
+ # to restrict returned results.
18
16
  #
19
17
  # Examples:
20
18
  #
21
- # rs = ResourceService.new
22
- # rs.list(:top => 2)
23
- # rs.list(:filter => "location eq 'centralus'")
19
+ # rs = Azure::Armrest::ResourceService.new
20
+ # rs.list(your_group, :top => 2)
21
+ # rs.list(your_group, :filter => "location eq 'centralus'")
24
22
  #
25
- def list(options = {})
26
- subscription_id = configuration.subscription_id
27
-
28
- if options[:resource_group]
29
- url = File.join(
30
- Azure::Armrest::COMMON_URI, subscription_id, 'resourcegroups',
31
- options[:resource_group], 'resources'
32
- )
33
- else
34
- url = File.join(Azure::Armrest::COMMON_URI, subscription_id, 'resources')
35
- end
36
-
37
- url << "?api-version=#{@api_version}"
38
- url << "&$top=#{options[:top]}" if options[:top]
39
- url << "&$filter=#{options[:filter]}" if options[:filter]
40
-
41
- response = rest_get(URI.escape(url))
23
+ def list(resource_group, options = {})
24
+ url = build_url(resource_group, options)
25
+ response = rest_get(url)
26
+ JSON.parse(response)['value'].map { |hash| Azure::Armrest::Resource.new(hash) }
27
+ end
42
28
 
43
- JSON.parse(response)["value"].map{ |hash| Azure::Armrest::Resource.new(hash) }
29
+ # Same as Azure::Armrest::ResourceService#list but returns all resources
30
+ # for all resource groups.
31
+ #
32
+ def list_all(options = {})
33
+ url = build_url(nil, options)
34
+ response = rest_get(url)
35
+ JSON.parse(response)['value'].map { |hash| Azure::Armrest::Resource.new(hash) }
44
36
  end
45
37
 
46
38
  # Move the resources from +source_group+ under +source_subscription+,
@@ -79,6 +71,23 @@ module Azure
79
71
  check_resource(resource_name, resource_type)['status'] == 'Allowed'
80
72
  end
81
73
 
74
+ private
75
+
76
+ def build_url(resource_group = nil, options = {})
77
+ url = File.join(Azure::Armrest::COMMON_URI, configuration.subscription_id)
78
+
79
+ if resource_group
80
+ url = File.join(url, 'resourceGroups', resource_group, 'resources')
81
+ else
82
+ url = File.join(url, 'resources')
83
+ end
84
+
85
+ url << "?api-version=#{@api_version}"
86
+ url << "&$top=#{options[:top]}" if options[:top]
87
+ url << "&$filter=#{options[:filter]}" if options[:filter]
88
+
89
+ url
90
+ end
82
91
  end # ResourceService
83
92
  end # Armrest
84
93
  end # Azure
@@ -4,15 +4,6 @@ module Azure
4
4
  module Armrest
5
5
  # Class for managing storage accounts.
6
6
  class StorageAccountService < ResourceGroupBasedService
7
-
8
- # Valid account types for the create or update method.
9
- VALID_ACCOUNT_TYPES = %w[
10
- Standard_LRS
11
- Standard_ZRS
12
- Standard_GRS
13
- Standard_RAGRS
14
- ]
15
-
16
7
  # Creates and returns a new StorageAccountService (SAS) instance.
17
8
  #
18
9
  def initialize(configuration, options = {})
@@ -89,7 +80,6 @@ module Azure
89
80
  #
90
81
  def create(account_name, rgroup = configuration.resource_group, options)
91
82
  validating = options.delete(:validating)
92
- validate_account_type(options[:properties][:accountType])
93
83
  validate_account_name(account_name)
94
84
 
95
85
  acct = super(account_name, rgroup, options) do |url|
@@ -222,7 +212,7 @@ module Azure
222
212
  end
223
213
 
224
214
  def parse_uri(uri)
225
- uri = URI.parse(uri)
215
+ uri = Addressable::URI.parse(uri)
226
216
  host_components = uri.host.split('.')
227
217
 
228
218
  rh = {
@@ -261,13 +251,7 @@ module Azure
261
251
 
262
252
  storage_accounts.each do |lstorage_account|
263
253
  threads << Thread.new(lstorage_account) do |storage_account|
264
- begin
265
- key = get_account_key(storage_account)
266
- rescue Azure::Armrest::ApiException => err
267
- # Most likely because the storage account isn't completely provisioned
268
- # yet or provisioning of the account was not successful
269
- next
270
- end
254
+ key = get_account_key(storage_account)
271
255
 
272
256
  storage_account.all_blobs(key).each do |blob|
273
257
  next unless File.extname(blob.name).casecmp('.vhd') == 0
@@ -336,12 +320,6 @@ module Azure
336
320
  hash
337
321
  end
338
322
 
339
- def validate_account_type(account_type)
340
- unless VALID_ACCOUNT_TYPES.include?(account_type)
341
- raise ArgumentError, "invalid account type '#{account_type}'"
342
- end
343
- end
344
-
345
323
  def validate_account_name(name)
346
324
  if name.size < 3 || name.size > 24 || name[/\W+/]
347
325
  raise ArgumentError, "name must be 3-24 alpha-numeric characters only"
@@ -1,5 +1,5 @@
1
1
  module Azure
2
2
  module Armrest
3
- VERSION = '0.2.10'.freeze
3
+ VERSION = '0.3.0'.freeze
4
4
  end
5
5
  end
@@ -17,14 +17,15 @@ module Azure
17
17
  end
18
18
 
19
19
  # Return a list of available VM series (aka sizes, flavors, etc), such
20
- # as "Basic_A1", though information is included as well.
20
+ # as "Basic_A1", though other information is included as well.
21
21
  #
22
22
  def series(location)
23
- unless @@providers_hash[provider.downcase] && @@providers_hash[provider.downcase]['locations/vmsizes']
24
- raise ArgumentError, "Invalid provider '#{provider}'"
25
- end
23
+ namespace = 'microsoft.compute'
24
+ version = configuration.provider_default_api_version(namespace, 'locations/vmsizes')
26
25
 
27
- version = @@providers_hash[provider.downcase]['locations/vmsizes']['api_version']
26
+ unless version
27
+ raise ArgumentError, "Unable to find resources for #{namespace}"
28
+ end
28
29
 
29
30
  url = url_with_api_version(
30
31
  version, @base_url, 'subscriptions', configuration.subscription_id,
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.2.10
4
+ version: 0.3.0
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-09-15 00:00:00.000000000 Z
14
+ date: 2016-06-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: json
@@ -97,6 +97,20 @@ dependencies:
97
97
  - - "~>"
98
98
  - !ruby/object:Gem::Version
99
99
  version: 1.6.0
100
+ - !ruby/object:Gem::Dependency
101
+ name: addressable
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: 2.4.0
107
+ type: :runtime
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: 2.4.0
100
114
  - !ruby/object:Gem::Dependency
101
115
  name: bundler
102
116
  requirement: !ruby/object:Gem::Requirement
@@ -194,6 +208,8 @@ files:
194
208
  - lib/azure/armrest/armrest_collection.rb
195
209
  - lib/azure/armrest/armrest_service.rb
196
210
  - lib/azure/armrest/availability_set_service.rb
211
+ - lib/azure/armrest/billing/usage_service.rb
212
+ - lib/azure/armrest/configuration.rb
197
213
  - lib/azure/armrest/exception.rb
198
214
  - lib/azure/armrest/insights/alert_service.rb
199
215
  - lib/azure/armrest/insights/event_service.rb