azure-armrest 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e916135112c85ebd2e061a02e63091e8eb6a629
4
- data.tar.gz: a3c229e0a8fdf72bd06f81da392273548d5cb62a
3
+ metadata.gz: db15c7c2486506cdae662e57d6a5ff870a405537
4
+ data.tar.gz: 94a95cd28468371f916dab1394cb25f7a6f23773
5
5
  SHA512:
6
- metadata.gz: bbdbea8e75c851b6ada07023ad9b6e4cce25a6cae9f14ab4e579030538518fd7489a86ae318786bfca0f512a951090fa9059ca2a2b772859b98fd1fcd6756a6f
7
- data.tar.gz: b327fa9ceea6ebda436f4f51aa5bf4db18d75735f884a1566c48d835a807201f0e31492dca373e709ad49585dceebaaf4e46bb9737163be2a773b327f05453e9
6
+ metadata.gz: c6bb034e35c08f91d1a34f4454ba4bc53af3ec8c263665b5d9a423273cc6534542fe061afd254e20c0d58d5c6f8d69c8bb04e2b8730d5bf60b3c360e24f68b4f
7
+ data.tar.gz: ce4243411b2067a1371c8305d553068fd1d9e5baea71960ceb3a02d5bec928e6f3ee044374d4134025f474422e4b189f04ef88739b0231e672486cab88969d72
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ = 0.1.2 - 2-Mar-2016
2
+ * When selecting the appropriate api version string, we now reject dates
3
+ that are ahead of the current date.
4
+ * Some minor rubocop cleanup.
5
+
1
6
  = 0.1.1 - 26-Feb-2016
2
7
  * Added proxy support for both the storage model and main configure method.
3
8
  * Added the SqlDatabaseService and SqlServerService classes.
@@ -1,3 +1,4 @@
1
+ require 'time'
1
2
  require_relative 'model/base_model'
2
3
 
3
4
  module Azure
@@ -59,6 +60,8 @@ module Azure
59
60
  # Configuration to access azure APIs
60
61
  attr_accessor :armrest_configuration
61
62
 
63
+ alias configuration armrest_configuration
64
+
62
65
  # Base url used for REST calls.
63
66
  attr_accessor :base_url
64
67
 
@@ -187,7 +190,7 @@ module Azure
187
190
  # Returns a list of the available resource providers.
188
191
  #
189
192
  def providers
190
- url = url_with_api_version(armrest_configuration.api_version, @base_url, 'providers')
193
+ url = url_with_api_version(configuration.api_version, @base_url, 'providers')
191
194
  resp = rest_get(url)
192
195
  JSON.parse(resp.body)["value"].map{ |hash| Azure::Armrest::ResourceProvider.new(hash) }
193
196
  end
@@ -195,7 +198,7 @@ module Azure
195
198
  # Returns information about the specific provider +namespace+.
196
199
  #
197
200
  def provider_info(provider)
198
- url = url_with_api_version(armrest_configuration.api_version, @base_url, 'providers', provider)
201
+ url = url_with_api_version(configuration.api_version, @base_url, 'providers', provider)
199
202
  response = rest_get(url)
200
203
  Azure::Armrest::ResourceProvider.new(response)
201
204
  end
@@ -221,7 +224,7 @@ module Azure
221
224
  # Returns a list of subscriptions for the tenant.
222
225
  #
223
226
  def subscriptions
224
- url = url_with_api_version(armrest_configuration.api_version, @base_url, 'subscriptions')
227
+ url = url_with_api_version(configuration.api_version, @base_url, 'subscriptions')
225
228
  response = rest_get(url)
226
229
  JSON.parse(response.body)["value"].map{ |hash| Azure::Armrest::Subscription.new(hash) }
227
230
  end
@@ -230,12 +233,12 @@ module Azure
230
233
  # subscription ID that was provided in the constructor if none is
231
234
  # specified.
232
235
  #
233
- def subscription_info(subscription_id = armrest_configuration.subscription_id)
236
+ def subscription_info(subscription_id = configuration.subscription_id)
234
237
  url = url_with_api_version(
235
- armrest_configuration.api_version,
238
+ configuration.api_version,
236
239
  @base_url,
237
240
  'subscriptions',
238
- armrest_configuration.subscription_id
241
+ subscription_id
239
242
  )
240
243
 
241
244
  response = rest_get(url)
@@ -247,11 +250,11 @@ module Azure
247
250
  # resource group.
248
251
  #
249
252
  def resources(resource_group = nil)
250
- url_comps = [@base_url, 'subscriptions', armrest_configuration.subscription_id]
253
+ url_comps = [@base_url, 'subscriptions', configuration.subscription_id]
251
254
  url_comps += ['resourcegroups', resource_group] if resource_group
252
255
  url_comps << 'resources'
253
256
 
254
- url = url_with_api_version(armrest_configuration.api_version, url_comps)
257
+ url = url_with_api_version(configuration.api_version, url_comps)
255
258
  response = rest_get(url)
256
259
 
257
260
  JSON.parse(response)["value"].map{ |hash| Azure::Armrest::Resource.new(hash) }
@@ -261,10 +264,10 @@ module Azure
261
264
  #
262
265
  def resource_groups
263
266
  url = url_with_api_version(
264
- armrest_configuration.api_version,
267
+ configuration.api_version,
265
268
  @base_url,
266
269
  'subscriptions',
267
- armrest_configuration.subscription_id,
270
+ configuration.subscription_id,
268
271
  'resourcegroups'
269
272
  )
270
273
  response = rest_get(url)
@@ -275,12 +278,12 @@ module Azure
275
278
  # subscription, or the resource group specified in the constructor if
276
279
  # none is provided.
277
280
  #
278
- def resource_group_info(resource_group = armrest_configuration.resource_group)
281
+ def resource_group_info(resource_group = configuration.resource_group)
279
282
  url = url_with_api_version(
280
- armrest_configuration.api_version,
283
+ configuration.api_version,
281
284
  @base_url,
282
285
  'subscriptions',
283
- armrest_configuration.subscription_id,
286
+ configuration.subscription_id,
284
287
  'resourcegroups',
285
288
  resource_group
286
289
  )
@@ -293,10 +296,10 @@ module Azure
293
296
  #
294
297
  def tags
295
298
  url = url_with_api_version(
296
- armrest_configuration.api_version,
299
+ configuration.api_version,
297
300
  @base_url,
298
301
  'subscriptions',
299
- armrest_configuration.subscription_id,
302
+ configuration.subscription_id,
300
303
  'tagNames'
301
304
  )
302
305
  resp = rest_get(url)
@@ -306,7 +309,7 @@ module Azure
306
309
  # Returns a list of tenants that can be accessed.
307
310
  #
308
311
  def tenants
309
- url = url_with_api_version(armrest_configuration.api_version, @base_url, 'tenants')
312
+ url = url_with_api_version(configuration.api_version, @base_url, 'tenants')
310
313
  resp = rest_get(url)
311
314
  JSON.parse(resp.body)['value'].map{ |hash| Azure::Armrest::Tenant.new(hash) }
312
315
  end
@@ -377,11 +380,11 @@ module Azure
377
380
  def rest_execute(url, body = nil, http_method = :get)
378
381
  options = {
379
382
  :url => url,
380
- :proxy => armrest_configuration.proxy,
383
+ :proxy => configuration.proxy,
381
384
  :headers => {
382
- :accept => armrest_configuration.accept,
383
- :content_type => armrest_configuration.content_type,
384
- :authorization => armrest_configuration.token
385
+ :accept => configuration.accept,
386
+ :content_type => configuration.content_type,
387
+ :authorization => configuration.token
385
388
  }
386
389
  }
387
390
 
@@ -435,8 +438,10 @@ module Azure
435
438
  provider_info = {}
436
439
  info.resource_types.each do |resource|
437
440
  provider_info[resource.resource_type.downcase] = {
438
- 'api_version' => resource.api_versions.reject{ |version| version =~ /preview/i }.first,
439
- 'locations' => resource.locations - [''] # Ignore empty elements
441
+ 'api_version' => resource.api_versions.reject{ |version|
442
+ version =~ /preview/i || Time.parse(version) > Time.now
443
+ }.first,
444
+ 'locations' => resource.locations - [''] # Ignore empty elements
440
445
  }
441
446
  end
442
447
  # TODO: how does base model handle method naming collision?
@@ -466,7 +471,7 @@ module Azure
466
471
  elsif @@providers_hash.has_key?(provider.downcase)
467
472
  @@providers_hash[provider.downcase][service.downcase]['api_version']
468
473
  else
469
- armrest_configuration.api_version
474
+ configuration.api_version
470
475
  end
471
476
  end
472
477
  end # ArmrestService
@@ -6,8 +6,8 @@ module Azure
6
6
  class AvailabilitySetService < ResourceGroupBasedService
7
7
  # Create and return a new AvailabilitySetService instance.
8
8
  #
9
- def initialize(armrest_configuration, options = {})
10
- super(armrest_configuration, 'availabilitySets', 'Microsoft.Compute', options)
9
+ def initialize(configuration, options = {})
10
+ super(configuration, 'availabilitySets', 'Microsoft.Compute', options)
11
11
  end
12
12
 
13
13
  def list_all
@@ -43,17 +43,17 @@ module Azure
43
43
  # person.to_json # => Returns original JSON
44
44
  #
45
45
  def initialize(json)
46
- # Find the exclusion list for the model of next level (@embedModel)
46
+ # Find the exclusion list for the model of next level (@embed_model)
47
47
  # '#' is the separator between levels. Remove attributes
48
48
  # before the first separator.
49
49
  child_excl_list = self.class.send(:excl_list).map do |e|
50
- e.index('#') ? e[e.index('#') + 1 .. -1] : ''
50
+ e.index('#') ? e[e.index('#') + 1..-1] : ''
51
51
  end
52
- @embedModel = Class.new(BaseModel) do
53
- attr_hash *child_excl_list
52
+ @embed_model = Class.new(BaseModel) do
53
+ attr_hash(*child_excl_list)
54
54
  end
55
55
 
56
- if json.is_a?(Hash)
56
+ if json.kind_of?(Hash)
57
57
  @hash = json
58
58
  @json = json.to_json
59
59
  else
@@ -68,9 +68,7 @@ module Azure
68
68
  @resource_group ||= id[/resourceGroups\/(.+?)\//i, 1] rescue nil
69
69
  end
70
70
 
71
- def resource_group=(rg)
72
- @resource_group = rg
73
- end
71
+ attr_writer :resource_group
74
72
 
75
73
  def to_h
76
74
  @hash
@@ -94,9 +92,9 @@ module Azure
94
92
 
95
93
  def inspect
96
94
  string = "<#{self.class} "
97
- method_list = methods(false).select{ |m| !m.to_s.include?('=') }
98
- string << method_list.map{ |m| "#{m}=#{send(m).inspect}" }.join(", ")
99
- string << ">"
95
+ method_list = methods(false).select { |m| !m.to_s.include?('=') }
96
+ string << method_list.map { |m| "#{m}=#{send(m).inspect}" }.join(', ')
97
+ string << '>'
100
98
  end
101
99
 
102
100
  def ==(other)
@@ -137,11 +135,11 @@ module Azure
137
135
  obj.each do |key, value|
138
136
  snake = snake_case(key)
139
137
  unless excl_list.include?(snake) # Must deal with nested models
140
- if value.is_a?(Array)
141
- newval = value.map { |elem| elem.is_a?(Hash) ? @embedModel.new(elem) : elem }
138
+ if value.kind_of?(Array)
139
+ newval = value.map { |elem| elem.kind_of?(Hash) ? @embed_model.new(elem) : elem }
142
140
  obj[key] = newval
143
- elsif value.is_a?(Hash)
144
- obj[key] = @embedModel.new(value)
141
+ elsif value.kind_of?(Hash)
142
+ obj[key] = @embed_model.new(value)
145
143
  end
146
144
  end
147
145
 
@@ -156,7 +154,7 @@ module Azure
156
154
  end
157
155
 
158
156
  def snake_case(name)
159
- name.to_s.gsub(/(.)([A-Z])/,'\1_\2').downcase
157
+ name.to_s.gsub(/(.)([A-Z])/, '\1_\2').downcase
160
158
  end
161
159
  end
162
160
 
@@ -2,7 +2,7 @@ module Azure
2
2
  module Armrest
3
3
  # Base class for services that need to run in a resource group
4
4
  class ResourceGroupBasedService < ArmrestService
5
- def create(name, rgroup = armrest_configuration.resource_group, options = {})
5
+ def create(name, rgroup = configuration.resource_group, options = {})
6
6
  validate_resource_group(rgroup)
7
7
  validate_resource(name)
8
8
 
@@ -14,7 +14,7 @@ module Azure
14
14
 
15
15
  alias update create
16
16
 
17
- def list(rgroup = armrest_configuration.resource_group)
17
+ def list(rgroup = configuration.resource_group)
18
18
  validate_resource_group(rgroup)
19
19
 
20
20
  url = build_url(rgroup)
@@ -30,7 +30,7 @@ module Azure
30
30
  JSON.parse(response)['value'].map { |hash| model_class.new(hash) }
31
31
  end
32
32
 
33
- def get(name, rgroup = armrest_configuration.resource_group)
33
+ def get(name, rgroup = configuration.resource_group)
34
34
  validate_resource_group(rgroup)
35
35
  validate_resource(name)
36
36
 
@@ -40,7 +40,7 @@ module Azure
40
40
  model_class.new(response)
41
41
  end
42
42
 
43
- def delete(name, rgroup = armrest_configuration.resource_group)
43
+ def delete(name, rgroup = configuration.resource_group)
44
44
  validate_resource_group(rgroup)
45
45
  validate_resource(name)
46
46
 
@@ -64,7 +64,7 @@ module Azure
64
64
  # arguments provided, and appends it with the api_version.
65
65
  #
66
66
  def build_url(resource_group = nil, *args)
67
- url = File.join(Azure::Armrest::COMMON_URI, armrest_configuration.subscription_id)
67
+ url = File.join(Azure::Armrest::COMMON_URI, configuration.subscription_id)
68
68
  url = File.join(url, 'resourceGroups', resource_group) if resource_group
69
69
  url = File.join(url, 'providers', @provider, @service_name)
70
70
  url = File.join(url, *args) unless args.empty?
@@ -6,12 +6,12 @@ module Azure
6
6
  # all other service classes should subclass, and call super within their
7
7
  # own constructors.
8
8
  #
9
- def initialize(armrest_configuration, service_name, subservice_name, default_provider, options)
9
+ def initialize(configuration, service_name, subservice_name, default_provider, options)
10
10
  @subservice_name = subservice_name
11
- super(armrest_configuration, service_name, default_provider, options)
11
+ super(configuration, service_name, default_provider, options)
12
12
  end
13
13
 
14
- def create(resource, subresource, rgroup = armrest_configuration.resource_group, options = {})
14
+ def create(resource, subresource, rgroup = configuration.resource_group, options = {})
15
15
  validate_resource_group(rgroup)
16
16
  validate_resource(resource)
17
17
  validate_subresource(subresource)
@@ -20,7 +20,7 @@ module Azure
20
20
 
21
21
  alias update create
22
22
 
23
- def list(resource, rgroup = armrest_configuration.resource_group)
23
+ def list(resource, rgroup = configuration.resource_group)
24
24
  validate_resource_group(rgroup)
25
25
  validate_resource(resource)
26
26
 
@@ -32,14 +32,14 @@ module Azure
32
32
 
33
33
  alias list_all list
34
34
 
35
- def get(resource, subresource, rgroup = armrest_configuration.resource_group)
35
+ def get(resource, subresource, rgroup = configuration.resource_group)
36
36
  validate_resource_group(rgroup)
37
37
  validate_resource(resource)
38
38
  validate_subresource(subresource)
39
39
  super(combine(resource, subresource), rgroup)
40
40
  end
41
41
 
42
- def delete(resource, subresource, rgroup = armrest_configuration.resource_group)
42
+ def delete(resource, subresource, rgroup = configuration.resource_group)
43
43
  validate_resource_group(rgroup)
44
44
  validate_resource(resource)
45
45
  validate_subresource(subresource)
@@ -6,8 +6,8 @@ module Azure
6
6
 
7
7
  # Creates and returns a new ResourceGroupService object.
8
8
  #
9
- def initialize(armrest_configuration, options = {})
10
- super(armrest_configuration, 'resourceGroups', 'Microsoft.Resources', options)
9
+ def initialize(configuration, options = {})
10
+ super(configuration, 'resourceGroups', 'Microsoft.Resources', options)
11
11
  end
12
12
 
13
13
  # List all the resources for the current subscription. You can optionally
@@ -70,7 +70,7 @@ module Azure
70
70
  private
71
71
 
72
72
  def build_url(group = nil, *args)
73
- id = armrest_configuration.subscription_id
73
+ id = configuration.subscription_id
74
74
  url = File.join(Azure::Armrest::COMMON_URI, id, 'resourcegroups')
75
75
  url = File.join(url, group) if group
76
76
  url = File.join(url, *args) unless args.empty?
@@ -23,8 +23,8 @@ module Azure
23
23
  #
24
24
  # You can also set the provider. The default is 'Microsoft.Resources'.
25
25
  #
26
- def initialize(armrest_configuration, options = {})
27
- super(armrest_configuration, 'resourceGroups', 'Microsoft.Resources', options)
26
+ def initialize(configuration, options = {})
27
+ super(configuration, 'resourceGroups', 'Microsoft.Resources', options)
28
28
 
29
29
  if options[:cache_time]
30
30
  @cache_time = options[:cache_time]
@@ -126,7 +126,7 @@ module Azure
126
126
  private
127
127
 
128
128
  def build_url(namespace = nil, *args)
129
- id = armrest_configuration.subscription_id
129
+ id = configuration.subscription_id
130
130
  url = File.join(Azure::Armrest::COMMON_URI, id, 'providers')
131
131
  url = File.join(url, namespace) if namespace
132
132
  url = File.join(url, *args) unless args.empty?
@@ -6,8 +6,8 @@ module Azure
6
6
 
7
7
  # Creates and returns a new ResourceService object.
8
8
  #
9
- def initialize(armrest_configuration, options = {})
10
- super(armrest_configuration, 'subscriptions', 'Microsoft.Resources', options)
9
+ def initialize(configuration, options = {})
10
+ super(configuration, 'subscriptions', 'Microsoft.Resources', options)
11
11
  end
12
12
 
13
13
  # List all the resources for the current subscription. You can optionally
@@ -23,7 +23,7 @@ module Azure
23
23
  # rs.list(:filter => "location eq 'centralus'")
24
24
  #
25
25
  def list(options = {})
26
- subscription_id = armrest_configuration.subscription_id
26
+ subscription_id = configuration.subscription_id
27
27
 
28
28
  if options[:resource_group]
29
29
  url = File.join(
@@ -46,7 +46,7 @@ module Azure
46
46
  # Move the resources from +source_group+ under +source_subscription+,
47
47
  # which may be a different subscription.
48
48
  #
49
- def move(source_group, source_subscription = armrest_configuration.subscription_id)
49
+ def move(source_group, source_subscription = configuration.subscription_id)
50
50
  url = File.join(
51
51
  Azure::Armrest::COMMON_URI, source_subscription,
52
52
  'resourcegroups', source_group, 'moveresources'
@@ -15,9 +15,9 @@ module Azure
15
15
 
16
16
  # Creates and returns a new StorageAccountService (SAS) instance.
17
17
  #
18
- def initialize(armrest_configuration, options = {})
18
+ def initialize(configuration, options = {})
19
19
  options = {'api_version' => '2015-05-01-preview'}.merge(options) # Must hard code for now
20
- super(armrest_configuration, 'storageAccounts', 'Microsoft.Storage', options)
20
+ super(configuration, 'storageAccounts', 'Microsoft.Storage', options)
21
21
  end
22
22
 
23
23
  # Creates a new storage account, or updates an existing account with the
@@ -48,16 +48,17 @@ module Azure
48
48
  #
49
49
  # sas = Azure::Armrest::StorageAccountService(config)
50
50
  #
51
- # sas.create("yourstorageaccount1",
51
+ # sas.create(
52
+ # "yourstorageaccount1",
53
+ # "yourresourcegroup",
52
54
  # {
53
55
  # :location => "West US",
54
56
  # :properties => {:accountType => "Standard_ZRS"},
55
57
  # :tags => {:YourCompany => true}
56
- # },
57
- # "yourresourcegroup"
58
+ # }
58
59
  # )
59
60
  #
60
- def create(account_name, rgroup = armrest_configuration.resource_group, options)
61
+ def create(account_name, rgroup = configuration.resource_group, options = {})
61
62
  validating = options.delete(:validating)
62
63
  validate_account_type(options[:properties][:accountType])
63
64
  validate_account_name(account_name)
@@ -70,7 +71,7 @@ module Azure
70
71
  # Returns the primary and secondary access keys for the given
71
72
  # storage account as a hash.
72
73
  #
73
- def list_account_keys(account_name, group = armrest_configuration.resource_group)
74
+ def list_account_keys(account_name, group = configuration.resource_group)
74
75
  validate_resource_group(group)
75
76
 
76
77
  url = build_url(group, account_name, 'listKeys')
@@ -86,7 +87,7 @@ module Azure
86
87
  # "keyName": "key1|key2"
87
88
  # }
88
89
  #
89
- def regenerate_storage_account_keys(account_name, group = armrest_configuration.resource_group, options)
90
+ def regenerate_storage_account_keys(account_name, group = configuration.resource_group, options = {})
90
91
  validate_resource_group(group)
91
92
 
92
93
  url = build_url(group, account_name, 'regenerateKey')
@@ -98,7 +99,7 @@ module Azure
98
99
  # storage accounts in the provided resource group. The custom keys
99
100
  # :uri and :operating_system have been added for convenience.
100
101
  #
101
- def list_private_images(group = armrest_configuration.resource_group)
102
+ def list_private_images(group = configuration.resource_group)
102
103
  results = []
103
104
  threads = []
104
105
  mutex = Mutex.new
@@ -3,14 +3,14 @@ module Azure
3
3
  # Base class for managing templates and deployments
4
4
  class TemplateDeploymentService < ResourceGroupBasedService
5
5
 
6
- def initialize(armrest_configuration, options = {})
6
+ def initialize(configuration, options = {})
7
7
  # Has to be hard coded for now
8
8
  options = {'api_version' => '2014-04-01-preview'}.merge(options)
9
- super(armrest_configuration, 'deployments', 'Microsoft.Resources', options)
9
+ super(configuration, 'deployments', 'Microsoft.Resources', options)
10
10
  end
11
11
 
12
12
  # Get names of all deployments in a resource group
13
- def list_names(resource_group = armrest_configuration.resource_group)
13
+ def list_names(resource_group = configuration.resource_group)
14
14
  list(resource_group).map(&:name)
15
15
  end
16
16
 
@@ -20,7 +20,7 @@ module Azure
20
20
  end
21
21
 
22
22
  # Get all operations of a deployment in a resource group
23
- def list_deployment_operations(deploy_name, resource_group = armrest_configuration.resource_group)
23
+ def list_deployment_operations(deploy_name, resource_group = configuration.resource_group)
24
24
  validate_resource_group(resource_group)
25
25
  validate_resource(deploy_name)
26
26
 
@@ -30,7 +30,7 @@ module Azure
30
30
  end
31
31
 
32
32
  # Get the operation of a deployment in a resource group
33
- def get_deployment_operation(op_id, deploy_name, resource_group = armrest_configuration.resource_group)
33
+ def get_deployment_operation(op_id, deploy_name, resource_group = configuration.resource_group)
34
34
  validate_resource_group(resource_group)
35
35
  validate_resource(deploy_name)
36
36
  raise ArgumentError, "must specify operation id" unless op_id
@@ -1,5 +1,5 @@
1
1
  module Azure
2
2
  module Armrest
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -7,7 +7,7 @@ module Azure
7
7
 
8
8
  # Creates and returns a new VirtualMachineExtensionService object.
9
9
  #
10
- def initialize(_armrest_configuration, options = {})
10
+ def initialize(_configuration, options = {})
11
11
  super
12
12
  set_service_api_version(options, 'virtualMachines/extensions')
13
13
  end
@@ -29,7 +29,7 @@ module Azure
29
29
  # For convenience, you may also specify a :resource_group as an option.
30
30
  #
31
31
  def create(vm_name, ext_name, options = {}, rgroup = nil)
32
- rgroup ||= options.delete(:resource_group) || armrest_configuration.resource_group
32
+ rgroup ||= options.delete(:resource_group) || configuration.resource_group
33
33
 
34
34
  raise ArgumentError, "no resource group provided" unless rgroup
35
35
 
@@ -50,7 +50,7 @@ module Azure
50
50
 
51
51
  # Delete the given extension for the provided VM and resource group.
52
52
  #
53
- def delete(vm_name, ext_name, rgroup = armrest_configuration.resource_group)
53
+ def delete(vm_name, ext_name, rgroup = configuration.resource_group)
54
54
  raise ArgumentError, "no resource group provided" unless rgroup
55
55
  url = build_url(rgroup, vm_name, ext_name)
56
56
  response = rest_delete(url)
@@ -61,7 +61,7 @@ module Azure
61
61
  # If the +instance_view+ option is true, it will retrieve instance
62
62
  # view information instead.
63
63
  #
64
- def get(vm_name, ext_name, rgroup = armrest_configuration.resource_group, instance_view = false)
64
+ def get(vm_name, ext_name, rgroup = configuration.resource_group, instance_view = false)
65
65
  raise ArgumentError, "no resource group provided" unless rgroup
66
66
  url = build_url(rgroup, vm_name, ext_name)
67
67
  url << "&expand=instanceView" if instance_view
@@ -70,13 +70,13 @@ module Azure
70
70
  end
71
71
 
72
72
  # Shortcut to get an extension in model view.
73
- def get_model_view(vm_name, ext_name, rgroup = armrest_configuration.resource_group)
73
+ def get_model_view(vm_name, ext_name, rgroup = configuration.resource_group)
74
74
  raise ArgumentError, "no resource group provided" unless rgroup
75
75
  get(vm_name, ext_name, rgroup, false)
76
76
  end
77
77
 
78
78
  # Shortcut to get an extension in instance view.
79
- def get_instance_view(vm_name, ext_name, rgroup = armrest_configuration.resource_group)
79
+ def get_instance_view(vm_name, ext_name, rgroup = configuration.resource_group)
80
80
  raise ArgumentError, "no resource group provided" unless rgroup
81
81
  get(vm_name, ext_name, rgroup, true)
82
82
  end
@@ -90,7 +90,7 @@ module Azure
90
90
  #--
91
91
  # BUG: https://github.com/Azure/azure-xplat-cli/issues/1826
92
92
  #
93
- def list(vm_name, rgroup = armrest_configuration.resource_group, instance_view = false)
93
+ def list(vm_name, rgroup = configuration.resource_group, instance_view = false)
94
94
  raise ArgumentError, "no resource group provided" unless rgroup
95
95
  url = build_url(rgroup, vm_name)
96
96
  url << "&expand=instanceView" if instance_view
@@ -99,13 +99,13 @@ module Azure
99
99
  end
100
100
 
101
101
  # Shortcut to get a list in model view.
102
- def list_model_view(vmname, rgroup = armrest_configuration.resource_group)
102
+ def list_model_view(vmname, rgroup = configuration.resource_group)
103
103
  raise ArgumentError, "no resource group provided" unless rgroup
104
104
  list(vmname, false, rgroup)
105
105
  end
106
106
 
107
107
  # Shortcut to get a list in instance view.
108
- def list_instance_view(vmname, rgroup = armrest_configuration.resource_group)
108
+ def list_instance_view(vmname, rgroup = configuration.resource_group)
109
109
  raise ArgumentError, "no resource group provided" unless rgroup
110
110
  list(vmname, true, rgroup)
111
111
  end
@@ -118,7 +118,7 @@ module Azure
118
118
  def build_url(resource_group, vm, *args)
119
119
  url = File.join(
120
120
  Azure::Armrest::COMMON_URI,
121
- armrest_configuration.subscription_id,
121
+ configuration.subscription_id,
122
122
  'resourceGroups',
123
123
  resource_group,
124
124
  'providers',
@@ -16,8 +16,8 @@ module Azure
16
16
  # :publisher options as well. The default provider is set to
17
17
  # 'Microsoft.Compute'.
18
18
  #
19
- def initialize(armrest_configuration, options = {})
20
- super(armrest_configuration, nil, 'Microsoft.Compute', options)
19
+ def initialize(configuration, options = {})
20
+ super(configuration, nil, 'Microsoft.Compute', options)
21
21
 
22
22
  @location = options[:location]
23
23
  @publisher = options[:publisher]
@@ -103,7 +103,7 @@ module Azure
103
103
  def build_url(location, *args)
104
104
  url = File.join(
105
105
  Azure::Armrest::COMMON_URI,
106
- armrest_configuration.subscription_id,
106
+ configuration.subscription_id,
107
107
  'providers',
108
108
  provider,
109
109
  'locations',
@@ -12,8 +12,8 @@ module Azure
12
12
  # default is 'Microsoft.ClassicCompute'. You may need to set this to
13
13
  # 'Microsoft.Compute' for your purposes.
14
14
  #
15
- def initialize(armrest_configuration, options = {})
16
- super(armrest_configuration, 'virtualMachines', 'Microsoft.Compute', options)
15
+ def initialize(configuration, options = {})
16
+ super(configuration, 'virtualMachines', 'Microsoft.Compute', options)
17
17
  end
18
18
 
19
19
  # Return a list of available VM series (aka sizes, flavors, etc), such
@@ -27,7 +27,7 @@ module Azure
27
27
  version = @@providers_hash[provider.downcase]['locations/vmsizes']['api_version']
28
28
 
29
29
  url = url_with_api_version(
30
- version, @base_url, 'subscriptions', armrest_configuration.subscription_id,
30
+ version, @base_url, 'subscriptions', configuration.subscription_id,
31
31
  'providers', provider, 'locations', location, 'vmSizes'
32
32
  )
33
33
 
@@ -44,19 +44,19 @@ module Azure
44
44
  # * overwriteVhds - Boolean that indicates whether or not to overwrite any VHD's
45
45
  # with the same prefix. The default is false.
46
46
  #
47
- def capture(vmname, options, group = armrest_configuration.resource_group)
47
+ def capture(vmname, options, group = configuration.resource_group)
48
48
  vm_operate('capture', vmname, group, options)
49
49
  end
50
50
 
51
51
  # Stop the VM +vmname+ in +group+ and deallocate the tenant in Fabric.
52
52
  #
53
- def deallocate(vmname, group = armrest_configuration.resource_group)
53
+ def deallocate(vmname, group = configuration.resource_group)
54
54
  vm_operate('deallocate', vmname, group)
55
55
  end
56
56
 
57
57
  # Sets the OSState for the +vmname+ in +group+ to 'Generalized'.
58
58
  #
59
- def generalize(vmname, group = armrest_configuration.resource_group)
59
+ def generalize(vmname, group = configuration.resource_group)
60
60
  vm_operate('generalize', vmname, group)
61
61
  end
62
62
 
@@ -67,21 +67,21 @@ module Azure
67
67
  # parameter is false, it will retrieve an instance view. The difference is
68
68
  # in the details of the information retrieved.
69
69
  #
70
- def get(vmname, group = armrest_configuration.resource_group, model_view = true)
70
+ def get(vmname, group = configuration.resource_group, model_view = true)
71
71
  model_view ? super(vmname, group) : get_instance_view(vmname, group)
72
72
  end
73
73
 
74
74
  # Convenient wrapper around the get method that retrieves the model view
75
75
  # for +vmname+ in resource_group +group+.
76
76
  #
77
- def get_model_view(vmname, group = armrest_configuration.resource_group)
77
+ def get_model_view(vmname, group = configuration.resource_group)
78
78
  get(vmname, group, true)
79
79
  end
80
80
 
81
81
  # Convenient wrapper around the get method that retrieves the instance view
82
82
  # for +vmname+ in resource_group +group+.
83
83
  #
84
- def get_instance_view(vmname, group = armrest_configuration.resource_group)
84
+ def get_instance_view(vmname, group = configuration.resource_group)
85
85
  raise ArgumentError, "must specify resource group" unless group
86
86
  raise ArgumentError, "must specify name of the resource" unless vmname
87
87
 
@@ -96,7 +96,7 @@ module Azure
96
96
  # This is an asynchronous operation that returns a response object
97
97
  # which you can inspect, such as response.code or response.headers.
98
98
  #
99
- def restart(vmname, group = armrest_configuration.resource_group)
99
+ def restart(vmname, group = configuration.resource_group)
100
100
  vm_operate('restart', vmname, group)
101
101
  end
102
102
 
@@ -106,7 +106,7 @@ module Azure
106
106
  # This is an asynchronous operation that returns a response object
107
107
  # which you can inspect, such as response.code or response.headers.
108
108
  #
109
- def start(vmname, group = armrest_configuration.resource_group)
109
+ def start(vmname, group = configuration.resource_group)
110
110
  vm_operate('start', vmname, group)
111
111
  end
112
112
 
@@ -116,7 +116,7 @@ module Azure
116
116
  # This is an asynchronous operation that returns a response object
117
117
  # which you can inspect, such as response.code or response.headers.
118
118
  #
119
- def stop(vmname, group = armrest_configuration.resource_group)
119
+ def stop(vmname, group = configuration.resource_group)
120
120
  vm_operate('powerOff', vmname, group)
121
121
  end
122
122
 
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.1.1
4
+ version: 0.1.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: 2016-02-26 00:00:00.000000000 Z
14
+ date: 2016-03-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: json