azure-armrest 0.0.9 → 0.1.0

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: f8b26339221636eee239e6934d67cf0c4ee3bbb9
4
- data.tar.gz: 1a6c35bd8f5a4af7ec2bd68d3734978add667981
3
+ metadata.gz: bfd3dade5a1dad37a43cb98080c1509d58d9bd31
4
+ data.tar.gz: b3aeb02c6b2ee98cb38a4bda0f71f6e221c81789
5
5
  SHA512:
6
- metadata.gz: 1a130d2af6d31ca1b55b40dbe528103b359022ac7a9b685d4954ea3144f1ec6bbc5be7247aaa9f2e23963819d308d322159f46d3390b74c81caf3ee8c3dec7fc
7
- data.tar.gz: fe7a7347b7bd16877848d8125ff496504d2e96822487ba0a70f62fc157798373767b9852ba5b89d3a0314e797803493745c77697b2b373eea86716e6b4086e52
6
+ metadata.gz: b9268be1252d095820a642cf5c20adf895d67555ad4354f6ad78fc35b381c26b693efd3ec1802fbd8cbbb7e9f897889509b9cb28c8cdbb363752325d404bde17
7
+ data.tar.gz: cd67fb3c615bd1d8e83644152e28826b816b1f17586c4b84a314a976fde879ea76cb3b620bbb9fbe0bbbb755ad2dc3cf763bdea3c7e3ccbc4739b75a96a2861a
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ = 0.1.0 - 26-Jan-2015
2
+ * Refactored the ArmrestService class api_version and provider handling.
3
+ * The ArmrestService class no longer uses "preview" api versions by default.
4
+ * Added RBAC service classes.
5
+
1
6
  = 0.0.9 - 17-Dec-2015
2
7
  * Added AlertService and EventService classes.
3
8
  * Added tables, table_info and table_data methods to the StorageAccount model.
data/lib/azure/armrest.rb CHANGED
@@ -41,6 +41,8 @@ require 'azure/armrest/network/network_security_group_service'
41
41
  require 'azure/armrest/network/network_security_rule_service'
42
42
  require 'azure/armrest/network/virtual_network_service'
43
43
  require 'azure/armrest/network/subnet_service'
44
+ require 'azure/armrest/role/assignment_service'
45
+ require 'azure/armrest/role/definition_service'
44
46
 
45
47
  # JSON wrapper classes. The service classes should require their own
46
48
  # wrappers from this point on.
@@ -55,6 +55,12 @@ module Azure
55
55
  # Base url used for REST calls.
56
56
  attr_accessor :base_url
57
57
 
58
+ # provider for service specific API calls
59
+ attr_accessor :provider
60
+
61
+ # The api-version string used for each request.
62
+ attr_accessor :api_version
63
+
58
64
  @@providers_hash = {} # Set in constructor
59
65
 
60
66
  @@tokens = {} # token caches
@@ -143,13 +149,15 @@ module Azure
143
149
  # all other service classes should subclass, and call super within their
144
150
  # own constructors.
145
151
  #
146
- def initialize(armrest_configuration, _options)
147
- self.armrest_configuration = armrest_configuration
152
+ def initialize(armrest_configuration, service_name, default_provider, options)
153
+ @armrest_configuration = armrest_configuration
154
+ @service_name = service_name
155
+ @provider = options[:provider] || default_provider
148
156
 
149
157
  # Base URL used for REST calls. Modify within method calls as needed.
150
158
  @base_url = Azure::Armrest::RESOURCE
151
159
 
152
- set_providers_info
160
+ set_service_api_version(options, service_name)
153
161
  end
154
162
 
155
163
  # Returns a list of the available resource providers.
@@ -410,8 +418,8 @@ module Azure
410
418
  providers.each do |info|
411
419
  provider_info = {}
412
420
  info.resource_types.each do |resource|
413
- provider_info[resource.resource_type] = {
414
- 'api_version' => resource.api_versions.first,
421
+ provider_info[resource.resource_type.downcase] = {
422
+ 'api_version' => resource.api_versions.reject{ |version| version =~ /preview/i }.first,
415
423
  'locations' => resource.locations - [''] # Ignore empty elements
416
424
  }
417
425
  end
@@ -435,11 +443,12 @@ module Azure
435
443
  # Finally api_version in armrest_configuration is used if service specific version
436
444
  # cannot be determined
437
445
  def set_service_api_version(options, service)
446
+ set_providers_info
438
447
  @api_version =
439
448
  if options.has_key?('api_version')
440
449
  options['api_version']
441
- elsif @@providers_hash.has_key?(@provider.downcase)
442
- @@providers_hash[@provider.downcase][service]['api_version']
450
+ elsif @@providers_hash.has_key?(provider.downcase)
451
+ @@providers_hash[provider.downcase][service.downcase]['api_version']
443
452
  else
444
453
  armrest_configuration.api_version
445
454
  end
@@ -4,16 +4,10 @@ module Azure
4
4
  module Armrest
5
5
  # Base class for managing availability sets.
6
6
  class AvailabilitySetService < ResourceGroupBasedService
7
- # The provider used in requests when gathering AvailabilitySet information.
8
- attr_reader :provider
9
-
10
7
  # Create and return a new AvailabilitySetService instance.
11
8
  #
12
- def initialize(_armrest_configuration, options = {})
13
- super
14
- @provider = options[:provider] || 'Microsoft.Compute'
15
- set_service_api_version(options, 'availabilitySets')
16
- @service_name = 'availabilitySets'
9
+ def initialize(armrest_configuration, options = {})
10
+ super(armrest_configuration, 'availabilitySets', 'Microsoft.Compute', options)
17
11
  end
18
12
 
19
13
  def list_all
@@ -6,16 +6,10 @@ module Azure
6
6
  module Insights
7
7
  # Base class for managing alert rules.
8
8
  class AlertService < ResourceGroupBasedService
9
- # The provider used in requests when gathering Alert information.
10
- attr_reader :provider
11
-
12
9
  # Create and return a new AlertService instance.
13
10
  #
14
- def initialize(_armrest_configuration, options = {})
15
- super
16
- @provider = options[:provider] || 'Microsoft.Insights'
17
- set_service_api_version(options, 'alertrules')
18
- @service_name = 'alertRules'
11
+ def initialize(armrest_configuration, options = {})
12
+ super(armrest_configuration, 'alertRules', 'Microsoft.Insights', options)
19
13
  end
20
14
  end # AlertService
21
15
  end # Insights
@@ -7,16 +7,10 @@ module Azure
7
7
 
8
8
  # Base class for managing events.
9
9
  class EventService < ArmrestService
10
- # The provider used in requests when gathering Event information.
11
- attr_reader :provider
12
-
13
10
  # Create and return a new EventService instance.
14
11
  #
15
- def initialize(_armrest_configuration, options = {})
16
- super
17
- @provider = options[:provider] || 'Microsoft.Insights'
18
- set_service_api_version(options, 'eventtypes')
19
- @service_name = 'eventTypes'
12
+ def initialize(armrest_configuration, options = {})
13
+ super(armrest_configuration, 'eventTypes', 'Microsoft.Insights', options)
20
14
  end
21
15
 
22
16
  # Returns a list of management events for the current subscription.
@@ -53,15 +47,16 @@ module Azure
53
47
  def build_url(filter = nil, select = nil)
54
48
  sub_id = armrest_configuration.subscription_id
55
49
 
56
- url = File.join(
57
- Azure::Armrest::COMMON_URI,
58
- sub_id,
59
- 'providers',
60
- @provider,
61
- 'eventtypes',
62
- 'management',
63
- 'values'
64
- )
50
+ url =
51
+ File.join(
52
+ Azure::Armrest::COMMON_URI,
53
+ sub_id,
54
+ 'providers',
55
+ provider,
56
+ 'eventtypes',
57
+ 'management',
58
+ 'values'
59
+ )
65
60
 
66
61
  url << "?api-version=#{@api_version}"
67
62
  url << "&$filter=#{filter}" if filter
@@ -195,6 +195,11 @@ module Azure
195
195
  class VirtualNetwork < BaseModel; end
196
196
  class Subnet < VirtualNetwork; end
197
197
  end
198
+
199
+ module Role
200
+ class Assignment < BaseModel; end
201
+ class Definition < BaseModel; end
202
+ end
198
203
  end
199
204
  end
200
205
 
@@ -6,11 +6,8 @@ module Azure
6
6
 
7
7
  # Creates and returns a new IpAddressService instance.
8
8
  #
9
- def initialize(_armrest_configuration, options = {})
10
- super
11
- @provider = options[:provider] || 'Microsoft.Network'
12
- @service_name = 'publicIPAddresses'
13
- set_service_api_version(options, @service_name)
9
+ def initialize(armrest_configuration, options = {})
10
+ super(armrest_configuration, 'publicIPAddresses', 'Microsoft.Network', options)
14
11
  end
15
12
 
16
13
  # Shortcut method that returns just the IP address for the given public
@@ -5,11 +5,8 @@ module Azure
5
5
  class NetworkInterfaceService < ResourceGroupBasedService
6
6
  # Creates and returns a new NetworkInterfaceService instance.
7
7
  #
8
- def initialize(_armrest_configuration, options = {})
9
- super
10
- @provider = options[:provider] || 'Microsoft.Network'
11
- @service_name = 'networkInterfaces'
12
- set_service_api_version(options, @service_name)
8
+ def initialize(armrest_configuration, options = {})
9
+ super(armrest_configuration, 'networkInterfaces', 'Microsoft.Network', options)
13
10
  end
14
11
  end
15
12
  end # Network
@@ -6,11 +6,8 @@ module Azure
6
6
 
7
7
  # Creates and returns a new NetworkSecurityGroupService instance.
8
8
  #
9
- def initialize(_armrest_configuration, options = {})
10
- super
11
- @provider = options[:provider] || 'Microsoft.Network'
12
- @service_name = 'networkSecurityGroups'
13
- set_service_api_version(options, @service_name)
9
+ def initialize(armrest_configuration, options = {})
10
+ super(armrest_configuration, 'networkSecurityGroups', 'Microsoft.Network', options)
14
11
  end
15
12
  end
16
13
  end # Network
@@ -6,11 +6,8 @@ module Azure
6
6
 
7
7
  # Creates and returns a new VirtualNetworkService instance.
8
8
  #
9
- def initialize(_armrest_configuration, options = {})
10
- super
11
- @provider = options[:provider] || 'Microsoft.Network'
12
- @service_name = 'virtualNetworks'
13
- set_service_api_version(options, @service_name)
9
+ def initialize(armrest_configuration, options = {})
10
+ super(armrest_configuration, 'virtualNetworks', 'Microsoft.Network', options)
14
11
  end
15
12
  end
16
13
  end # Network
@@ -6,10 +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
11
- @provider = options[:provider] || 'Microsoft.Resources'
12
- set_service_api_version(options, 'resourceGroups')
9
+ def initialize(armrest_configuration, options = {})
10
+ super(armrest_configuration, 'resourceGroups', 'Microsoft.Resources', options)
13
11
  end
14
12
 
15
13
  # List all the resources for the current subscription. You can optionally
@@ -23,17 +23,13 @@ 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
28
-
29
- @provider = options[:provider] || 'Microsoft.Resources'
26
+ def initialize(armrest_configuration, options = {})
27
+ super(armrest_configuration, 'resourceGroups', 'Microsoft.Resources', options)
30
28
 
31
29
  if options[:cache_time]
32
30
  @cache_time = options[:cache_time]
33
31
  self.class.send(:cache_time=, @cache_time)
34
32
  end
35
-
36
- set_service_api_version(options, 'resourceGroups')
37
33
  end
38
34
 
39
35
  # List all the providers for the current subscription. The results of
@@ -6,10 +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
11
- @provider = options[:provider] || 'Microsoft.Resources'
12
- set_service_api_version(options, 'subscriptions')
9
+ def initialize(armrest_configuration, options = {})
10
+ super(armrest_configuration, 'subscriptions', 'Microsoft.Resources', options)
13
11
  end
14
12
 
15
13
  # List all the resources for the current subscription. You can optionally
@@ -0,0 +1,17 @@
1
+ # Azure namespace
2
+ module Azure
3
+ # Armrest namespace
4
+ module Armrest
5
+ # Role namespace
6
+ module Role
7
+ # Base class for managing Role Assignments
8
+ class AssignmentService < ResourceGroupBasedService
9
+ # Create and return a new AssignmentService instance.
10
+ #
11
+ def initialize(armrest_configuration, options = {})
12
+ super(armrest_configuration, 'roleAssignments', 'Microsoft.Authorization', options)
13
+ end
14
+ end # AssignmentService
15
+ end # Role
16
+ end # Armrest
17
+ end # Azure
@@ -0,0 +1,17 @@
1
+ # Azure namespace
2
+ module Azure
3
+ # Armrest namespace
4
+ module Armrest
5
+ # Role namespace
6
+ module Role
7
+ # Base class for managing Role Definitions
8
+ class DefinitionService < ResourceGroupBasedService
9
+ # Create and return a new DefinitionService instance.
10
+ #
11
+ def initialize(armrest_configuration, options = {})
12
+ super(armrest_configuration, 'roleDefinitions', 'Microsoft.Authorization', options)
13
+ end
14
+ end # DefinitionService
15
+ end # Role
16
+ end # Armrest
17
+ end # Azure
@@ -15,12 +15,9 @@ module Azure
15
15
 
16
16
  # Creates and returns a new StorageAccountService (SAS) instance.
17
17
  #
18
- def initialize(_armrest_configuration, options = {})
19
- super
20
- @provider = options[:provider] || 'Microsoft.Storage'
21
- #set_service_api_version(options, 'storageAccounts')
22
- @api_version = '2015-05-01-preview' # Must hard code for now
23
- @service_name = 'storageAccounts'
18
+ def initialize(armrest_configuration, options = {})
19
+ options = {'api_version' => '2015-05-01-preview'}.merge(options) # Must hard code for now
20
+ super(armrest_configuration, 'storageAccounts', 'Microsoft.Storage', options)
24
21
  end
25
22
 
26
23
  # Creates a new storage account, or updates an existing account with the
@@ -2,12 +2,10 @@ module Azure::Armrest
2
2
  # Base class for managing templates and deployments
3
3
  class TemplateDeploymentService < ResourceGroupBasedService
4
4
 
5
- def initialize(_armrest_configuration, options = {})
6
- super
7
- @provider = options[:provider] || 'Microsoft.Resources'
5
+ def initialize(armrest_configuration, options = {})
8
6
  # Has to be hard coded for now
9
- set_service_api_version({'api_version' => '2014-04-01-preview'}, '')
10
- @service_name = 'deployments'
7
+ options = {'api_version' => '2014-04-01-preview'}.merge(options)
8
+ super(armrest_configuration, 'deployments', 'Microsoft.Resources', options)
11
9
  end
12
10
 
13
11
  # Get names of all deployments in a resource group
@@ -1,5 +1,5 @@
1
1
  module Azure
2
2
  module Armrest
3
- VERSION = "0.0.9"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -9,7 +9,6 @@ module Azure
9
9
  #
10
10
  def initialize(_armrest_configuration, options = {})
11
11
  super
12
- @provider = options[:provider] || 'Microsoft.Compute'
13
12
  set_service_api_version(options, 'virtualMachines/extensions')
14
13
  end
15
14
 
@@ -7,9 +7,6 @@ module Azure
7
7
  # The location used in requests when gathering VM image information.
8
8
  attr_accessor :location
9
9
 
10
- # The provider used in requests when gathering VM image information.
11
- attr_reader :provider
12
-
13
10
  # The publisher used in requests when gathering VM image information.
14
11
  attr_accessor :publisher
15
12
 
@@ -19,25 +16,15 @@ module Azure
19
16
  # :publisher options as well. The default provider is set to
20
17
  # 'Microsoft.Compute'.
21
18
  #
22
- def initialize(_armrest_configuration, options = {})
23
- super
19
+ def initialize(armrest_configuration, options = {})
20
+ super(armrest_configuration, nil, 'Microsoft.Compute', options)
24
21
 
25
22
  @location = options[:location]
26
- @provider = options[:provider] || 'Microsoft.Compute'
27
23
  @publisher = options[:publisher]
28
24
 
29
25
  set_service_api_version(options, 'locations/publishers')
30
26
  end
31
27
 
32
- # Set a new provider to use the default for other methods. This may alter
33
- # the api_version used for future requests. In practice, only
34
- # 'Microsoft.Compute' or 'Microsoft.ClassicCompute' should be used.
35
- #
36
- def provider=(name)
37
- @provider = name
38
- set_service_api_version({}, 'locations/publishers')
39
- end
40
-
41
28
  # Return a list of VM image offers from the given +publisher+ and +location+.
42
29
  #
43
30
  # Example:
@@ -4,10 +4,6 @@ module Azure
4
4
  module Armrest
5
5
  # Base class for managing virtual machines
6
6
  class VirtualMachineService < ResourceGroupBasedService
7
-
8
- # The provider used in requests when gathering VM information.
9
- attr_reader :provider
10
-
11
7
  # Create and return a new VirtualMachineService (VMM) instance. Most
12
8
  # methods for a VMM instance will return one or more VirtualMachine
13
9
  # instances.
@@ -16,31 +12,19 @@ module Azure
16
12
  # default is 'Microsoft.ClassicCompute'. You may need to set this to
17
13
  # 'Microsoft.Compute' for your purposes.
18
14
  #
19
- def initialize(_armrest_configuration, options = {})
20
- super
21
- @provider = options[:provider] || 'Microsoft.Compute'
22
- @service_name = 'virtualMachines'
23
- set_service_api_version(options, @service_name)
24
- end
25
-
26
- # Set a new provider to use the default for other methods. This may alter
27
- # the api_version used for future requests. In practice, only
28
- # 'Microsoft.Compute' or 'Microsoft.ClassicCompute' should be used.
29
- #
30
- def provider=(name, options = {})
31
- @provider = name
32
- set_service_api_version(options, 'virtualMachines')
15
+ def initialize(armrest_configuration, options = {})
16
+ super(armrest_configuration, 'virtualMachines', 'Microsoft.Compute', options)
33
17
  end
34
18
 
35
19
  # Return a list of available VM series (aka sizes, flavors, etc), such
36
20
  # as "Basic_A1", though information is included as well.
37
21
  #
38
22
  def series(location)
39
- unless @@providers_hash[@provider.downcase] && @@providers_hash[@provider.downcase]['locations/vmSizes']
23
+ unless @@providers_hash[provider.downcase] && @@providers_hash[provider.downcase]['locations/vmsizes']
40
24
  raise ArgumentError, "Invalid provider '#{provider}'"
41
25
  end
42
26
 
43
- version = @@providers_hash[@provider.downcase]['locations/vmSizes']['api_version']
27
+ version = @@providers_hash[provider.downcase]['locations/vmsizes']['api_version']
44
28
 
45
29
  url = url_with_api_version(
46
30
  version, @base_url, 'subscriptions', armrest_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.0.9
4
+ version: 0.1.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: 2015-12-17 00:00:00.000000000 Z
14
+ date: 2016-01-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: json
@@ -208,6 +208,8 @@ files:
208
208
  - lib/azure/armrest/resource_group_service.rb
209
209
  - lib/azure/armrest/resource_provider_service.rb
210
210
  - lib/azure/armrest/resource_service.rb
211
+ - lib/azure/armrest/role/assignment_service.rb
212
+ - lib/azure/armrest/role/definition_service.rb
211
213
  - lib/azure/armrest/storage_account_service.rb
212
214
  - lib/azure/armrest/template_deployment_service.rb
213
215
  - lib/azure/armrest/version.rb