azure-armrest 0.9.10 → 0.9.11

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
  SHA256:
3
- metadata.gz: 190b8f78bc2b4608e5853a9b575a56d4d798fb5b5209bf09385338691598b55e
4
- data.tar.gz: 5abedf568e89bbdb12417168f5c2f29f9e2512aeba02421e912114b721a826a1
3
+ metadata.gz: 49845f9146789f624afa28dac9e05a2208b3afd0ca1ee69c77e082d22ac6d9e5
4
+ data.tar.gz: 9a0a6539ada1cacc3b4b075b9027bec7092e232bfd9b16c802e5191caaebd2d3
5
5
  SHA512:
6
- metadata.gz: ab40c738668a595f21ae881bbc78236473416fd1b60244018fcb827b2a6845d612fd8a3e7b4505671e3efb7e60e1ae4a95ff7cb25fbc480d444e1ed963f91031
7
- data.tar.gz: 9c2f3130de29243f2e2fd342e453ba2bad1b754529b0e732ed0b324ad1fbfd9b230a284c1a565921b4a3c2d156f75ab18606f9f72a384fe11c6b3a0ab0a929d9
6
+ metadata.gz: 4b52e91d05f9d32f46d20d122b1c1bfe504e1e4e4781d603e890cdef534d65797f993747745f6cc00e0ec4402eac23189219eaf23c1da7f78becd0a27361a739
7
+ data.tar.gz: 8a7b05918d80333d49fa546f011a42c18b970d0b04c4d3167bae451b9d3c30bbe068f72374753888eeb282c199498e786c6fe7032215b86cb7fd8c38279a68bf
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ = 0.9.11 - 8-May-2018
2
+ * Added the ResourceProviderService#supported? method.
3
+ * Added the Environment.discover singleton method. This will allow you to
4
+ automatically generate a minimum environment profile based on an endpoint.
5
+
1
6
  = 0.9.10 - 17-Apr-2018
2
7
  * Fixed a bug in the TemplateDeploymentService#create method where it would
3
8
  transform template keys that shouldn't be transformed. Individual subclasses
@@ -2,22 +2,22 @@ module Azure
2
2
  module Armrest
3
3
  class Environment
4
4
  # A list of valid keys that can be passed to the constructor
5
- VALID_KEYS = [
6
- :name,
7
- :active_directory_authority,
8
- :active_directory_resource_id,
9
- :gallery_url,
10
- :graph_url,
11
- :graph_api_version,
12
- :key_vault_dns_suffix,
13
- :key_vault_service_resource_id,
14
- :publish_settings_file_url,
15
- :resource_manager_url,
16
- :service_management_url,
17
- :sql_database_dns_suffix,
18
- :storage_suffix,
19
- :traffic_manager_dns_suffix
20
- ]
5
+ VALID_KEYS = %i[
6
+ name
7
+ active_directory_authority
8
+ active_directory_resource_id
9
+ gallery_url
10
+ graph_url
11
+ graph_api_version
12
+ key_vault_dns_suffix
13
+ key_vault_service_resource_id
14
+ publish_settings_file_url
15
+ resource_manager_url
16
+ service_management_url
17
+ sql_database_dns_suffix
18
+ storage_suffix
19
+ traffic_manager_dns_suffix
20
+ ].freeze
21
21
 
22
22
  # The Environment name
23
23
  attr_reader :name
@@ -74,7 +74,7 @@ module Azure
74
74
  instance_variable_set("@#{key}", value)
75
75
  end
76
76
 
77
- [:name, :active_directory_authority, :resource_manager_url].each do |key|
77
+ %i[name active_directory_authority resource_manager_url].each do |key|
78
78
  unless instance_variable_get("@#{key}")
79
79
  raise ArgumentError, "Mandatory argument '#{key}' not set"
80
80
  end
@@ -82,7 +82,41 @@ module Azure
82
82
  end
83
83
 
84
84
  alias authority_url active_directory_authority
85
+ alias login_endpoint active_directory_authority
85
86
  alias resource_url resource_manager_url
87
+ alias gallery_endpoint gallery_url
88
+ alias graph_endpoint graph_url
89
+
90
+ # Automatically discover and create an Environment given a resource
91
+ # manager endpoint. The +options+ hash must include an endpoint :url key.
92
+ # It may also include a :name (recommended), and http proxy options.
93
+ #
94
+ def self.discover(options)
95
+ url = options.fetch(:url)
96
+ name = options[:name] || 'Custom'
97
+
98
+ uri = Addressable::URI.join(url, '/metadata/', 'endpoints')
99
+ uri.query = "api-version=1.0"
100
+
101
+ response = ArmrestService.send(
102
+ :rest_get,
103
+ :url => uri.to_s,
104
+ :proxy => options[:proxy],
105
+ :ssl_version => options[:ssl_version],
106
+ :ssl_verify => options[:ssl_verify]
107
+ )
108
+
109
+ endpoint = Endpoint.new(response.body)
110
+
111
+ new(
112
+ :name => name,
113
+ :gallery_url => endpoint.gallery_endpoint,
114
+ :graph_url => endpoint.graph_endpoint,
115
+ :active_directory_authority => endpoint.authentication.login_endpoint,
116
+ :active_directory_resource_id => endpoint.authentication.audiences.first,
117
+ :resource_manager_url => url
118
+ )
119
+ end
86
120
 
87
121
  # Pre-generated environments
88
122
 
@@ -259,6 +259,7 @@ module Azure
259
259
 
260
260
  class AvailabilitySet < BaseModel; end
261
261
  class Container < BaseModel; end
262
+ class Endpoint < BaseModel; end
262
263
  class Event < BaseModel; end
263
264
  class ImageVersion < BaseModel; end
264
265
  class Location < BaseModel; end
@@ -118,6 +118,14 @@ module Azure
118
118
  false
119
119
  end
120
120
 
121
+ # Returns whether or not the given +resource_type+ is supported by the
122
+ # given +namespace+. By default it will search the Microsoft.Compute
123
+ # namespace.
124
+ #
125
+ def supported?(resource_type, namespace = 'Microsoft.Compute')
126
+ get(namespace).resource_types.map(&:resource_type).map(&:downcase).include?(resource_type.downcase)
127
+ end
128
+
121
129
  private
122
130
 
123
131
  def build_url(namespace = nil, *args)
@@ -1,6 +1,6 @@
1
1
  module Azure
2
2
  module Armrest
3
3
  # The version of the azure-armrest library.
4
- VERSION = '0.9.10'.freeze
4
+ VERSION = '0.9.11'.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.9.10
4
+ version: 0.9.11
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: 2018-04-17 00:00:00.000000000 Z
14
+ date: 2018-05-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: json