azure_mgmt_network 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +3 -0
- data/.travis.yml +3 -0
- data/Gemfile +15 -0
- data/LICENSE.txt +21 -0
- data/README.md +131 -0
- data/Rakefile +5 -0
- data/azure_mgmt_network.gemspec +39 -0
- data/lib/azure_mgmt_network.rb +139 -0
- data/lib/azure_mgmt_network/Models/address_space.rb +60 -0
- data/lib/azure_mgmt_network/Models/application_gateway.rb +104 -0
- data/lib/azure_mgmt_network/Models/application_gateway_backend_address.rb +67 -0
- data/lib/azure_mgmt_network/Models/application_gateway_backend_address_pool.rb +90 -0
- data/lib/azure_mgmt_network/Models/application_gateway_backend_address_pool_properties_format.rb +121 -0
- data/lib/azure_mgmt_network/Models/application_gateway_backend_http_settings.rb +90 -0
- data/lib/azure_mgmt_network/Models/application_gateway_backend_http_settings_properties_format.rb +98 -0
- data/lib/azure_mgmt_network/Models/application_gateway_cookie_based_affinity.rb +16 -0
- data/lib/azure_mgmt_network/Models/application_gateway_frontend_ip_configuration.rb +91 -0
- data/lib/azure_mgmt_network/Models/application_gateway_frontend_ip_configuration_properties_format.rb +117 -0
- data/lib/azure_mgmt_network/Models/application_gateway_frontend_port.rb +90 -0
- data/lib/azure_mgmt_network/Models/application_gateway_frontend_port_properties_format.rb +70 -0
- data/lib/azure_mgmt_network/Models/application_gateway_http_listener.rb +90 -0
- data/lib/azure_mgmt_network/Models/application_gateway_http_listener_properties_format.rb +124 -0
- data/lib/azure_mgmt_network/Models/application_gateway_ip_configuration.rb +90 -0
- data/lib/azure_mgmt_network/Models/application_gateway_ip_configuration_properties_format.rb +77 -0
- data/lib/azure_mgmt_network/Models/application_gateway_list_result.rb +88 -0
- data/lib/azure_mgmt_network/Models/application_gateway_operational_state.rb +18 -0
- data/lib/azure_mgmt_network/Models/application_gateway_properties_format.rb +338 -0
- data/lib/azure_mgmt_network/Models/application_gateway_protocol.rb +16 -0
- data/lib/azure_mgmt_network/Models/application_gateway_request_routing_rule.rb +90 -0
- data/lib/azure_mgmt_network/Models/application_gateway_request_routing_rule_properties_format.rb +124 -0
- data/lib/azure_mgmt_network/Models/application_gateway_request_routing_rule_type.rb +15 -0
- data/lib/azure_mgmt_network/Models/application_gateway_sku.rb +88 -0
- data/lib/azure_mgmt_network/Models/application_gateway_sku_name.rb +17 -0
- data/lib/azure_mgmt_network/Models/application_gateway_ssl_certificate.rb +90 -0
- data/lib/azure_mgmt_network/Models/application_gateway_ssl_certificate_properties_format.rb +87 -0
- data/lib/azure_mgmt_network/Models/application_gateway_tier.rb +15 -0
- data/lib/azure_mgmt_network/Models/azure_async_operation_result.rb +85 -0
- data/lib/azure_mgmt_network/Models/backend_address_pool.rb +90 -0
- data/lib/azure_mgmt_network/Models/backend_address_pool_properties_format.rb +120 -0
- data/lib/azure_mgmt_network/Models/connection_reset_shared_key.rb +64 -0
- data/lib/azure_mgmt_network/Models/connection_reset_shared_key_properties_format.rb +60 -0
- data/lib/azure_mgmt_network/Models/connection_shared_key.rb +58 -0
- data/lib/azure_mgmt_network/Models/dhcp_options.rb +60 -0
- data/lib/azure_mgmt_network/Models/dns_name_availability_result.rb +58 -0
- data/lib/azure_mgmt_network/Models/error.rb +114 -0
- data/lib/azure_mgmt_network/Models/error_details.rb +76 -0
- data/lib/azure_mgmt_network/Models/frontend_ip_configuration.rb +90 -0
- data/lib/azure_mgmt_network/Models/frontend_ip_configuration_properties_format.rb +181 -0
- data/lib/azure_mgmt_network/Models/inbound_nat_rule.rb +90 -0
- data/lib/azure_mgmt_network/Models/inbound_nat_rule_properties_format.rb +163 -0
- data/lib/azure_mgmt_network/Models/ip_allocation_method.rb +16 -0
- data/lib/azure_mgmt_network/Models/load_balancer.rb +104 -0
- data/lib/azure_mgmt_network/Models/load_balancer_list_result.rb +88 -0
- data/lib/azure_mgmt_network/Models/load_balancer_properties_format.rb +210 -0
- data/lib/azure_mgmt_network/Models/load_balancing_rule.rb +90 -0
- data/lib/azure_mgmt_network/Models/load_balancing_rule_properties_format.rb +195 -0
- data/lib/azure_mgmt_network/Models/load_distribution.rb +17 -0
- data/lib/azure_mgmt_network/Models/local_network_gateway.rb +104 -0
- data/lib/azure_mgmt_network/Models/local_network_gateway_list_result.rb +88 -0
- data/lib/azure_mgmt_network/Models/local_network_gateway_properties_format.rb +83 -0
- data/lib/azure_mgmt_network/Models/network_interface.rb +104 -0
- data/lib/azure_mgmt_network/Models/network_interface_dns_settings.rb +89 -0
- data/lib/azure_mgmt_network/Models/network_interface_ip_configuration.rb +90 -0
- data/lib/azure_mgmt_network/Models/network_interface_ip_configuration_properties_format.rb +179 -0
- data/lib/azure_mgmt_network/Models/network_interface_list_result.rb +88 -0
- data/lib/azure_mgmt_network/Models/network_interface_properties_format.rb +158 -0
- data/lib/azure_mgmt_network/Models/network_security_group.rb +104 -0
- data/lib/azure_mgmt_network/Models/network_security_group_list_result.rb +88 -0
- data/lib/azure_mgmt_network/Models/network_security_group_properties_format.rb +181 -0
- data/lib/azure_mgmt_network/Models/operation_status.rb +17 -0
- data/lib/azure_mgmt_network/Models/probe.rb +90 -0
- data/lib/azure_mgmt_network/Models/probe_properties_format.rb +157 -0
- data/lib/azure_mgmt_network/Models/probe_protocol.rb +16 -0
- data/lib/azure_mgmt_network/Models/public_ip_address.rb +104 -0
- data/lib/azure_mgmt_network/Models/public_ip_address_dns_settings.rb +85 -0
- data/lib/azure_mgmt_network/Models/public_ip_address_list_result.rb +88 -0
- data/lib/azure_mgmt_network/Models/public_ip_address_properties_format.rb +126 -0
- data/lib/azure_mgmt_network/Models/security_rule.rb +90 -0
- data/lib/azure_mgmt_network/Models/security_rule_access.rb +16 -0
- data/lib/azure_mgmt_network/Models/security_rule_direction.rb +16 -0
- data/lib/azure_mgmt_network/Models/security_rule_list_result.rb +89 -0
- data/lib/azure_mgmt_network/Models/security_rule_properties_format.rb +174 -0
- data/lib/azure_mgmt_network/Models/security_rule_protocol.rb +17 -0
- data/lib/azure_mgmt_network/Models/subnet.rb +90 -0
- data/lib/azure_mgmt_network/Models/subnet_list_result.rb +88 -0
- data/lib/azure_mgmt_network/Models/subnet_properties_format.rb +115 -0
- data/lib/azure_mgmt_network/Models/transport_protocol.rb +16 -0
- data/lib/azure_mgmt_network/Models/usage.rb +98 -0
- data/lib/azure_mgmt_network/Models/usage_name.rb +68 -0
- data/lib/azure_mgmt_network/Models/usage_unit.rb +15 -0
- data/lib/azure_mgmt_network/Models/usages_list_result.rb +78 -0
- data/lib/azure_mgmt_network/Models/virtual_network.rb +104 -0
- data/lib/azure_mgmt_network/Models/virtual_network_gateway.rb +104 -0
- data/lib/azure_mgmt_network/Models/virtual_network_gateway_connection.rb +104 -0
- data/lib/azure_mgmt_network/Models/virtual_network_gateway_connection_list_result.rb +89 -0
- data/lib/azure_mgmt_network/Models/virtual_network_gateway_connection_properties_format.rb +141 -0
- data/lib/azure_mgmt_network/Models/virtual_network_gateway_connection_type.rb +18 -0
- data/lib/azure_mgmt_network/Models/virtual_network_gateway_ip_configuration.rb +90 -0
- data/lib/azure_mgmt_network/Models/virtual_network_gateway_ip_configuration_properties_format.rb +117 -0
- data/lib/azure_mgmt_network/Models/virtual_network_gateway_list_result.rb +88 -0
- data/lib/azure_mgmt_network/Models/virtual_network_gateway_properties_format.rb +126 -0
- data/lib/azure_mgmt_network/Models/virtual_network_gateway_type.rb +15 -0
- data/lib/azure_mgmt_network/Models/virtual_network_list_result.rb +88 -0
- data/lib/azure_mgmt_network/Models/virtual_network_properties_format.rb +123 -0
- data/lib/azure_mgmt_network/Models/vpn_type.rb +16 -0
- data/lib/azure_mgmt_network/application_gateways.rb +915 -0
- data/lib/azure_mgmt_network/load_balancers.rb +709 -0
- data/lib/azure_mgmt_network/local_network_gateways.rb +550 -0
- data/lib/azure_mgmt_network/module_definition.rb +6 -0
- data/lib/azure_mgmt_network/network_interfaces.rb +709 -0
- data/lib/azure_mgmt_network/network_resource_provider_client.rb +195 -0
- data/lib/azure_mgmt_network/network_security_groups.rb +718 -0
- data/lib/azure_mgmt_network/public_ip_addresses.rb +711 -0
- data/lib/azure_mgmt_network/security_rules.rb +563 -0
- data/lib/azure_mgmt_network/subnets.rb +552 -0
- data/lib/azure_mgmt_network/usages.rb +113 -0
- data/lib/azure_mgmt_network/version.rb +6 -0
- data/lib/azure_mgmt_network/virtual_network_gateway_connections.rb +945 -0
- data/lib/azure_mgmt_network/virtual_network_gateways.rb +686 -0
- data/lib/azure_mgmt_network/virtual_networks.rb +707 -0
- metadata +311 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
|
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
|
4
|
+
# regenerated.
|
|
5
|
+
|
|
6
|
+
module Azure::ARM::Network
|
|
7
|
+
#
|
|
8
|
+
# A service client - single point of access to the REST API.
|
|
9
|
+
#
|
|
10
|
+
class NetworkResourceProviderClient < MsRestAzure::AzureServiceClient
|
|
11
|
+
include Azure::ARM::Network::Models
|
|
12
|
+
include MsRestAzure
|
|
13
|
+
|
|
14
|
+
# @return [String] the base URI of the service.
|
|
15
|
+
attr_accessor :base_url
|
|
16
|
+
|
|
17
|
+
# @return [ServiceClientCredentials] The management credentials for Azure.
|
|
18
|
+
attr_reader :credentials
|
|
19
|
+
|
|
20
|
+
# @return [String] Gets subscription credentials which uniquely identify
|
|
21
|
+
# Microsoft Azure subscription. The subscription ID forms part of the URI
|
|
22
|
+
# for every service call.
|
|
23
|
+
attr_accessor :subscription_id
|
|
24
|
+
|
|
25
|
+
# @return [String] Client Api Version.
|
|
26
|
+
attr_reader :api_version
|
|
27
|
+
|
|
28
|
+
# @return [String] Gets or sets the preferred language for the response.
|
|
29
|
+
attr_accessor :accept_language
|
|
30
|
+
|
|
31
|
+
# @return [Integer] The retry timeout for Long Running Operations.
|
|
32
|
+
attr_accessor :long_running_operation_retry_timeout
|
|
33
|
+
|
|
34
|
+
# @return [ServiceClient] Subscription credentials which uniquely identify
|
|
35
|
+
# client subscription.
|
|
36
|
+
attr_accessor :credentials
|
|
37
|
+
|
|
38
|
+
# @return application_gateways
|
|
39
|
+
attr_reader :application_gateways
|
|
40
|
+
|
|
41
|
+
# @return load_balancers
|
|
42
|
+
attr_reader :load_balancers
|
|
43
|
+
|
|
44
|
+
# @return local_network_gateways
|
|
45
|
+
attr_reader :local_network_gateways
|
|
46
|
+
|
|
47
|
+
# @return network_interfaces
|
|
48
|
+
attr_reader :network_interfaces
|
|
49
|
+
|
|
50
|
+
# @return network_security_groups
|
|
51
|
+
attr_reader :network_security_groups
|
|
52
|
+
|
|
53
|
+
# @return public_ip_addresses
|
|
54
|
+
attr_reader :public_ip_addresses
|
|
55
|
+
|
|
56
|
+
# @return security_rules
|
|
57
|
+
attr_reader :security_rules
|
|
58
|
+
|
|
59
|
+
# @return subnets
|
|
60
|
+
attr_reader :subnets
|
|
61
|
+
|
|
62
|
+
# @return usages
|
|
63
|
+
attr_reader :usages
|
|
64
|
+
|
|
65
|
+
# @return virtual_network_gateway_connections
|
|
66
|
+
attr_reader :virtual_network_gateway_connections
|
|
67
|
+
|
|
68
|
+
# @return virtual_network_gateways
|
|
69
|
+
attr_reader :virtual_network_gateways
|
|
70
|
+
|
|
71
|
+
# @return virtual_networks
|
|
72
|
+
attr_reader :virtual_networks
|
|
73
|
+
|
|
74
|
+
#
|
|
75
|
+
# Creates initializes a new instance of the NetworkResourceProviderClient class.
|
|
76
|
+
# @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
|
|
77
|
+
# @param base_url [String] the base URI of the service.
|
|
78
|
+
# @param options [Array] filters to be applied to the HTTP requests.
|
|
79
|
+
#
|
|
80
|
+
def initialize(credentials, base_url = nil, options = nil)
|
|
81
|
+
super(credentials, options)
|
|
82
|
+
@base_url = base_url || 'https://management.azure.com'
|
|
83
|
+
|
|
84
|
+
fail ArgumentError, 'credentials is nil' if credentials.nil?
|
|
85
|
+
fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials)
|
|
86
|
+
@credentials = credentials
|
|
87
|
+
|
|
88
|
+
@application_gateways = ApplicationGateways.new(self)
|
|
89
|
+
@load_balancers = LoadBalancers.new(self)
|
|
90
|
+
@local_network_gateways = LocalNetworkGateways.new(self)
|
|
91
|
+
@network_interfaces = NetworkInterfaces.new(self)
|
|
92
|
+
@network_security_groups = NetworkSecurityGroups.new(self)
|
|
93
|
+
@public_ip_addresses = PublicIpAddresses.new(self)
|
|
94
|
+
@security_rules = SecurityRules.new(self)
|
|
95
|
+
@subnets = Subnets.new(self)
|
|
96
|
+
@usages = Usages.new(self)
|
|
97
|
+
@virtual_network_gateway_connections = VirtualNetworkGatewayConnections.new(self)
|
|
98
|
+
@virtual_network_gateways = VirtualNetworkGateways.new(self)
|
|
99
|
+
@virtual_networks = VirtualNetworks.new(self)
|
|
100
|
+
@api_version = "2015-05-01-preview"
|
|
101
|
+
@accept_language = "en-US"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
#
|
|
105
|
+
# Checks whether a domain name in the cloudapp.net zone is available for use.
|
|
106
|
+
# @param location [String] The location of the domain name
|
|
107
|
+
# @param domain_name_label [String] The domain name to be verified. It must
|
|
108
|
+
# conform to the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$.
|
|
109
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
110
|
+
# applied to HTTP request.
|
|
111
|
+
#
|
|
112
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
113
|
+
# response.
|
|
114
|
+
#
|
|
115
|
+
def check_dns_name_availability(location, domain_name_label = nil, custom_headers = nil)
|
|
116
|
+
fail ArgumentError, 'location is nil' if location.nil?
|
|
117
|
+
fail ArgumentError, 'api_version is nil' if api_version.nil?
|
|
118
|
+
fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
|
|
119
|
+
# Construct URL
|
|
120
|
+
path = "/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability"
|
|
121
|
+
path['{location}'] = ERB::Util.url_encode(location) if path.include?('{location}')
|
|
122
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(subscription_id) if path.include?('{subscriptionId}')
|
|
123
|
+
url = URI.join(self.base_url, path)
|
|
124
|
+
properties = {}
|
|
125
|
+
properties['domainNameLabel'] = ERB::Util.url_encode(domain_name_label.to_s) unless domain_name_label.nil?
|
|
126
|
+
properties['api-version'] = ERB::Util.url_encode(api_version.to_s) unless api_version.nil?
|
|
127
|
+
unless url.query.nil?
|
|
128
|
+
url.query.split('&').each do |url_item|
|
|
129
|
+
url_items_parts = url_item.split('=')
|
|
130
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
properties.reject!{ |key, value| value.nil? }
|
|
134
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
135
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
136
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
137
|
+
url = URI.parse(corrected_url)
|
|
138
|
+
|
|
139
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
140
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
141
|
+
faraday.use :cookie_jar
|
|
142
|
+
faraday.adapter Faraday.default_adapter
|
|
143
|
+
end
|
|
144
|
+
request_headers = Hash.new
|
|
145
|
+
|
|
146
|
+
# Set Headers
|
|
147
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
148
|
+
request_headers["accept-language"] = accept_language unless accept_language.nil?
|
|
149
|
+
|
|
150
|
+
unless custom_headers.nil?
|
|
151
|
+
custom_headers.each do |key, value|
|
|
152
|
+
request_headers[key] = value
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Send Request
|
|
157
|
+
promise = Concurrent::Promise.new do
|
|
158
|
+
connection.get do |request|
|
|
159
|
+
request.headers = request_headers
|
|
160
|
+
self.credentials.sign_request(request) unless self.credentials.nil?
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
promise = promise.then do |http_response|
|
|
165
|
+
status_code = http_response.status
|
|
166
|
+
response_content = http_response.body
|
|
167
|
+
unless (status_code == 200)
|
|
168
|
+
error_model = JSON.load(response_content)
|
|
169
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Create Result
|
|
173
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
174
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
175
|
+
# Deserialize Response
|
|
176
|
+
if status_code == 200
|
|
177
|
+
begin
|
|
178
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
179
|
+
unless parsed_response.nil?
|
|
180
|
+
parsed_response = DnsNameAvailabilityResult.deserialize_object(parsed_response)
|
|
181
|
+
end
|
|
182
|
+
result.body = parsed_response
|
|
183
|
+
rescue Exception => e
|
|
184
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
result
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
promise.execute
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
end
|
|
195
|
+
end
|
|
@@ -0,0 +1,718 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
|
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
|
4
|
+
# regenerated.
|
|
5
|
+
|
|
6
|
+
module Azure::ARM::Network
|
|
7
|
+
#
|
|
8
|
+
# NetworkSecurityGroups
|
|
9
|
+
#
|
|
10
|
+
class NetworkSecurityGroups
|
|
11
|
+
include Azure::ARM::Network::Models
|
|
12
|
+
include MsRestAzure
|
|
13
|
+
|
|
14
|
+
#
|
|
15
|
+
# Creates and initializes a new instance of the NetworkSecurityGroups class.
|
|
16
|
+
# @param client service class for accessing basic functionality.
|
|
17
|
+
#
|
|
18
|
+
def initialize(client)
|
|
19
|
+
@client = client
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @return reference to the NetworkResourceProviderClient
|
|
23
|
+
attr_reader :client
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# The Delete NetworkSecurityGroup operation deletes the specifed network
|
|
27
|
+
# security group
|
|
28
|
+
# @param resource_group_name [String] The name of the resource group.
|
|
29
|
+
# @param network_security_group_name [String] The name of the network security
|
|
30
|
+
# group.
|
|
31
|
+
# @return [Concurrent::Promise] promise which provides async access to http
|
|
32
|
+
# response.
|
|
33
|
+
#
|
|
34
|
+
def delete(resource_group_name, network_security_group_name, custom_headers = nil)
|
|
35
|
+
# Send request
|
|
36
|
+
promise = begin_delete(resource_group_name, network_security_group_name, custom_headers)
|
|
37
|
+
|
|
38
|
+
promise = promise.then do |response|
|
|
39
|
+
# Defining deserialization method.
|
|
40
|
+
deserialize_method = lambda do |parsed_response|
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Waiting for response.
|
|
44
|
+
@client.get_post_or_delete_operation_result(response, nil, deserialize_method)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
promise
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
#
|
|
51
|
+
# The Delete NetworkSecurityGroup operation deletes the specifed network
|
|
52
|
+
# security group
|
|
53
|
+
# @param resource_group_name [String] The name of the resource group.
|
|
54
|
+
# @param network_security_group_name [String] The name of the network security
|
|
55
|
+
# group.
|
|
56
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
57
|
+
# applied to HTTP request.
|
|
58
|
+
#
|
|
59
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
60
|
+
# response.
|
|
61
|
+
#
|
|
62
|
+
def begin_delete(resource_group_name, network_security_group_name, custom_headers = nil)
|
|
63
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
|
64
|
+
fail ArgumentError, 'network_security_group_name is nil' if network_security_group_name.nil?
|
|
65
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
|
66
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
|
67
|
+
# Construct URL
|
|
68
|
+
path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}"
|
|
69
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
|
70
|
+
path['{networkSecurityGroupName}'] = ERB::Util.url_encode(network_security_group_name) if path.include?('{networkSecurityGroupName}')
|
|
71
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
|
72
|
+
url = URI.join(@client.base_url, path)
|
|
73
|
+
properties = {}
|
|
74
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
|
75
|
+
unless url.query.nil?
|
|
76
|
+
url.query.split('&').each do |url_item|
|
|
77
|
+
url_items_parts = url_item.split('=')
|
|
78
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
properties.reject!{ |key, value| value.nil? }
|
|
82
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
83
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
84
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
85
|
+
url = URI.parse(corrected_url)
|
|
86
|
+
|
|
87
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
88
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
89
|
+
faraday.use :cookie_jar
|
|
90
|
+
faraday.adapter Faraday.default_adapter
|
|
91
|
+
end
|
|
92
|
+
request_headers = Hash.new
|
|
93
|
+
|
|
94
|
+
# Set Headers
|
|
95
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
96
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
|
97
|
+
|
|
98
|
+
unless custom_headers.nil?
|
|
99
|
+
custom_headers.each do |key, value|
|
|
100
|
+
request_headers[key] = value
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Send Request
|
|
105
|
+
promise = Concurrent::Promise.new do
|
|
106
|
+
connection.delete do |request|
|
|
107
|
+
request.headers = request_headers
|
|
108
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
promise = promise.then do |http_response|
|
|
113
|
+
status_code = http_response.status
|
|
114
|
+
response_content = http_response.body
|
|
115
|
+
unless (status_code == 204 || status_code == 202 || status_code == 200)
|
|
116
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Create Result
|
|
120
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
121
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
122
|
+
|
|
123
|
+
result
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
promise.execute
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
#
|
|
130
|
+
# The Get NetworkSecurityGroups operation retrieves information about the
|
|
131
|
+
# specified network security group.
|
|
132
|
+
# @param resource_group_name [String] The name of the resource group.
|
|
133
|
+
# @param network_security_group_name [String] The name of the network security
|
|
134
|
+
# group.
|
|
135
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
136
|
+
# applied to HTTP request.
|
|
137
|
+
#
|
|
138
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
139
|
+
# response.
|
|
140
|
+
#
|
|
141
|
+
def get(resource_group_name, network_security_group_name, custom_headers = nil)
|
|
142
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
|
143
|
+
fail ArgumentError, 'network_security_group_name is nil' if network_security_group_name.nil?
|
|
144
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
|
145
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
|
146
|
+
# Construct URL
|
|
147
|
+
path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}"
|
|
148
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
|
149
|
+
path['{networkSecurityGroupName}'] = ERB::Util.url_encode(network_security_group_name) if path.include?('{networkSecurityGroupName}')
|
|
150
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
|
151
|
+
url = URI.join(@client.base_url, path)
|
|
152
|
+
properties = {}
|
|
153
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
|
154
|
+
unless url.query.nil?
|
|
155
|
+
url.query.split('&').each do |url_item|
|
|
156
|
+
url_items_parts = url_item.split('=')
|
|
157
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
properties.reject!{ |key, value| value.nil? }
|
|
161
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
162
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
163
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
164
|
+
url = URI.parse(corrected_url)
|
|
165
|
+
|
|
166
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
167
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
168
|
+
faraday.use :cookie_jar
|
|
169
|
+
faraday.adapter Faraday.default_adapter
|
|
170
|
+
end
|
|
171
|
+
request_headers = Hash.new
|
|
172
|
+
|
|
173
|
+
# Set Headers
|
|
174
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
175
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
|
176
|
+
|
|
177
|
+
unless custom_headers.nil?
|
|
178
|
+
custom_headers.each do |key, value|
|
|
179
|
+
request_headers[key] = value
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Send Request
|
|
184
|
+
promise = Concurrent::Promise.new do
|
|
185
|
+
connection.get do |request|
|
|
186
|
+
request.headers = request_headers
|
|
187
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
promise = promise.then do |http_response|
|
|
192
|
+
status_code = http_response.status
|
|
193
|
+
response_content = http_response.body
|
|
194
|
+
unless (status_code == 200)
|
|
195
|
+
error_model = JSON.load(response_content)
|
|
196
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Create Result
|
|
200
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
201
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
202
|
+
# Deserialize Response
|
|
203
|
+
if status_code == 200
|
|
204
|
+
begin
|
|
205
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
206
|
+
unless parsed_response.nil?
|
|
207
|
+
parsed_response = NetworkSecurityGroup.deserialize_object(parsed_response)
|
|
208
|
+
end
|
|
209
|
+
result.body = parsed_response
|
|
210
|
+
rescue Exception => e
|
|
211
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
result
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
promise.execute
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
#
|
|
222
|
+
# The Put NetworkSecurityGroup operation creates/updates a network security
|
|
223
|
+
# groupin the specified resource group.
|
|
224
|
+
# @param resource_group_name [String] The name of the resource group.
|
|
225
|
+
# @param network_security_group_name [String] The name of the network security
|
|
226
|
+
# group.
|
|
227
|
+
# @param parameters [NetworkSecurityGroup] Parameters supplied to the
|
|
228
|
+
# create/update Network Security Group operation
|
|
229
|
+
# @param @client.api_version [String] Client Api Version.
|
|
230
|
+
# @param @client.subscription_id [String] Gets subscription credentials which
|
|
231
|
+
# uniquely identify Microsoft Azure subscription. The subscription ID forms
|
|
232
|
+
# part of the URI for every service call.
|
|
233
|
+
# @param @client.accept_language [String] Gets or sets the preferred language
|
|
234
|
+
# for the response.
|
|
235
|
+
#
|
|
236
|
+
# @return [Concurrent::Promise] promise which provides async access to http
|
|
237
|
+
# response.
|
|
238
|
+
#
|
|
239
|
+
def create_or_update(resource_group_name, network_security_group_name, parameters, custom_headers = nil)
|
|
240
|
+
# Send request
|
|
241
|
+
promise = begin_create_or_update(resource_group_name, network_security_group_name, parameters, custom_headers)
|
|
242
|
+
|
|
243
|
+
promise = promise.then do |response|
|
|
244
|
+
# Defining deserialization method.
|
|
245
|
+
deserialize_method = lambda do |parsed_response|
|
|
246
|
+
unless parsed_response.nil?
|
|
247
|
+
parsed_response = NetworkSecurityGroup.deserialize_object(parsed_response)
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# Waiting for response.
|
|
252
|
+
@client.get_put_operation_result(response, custom_headers, deserialize_method)
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
promise
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
#
|
|
259
|
+
# The Put NetworkSecurityGroup operation creates/updates a network security
|
|
260
|
+
# groupin the specified resource group.
|
|
261
|
+
# @param resource_group_name [String] The name of the resource group.
|
|
262
|
+
# @param network_security_group_name [String] The name of the network security
|
|
263
|
+
# group.
|
|
264
|
+
# @param parameters [NetworkSecurityGroup] Parameters supplied to the
|
|
265
|
+
# create/update Network Security Group operation
|
|
266
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
267
|
+
# applied to HTTP request.
|
|
268
|
+
#
|
|
269
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
270
|
+
# response.
|
|
271
|
+
#
|
|
272
|
+
def begin_create_or_update(resource_group_name, network_security_group_name, parameters, custom_headers = nil)
|
|
273
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
|
274
|
+
fail ArgumentError, 'network_security_group_name is nil' if network_security_group_name.nil?
|
|
275
|
+
fail ArgumentError, 'parameters is nil' if parameters.nil?
|
|
276
|
+
parameters.validate unless parameters.nil?
|
|
277
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
|
278
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
|
279
|
+
# Construct URL
|
|
280
|
+
path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}"
|
|
281
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
|
282
|
+
path['{networkSecurityGroupName}'] = ERB::Util.url_encode(network_security_group_name) if path.include?('{networkSecurityGroupName}')
|
|
283
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
|
284
|
+
url = URI.join(@client.base_url, path)
|
|
285
|
+
properties = {}
|
|
286
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
|
287
|
+
unless url.query.nil?
|
|
288
|
+
url.query.split('&').each do |url_item|
|
|
289
|
+
url_items_parts = url_item.split('=')
|
|
290
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
properties.reject!{ |key, value| value.nil? }
|
|
294
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
295
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
296
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
297
|
+
url = URI.parse(corrected_url)
|
|
298
|
+
|
|
299
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
300
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
301
|
+
faraday.use :cookie_jar
|
|
302
|
+
faraday.adapter Faraday.default_adapter
|
|
303
|
+
end
|
|
304
|
+
request_headers = Hash.new
|
|
305
|
+
|
|
306
|
+
# Set Headers
|
|
307
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
308
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
|
309
|
+
|
|
310
|
+
unless custom_headers.nil?
|
|
311
|
+
custom_headers.each do |key, value|
|
|
312
|
+
request_headers[key] = value
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
# Serialize Request
|
|
317
|
+
request_headers['Content-Type'] = 'application/json'
|
|
318
|
+
unless parameters.nil?
|
|
319
|
+
parameters = NetworkSecurityGroup.serialize_object(parameters)
|
|
320
|
+
end
|
|
321
|
+
request_content = JSON.generate(parameters, quirks_mode: true)
|
|
322
|
+
|
|
323
|
+
# Send Request
|
|
324
|
+
promise = Concurrent::Promise.new do
|
|
325
|
+
connection.put do |request|
|
|
326
|
+
request.headers = request_headers
|
|
327
|
+
request.body = request_content
|
|
328
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
promise = promise.then do |http_response|
|
|
333
|
+
status_code = http_response.status
|
|
334
|
+
response_content = http_response.body
|
|
335
|
+
unless (status_code == 201 || status_code == 200)
|
|
336
|
+
error_model = JSON.load(response_content)
|
|
337
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
# Create Result
|
|
341
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
342
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
343
|
+
# Deserialize Response
|
|
344
|
+
if status_code == 201
|
|
345
|
+
begin
|
|
346
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
347
|
+
unless parsed_response.nil?
|
|
348
|
+
parsed_response = NetworkSecurityGroup.deserialize_object(parsed_response)
|
|
349
|
+
end
|
|
350
|
+
result.body = parsed_response
|
|
351
|
+
rescue Exception => e
|
|
352
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
# Deserialize Response
|
|
356
|
+
if status_code == 200
|
|
357
|
+
begin
|
|
358
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
359
|
+
unless parsed_response.nil?
|
|
360
|
+
parsed_response = NetworkSecurityGroup.deserialize_object(parsed_response)
|
|
361
|
+
end
|
|
362
|
+
result.body = parsed_response
|
|
363
|
+
rescue Exception => e
|
|
364
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
result
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
promise.execute
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
#
|
|
375
|
+
# The list NetworkSecurityGroups returns all network security groups in a
|
|
376
|
+
# subscription
|
|
377
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
378
|
+
# applied to HTTP request.
|
|
379
|
+
#
|
|
380
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
381
|
+
# response.
|
|
382
|
+
#
|
|
383
|
+
def list_all(custom_headers = nil)
|
|
384
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
|
385
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
|
386
|
+
# Construct URL
|
|
387
|
+
path = "/subscriptions/{subscriptionId}/providers/Microsoft.Network/networkSecurityGroups"
|
|
388
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
|
389
|
+
url = URI.join(@client.base_url, path)
|
|
390
|
+
properties = {}
|
|
391
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
|
392
|
+
unless url.query.nil?
|
|
393
|
+
url.query.split('&').each do |url_item|
|
|
394
|
+
url_items_parts = url_item.split('=')
|
|
395
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
396
|
+
end
|
|
397
|
+
end
|
|
398
|
+
properties.reject!{ |key, value| value.nil? }
|
|
399
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
400
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
401
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
402
|
+
url = URI.parse(corrected_url)
|
|
403
|
+
|
|
404
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
405
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
406
|
+
faraday.use :cookie_jar
|
|
407
|
+
faraday.adapter Faraday.default_adapter
|
|
408
|
+
end
|
|
409
|
+
request_headers = Hash.new
|
|
410
|
+
|
|
411
|
+
# Set Headers
|
|
412
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
413
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
|
414
|
+
|
|
415
|
+
unless custom_headers.nil?
|
|
416
|
+
custom_headers.each do |key, value|
|
|
417
|
+
request_headers[key] = value
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
# Send Request
|
|
422
|
+
promise = Concurrent::Promise.new do
|
|
423
|
+
connection.get do |request|
|
|
424
|
+
request.headers = request_headers
|
|
425
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
|
426
|
+
end
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
promise = promise.then do |http_response|
|
|
430
|
+
status_code = http_response.status
|
|
431
|
+
response_content = http_response.body
|
|
432
|
+
unless (status_code == 200)
|
|
433
|
+
error_model = JSON.load(response_content)
|
|
434
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
# Create Result
|
|
438
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
439
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
440
|
+
# Deserialize Response
|
|
441
|
+
if status_code == 200
|
|
442
|
+
begin
|
|
443
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
444
|
+
unless parsed_response.nil?
|
|
445
|
+
parsed_response = NetworkSecurityGroupListResult.deserialize_object(parsed_response)
|
|
446
|
+
end
|
|
447
|
+
result.body = parsed_response
|
|
448
|
+
rescue Exception => e
|
|
449
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
450
|
+
end
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
result
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
promise.execute
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
#
|
|
460
|
+
# The list NetworkSecurityGroups returns all network security groups in a
|
|
461
|
+
# resource group
|
|
462
|
+
# @param resource_group_name [String] The name of the resource group.
|
|
463
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
464
|
+
# applied to HTTP request.
|
|
465
|
+
#
|
|
466
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
467
|
+
# response.
|
|
468
|
+
#
|
|
469
|
+
def list(resource_group_name, custom_headers = nil)
|
|
470
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
|
471
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
|
472
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
|
473
|
+
# Construct URL
|
|
474
|
+
path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups"
|
|
475
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
|
476
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
|
477
|
+
url = URI.join(@client.base_url, path)
|
|
478
|
+
properties = {}
|
|
479
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
|
480
|
+
unless url.query.nil?
|
|
481
|
+
url.query.split('&').each do |url_item|
|
|
482
|
+
url_items_parts = url_item.split('=')
|
|
483
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
484
|
+
end
|
|
485
|
+
end
|
|
486
|
+
properties.reject!{ |key, value| value.nil? }
|
|
487
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
488
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
489
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
490
|
+
url = URI.parse(corrected_url)
|
|
491
|
+
|
|
492
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
493
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
494
|
+
faraday.use :cookie_jar
|
|
495
|
+
faraday.adapter Faraday.default_adapter
|
|
496
|
+
end
|
|
497
|
+
request_headers = Hash.new
|
|
498
|
+
|
|
499
|
+
# Set Headers
|
|
500
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
501
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
|
502
|
+
|
|
503
|
+
unless custom_headers.nil?
|
|
504
|
+
custom_headers.each do |key, value|
|
|
505
|
+
request_headers[key] = value
|
|
506
|
+
end
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
# Send Request
|
|
510
|
+
promise = Concurrent::Promise.new do
|
|
511
|
+
connection.get do |request|
|
|
512
|
+
request.headers = request_headers
|
|
513
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
|
514
|
+
end
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
promise = promise.then do |http_response|
|
|
518
|
+
status_code = http_response.status
|
|
519
|
+
response_content = http_response.body
|
|
520
|
+
unless (status_code == 200)
|
|
521
|
+
error_model = JSON.load(response_content)
|
|
522
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
# Create Result
|
|
526
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
527
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
528
|
+
# Deserialize Response
|
|
529
|
+
if status_code == 200
|
|
530
|
+
begin
|
|
531
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
532
|
+
unless parsed_response.nil?
|
|
533
|
+
parsed_response = NetworkSecurityGroupListResult.deserialize_object(parsed_response)
|
|
534
|
+
end
|
|
535
|
+
result.body = parsed_response
|
|
536
|
+
rescue Exception => e
|
|
537
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
538
|
+
end
|
|
539
|
+
end
|
|
540
|
+
|
|
541
|
+
result
|
|
542
|
+
end
|
|
543
|
+
|
|
544
|
+
promise.execute
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
#
|
|
548
|
+
# The list NetworkSecurityGroups returns all network security groups in a
|
|
549
|
+
# subscription
|
|
550
|
+
# @param next_page_link [String] The NextLink from the previous successful
|
|
551
|
+
# call to List operation.
|
|
552
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
553
|
+
# applied to HTTP request.
|
|
554
|
+
#
|
|
555
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
556
|
+
# response.
|
|
557
|
+
#
|
|
558
|
+
def list_all_next(next_page_link, custom_headers = nil)
|
|
559
|
+
fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
|
|
560
|
+
# Construct URL
|
|
561
|
+
path = "{nextLink}"
|
|
562
|
+
path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
|
|
563
|
+
url = URI.parse(path)
|
|
564
|
+
properties = {}
|
|
565
|
+
unless url.query.nil?
|
|
566
|
+
url.query.split('&').each do |url_item|
|
|
567
|
+
url_items_parts = url_item.split('=')
|
|
568
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
569
|
+
end
|
|
570
|
+
end
|
|
571
|
+
properties.reject!{ |key, value| value.nil? }
|
|
572
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
573
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
574
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
575
|
+
url = URI.parse(corrected_url)
|
|
576
|
+
|
|
577
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
578
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
579
|
+
faraday.use :cookie_jar
|
|
580
|
+
faraday.adapter Faraday.default_adapter
|
|
581
|
+
end
|
|
582
|
+
request_headers = Hash.new
|
|
583
|
+
|
|
584
|
+
# Set Headers
|
|
585
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
586
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
|
587
|
+
|
|
588
|
+
unless custom_headers.nil?
|
|
589
|
+
custom_headers.each do |key, value|
|
|
590
|
+
request_headers[key] = value
|
|
591
|
+
end
|
|
592
|
+
end
|
|
593
|
+
|
|
594
|
+
# Send Request
|
|
595
|
+
promise = Concurrent::Promise.new do
|
|
596
|
+
connection.get do |request|
|
|
597
|
+
request.headers = request_headers
|
|
598
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
|
599
|
+
end
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
promise = promise.then do |http_response|
|
|
603
|
+
status_code = http_response.status
|
|
604
|
+
response_content = http_response.body
|
|
605
|
+
unless (status_code == 200)
|
|
606
|
+
error_model = JSON.load(response_content)
|
|
607
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
|
608
|
+
end
|
|
609
|
+
|
|
610
|
+
# Create Result
|
|
611
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
612
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
613
|
+
# Deserialize Response
|
|
614
|
+
if status_code == 200
|
|
615
|
+
begin
|
|
616
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
617
|
+
unless parsed_response.nil?
|
|
618
|
+
parsed_response = NetworkSecurityGroupListResult.deserialize_object(parsed_response)
|
|
619
|
+
end
|
|
620
|
+
result.body = parsed_response
|
|
621
|
+
rescue Exception => e
|
|
622
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
623
|
+
end
|
|
624
|
+
end
|
|
625
|
+
|
|
626
|
+
result
|
|
627
|
+
end
|
|
628
|
+
|
|
629
|
+
promise.execute
|
|
630
|
+
end
|
|
631
|
+
|
|
632
|
+
#
|
|
633
|
+
# The list NetworkSecurityGroups returns all network security groups in a
|
|
634
|
+
# resource group
|
|
635
|
+
# @param next_page_link [String] The NextLink from the previous successful
|
|
636
|
+
# call to List operation.
|
|
637
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
638
|
+
# applied to HTTP request.
|
|
639
|
+
#
|
|
640
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
641
|
+
# response.
|
|
642
|
+
#
|
|
643
|
+
def list_next(next_page_link, custom_headers = nil)
|
|
644
|
+
fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
|
|
645
|
+
# Construct URL
|
|
646
|
+
path = "{nextLink}"
|
|
647
|
+
path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
|
|
648
|
+
url = URI.parse(path)
|
|
649
|
+
properties = {}
|
|
650
|
+
unless url.query.nil?
|
|
651
|
+
url.query.split('&').each do |url_item|
|
|
652
|
+
url_items_parts = url_item.split('=')
|
|
653
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
654
|
+
end
|
|
655
|
+
end
|
|
656
|
+
properties.reject!{ |key, value| value.nil? }
|
|
657
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
658
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
659
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
660
|
+
url = URI.parse(corrected_url)
|
|
661
|
+
|
|
662
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
663
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
664
|
+
faraday.use :cookie_jar
|
|
665
|
+
faraday.adapter Faraday.default_adapter
|
|
666
|
+
end
|
|
667
|
+
request_headers = Hash.new
|
|
668
|
+
|
|
669
|
+
# Set Headers
|
|
670
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
671
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
|
672
|
+
|
|
673
|
+
unless custom_headers.nil?
|
|
674
|
+
custom_headers.each do |key, value|
|
|
675
|
+
request_headers[key] = value
|
|
676
|
+
end
|
|
677
|
+
end
|
|
678
|
+
|
|
679
|
+
# Send Request
|
|
680
|
+
promise = Concurrent::Promise.new do
|
|
681
|
+
connection.get do |request|
|
|
682
|
+
request.headers = request_headers
|
|
683
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
|
684
|
+
end
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
promise = promise.then do |http_response|
|
|
688
|
+
status_code = http_response.status
|
|
689
|
+
response_content = http_response.body
|
|
690
|
+
unless (status_code == 200)
|
|
691
|
+
error_model = JSON.load(response_content)
|
|
692
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
|
693
|
+
end
|
|
694
|
+
|
|
695
|
+
# Create Result
|
|
696
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
697
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
698
|
+
# Deserialize Response
|
|
699
|
+
if status_code == 200
|
|
700
|
+
begin
|
|
701
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
702
|
+
unless parsed_response.nil?
|
|
703
|
+
parsed_response = NetworkSecurityGroupListResult.deserialize_object(parsed_response)
|
|
704
|
+
end
|
|
705
|
+
result.body = parsed_response
|
|
706
|
+
rescue Exception => e
|
|
707
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
708
|
+
end
|
|
709
|
+
end
|
|
710
|
+
|
|
711
|
+
result
|
|
712
|
+
end
|
|
713
|
+
|
|
714
|
+
promise.execute
|
|
715
|
+
end
|
|
716
|
+
|
|
717
|
+
end
|
|
718
|
+
end
|