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,563 @@
|
|
|
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
|
+
# SecurityRules
|
|
9
|
+
#
|
|
10
|
+
class SecurityRules
|
|
11
|
+
include Azure::ARM::Network::Models
|
|
12
|
+
include MsRestAzure
|
|
13
|
+
|
|
14
|
+
#
|
|
15
|
+
# Creates and initializes a new instance of the SecurityRules 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 network security rule operation deletes the specified network
|
|
27
|
+
# security rule.
|
|
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
|
+
# @param security_rule_name [String] The name of the security rule.
|
|
32
|
+
# @return [Concurrent::Promise] promise which provides async access to http
|
|
33
|
+
# response.
|
|
34
|
+
#
|
|
35
|
+
def delete(resource_group_name, network_security_group_name, security_rule_name, custom_headers = nil)
|
|
36
|
+
# Send request
|
|
37
|
+
promise = begin_delete(resource_group_name, network_security_group_name, security_rule_name, custom_headers)
|
|
38
|
+
|
|
39
|
+
promise = promise.then do |response|
|
|
40
|
+
# Defining deserialization method.
|
|
41
|
+
deserialize_method = lambda do |parsed_response|
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Waiting for response.
|
|
45
|
+
@client.get_post_or_delete_operation_result(response, nil, deserialize_method)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
promise
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
#
|
|
52
|
+
# The delete network security rule operation deletes the specified network
|
|
53
|
+
# security rule.
|
|
54
|
+
# @param resource_group_name [String] The name of the resource group.
|
|
55
|
+
# @param network_security_group_name [String] The name of the network security
|
|
56
|
+
# group.
|
|
57
|
+
# @param security_rule_name [String] The name of the security rule.
|
|
58
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
59
|
+
# applied to HTTP request.
|
|
60
|
+
#
|
|
61
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
62
|
+
# response.
|
|
63
|
+
#
|
|
64
|
+
def begin_delete(resource_group_name, network_security_group_name, security_rule_name, custom_headers = nil)
|
|
65
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
|
66
|
+
fail ArgumentError, 'network_security_group_name is nil' if network_security_group_name.nil?
|
|
67
|
+
fail ArgumentError, 'security_rule_name is nil' if security_rule_name.nil?
|
|
68
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
|
69
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
|
70
|
+
# Construct URL
|
|
71
|
+
path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}"
|
|
72
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
|
73
|
+
path['{networkSecurityGroupName}'] = ERB::Util.url_encode(network_security_group_name) if path.include?('{networkSecurityGroupName}')
|
|
74
|
+
path['{securityRuleName}'] = ERB::Util.url_encode(security_rule_name) if path.include?('{securityRuleName}')
|
|
75
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
|
76
|
+
url = URI.join(@client.base_url, path)
|
|
77
|
+
properties = {}
|
|
78
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
|
79
|
+
unless url.query.nil?
|
|
80
|
+
url.query.split('&').each do |url_item|
|
|
81
|
+
url_items_parts = url_item.split('=')
|
|
82
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
properties.reject!{ |key, value| value.nil? }
|
|
86
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
87
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
88
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
89
|
+
url = URI.parse(corrected_url)
|
|
90
|
+
|
|
91
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
92
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
93
|
+
faraday.use :cookie_jar
|
|
94
|
+
faraday.adapter Faraday.default_adapter
|
|
95
|
+
end
|
|
96
|
+
request_headers = Hash.new
|
|
97
|
+
|
|
98
|
+
# Set Headers
|
|
99
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
100
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
|
101
|
+
|
|
102
|
+
unless custom_headers.nil?
|
|
103
|
+
custom_headers.each do |key, value|
|
|
104
|
+
request_headers[key] = value
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Send Request
|
|
109
|
+
promise = Concurrent::Promise.new do
|
|
110
|
+
connection.delete do |request|
|
|
111
|
+
request.headers = request_headers
|
|
112
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
promise = promise.then do |http_response|
|
|
117
|
+
status_code = http_response.status
|
|
118
|
+
response_content = http_response.body
|
|
119
|
+
unless (status_code == 202 || status_code == 200 || status_code == 204)
|
|
120
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Create Result
|
|
124
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
125
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
126
|
+
|
|
127
|
+
result
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
promise.execute
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
#
|
|
134
|
+
# The Get NetworkSecurityRule operation retreives information about the
|
|
135
|
+
# specified network security rule.
|
|
136
|
+
# @param resource_group_name [String] The name of the resource group.
|
|
137
|
+
# @param network_security_group_name [String] The name of the network security
|
|
138
|
+
# group.
|
|
139
|
+
# @param security_rule_name [String] The name of the security rule.
|
|
140
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
141
|
+
# applied to HTTP request.
|
|
142
|
+
#
|
|
143
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
144
|
+
# response.
|
|
145
|
+
#
|
|
146
|
+
def get(resource_group_name, network_security_group_name, security_rule_name, custom_headers = nil)
|
|
147
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
|
148
|
+
fail ArgumentError, 'network_security_group_name is nil' if network_security_group_name.nil?
|
|
149
|
+
fail ArgumentError, 'security_rule_name is nil' if security_rule_name.nil?
|
|
150
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
|
151
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
|
152
|
+
# Construct URL
|
|
153
|
+
path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}"
|
|
154
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
|
155
|
+
path['{networkSecurityGroupName}'] = ERB::Util.url_encode(network_security_group_name) if path.include?('{networkSecurityGroupName}')
|
|
156
|
+
path['{securityRuleName}'] = ERB::Util.url_encode(security_rule_name) if path.include?('{securityRuleName}')
|
|
157
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
|
158
|
+
url = URI.join(@client.base_url, path)
|
|
159
|
+
properties = {}
|
|
160
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
|
161
|
+
unless url.query.nil?
|
|
162
|
+
url.query.split('&').each do |url_item|
|
|
163
|
+
url_items_parts = url_item.split('=')
|
|
164
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
properties.reject!{ |key, value| value.nil? }
|
|
168
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
169
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
170
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
171
|
+
url = URI.parse(corrected_url)
|
|
172
|
+
|
|
173
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
174
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
175
|
+
faraday.use :cookie_jar
|
|
176
|
+
faraday.adapter Faraday.default_adapter
|
|
177
|
+
end
|
|
178
|
+
request_headers = Hash.new
|
|
179
|
+
|
|
180
|
+
# Set Headers
|
|
181
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
182
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
|
183
|
+
|
|
184
|
+
unless custom_headers.nil?
|
|
185
|
+
custom_headers.each do |key, value|
|
|
186
|
+
request_headers[key] = value
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Send Request
|
|
191
|
+
promise = Concurrent::Promise.new do
|
|
192
|
+
connection.get do |request|
|
|
193
|
+
request.headers = request_headers
|
|
194
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
promise = promise.then do |http_response|
|
|
199
|
+
status_code = http_response.status
|
|
200
|
+
response_content = http_response.body
|
|
201
|
+
unless (status_code == 200)
|
|
202
|
+
error_model = JSON.load(response_content)
|
|
203
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Create Result
|
|
207
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
208
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
209
|
+
# Deserialize Response
|
|
210
|
+
if status_code == 200
|
|
211
|
+
begin
|
|
212
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
213
|
+
unless parsed_response.nil?
|
|
214
|
+
parsed_response = SecurityRule.deserialize_object(parsed_response)
|
|
215
|
+
end
|
|
216
|
+
result.body = parsed_response
|
|
217
|
+
rescue Exception => e
|
|
218
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
result
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
promise.execute
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
#
|
|
229
|
+
# The Put network security rule operation creates/updates a security rule in
|
|
230
|
+
# the specified network security group
|
|
231
|
+
# @param resource_group_name [String] The name of the resource group.
|
|
232
|
+
# @param network_security_group_name [String] The name of the network security
|
|
233
|
+
# group.
|
|
234
|
+
# @param security_rule_name [String] The name of the security rule.
|
|
235
|
+
# @param security_rule_parameters [SecurityRule] Parameters supplied to the
|
|
236
|
+
# create/update network security rule operation
|
|
237
|
+
# @param @client.api_version [String] Client Api Version.
|
|
238
|
+
# @param @client.subscription_id [String] Gets subscription credentials which
|
|
239
|
+
# uniquely identify Microsoft Azure subscription. The subscription ID forms
|
|
240
|
+
# part of the URI for every service call.
|
|
241
|
+
# @param @client.accept_language [String] Gets or sets the preferred language
|
|
242
|
+
# for the response.
|
|
243
|
+
#
|
|
244
|
+
# @return [Concurrent::Promise] promise which provides async access to http
|
|
245
|
+
# response.
|
|
246
|
+
#
|
|
247
|
+
def create_or_update(resource_group_name, network_security_group_name, security_rule_name, security_rule_parameters, custom_headers = nil)
|
|
248
|
+
# Send request
|
|
249
|
+
promise = begin_create_or_update(resource_group_name, network_security_group_name, security_rule_name, security_rule_parameters, custom_headers)
|
|
250
|
+
|
|
251
|
+
promise = promise.then do |response|
|
|
252
|
+
# Defining deserialization method.
|
|
253
|
+
deserialize_method = lambda do |parsed_response|
|
|
254
|
+
unless parsed_response.nil?
|
|
255
|
+
parsed_response = SecurityRule.deserialize_object(parsed_response)
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# Waiting for response.
|
|
260
|
+
@client.get_put_operation_result(response, custom_headers, deserialize_method)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
promise
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
#
|
|
267
|
+
# The Put network security rule operation creates/updates a security rule in
|
|
268
|
+
# the specified network security group
|
|
269
|
+
# @param resource_group_name [String] The name of the resource group.
|
|
270
|
+
# @param network_security_group_name [String] The name of the network security
|
|
271
|
+
# group.
|
|
272
|
+
# @param security_rule_name [String] The name of the security rule.
|
|
273
|
+
# @param security_rule_parameters [SecurityRule] Parameters supplied to the
|
|
274
|
+
# create/update network security rule operation
|
|
275
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
276
|
+
# applied to HTTP request.
|
|
277
|
+
#
|
|
278
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
279
|
+
# response.
|
|
280
|
+
#
|
|
281
|
+
def begin_create_or_update(resource_group_name, network_security_group_name, security_rule_name, security_rule_parameters, custom_headers = nil)
|
|
282
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
|
283
|
+
fail ArgumentError, 'network_security_group_name is nil' if network_security_group_name.nil?
|
|
284
|
+
fail ArgumentError, 'security_rule_name is nil' if security_rule_name.nil?
|
|
285
|
+
fail ArgumentError, 'security_rule_parameters is nil' if security_rule_parameters.nil?
|
|
286
|
+
security_rule_parameters.validate unless security_rule_parameters.nil?
|
|
287
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
|
288
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
|
289
|
+
# Construct URL
|
|
290
|
+
path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}"
|
|
291
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
|
292
|
+
path['{networkSecurityGroupName}'] = ERB::Util.url_encode(network_security_group_name) if path.include?('{networkSecurityGroupName}')
|
|
293
|
+
path['{securityRuleName}'] = ERB::Util.url_encode(security_rule_name) if path.include?('{securityRuleName}')
|
|
294
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
|
295
|
+
url = URI.join(@client.base_url, path)
|
|
296
|
+
properties = {}
|
|
297
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
|
298
|
+
unless url.query.nil?
|
|
299
|
+
url.query.split('&').each do |url_item|
|
|
300
|
+
url_items_parts = url_item.split('=')
|
|
301
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
properties.reject!{ |key, value| value.nil? }
|
|
305
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
306
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
307
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
308
|
+
url = URI.parse(corrected_url)
|
|
309
|
+
|
|
310
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
311
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
312
|
+
faraday.use :cookie_jar
|
|
313
|
+
faraday.adapter Faraday.default_adapter
|
|
314
|
+
end
|
|
315
|
+
request_headers = Hash.new
|
|
316
|
+
|
|
317
|
+
# Set Headers
|
|
318
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
319
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
|
320
|
+
|
|
321
|
+
unless custom_headers.nil?
|
|
322
|
+
custom_headers.each do |key, value|
|
|
323
|
+
request_headers[key] = value
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
# Serialize Request
|
|
328
|
+
request_headers['Content-Type'] = 'application/json'
|
|
329
|
+
unless security_rule_parameters.nil?
|
|
330
|
+
security_rule_parameters = SecurityRule.serialize_object(security_rule_parameters)
|
|
331
|
+
end
|
|
332
|
+
request_content = JSON.generate(security_rule_parameters, quirks_mode: true)
|
|
333
|
+
|
|
334
|
+
# Send Request
|
|
335
|
+
promise = Concurrent::Promise.new do
|
|
336
|
+
connection.put do |request|
|
|
337
|
+
request.headers = request_headers
|
|
338
|
+
request.body = request_content
|
|
339
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
promise = promise.then do |http_response|
|
|
344
|
+
status_code = http_response.status
|
|
345
|
+
response_content = http_response.body
|
|
346
|
+
unless (status_code == 200 || status_code == 201)
|
|
347
|
+
error_model = JSON.load(response_content)
|
|
348
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
# Create Result
|
|
352
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
353
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
354
|
+
# Deserialize Response
|
|
355
|
+
if status_code == 200
|
|
356
|
+
begin
|
|
357
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
358
|
+
unless parsed_response.nil?
|
|
359
|
+
parsed_response = SecurityRule.deserialize_object(parsed_response)
|
|
360
|
+
end
|
|
361
|
+
result.body = parsed_response
|
|
362
|
+
rescue Exception => e
|
|
363
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
# Deserialize Response
|
|
367
|
+
if status_code == 201
|
|
368
|
+
begin
|
|
369
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
370
|
+
unless parsed_response.nil?
|
|
371
|
+
parsed_response = SecurityRule.deserialize_object(parsed_response)
|
|
372
|
+
end
|
|
373
|
+
result.body = parsed_response
|
|
374
|
+
rescue Exception => e
|
|
375
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
result
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
promise.execute
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
#
|
|
386
|
+
# The List network security rule opertion retrieves all the security rules in
|
|
387
|
+
# a network security group.
|
|
388
|
+
# @param resource_group_name [String] The name of the resource group.
|
|
389
|
+
# @param network_security_group_name [String] The name of the network security
|
|
390
|
+
# group.
|
|
391
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
392
|
+
# applied to HTTP request.
|
|
393
|
+
#
|
|
394
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
395
|
+
# response.
|
|
396
|
+
#
|
|
397
|
+
def list(resource_group_name, network_security_group_name, custom_headers = nil)
|
|
398
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
|
399
|
+
fail ArgumentError, 'network_security_group_name is nil' if network_security_group_name.nil?
|
|
400
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
|
401
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
|
402
|
+
# Construct URL
|
|
403
|
+
path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules"
|
|
404
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
|
405
|
+
path['{networkSecurityGroupName}'] = ERB::Util.url_encode(network_security_group_name) if path.include?('{networkSecurityGroupName}')
|
|
406
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
|
407
|
+
url = URI.join(@client.base_url, path)
|
|
408
|
+
properties = {}
|
|
409
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
|
410
|
+
unless url.query.nil?
|
|
411
|
+
url.query.split('&').each do |url_item|
|
|
412
|
+
url_items_parts = url_item.split('=')
|
|
413
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
properties.reject!{ |key, value| value.nil? }
|
|
417
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
418
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
419
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
420
|
+
url = URI.parse(corrected_url)
|
|
421
|
+
|
|
422
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
423
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
424
|
+
faraday.use :cookie_jar
|
|
425
|
+
faraday.adapter Faraday.default_adapter
|
|
426
|
+
end
|
|
427
|
+
request_headers = Hash.new
|
|
428
|
+
|
|
429
|
+
# Set Headers
|
|
430
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
431
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
|
432
|
+
|
|
433
|
+
unless custom_headers.nil?
|
|
434
|
+
custom_headers.each do |key, value|
|
|
435
|
+
request_headers[key] = value
|
|
436
|
+
end
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
# Send Request
|
|
440
|
+
promise = Concurrent::Promise.new do
|
|
441
|
+
connection.get do |request|
|
|
442
|
+
request.headers = request_headers
|
|
443
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
|
444
|
+
end
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
promise = promise.then do |http_response|
|
|
448
|
+
status_code = http_response.status
|
|
449
|
+
response_content = http_response.body
|
|
450
|
+
unless (status_code == 200)
|
|
451
|
+
error_model = JSON.load(response_content)
|
|
452
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
# Create Result
|
|
456
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
457
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
458
|
+
# Deserialize Response
|
|
459
|
+
if status_code == 200
|
|
460
|
+
begin
|
|
461
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
462
|
+
unless parsed_response.nil?
|
|
463
|
+
parsed_response = SecurityRuleListResult.deserialize_object(parsed_response)
|
|
464
|
+
end
|
|
465
|
+
result.body = parsed_response
|
|
466
|
+
rescue Exception => e
|
|
467
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
result
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
promise.execute
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
#
|
|
478
|
+
# The List network security rule opertion retrieves all the security rules in
|
|
479
|
+
# a network security group.
|
|
480
|
+
# @param next_page_link [String] The NextLink from the previous successful
|
|
481
|
+
# call to List operation.
|
|
482
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
|
483
|
+
# applied to HTTP request.
|
|
484
|
+
#
|
|
485
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
|
486
|
+
# response.
|
|
487
|
+
#
|
|
488
|
+
def list_next(next_page_link, custom_headers = nil)
|
|
489
|
+
fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
|
|
490
|
+
# Construct URL
|
|
491
|
+
path = "{nextLink}"
|
|
492
|
+
path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
|
|
493
|
+
url = URI.parse(path)
|
|
494
|
+
properties = {}
|
|
495
|
+
unless url.query.nil?
|
|
496
|
+
url.query.split('&').each do |url_item|
|
|
497
|
+
url_items_parts = url_item.split('=')
|
|
498
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
properties.reject!{ |key, value| value.nil? }
|
|
502
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
|
503
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
|
504
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
|
505
|
+
url = URI.parse(corrected_url)
|
|
506
|
+
|
|
507
|
+
connection = Faraday.new(:url => url) do |faraday|
|
|
508
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
|
509
|
+
faraday.use :cookie_jar
|
|
510
|
+
faraday.adapter Faraday.default_adapter
|
|
511
|
+
end
|
|
512
|
+
request_headers = Hash.new
|
|
513
|
+
|
|
514
|
+
# Set Headers
|
|
515
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
516
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
|
517
|
+
|
|
518
|
+
unless custom_headers.nil?
|
|
519
|
+
custom_headers.each do |key, value|
|
|
520
|
+
request_headers[key] = value
|
|
521
|
+
end
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
# Send Request
|
|
525
|
+
promise = Concurrent::Promise.new do
|
|
526
|
+
connection.get do |request|
|
|
527
|
+
request.headers = request_headers
|
|
528
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
|
529
|
+
end
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
promise = promise.then do |http_response|
|
|
533
|
+
status_code = http_response.status
|
|
534
|
+
response_content = http_response.body
|
|
535
|
+
unless (status_code == 200)
|
|
536
|
+
error_model = JSON.load(response_content)
|
|
537
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
# Create Result
|
|
541
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
|
542
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
543
|
+
# Deserialize Response
|
|
544
|
+
if status_code == 200
|
|
545
|
+
begin
|
|
546
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
|
547
|
+
unless parsed_response.nil?
|
|
548
|
+
parsed_response = SecurityRuleListResult.deserialize_object(parsed_response)
|
|
549
|
+
end
|
|
550
|
+
result.body = parsed_response
|
|
551
|
+
rescue Exception => e
|
|
552
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
|
553
|
+
end
|
|
554
|
+
end
|
|
555
|
+
|
|
556
|
+
result
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
promise.execute
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
end
|
|
563
|
+
end
|