azure-armrest 0.3.9 → 0.3.10
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 +4 -4
- data/CHANGES +5 -1
- data/lib/azure/armrest/resource_group_based_service.rb +70 -0
- data/lib/azure/armrest/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9777098a3e4838e748f6da116a2537864c42002
|
4
|
+
data.tar.gz: 3ec9b411092bfb9d6cd5fc24c0aadecd2a0ccbc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d67953ce9e556be3f25a410b64899cde8d6294089eca9bc0b3e320ce1e452e2277783a48459ff7250422c487e39898fb1ab9ac471df482ae382fe4d81539156f
|
7
|
+
data.tar.gz: 4b7966bd30284bd34bd16eacb0960bb49ba23ea767db1a9275159c0c1f459dde5ae34d69151c679ec8a83b2df3d8b2b0bfb3a192c23b844ff984b7ab3b4aef7c
|
data/CHANGES
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
= 0.3.10 - 28-Oct-2016
|
2
|
+
* Added the ResourceGroupBasedService#get_associated_resource method. This
|
3
|
+
method will retrieve a service or subservice resource based on an ID string.
|
4
|
+
|
1
5
|
= 0.3.9 - 19-Oct-2016
|
2
6
|
* The StorageAccount#delete_blob method now returns a ResponseHeaders object
|
3
7
|
instead of true.
|
4
|
-
|
8
|
+
* The Configuration.clear_caches method now additionally clears the
|
5
9
|
CacheMethod config store.
|
6
10
|
|
7
11
|
= 0.3.8 - 7-Oct-2-16
|
@@ -2,6 +2,22 @@ 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
|
+
# Used to map service name strings to internal classes
|
6
|
+
SERVICE_NAME_MAP = {
|
7
|
+
'availabilitysets' => Azure::Armrest::AvailabilitySet,
|
8
|
+
'loadbalancers' => Azure::Armrest::Network::LoadBalancer,
|
9
|
+
'networkinterfaces' => Azure::Armrest::Network::NetworkInterface,
|
10
|
+
'networksecuritygroups' => Azure::Armrest::Network::NetworkSecurityGroup,
|
11
|
+
'publicipaddresses' => Azure::Armrest::Network::IpAddress,
|
12
|
+
'storageaccounts' => Azure::Armrest::StorageAccount,
|
13
|
+
'virtualnetworks' => Azure::Armrest::Network::VirtualNetwork,
|
14
|
+
'subnets' => Azure::Armrest::Network::Subnet,
|
15
|
+
'inboundnatrules' => Azure::Armrest::Network::InboundNat,
|
16
|
+
'securityrules' => Azure::Armrest::Network::NetworkSecurityRule,
|
17
|
+
'routes' => Azure::Armrest::Network::Route,
|
18
|
+
'databases' => Azure::Armrest::Sql::SqlDatabase,
|
19
|
+
}.freeze
|
20
|
+
|
5
21
|
# Create a resource +name+ within the resource group +rgroup+, or the
|
6
22
|
# resource group that was specified in the configuration, along with
|
7
23
|
# a hash of appropriate +options+.
|
@@ -73,6 +89,41 @@ module Azure
|
|
73
89
|
filter.empty? ? results : results.select { |obj| filter.all? { |k, v| obj.public_send(k) == v } }
|
74
90
|
end
|
75
91
|
|
92
|
+
# This method returns a model object based on an ID string for a Service.
|
93
|
+
#
|
94
|
+
# Example:
|
95
|
+
#
|
96
|
+
# vms = Azure::Armrest::VirtualMachineService.new(conf)
|
97
|
+
#
|
98
|
+
# vm = vms.get('your_vm', 'your_group')
|
99
|
+
# nic_id = vm.properties.network_profile.network_interfaces[0].id
|
100
|
+
# nic = vm.get_associated_resource(nic_id)
|
101
|
+
#
|
102
|
+
def get_associated_resource(id_string)
|
103
|
+
info = parse_id_string(id_string)
|
104
|
+
|
105
|
+
if info['subservice_name']
|
106
|
+
full_service_name = info['service_name'] + '/' + info['subservice_name']
|
107
|
+
api_version = configuration.provider_default_api_version(info['provider'], full_service_name)
|
108
|
+
api_version ||= configuration.provider_default_api_version(info['provider'], info['service_name'])
|
109
|
+
else
|
110
|
+
api_version = configuration.provider_default_api_version(info['provider'], info['service_name'])
|
111
|
+
end
|
112
|
+
|
113
|
+
api_version ||= configuration.api_version
|
114
|
+
service_name = info['subservice_name'] || info['service_name']
|
115
|
+
|
116
|
+
url = File.join(Azure::Armrest::RESOURCE, id_string) + "?api-version=#{api_version}"
|
117
|
+
|
118
|
+
model_class = SERVICE_NAME_MAP.fetch(service_name.downcase) do
|
119
|
+
raise ArgumentError, "unable to map service name #{service_name} to model"
|
120
|
+
end
|
121
|
+
|
122
|
+
model_class.new(rest_get(url))
|
123
|
+
end
|
124
|
+
|
125
|
+
alias get_by_id get_associated_resource
|
126
|
+
|
76
127
|
# Get information about a single resource +name+ within resource group
|
77
128
|
# +rgroup+, or the resource group that was set in the configuration.
|
78
129
|
#
|
@@ -120,6 +171,25 @@ module Azure
|
|
120
171
|
|
121
172
|
private
|
122
173
|
|
174
|
+
# Parse the provider and service name out of an ID string.
|
175
|
+
def parse_id_string(id_string)
|
176
|
+
regex = %r{
|
177
|
+
subscriptions/
|
178
|
+
(?<subscription_id>[\w\-]+)?/
|
179
|
+
resourceGroups/
|
180
|
+
(?<resource_group>\w+)?/
|
181
|
+
providers/
|
182
|
+
(?<provider>[\w\.]+)?/
|
183
|
+
(?<service_name>\w+)?/
|
184
|
+
(?<resource_name>\w+)
|
185
|
+
(/(?<subservice_name>\w+)?/(?<subservice_resource_name>\w+))*
|
186
|
+
\z
|
187
|
+
}x
|
188
|
+
|
189
|
+
match = regex.match(id_string)
|
190
|
+
Hash[match.names.zip(match.captures)]
|
191
|
+
end
|
192
|
+
|
123
193
|
# Make additional calls and concatenate the results if a continuation URL is found.
|
124
194
|
def get_all_results(response)
|
125
195
|
results = Azure::Armrest::ArmrestCollection.create_from_response(response, model_class)
|
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.3.
|
4
|
+
version: 0.3.10
|
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-10-
|
14
|
+
date: 2016-10-28 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: json
|
@@ -275,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
275
|
version: '0'
|
276
276
|
requirements: []
|
277
277
|
rubyforge_project:
|
278
|
-
rubygems_version: 2.6.
|
278
|
+
rubygems_version: 2.6.7
|
279
279
|
signing_key:
|
280
280
|
specification_version: 4
|
281
281
|
summary: An interface for ARM/JSON Azure REST API
|