azure_mgmt_postgresql 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql.rb +71 -0
  4. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/check_name_availability.rb +126 -0
  5. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/configurations.rb +396 -0
  6. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/databases.rb +541 -0
  7. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/firewall_rules.rb +541 -0
  8. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/location_based_performance_tier.rb +116 -0
  9. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/log_files.rb +126 -0
  10. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/configuration.rb +132 -0
  11. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/configuration_list_result.rb +55 -0
  12. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/database.rb +84 -0
  13. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/database_list_result.rb +55 -0
  14. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/firewall_rule.rb +92 -0
  15. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/firewall_rule_list_result.rb +55 -0
  16. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/geo_redundant_backup.rb +16 -0
  17. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/log_file.rb +119 -0
  18. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/log_file_list_result.rb +55 -0
  19. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/name_availability.rb +68 -0
  20. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/name_availability_request.rb +57 -0
  21. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/operation.rb +95 -0
  22. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/operation_display.rb +83 -0
  23. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/operation_list_result.rb +55 -0
  24. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/operation_origin.rb +17 -0
  25. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/performance_tier_list_result.rb +56 -0
  26. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/performance_tier_properties.rb +67 -0
  27. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/performance_tier_service_level_objectives.rb +126 -0
  28. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/proxy_resource.rb +71 -0
  29. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/server.rb +220 -0
  30. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/server_for_create.rb +92 -0
  31. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/server_list_result.rb +55 -0
  32. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/server_properties_for_create.rb +86 -0
  33. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/server_properties_for_default_create.rb +100 -0
  34. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/server_properties_for_geo_restore.rb +88 -0
  35. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/server_properties_for_replica.rb +87 -0
  36. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/server_properties_for_restore.rb +99 -0
  37. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/server_state.rb +17 -0
  38. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/server_update_parameters.rb +115 -0
  39. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/server_version.rb +16 -0
  40. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/sku.rb +97 -0
  41. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/sku_tier.rb +17 -0
  42. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/ssl_enforcement_enum.rb +16 -0
  43. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/storage_profile.rb +69 -0
  44. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/models/tracked_resource.rb +93 -0
  45. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/module_definition.rb +9 -0
  46. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/operations.rb +110 -0
  47. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/postgre_sqlmanagement_client.rb +164 -0
  48. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/replicas.rb +126 -0
  49. data/lib/2017-12-01-preview/generated/azure_mgmt_postgresql/servers.rb +771 -0
  50. data/lib/2017-12-01/generated/azure_mgmt_postgresql.rb +78 -0
  51. data/lib/2017-12-01/generated/azure_mgmt_postgresql/check_name_availability.rb +126 -0
  52. data/lib/2017-12-01/generated/azure_mgmt_postgresql/configurations.rb +396 -0
  53. data/lib/2017-12-01/generated/azure_mgmt_postgresql/databases.rb +541 -0
  54. data/lib/2017-12-01/generated/azure_mgmt_postgresql/firewall_rules.rb +541 -0
  55. data/lib/2017-12-01/generated/azure_mgmt_postgresql/location_based_performance_tier.rb +116 -0
  56. data/lib/2017-12-01/generated/azure_mgmt_postgresql/log_files.rb +126 -0
  57. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/configuration.rb +132 -0
  58. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/configuration_list_result.rb +55 -0
  59. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/database.rb +84 -0
  60. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/database_list_result.rb +55 -0
  61. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/firewall_rule.rb +92 -0
  62. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/firewall_rule_list_result.rb +55 -0
  63. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/geo_redundant_backup.rb +16 -0
  64. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/log_file.rb +119 -0
  65. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/log_file_list_result.rb +55 -0
  66. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/name_availability.rb +68 -0
  67. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/name_availability_request.rb +57 -0
  68. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/operation.rb +95 -0
  69. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/operation_display.rb +83 -0
  70. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/operation_list_result.rb +55 -0
  71. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/operation_origin.rb +17 -0
  72. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/performance_tier_list_result.rb +56 -0
  73. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/performance_tier_properties.rb +67 -0
  74. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/performance_tier_service_level_objectives.rb +126 -0
  75. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/proxy_resource.rb +71 -0
  76. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server.rb +220 -0
  77. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server_for_create.rb +92 -0
  78. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server_list_result.rb +55 -0
  79. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server_properties_for_create.rb +86 -0
  80. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server_properties_for_default_create.rb +100 -0
  81. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server_properties_for_geo_restore.rb +88 -0
  82. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server_properties_for_replica.rb +87 -0
  83. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server_properties_for_restore.rb +99 -0
  84. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server_security_alert_policy.rb +166 -0
  85. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server_security_alert_policy_state.rb +16 -0
  86. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server_state.rb +17 -0
  87. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server_update_parameters.rb +126 -0
  88. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/server_version.rb +19 -0
  89. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/sku.rb +97 -0
  90. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/sku_tier.rb +17 -0
  91. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/ssl_enforcement_enum.rb +16 -0
  92. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/storage_profile.rb +69 -0
  93. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/tracked_resource.rb +93 -0
  94. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/virtual_network_rule.rb +99 -0
  95. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/virtual_network_rule_list_result.rb +100 -0
  96. data/lib/2017-12-01/generated/azure_mgmt_postgresql/models/virtual_network_rule_state.rb +19 -0
  97. data/lib/2017-12-01/generated/azure_mgmt_postgresql/module_definition.rb +9 -0
  98. data/lib/2017-12-01/generated/azure_mgmt_postgresql/operations.rb +110 -0
  99. data/lib/2017-12-01/generated/azure_mgmt_postgresql/postgre_sqlmanagement_client.rb +172 -0
  100. data/lib/2017-12-01/generated/azure_mgmt_postgresql/replicas.rb +126 -0
  101. data/lib/2017-12-01/generated/azure_mgmt_postgresql/server_security_alert_policies.rb +290 -0
  102. data/lib/2017-12-01/generated/azure_mgmt_postgresql/servers.rb +900 -0
  103. data/lib/2017-12-01/generated/azure_mgmt_postgresql/virtual_network_rules.rb +666 -0
  104. data/lib/azure_mgmt_postgresql.rb +7 -0
  105. data/lib/module_definition.rb +7 -0
  106. data/lib/profiles/latest/modules/postgresql_profile_module.rb +241 -0
  107. data/lib/profiles/latest/postgresql_latest_profile_client.rb +40 -0
  108. data/lib/profiles/latest/postgresql_module_definition.rb +8 -0
  109. data/lib/version.rb +7 -0
  110. metadata +225 -0
@@ -0,0 +1,666 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::Postgresql::Mgmt::V2017_12_01
7
+ #
8
+ # The Microsoft Azure management API provides create, read, update, and
9
+ # delete functionality for Azure PostgreSQL resources including servers,
10
+ # databases, firewall rules, VNET rules, security alert policies, log files
11
+ # and configurations with new business model.
12
+ #
13
+ class VirtualNetworkRules
14
+ include MsRestAzure
15
+
16
+ #
17
+ # Creates and initializes a new instance of the VirtualNetworkRules class.
18
+ # @param client service class for accessing basic functionality.
19
+ #
20
+ def initialize(client)
21
+ @client = client
22
+ end
23
+
24
+ # @return [PostgreSQLManagementClient] reference to the PostgreSQLManagementClient
25
+ attr_reader :client
26
+
27
+ #
28
+ # Gets a virtual network rule.
29
+ #
30
+ # @param resource_group_name [String] The name of the resource group that
31
+ # contains the resource. You can obtain this value from the Azure Resource
32
+ # Manager API or the portal.
33
+ # @param server_name [String] The name of the server.
34
+ # @param virtual_network_rule_name [String] The name of the virtual network
35
+ # rule.
36
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
37
+ # will be added to the HTTP request.
38
+ #
39
+ # @return [VirtualNetworkRule] operation results.
40
+ #
41
+ def get(resource_group_name, server_name, virtual_network_rule_name, custom_headers:nil)
42
+ response = get_async(resource_group_name, server_name, virtual_network_rule_name, custom_headers:custom_headers).value!
43
+ response.body unless response.nil?
44
+ end
45
+
46
+ #
47
+ # Gets a virtual network rule.
48
+ #
49
+ # @param resource_group_name [String] The name of the resource group that
50
+ # contains the resource. You can obtain this value from the Azure Resource
51
+ # Manager API or the portal.
52
+ # @param server_name [String] The name of the server.
53
+ # @param virtual_network_rule_name [String] The name of the virtual network
54
+ # rule.
55
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
56
+ # will be added to the HTTP request.
57
+ #
58
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
59
+ #
60
+ def get_with_http_info(resource_group_name, server_name, virtual_network_rule_name, custom_headers:nil)
61
+ get_async(resource_group_name, server_name, virtual_network_rule_name, custom_headers:custom_headers).value!
62
+ end
63
+
64
+ #
65
+ # Gets a virtual network rule.
66
+ #
67
+ # @param resource_group_name [String] The name of the resource group that
68
+ # contains the resource. You can obtain this value from the Azure Resource
69
+ # Manager API or the portal.
70
+ # @param server_name [String] The name of the server.
71
+ # @param virtual_network_rule_name [String] The name of the virtual network
72
+ # rule.
73
+ # @param [Hash{String => String}] A hash of custom headers that will be added
74
+ # to the HTTP request.
75
+ #
76
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
77
+ #
78
+ def get_async(resource_group_name, server_name, virtual_network_rule_name, custom_headers:nil)
79
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
80
+ fail ArgumentError, 'server_name is nil' if server_name.nil?
81
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
82
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
83
+ fail ArgumentError, 'virtual_network_rule_name is nil' if virtual_network_rule_name.nil?
84
+
85
+
86
+ request_headers = {}
87
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
88
+
89
+ # Set Headers
90
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
91
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
92
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'
93
+
94
+ request_url = @base_url || @client.base_url
95
+
96
+ options = {
97
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
98
+ path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id,'virtualNetworkRuleName' => virtual_network_rule_name},
99
+ query_params: {'api-version' => @client.api_version},
100
+ headers: request_headers.merge(custom_headers || {}),
101
+ base_url: request_url
102
+ }
103
+ promise = @client.make_request_async(:get, path_template, options)
104
+
105
+ promise = promise.then do |result|
106
+ http_response = result.response
107
+ status_code = http_response.status
108
+ response_content = http_response.body
109
+ unless status_code == 200
110
+ error_model = JSON.load(response_content)
111
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
112
+ end
113
+
114
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
115
+ # Deserialize Response
116
+ if status_code == 200
117
+ begin
118
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
119
+ result_mapper = Azure::Postgresql::Mgmt::V2017_12_01::Models::VirtualNetworkRule.mapper()
120
+ result.body = @client.deserialize(result_mapper, parsed_response)
121
+ rescue Exception => e
122
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
123
+ end
124
+ end
125
+
126
+ result
127
+ end
128
+
129
+ promise.execute
130
+ end
131
+
132
+ #
133
+ # Creates or updates an existing virtual network rule.
134
+ #
135
+ # @param resource_group_name [String] The name of the resource group that
136
+ # contains the resource. You can obtain this value from the Azure Resource
137
+ # Manager API or the portal.
138
+ # @param server_name [String] The name of the server.
139
+ # @param virtual_network_rule_name [String] The name of the virtual network
140
+ # rule.
141
+ # @param parameters [VirtualNetworkRule] The requested virtual Network Rule
142
+ # Resource state.
143
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
144
+ # will be added to the HTTP request.
145
+ #
146
+ # @return [VirtualNetworkRule] operation results.
147
+ #
148
+ def create_or_update(resource_group_name, server_name, virtual_network_rule_name, parameters, custom_headers:nil)
149
+ response = create_or_update_async(resource_group_name, server_name, virtual_network_rule_name, parameters, custom_headers:custom_headers).value!
150
+ response.body unless response.nil?
151
+ end
152
+
153
+ #
154
+ # @param resource_group_name [String] The name of the resource group that
155
+ # contains the resource. You can obtain this value from the Azure Resource
156
+ # Manager API or the portal.
157
+ # @param server_name [String] The name of the server.
158
+ # @param virtual_network_rule_name [String] The name of the virtual network
159
+ # rule.
160
+ # @param parameters [VirtualNetworkRule] The requested virtual Network Rule
161
+ # Resource state.
162
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
163
+ # will be added to the HTTP request.
164
+ #
165
+ # @return [Concurrent::Promise] promise which provides async access to http
166
+ # response.
167
+ #
168
+ def create_or_update_async(resource_group_name, server_name, virtual_network_rule_name, parameters, custom_headers:nil)
169
+ # Send request
170
+ promise = begin_create_or_update_async(resource_group_name, server_name, virtual_network_rule_name, parameters, custom_headers:custom_headers)
171
+
172
+ promise = promise.then do |response|
173
+ # Defining deserialization method.
174
+ deserialize_method = lambda do |parsed_response|
175
+ result_mapper = Azure::Postgresql::Mgmt::V2017_12_01::Models::VirtualNetworkRule.mapper()
176
+ parsed_response = @client.deserialize(result_mapper, parsed_response)
177
+ end
178
+
179
+ # Waiting for response.
180
+ @client.get_long_running_operation_result(response, deserialize_method)
181
+ end
182
+
183
+ promise
184
+ end
185
+
186
+ #
187
+ # Deletes the virtual network rule with the given name.
188
+ #
189
+ # @param resource_group_name [String] The name of the resource group that
190
+ # contains the resource. You can obtain this value from the Azure Resource
191
+ # Manager API or the portal.
192
+ # @param server_name [String] The name of the server.
193
+ # @param virtual_network_rule_name [String] The name of the virtual network
194
+ # rule.
195
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
196
+ # will be added to the HTTP request.
197
+ #
198
+ def delete(resource_group_name, server_name, virtual_network_rule_name, custom_headers:nil)
199
+ response = delete_async(resource_group_name, server_name, virtual_network_rule_name, custom_headers:custom_headers).value!
200
+ nil
201
+ end
202
+
203
+ #
204
+ # @param resource_group_name [String] The name of the resource group that
205
+ # contains the resource. You can obtain this value from the Azure Resource
206
+ # Manager API or the portal.
207
+ # @param server_name [String] The name of the server.
208
+ # @param virtual_network_rule_name [String] The name of the virtual network
209
+ # rule.
210
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
211
+ # will be added to the HTTP request.
212
+ #
213
+ # @return [Concurrent::Promise] promise which provides async access to http
214
+ # response.
215
+ #
216
+ def delete_async(resource_group_name, server_name, virtual_network_rule_name, custom_headers:nil)
217
+ # Send request
218
+ promise = begin_delete_async(resource_group_name, server_name, virtual_network_rule_name, custom_headers:custom_headers)
219
+
220
+ promise = promise.then do |response|
221
+ # Defining deserialization method.
222
+ deserialize_method = lambda do |parsed_response|
223
+ end
224
+
225
+ # Waiting for response.
226
+ @client.get_long_running_operation_result(response, deserialize_method)
227
+ end
228
+
229
+ promise
230
+ end
231
+
232
+ #
233
+ # Gets a list of virtual network rules in a server.
234
+ #
235
+ # @param resource_group_name [String] The name of the resource group that
236
+ # contains the resource. You can obtain this value from the Azure Resource
237
+ # Manager API or the portal.
238
+ # @param server_name [String] The name of the server.
239
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
240
+ # will be added to the HTTP request.
241
+ #
242
+ # @return [Array<VirtualNetworkRule>] operation results.
243
+ #
244
+ def list_by_server(resource_group_name, server_name, custom_headers:nil)
245
+ first_page = list_by_server_as_lazy(resource_group_name, server_name, custom_headers:custom_headers)
246
+ first_page.get_all_items
247
+ end
248
+
249
+ #
250
+ # Gets a list of virtual network rules in a server.
251
+ #
252
+ # @param resource_group_name [String] The name of the resource group that
253
+ # contains the resource. You can obtain this value from the Azure Resource
254
+ # Manager API or the portal.
255
+ # @param server_name [String] The name of the server.
256
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
257
+ # will be added to the HTTP request.
258
+ #
259
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
260
+ #
261
+ def list_by_server_with_http_info(resource_group_name, server_name, custom_headers:nil)
262
+ list_by_server_async(resource_group_name, server_name, custom_headers:custom_headers).value!
263
+ end
264
+
265
+ #
266
+ # Gets a list of virtual network rules in a server.
267
+ #
268
+ # @param resource_group_name [String] The name of the resource group that
269
+ # contains the resource. You can obtain this value from the Azure Resource
270
+ # Manager API or the portal.
271
+ # @param server_name [String] The name of the server.
272
+ # @param [Hash{String => String}] A hash of custom headers that will be added
273
+ # to the HTTP request.
274
+ #
275
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
276
+ #
277
+ def list_by_server_async(resource_group_name, server_name, custom_headers:nil)
278
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
279
+ fail ArgumentError, 'server_name is nil' if server_name.nil?
280
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
281
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
282
+
283
+
284
+ request_headers = {}
285
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
286
+
287
+ # Set Headers
288
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
289
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
290
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/virtualNetworkRules'
291
+
292
+ request_url = @base_url || @client.base_url
293
+
294
+ options = {
295
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
296
+ path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id},
297
+ query_params: {'api-version' => @client.api_version},
298
+ headers: request_headers.merge(custom_headers || {}),
299
+ base_url: request_url
300
+ }
301
+ promise = @client.make_request_async(:get, path_template, options)
302
+
303
+ promise = promise.then do |result|
304
+ http_response = result.response
305
+ status_code = http_response.status
306
+ response_content = http_response.body
307
+ unless status_code == 200
308
+ error_model = JSON.load(response_content)
309
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
310
+ end
311
+
312
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
313
+ # Deserialize Response
314
+ if status_code == 200
315
+ begin
316
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
317
+ result_mapper = Azure::Postgresql::Mgmt::V2017_12_01::Models::VirtualNetworkRuleListResult.mapper()
318
+ result.body = @client.deserialize(result_mapper, parsed_response)
319
+ rescue Exception => e
320
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
321
+ end
322
+ end
323
+
324
+ result
325
+ end
326
+
327
+ promise.execute
328
+ end
329
+
330
+ #
331
+ # Creates or updates an existing virtual network rule.
332
+ #
333
+ # @param resource_group_name [String] The name of the resource group that
334
+ # contains the resource. You can obtain this value from the Azure Resource
335
+ # Manager API or the portal.
336
+ # @param server_name [String] The name of the server.
337
+ # @param virtual_network_rule_name [String] The name of the virtual network
338
+ # rule.
339
+ # @param parameters [VirtualNetworkRule] The requested virtual Network Rule
340
+ # Resource state.
341
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
342
+ # will be added to the HTTP request.
343
+ #
344
+ # @return [VirtualNetworkRule] operation results.
345
+ #
346
+ def begin_create_or_update(resource_group_name, server_name, virtual_network_rule_name, parameters, custom_headers:nil)
347
+ response = begin_create_or_update_async(resource_group_name, server_name, virtual_network_rule_name, parameters, custom_headers:custom_headers).value!
348
+ response.body unless response.nil?
349
+ end
350
+
351
+ #
352
+ # Creates or updates an existing virtual network rule.
353
+ #
354
+ # @param resource_group_name [String] The name of the resource group that
355
+ # contains the resource. You can obtain this value from the Azure Resource
356
+ # Manager API or the portal.
357
+ # @param server_name [String] The name of the server.
358
+ # @param virtual_network_rule_name [String] The name of the virtual network
359
+ # rule.
360
+ # @param parameters [VirtualNetworkRule] The requested virtual Network Rule
361
+ # Resource state.
362
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
363
+ # will be added to the HTTP request.
364
+ #
365
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
366
+ #
367
+ def begin_create_or_update_with_http_info(resource_group_name, server_name, virtual_network_rule_name, parameters, custom_headers:nil)
368
+ begin_create_or_update_async(resource_group_name, server_name, virtual_network_rule_name, parameters, custom_headers:custom_headers).value!
369
+ end
370
+
371
+ #
372
+ # Creates or updates an existing virtual network rule.
373
+ #
374
+ # @param resource_group_name [String] The name of the resource group that
375
+ # contains the resource. You can obtain this value from the Azure Resource
376
+ # Manager API or the portal.
377
+ # @param server_name [String] The name of the server.
378
+ # @param virtual_network_rule_name [String] The name of the virtual network
379
+ # rule.
380
+ # @param parameters [VirtualNetworkRule] The requested virtual Network Rule
381
+ # Resource state.
382
+ # @param [Hash{String => String}] A hash of custom headers that will be added
383
+ # to the HTTP request.
384
+ #
385
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
386
+ #
387
+ def begin_create_or_update_async(resource_group_name, server_name, virtual_network_rule_name, parameters, custom_headers:nil)
388
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
389
+ fail ArgumentError, 'server_name is nil' if server_name.nil?
390
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
391
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
392
+ fail ArgumentError, 'virtual_network_rule_name is nil' if virtual_network_rule_name.nil?
393
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
394
+
395
+
396
+ request_headers = {}
397
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
398
+
399
+ # Set Headers
400
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
401
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
402
+
403
+ # Serialize Request
404
+ request_mapper = Azure::Postgresql::Mgmt::V2017_12_01::Models::VirtualNetworkRule.mapper()
405
+ request_content = @client.serialize(request_mapper, parameters)
406
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
407
+
408
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'
409
+
410
+ request_url = @base_url || @client.base_url
411
+
412
+ options = {
413
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
414
+ path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id,'virtualNetworkRuleName' => virtual_network_rule_name},
415
+ query_params: {'api-version' => @client.api_version},
416
+ body: request_content,
417
+ headers: request_headers.merge(custom_headers || {}),
418
+ base_url: request_url
419
+ }
420
+ promise = @client.make_request_async(:put, path_template, options)
421
+
422
+ promise = promise.then do |result|
423
+ http_response = result.response
424
+ status_code = http_response.status
425
+ response_content = http_response.body
426
+ unless status_code == 200 || status_code == 202 || status_code == 201
427
+ error_model = JSON.load(response_content)
428
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
429
+ end
430
+
431
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
432
+ # Deserialize Response
433
+ if status_code == 200
434
+ begin
435
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
436
+ result_mapper = Azure::Postgresql::Mgmt::V2017_12_01::Models::VirtualNetworkRule.mapper()
437
+ result.body = @client.deserialize(result_mapper, parsed_response)
438
+ rescue Exception => e
439
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
440
+ end
441
+ end
442
+ # Deserialize Response
443
+ if status_code == 201
444
+ begin
445
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
446
+ result_mapper = Azure::Postgresql::Mgmt::V2017_12_01::Models::VirtualNetworkRule.mapper()
447
+ result.body = @client.deserialize(result_mapper, parsed_response)
448
+ rescue Exception => e
449
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
450
+ end
451
+ end
452
+
453
+ result
454
+ end
455
+
456
+ promise.execute
457
+ end
458
+
459
+ #
460
+ # Deletes the virtual network rule with the given name.
461
+ #
462
+ # @param resource_group_name [String] The name of the resource group that
463
+ # contains the resource. You can obtain this value from the Azure Resource
464
+ # Manager API or the portal.
465
+ # @param server_name [String] The name of the server.
466
+ # @param virtual_network_rule_name [String] The name of the virtual network
467
+ # rule.
468
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
469
+ # will be added to the HTTP request.
470
+ #
471
+ #
472
+ def begin_delete(resource_group_name, server_name, virtual_network_rule_name, custom_headers:nil)
473
+ response = begin_delete_async(resource_group_name, server_name, virtual_network_rule_name, custom_headers:custom_headers).value!
474
+ nil
475
+ end
476
+
477
+ #
478
+ # Deletes the virtual network rule with the given name.
479
+ #
480
+ # @param resource_group_name [String] The name of the resource group that
481
+ # contains the resource. You can obtain this value from the Azure Resource
482
+ # Manager API or the portal.
483
+ # @param server_name [String] The name of the server.
484
+ # @param virtual_network_rule_name [String] The name of the virtual network
485
+ # rule.
486
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
487
+ # will be added to the HTTP request.
488
+ #
489
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
490
+ #
491
+ def begin_delete_with_http_info(resource_group_name, server_name, virtual_network_rule_name, custom_headers:nil)
492
+ begin_delete_async(resource_group_name, server_name, virtual_network_rule_name, custom_headers:custom_headers).value!
493
+ end
494
+
495
+ #
496
+ # Deletes the virtual network rule with the given name.
497
+ #
498
+ # @param resource_group_name [String] The name of the resource group that
499
+ # contains the resource. You can obtain this value from the Azure Resource
500
+ # Manager API or the portal.
501
+ # @param server_name [String] The name of the server.
502
+ # @param virtual_network_rule_name [String] The name of the virtual network
503
+ # rule.
504
+ # @param [Hash{String => String}] A hash of custom headers that will be added
505
+ # to the HTTP request.
506
+ #
507
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
508
+ #
509
+ def begin_delete_async(resource_group_name, server_name, virtual_network_rule_name, custom_headers:nil)
510
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
511
+ fail ArgumentError, 'server_name is nil' if server_name.nil?
512
+ fail ArgumentError, 'virtual_network_rule_name is nil' if virtual_network_rule_name.nil?
513
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
514
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
515
+
516
+
517
+ request_headers = {}
518
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
519
+
520
+ # Set Headers
521
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
522
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
523
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}'
524
+
525
+ request_url = @base_url || @client.base_url
526
+
527
+ options = {
528
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
529
+ path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'virtualNetworkRuleName' => virtual_network_rule_name,'subscriptionId' => @client.subscription_id},
530
+ query_params: {'api-version' => @client.api_version},
531
+ headers: request_headers.merge(custom_headers || {}),
532
+ base_url: request_url
533
+ }
534
+ promise = @client.make_request_async(:delete, path_template, options)
535
+
536
+ promise = promise.then do |result|
537
+ http_response = result.response
538
+ status_code = http_response.status
539
+ response_content = http_response.body
540
+ unless status_code == 200 || status_code == 202 || status_code == 204
541
+ error_model = JSON.load(response_content)
542
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
543
+ end
544
+
545
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
546
+
547
+ result
548
+ end
549
+
550
+ promise.execute
551
+ end
552
+
553
+ #
554
+ # Gets a list of virtual network rules in a server.
555
+ #
556
+ # @param next_page_link [String] The NextLink from the previous successful call
557
+ # to List operation.
558
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
559
+ # will be added to the HTTP request.
560
+ #
561
+ # @return [VirtualNetworkRuleListResult] operation results.
562
+ #
563
+ def list_by_server_next(next_page_link, custom_headers:nil)
564
+ response = list_by_server_next_async(next_page_link, custom_headers:custom_headers).value!
565
+ response.body unless response.nil?
566
+ end
567
+
568
+ #
569
+ # Gets a list of virtual network rules in a server.
570
+ #
571
+ # @param next_page_link [String] The NextLink from the previous successful call
572
+ # to List operation.
573
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
574
+ # will be added to the HTTP request.
575
+ #
576
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
577
+ #
578
+ def list_by_server_next_with_http_info(next_page_link, custom_headers:nil)
579
+ list_by_server_next_async(next_page_link, custom_headers:custom_headers).value!
580
+ end
581
+
582
+ #
583
+ # Gets a list of virtual network rules in a server.
584
+ #
585
+ # @param next_page_link [String] The NextLink from the previous successful call
586
+ # to List operation.
587
+ # @param [Hash{String => String}] A hash of custom headers that will be added
588
+ # to the HTTP request.
589
+ #
590
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
591
+ #
592
+ def list_by_server_next_async(next_page_link, custom_headers:nil)
593
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
594
+
595
+
596
+ request_headers = {}
597
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
598
+
599
+ # Set Headers
600
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
601
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
602
+ path_template = '{nextLink}'
603
+
604
+ request_url = @base_url || @client.base_url
605
+
606
+ options = {
607
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
608
+ skip_encoding_path_params: {'nextLink' => next_page_link},
609
+ headers: request_headers.merge(custom_headers || {}),
610
+ base_url: request_url
611
+ }
612
+ promise = @client.make_request_async(:get, path_template, options)
613
+
614
+ promise = promise.then do |result|
615
+ http_response = result.response
616
+ status_code = http_response.status
617
+ response_content = http_response.body
618
+ unless status_code == 200
619
+ error_model = JSON.load(response_content)
620
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
621
+ end
622
+
623
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
624
+ # Deserialize Response
625
+ if status_code == 200
626
+ begin
627
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
628
+ result_mapper = Azure::Postgresql::Mgmt::V2017_12_01::Models::VirtualNetworkRuleListResult.mapper()
629
+ result.body = @client.deserialize(result_mapper, parsed_response)
630
+ rescue Exception => e
631
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
632
+ end
633
+ end
634
+
635
+ result
636
+ end
637
+
638
+ promise.execute
639
+ end
640
+
641
+ #
642
+ # Gets a list of virtual network rules in a server.
643
+ #
644
+ # @param resource_group_name [String] The name of the resource group that
645
+ # contains the resource. You can obtain this value from the Azure Resource
646
+ # Manager API or the portal.
647
+ # @param server_name [String] The name of the server.
648
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
649
+ # will be added to the HTTP request.
650
+ #
651
+ # @return [VirtualNetworkRuleListResult] which provide lazy access to pages of
652
+ # the response.
653
+ #
654
+ def list_by_server_as_lazy(resource_group_name, server_name, custom_headers:nil)
655
+ response = list_by_server_async(resource_group_name, server_name, custom_headers:custom_headers).value!
656
+ unless response.nil?
657
+ page = response.body
658
+ page.next_method = Proc.new do |next_page_link|
659
+ list_by_server_next_async(next_page_link, custom_headers:custom_headers)
660
+ end
661
+ page
662
+ end
663
+ end
664
+
665
+ end
666
+ end